Compare commits

...
12 Commits
Author SHA1 Message Date
almaz045andAlmaz Vakhitov b69b5157a0 Entropy trace (#1659)
* I do an entropy check earlier than the others and add the info to the trace

Maybe I'm wrong, but it seems to me that if the regex allowlist is large, it's easier to first check for entropy, since we won't have to go through all these regexes. Plus, we need to check entropy anyway.
Additionally, when using -l trace, there was no information that the find was missed precisely because of entropy. Now it will be shown

* adding info into trace about entropy

* Fixed name of variables

---------

Co-authored-by: Almaz Vakhitov <a.vakhitov@vk.team>
2024-12-30 10:15:51 -06:00
Richard Gomez 7357adca5e build: add 'toolchain' to go.mod (#1682) 2024-12-30 10:08:24 -06:00
Richard Gomez 4c3da6ebb7 refactor(detect): create readUntilSafeBoundary + add tests (#1676) 2024-12-28 15:14:49 -06:00
Zachary Rice dbe3746455 twitter really does suck ass now 2024-12-28 10:22:25 -06:00
Ben-grmbl 7edfc6b5d5 chore(tests): test cases for generate.go (#1623)
GenerateSemiGenericRegex,
GenerateUniqueTokenRegex

to clarify and document current behavior
2024-12-20 20:55:10 -06:00
Richard Gomez efe40cae39 fix: only use non-empty secret groups (#1632) 2024-12-20 20:53:44 -06:00
Richard Gomez 7cb5f6f64c build: upgrade sprig v2->v3 (#1674) 2024-12-20 19:44:18 -06:00
Kenichi Kamiya 2930537190 fix: generate report file even if no findings (#1673) 2024-12-20 10:17:23 -06:00
ahrav a91c6717a0 replace std library regex engine with go-re2 (#1669) 2024-12-20 09:53:01 -06:00
David Mateo 906085fba6 Update golang version to 1.23 (#1672)
Because go mod 1.23 has been updated, the golang image needs it too
2024-12-20 08:38:11 -06:00
Zach d0ba52e2be bump go in dockerfile 2024-12-20 05:54:52 -06:00
Zachary Rice 8a8306288e log bytes (#1670) 2024-12-20 05:46:25 -06:00
55 changed files with 625 additions and 193 deletions

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.22 AS build
FROM golang:1.23 AS build
WORKDIR /go/src/github.com/zricethezav/gitleaks
COPY . .
RUN VERSION=$(git describe --tags --abbrev=0) && \
-3
View File
@@ -19,9 +19,6 @@
<a href="https://github.com/gitleaks/gitleaks-action">
<img alt="gitleaks badge" src="https://img.shields.io/badge/protected%20by-gitleaks-blue">
</a>
<a href="https://twitter.com/intent/follow?screen_name=zricethezav">
<img src="https://img.shields.io/twitter/follow/zricethezav?label=Follow%20zricethezav&style=social&color=blue" alt="Follow @zricethezav" />
</a>
</p>
</p>
+1 -1
View File
@@ -2,9 +2,9 @@ package base
import (
"fmt"
"regexp"
"strings"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config"
)
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+2 -1
View File
@@ -2,7 +2,8 @@ package rules
import (
"fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -2,7 +2,7 @@ package rules
import (
"fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+8 -8
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
@@ -127,7 +127,7 @@ func GenericCredential() *config.Rule {
`[DEBUG] org.neo4j.neo4j-graphdb-api:jar:3.5.12:test`,
`apiUrl=apigee.corpint.com`,
// TODO: Jetbrains IML files (requires line-level allowlist).
//`<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.directory.api:api-asn1-api:1.0.0-M20" level="projcet" />`
// `<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.directory.api:api-asn1-api:1.0.0-M20" level="projcet" />`
// Auth
`author = "james.fake@ymail.com",`,
@@ -156,9 +156,9 @@ func GenericCredential() *config.Rule {
`minisat-master-keying:x64-uwp=fail`,
`IceSSL.KeyFile=s_rsa1024_priv.pem`,
`"bucket_key": "SalesResults-1.2"`,
//`<TAR key="REF_ID_923.properties" value="/opts/config/alias/"/>`,
// `<TAR key="REF_ID_923.properties" value="/opts/config/alias/"/>`,
`<key tag="SecurityIdentifier" name="SecurityIdentifier" type="STRING" />`,
//`packageKey":` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
// `packageKey":` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
`schemaKey = 'DOC_Vector_5_32'`,
`sequenceKey = "18"`,
`app.keystore.file=env/cert.p12`,
@@ -166,15 +166,15 @@ func GenericCredential() *config.Rule {
` doc.Security.KeySize = PdfEncryptionKeySize.Key128Bit;`,
`o.keySelector=n,o.haKey=!1,`,
// TODO: Requires line-level allowlists.
//`<add key="SchemaTable" value="G:\SchemaTable.xml" />`,
// `<add key="SchemaTable" value="G:\SchemaTable.xml" />`,
// `secret:
//secretName: app-decryption-secret
//items:
// secretName: app-decryption-secret
// items:
// - key: app-k8s.yml
// path: app-k8s.yml`,
// TODO: https://learn.microsoft.com/en-us/windows/apps/design/style/xaml-theme-resources
//`<Color x:Key="NormalBrushGradient1">#FFBAE4FF</Color>`,
// `<Color x:Key="NormalBrushGradient1">#FFBAE4FF</Color>`,
// Password
`password combination.
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config"
+2 -1
View File
@@ -2,7 +2,8 @@ package rules
import (
"fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -3,8 +3,8 @@ package rules
import (
b64 "encoding/base64"
"fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
+5 -4
View File
@@ -2,7 +2,8 @@ package rules
import (
"fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config"
@@ -42,7 +43,7 @@ func KubernetesSecret() *config.Rule {
regexp.MustCompile(`[\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:\{\{[ \t\w"|$:=,.-]+}}|""|'')`),
// TODO: Requires multiple allowlists to target match.
// Avoid overreach between directives.
//regexp.MustCompile(`(kind:(.|\s)+\n---\n(.|\s)+\bdata:|data:(.|\s)+\n---\n(.|\s)+\bkind:)`),
// regexp.MustCompile(`(kind:(.|\s)+\n---\n(.|\s)+\bdata:|data:(.|\s)+\n---\n(.|\s)+\bkind:)`),
},
},
},
@@ -250,9 +251,9 @@ type: Opaque
// name: mysecret
// creationPolicy: Owner
//
//---
// ---
//
//kind: ConfigMap
// kind: ConfigMap
// data:
// conversionStrategy: Default
// decodingStrategy: None
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -2,7 +2,7 @@ package rules
import (
"encoding/base64"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+1 -1
View File
@@ -2,7 +2,7 @@ package rules
import (
"fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
+25 -24
View File
@@ -6,8 +6,9 @@ package utils
import (
"fmt"
"regexp"
"strings"
regexp "github.com/wasilibs/go-re2"
)
const (
@@ -92,20 +93,20 @@ func GenerateSampleSecrets(identifier string, secret string) []string {
"ini - unquoted2": "{i}Token = {s}",
// JSON
"json - string": "{\n \"{i}_token\": \"{s}\"\n}",
//TODO: "json - escaped string": "\\{\n \\\"{i}_token\\\": \\\"{s}\\\"\n\\}",
//TODO: "json - string key/value": "{\n \"name\": \"{i}_token\",\n \"value\": \"{s}\"\n}",
// TODO: "json - escaped string": "\\{\n \\\"{i}_token\\\": \\\"{s}\\\"\n\\}",
// TODO: "json - string key/value": "{\n \"name\": \"{i}_token\",\n \"value\": \"{s}\"\n}",
// XML
//TODO: "xml - element": "<{i}Token>{s}</{i}Token>",
// TODO: "xml - element": "<{i}Token>{s}</{i}Token>",
"xml - element multiline": "<{i}Token>\n {s}\n</{i}Token>",
//TODO: "xml - attribute": "<entry name=\"{i}Token\" value=\"{s}\" />",
//TODO: "xml - key/value elements": "<entry>\n <name=\"{i}Token\" />\n <value=\"{s}\" />\n</entry>",
// TODO: "xml - attribute": "<entry name=\"{i}Token\" value=\"{s}\" />",
// TODO: "xml - key/value elements": "<entry>\n <name=\"{i}Token\" />\n <value=\"{s}\" />\n</entry>",
// YAML
"yaml - singleline - unquoted": "{i}_token: {s}",
"yaml - singleline - single quote": "{i}_token: '{s}'",
"yaml - singleline - double quote": "{i}_token: \"{s}\"",
//TODO: "yaml - multiline - literal": "{i}_token: |\n {s}",
//TODO: "yaml - multiline - folding": "{i}_token: >\n {s}",
//"": "",
// TODO: "yaml - multiline - literal": "{i}_token: |\n {s}",
// TODO: "yaml - multiline - folding": "{i}_token: >\n {s}",
// "": "",
// Programming Languages
"C#": `string {i}Token = "{s}";`,
@@ -113,26 +114,26 @@ func GenerateSampleSecrets(identifier string, secret string) []string {
"go - short": `{i}Token := "{s}"`,
"go - backticks": "{i}Token := `{s}`",
"java": "String {i}Token = \"{s}\";",
//TODO: "java - escaped quotes": `config.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"JDOE35\" {i}Token=\"{s}\""`,
//TODO:"kotlin - type": "var {i}Token: string = \"{s}\"",
// TODO: "java - escaped quotes": `config.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"JDOE35\" {i}Token=\"{s}\""`,
// TODO:"kotlin - type": "var {i}Token: string = \"{s}\"",
"kotlin - notype": "var {i}Token = \"{s}\"",
"php - string concat": `${i}Token .= "{s}"`,
//TODO: "php - null coalesce": `${i}Token ??= "{s}"`,
// TODO: "php - null coalesce": `${i}Token ??= "{s}"`,
"python - single quote": "{i}Token = '{s}'",
"python - double quote": `{i}Token = "{s}"`,
//"": "",
// "": "",
// Miscellaneous
//TODO: "url - basic auth": `https://{i}:{s}@example.com/`,
//TODO: "url - query parameter": "https://example.com?{i}Token={s}&fooBar=baz",
//TODO: "comment - slash": "//{s} is the password",
//TODO: "comment - slash multiline": "/*{s} is the password",
//TODO: "comment - hashtag": "#{s} is the password",
//TODO: "comment - semicolon": ";{s} is the password",
//TODO: "csv - unquoted": `{i}Token,{s},`,
// TODO: "url - basic auth": `https://{i}:{s}@example.com/`,
// TODO: "url - query parameter": "https://example.com?{i}Token={s}&fooBar=baz",
// TODO: "comment - slash": "//{s} is the password",
// TODO: "comment - slash multiline": "/*{s} is the password",
// TODO: "comment - hashtag": "#{s} is the password",
// TODO: "comment - semicolon": ";{s} is the password",
// TODO: "csv - unquoted": `{i}Token,{s},`,
"logstash": " \"{i}Token\" => \"{s}\"",
//TODO: "sql - tabular": "|{s}|",
//TODO: "sql": "",
// TODO: "sql - tabular": "|{s}|",
// TODO: "sql": "",
// Makefile
// See: https://github.com/gitleaks/gitleaks/pull/1191
@@ -141,9 +142,9 @@ func GenerateSampleSecrets(identifier string, secret string) []string {
"make - shell assignment": "{i}_TOKEN ::= \"{s}\"",
"make - evaluated shell assignment": "{i}_TOKEN :::= \"{s}\"",
"make - conditional assignment": "{i}_TOKEN ?= \"{s}\"",
//TODO: "make - append": "{i}_TOKEN += \"{s}\"",
// TODO: "make - append": "{i}_TOKEN += \"{s}\"",
//"": "",
// "": "",
}
replacer := strings.NewReplacer("{i}", identifier, "{s}", secret)
+235
View File
@@ -0,0 +1,235 @@
package utils
import (
"testing"
)
func TestGenerateSemiGenericRegex(t *testing.T) {
tests := []struct {
name string
identifiers []string
secretRegex string
isCaseInsensitive []bool
validStrings []string
invalidStrings []string
}{
{
name: "secret is case sensitive, if isCaseInsensitive is false",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{false},
validStrings: []string{"api_key=xxx"},
invalidStrings: []string{"api_key=XXX", "api_key=xXx"},
},
{
name: "secret is case insensitive, if isCaseInsensitive is true",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true},
validStrings: []string{"api_key=xxx", "api_key=XXX", "api_key=xXx"},
invalidStrings: []string{"api_key=x!x"},
},
{
name: "identifier is case insensitive, regardless of isCaseInsensitive",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{"api_key=xxx", "ApI_KeY=xxx", "aPi_kEy=xxx", "API_KEY=xxx"},
invalidStrings: []string{"api!key=xxx"},
},
{
name: "identifier can be case sensitive",
identifiers: []string{"(?-i:[Aa]pi_?[Kk]ey|API_?KEY)"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{"apikey=xxx", "ApiKey=xxx", "Apikey=xxx", "APIKEY=xxx", "api_key=xxx"},
invalidStrings: []string{"ApIKeY=xxx", "aPikEy=xxx"},
},
{
name: "identifier can be part of a longer word",
identifiers: []string{"key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{"mykey=xxx", "keys=xxx", "key1=xxx", "keystore=xxx", "monkey=xxx"},
invalidStrings: []string{},
},
{
name: "identifier may be followed by specific characters",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{
"api_key-----=xxx",
"api_key.....=xxx",
"api_key_____=xxx",
"'''api_key'''=xxx",
`"""api_key"""=xxx`,
"api_key =xxx",
"api_key\t\t\t\t\t=xxx",
"api_key\n\n\n=xxx", // potentially invalid?,
"api_key\r\n=xxx",
"api_key|||=xxx",
},
invalidStrings: []string{
"api_key&=xxx",
"$api_key$=xxx",
"%api_key%=xxx",
"api_key[0]=xxx",
"api_key/*REMOVE*/=xxx",
},
},
{
name: "identifier and secret must be separated by specific operators",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{
"api_key=xxx",
"api_key: xxx",
"<api_key>xxx",
"api_key:=xxx",
"api_key:::=xxx",
"api_key||:=xxx",
"api_key <= xxx",
"api_key => xxx",
"api_key ?= xxx",
},
invalidStrings: []string{
"api_keyxxx",
"api_key\txxx", // potentially valid in a tab-separated file
"api_key, xxx",
"api_key; xxx",
"api_key<xxx>",
"api_key&xxx",
"api_key = true ? 'xxx' : 'yyy'",
},
},
{
name: "secret is limited by specific boundaries",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{
"api_key= xxx ",
"api_key=xxx\n",
"api_key=xxx\r\n",
"api_key=\n\n\n\n\nxxx", // potentially invalid (e.g. .env.example)
"api_key=\r\n\r\nxxx",
"api_key=\t\t\t\txxx\t",
"api_key======xxx;",
"api_key='''xxx'''",
`api_key="""xxx"""`,
"api_key=```xxx```",
`api_key="xxx'`, // could try to match only same opening and closing quotes, might not be worth the complexity
`api_key="don't do it!"`,
`api_key="xxx;notpartofthematch"`,
},
invalidStrings: []string{
"api_key=_xxx",
"api_key=xxx_",
"api_key=$xxx",
"api_key=%xxx%",
"api_key=[xxx]",
"api_key=(xxx)",
"api_key=<xxx>",
"api_key={xxx}",
"<api_key>xxx</api_key>", // potentially valid
"example.com?api_key=xxx&other=yyy", // potentially valid
},
},
// Note: these test cases do not necessarily prescribe the expected behavior of the function,
// but rather document the current behavior, to ensure that future changes are intentional.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for _, isCaseInsensitive := range tt.isCaseInsensitive {
regex := GenerateSemiGenericRegex(tt.identifiers, tt.secretRegex, isCaseInsensitive)
for _, validString := range tt.validStrings {
if !regex.MatchString(validString) {
t.Errorf("Expected match, but got none, \nfor GenerateSemiGenericRegex(%v, /%v/, caseInsensitive=%v).MatchString(`%v`)\n%v",
tt.identifiers, tt.secretRegex, isCaseInsensitive, validString, regex)
}
}
for _, invalidString := range tt.invalidStrings {
if regex.MatchString(invalidString) {
t.Errorf("Expected no match, but got one, \nfor GenerateSemiGenericRegex(%v, /%v/, caseInsensitive=%v).MatchString(`%v`)\n%v",
tt.identifiers, tt.secretRegex, isCaseInsensitive, invalidString, regex)
}
}
}
})
}
}
func TestGenerateUniqueTokenRegex(t *testing.T) {
tests := []struct {
name string
secretRegex string
isCaseInsensitive bool
validStrings []string
invalidStrings []string
}{
{
name: "case sensitive secret",
secretRegex: `[a-c]{3}`,
isCaseInsensitive: false,
validStrings: []string{"abc"},
invalidStrings: []string{"ABC", "Abc"},
},
{
name: "case insensitive secret",
secretRegex: `[a-c]{3}`,
isCaseInsensitive: true,
validStrings: []string{"abc", "ABC", "Abc"},
invalidStrings: []string{"123"},
},
{
name: "allowed boundaries",
secretRegex: `[a-c]{3}`,
isCaseInsensitive: false,
validStrings: []string{
"abc",
" abc ",
"\nabc\n",
"\r\nabc\r\n",
"\tabc\t",
"'abc'",
`"abc"`,
"```abc```",
"my abc's",
".com?abc",
},
invalidStrings: []string{
"abcabc",
"_abc_",
".com?abc&def", // potentially valid
"/*abc*/",
"<abc>",
"<str>abc</str>", // potentially valid
"{{{abc}}}",
"abc, d",
},
},
// Note: these test cases do not necessarily prescribe the expected behavior of the function,
// but rather document the current behavior, to ensure that future changes are intentional.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
regex := GenerateUniqueTokenRegex(tt.secretRegex, tt.isCaseInsensitive)
for _, validString := range tt.validStrings {
if !regex.MatchString(validString) {
t.Errorf("Expected match, but got none, \nfor GenerateUniqueTokenRegex(/%v/, caseInsensitive=%v).MatchString(`%v`)\n%v",
tt.secretRegex, tt.isCaseInsensitive, validString, regex)
}
}
for _, invalidString := range tt.invalidStrings {
if regex.MatchString(invalidString) {
t.Errorf("Expected no match, but got one, \nfor GenerateUniqueTokenRegex(/%v/, caseInsensitive=%v).MatchString(`%v`)\n%v",
tt.secretRegex, tt.isCaseInsensitive, invalidString, regex)
}
}
})
}
}
+41 -2
View File
@@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"strings"
"sync/atomic"
"time"
"github.com/rs/zerolog"
@@ -40,6 +41,13 @@ var rootCmd = &cobra.Command{
Version: Version,
}
const (
BYTE = 1.0
KILOBYTE = BYTE * 1000
MEGABYTE = KILOBYTE * 1000
GIGABYTE = MEGABYTE * 1000
)
func init() {
cobra.OnInitialize(initLog)
rootCmd.PersistentFlags().StringP("config", "c", "", configDescription)
@@ -59,6 +67,7 @@ func init() {
rootCmd.PersistentFlags().StringSlice("enable-rule", []string{}, "only enable specific rules by id")
rootCmd.PersistentFlags().StringP("gitleaks-ignore-path", "i", ".", "path to .gitleaksignore file or folder containing one")
rootCmd.PersistentFlags().Int("max-decode-depth", 0, "allow recursive decoding up to this depth (default \"0\", no decoding is done)")
err := viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
if err != nil {
log.Fatal().Msgf("err binding config %s", err.Error())
@@ -321,15 +330,45 @@ func mustGetStringFlag(name string) string {
return reportPath
}
func bytesConvert(bytes uint64) string {
unit := ""
value := float32(bytes)
switch {
case bytes >= GIGABYTE:
unit = "GB"
value = value / GIGABYTE
case bytes >= MEGABYTE:
unit = "MB"
value = value / MEGABYTE
case bytes >= KILOBYTE:
unit = "KB"
value = value / KILOBYTE
case bytes >= BYTE:
unit = "bytes"
case bytes == 0:
return "0"
}
stringValue := strings.TrimSuffix(
fmt.Sprintf("%.2f", value), ".00",
)
return fmt.Sprintf("%s %s", stringValue, unit)
}
func findingSummaryAndExit(detector *detect.Detector, findings []report.Finding, exitCode int, start time.Time, err error) {
totalBytes := atomic.LoadUint64(&detector.TotalBytes)
bytesMsg := fmt.Sprintf("scanned ~%d bytes (%s)", totalBytes, bytesConvert(totalBytes))
if err == nil {
log.Info().Msgf("scan completed in %s", FormatDuration(time.Since(start)))
log.Info().Msgf("%s in %s", bytesMsg, FormatDuration(time.Since(start)))
if len(findings) != 0 {
log.Warn().Msgf("leaks found: %d", len(findings))
} else {
log.Info().Msg("no leaks found")
}
} else {
log.Warn().Msg(bytesMsg)
log.Warn().Msgf("partial scan completed in %s", FormatDuration(time.Since(start)))
if len(findings) != 0 {
log.Warn().Msgf("%d leaks found in partial scan", len(findings))
@@ -339,7 +378,7 @@ func findingSummaryAndExit(detector *detect.Detector, findings []report.Finding,
}
// write report if desired
if detector.Reporter != nil && len(findings) > 0 {
if detector.Reporter != nil {
var (
file io.WriteCloser
reportErr error
+1 -1
View File
@@ -2,9 +2,9 @@ package config
import (
"fmt"
"regexp"
"strings"
regexp "github.com/wasilibs/go-re2"
"golang.org/x/exp/maps"
)
+1 -1
View File
@@ -2,12 +2,12 @@ package config
import (
"errors"
"regexp"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/assert"
regexp "github.com/wasilibs/go-re2"
)
func TestCommitAllowed(t *testing.T) {
+1 -1
View File
@@ -3,12 +3,12 @@ package config
import (
_ "embed"
"fmt"
"regexp"
"sort"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
regexp "github.com/wasilibs/go-re2"
)
//go:embed gitleaks.toml
+1 -1
View File
@@ -2,10 +2,10 @@ package config
import (
"fmt"
"regexp"
"testing"
"github.com/google/go-cmp/cmp"
regexp "github.com/wasilibs/go-re2"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
+2 -1
View File
@@ -2,8 +2,9 @@ package config
import (
"fmt"
"regexp"
"strings"
regexp "github.com/wasilibs/go-re2"
)
// Rules contain information that define details on how to detect secrets
+1 -1
View File
@@ -1,7 +1,7 @@
package config
import (
"regexp"
regexp "github.com/wasilibs/go-re2"
)
func anyRegexMatch(f string, res []*regexp.Regexp) bool {
+38 -33
View File
@@ -8,6 +8,7 @@ import (
"regexp"
"strings"
"sync"
"sync/atomic"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/report"
@@ -87,6 +88,8 @@ type Detector struct {
// report-related settings.
ReportPath string
Reporter report.Reporter
TotalBytes uint64
}
// Fragment contains the data to be scanned
@@ -94,6 +97,8 @@ type Fragment struct {
// Raw is the raw content of the fragment
Raw string
Bytes []byte
// FilePath is the path to the file if applicable
FilePath string
SymlinkFile string
@@ -178,6 +183,11 @@ func (d *Detector) DetectString(content string) []report.Finding {
// Detect scans the given fragment and returns a list of findings
func (d *Detector) Detect(fragment Fragment) []report.Finding {
if fragment.Bytes == nil {
atomic.AddUint64(&d.TotalBytes, uint64(len(fragment.Raw)))
}
atomic.AddUint64(&d.TotalBytes, uint64(len(fragment.Bytes)))
var findings []report.Finding
// check if filepath is allowed
@@ -401,21 +411,39 @@ MatchLoop:
finding.Secret = groups[r.SecretGroup]
} else {
// If |secretGroup| is not set, we will use the first suitable capture group.
if len(groups) == 2 {
// Use the only group.
finding.Secret = groups[1]
} else {
// Use the first non-empty group.
for _, s := range groups[1:] {
if len(s) > 0 {
finding.Secret = s
break
}
for _, s := range groups[1:] {
if len(s) > 0 {
finding.Secret = s
break
}
}
}
}
// check entropy
entropy := shannonEntropy(finding.Secret)
finding.Entropy = float32(entropy)
if r.Entropy != 0.0 {
if entropy <= r.Entropy {
logger.Trace().
Float32("entropy", finding.Entropy).
Msg("Skipping finding due to low entropy")
// entropy is too low, skip this finding
continue
}
// NOTE: this is a goofy hack to get around the fact there golang's regex engine
// does not support positive lookaheads. Ideally we would want to add a
// restriction on generic rules regex that requires the secret match group
// contains both numbers and alphabetical characters, not just alphabetical characters.
// What this bit of code does is check if the ruleid is prepended with "generic" and enforces the
// secret contains both digits and alphabetical characters.
// TODO: this should be replaced with stop words
if strings.HasPrefix(r.RuleID, "generic") {
if !containsDigit(finding.Secret) {
continue
}
}
}
// check if the regexTarget is defined in the allowlist "regexes" entry
// or if the secret is in the list of stopwords
globalAllowlistTarget := finding.Secret
@@ -485,29 +513,6 @@ MatchLoop:
continue MatchLoop
}
}
// check entropy
entropy := shannonEntropy(finding.Secret)
finding.Entropy = float32(entropy)
if r.Entropy != 0.0 {
if entropy <= r.Entropy {
// entropy is too low, skip this finding
continue
}
// NOTE: this is a goofy hack to get around the fact there golang's regex engine
// does not support positive lookaheads. Ideally we would want to add a
// restriction on generic rules regex that requires the secret match group
// contains both numbers and alphabetical characters, not just alphabetical characters.
// What this bit of code does is check if the ruleid is prepended with "generic" and enforces the
// secret contains both digits and alphabetical characters.
// TODO: this should be replaced with stop words
if strings.HasPrefix(r.RuleID, "generic") {
if !containsDigit(finding.Secret) {
continue
}
}
}
findings = append(findings, finding)
}
return findings
+1 -1
View File
@@ -4,7 +4,6 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"testing"
"github.com/google/go-cmp/cmp"
@@ -12,6 +11,7 @@ import (
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/report"
+95 -55
View File
@@ -1,6 +1,7 @@
package detect
import (
"bufio"
"bytes"
"io"
"os"
@@ -49,72 +50,41 @@ func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Findin
}
}
// Buffer to hold file chunks
buf := make([]byte, chunkSize)
totalLines := 0
var (
// Buffer to hold file chunks
reader = bufio.NewReaderSize(f, chunkSize)
buf = make([]byte, chunkSize)
totalLines = 0
)
for {
n, err := f.Read(buf)
n, err := reader.Read(buf)
// "Callers should always process the n > 0 bytes returned before considering the error err."
// https://pkg.go.dev/io#Reader
if n > 0 {
// TODO: optimization could be introduced here
if mimetype, err := filetype.Match(buf[:n]); err != nil {
return nil
} else if mimetype.MIME.Type == "application" {
return nil // skip binary files
// Only check the filetype at the start of file.
if totalLines == 0 {
// TODO: could other optimizations be introduced here?
if mimetype, err := filetype.Match(buf[:n]); err != nil {
return nil
} else if mimetype.MIME.Type == "application" {
return nil // skip binary files
}
}
// If the chunk doesn't end in a newline, peek |maxPeekSize| until we find one.
// This hopefully avoids splitting
// See: https://github.com/gitleaks/gitleaks/issues/1651
var (
peekBuf = bytes.NewBuffer(buf[:n])
tempBuf = make([]byte, 1)
newlineCount = 0 // Tracks consecutive newlines
)
for {
data := peekBuf.Bytes()
if len(data) == 0 {
break
}
// Check if the last character is a newline.
lastChar := data[len(data)-1]
if lastChar == '\n' || lastChar == '\r' {
newlineCount++
// Stop if two consecutive newlines are found
if newlineCount >= 2 {
break
}
} else {
newlineCount = 0 // Reset if a non-newline character is found
}
// Stop growing the buffer if it reaches maxSize
if (peekBuf.Len() - n) >= maxPeekSize {
break
}
// Read additional data into a temporary buffer
m, readErr := f.Read(tempBuf)
if m > 0 {
peekBuf.Write(tempBuf[:m])
}
// Stop if EOF is reached
if readErr != nil {
if readErr == io.EOF {
break
}
return readErr
}
// Try to split chunks across large areas of whitespace, if possible.
peekBuf := bytes.NewBuffer(buf[:n])
if readErr := readUntilSafeBoundary(reader, n, maxPeekSize, peekBuf); readErr != nil {
return readErr
}
// Count the number of newlines in this chunk
chunk := string(peekBuf.Bytes())
chunk := peekBuf.String()
linesInChunk := strings.Count(chunk, "\n")
totalLines += linesInChunk
fragment := Fragment{
Raw: chunk,
Bytes: peekBuf.Bytes(),
FilePath: pa.Path,
}
if pa.Symlink != "" {
@@ -144,3 +114,73 @@ func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Findin
return d.findings, nil
}
// readUntilSafeBoundary consumes |f| until it finds two consecutive `\n` characters, up to |maxPeekSize|.
// This hopefully avoids splitting. (https://github.com/gitleaks/gitleaks/issues/1651)
func readUntilSafeBoundary(r *bufio.Reader, n int, maxPeekSize int, peekBuf *bytes.Buffer) error {
if peekBuf.Len() == 0 {
return nil
}
// Does the buffer end in consecutive newlines?
var (
data = peekBuf.Bytes()
lastChar = data[len(data)-1]
newlineCount = 0 // Tracks consecutive newlines
)
if isWhitespace(lastChar) {
for i := len(data) - 1; i >= 0; i-- {
lastChar = data[i]
if lastChar == '\n' {
newlineCount++
// Stop if two consecutive newlines are found
if newlineCount >= 2 {
return nil
}
} else if lastChar == '\r' || lastChar == ' ' || lastChar == '\t' {
// The presence of other whitespace characters (`\r`, ` `, `\t`) shouldn't reset the count.
// (Intentionally do nothing.)
} else {
break
}
}
}
// If not, read ahead until we (hopefully) find some.
newlineCount = 0
for {
data = peekBuf.Bytes()
// Check if the last character is a newline.
lastChar = data[len(data)-1]
if lastChar == '\n' {
newlineCount++
// Stop if two consecutive newlines are found
if newlineCount >= 2 {
break
}
} else if lastChar == '\r' || lastChar == ' ' || lastChar == '\t' {
// The presence of other whitespace characters (`\r`, ` `, `\t`) shouldn't reset the count.
// (Intentionally do nothing.)
} else {
newlineCount = 0 // Reset if a non-newline character is found
}
// Stop growing the buffer if it reaches maxSize
if (peekBuf.Len() - n) >= maxPeekSize {
break
}
// Read additional data into a temporary buffer
b, err := r.ReadByte()
if err != nil {
if err == io.EOF {
break
}
return err
}
peekBuf.WriteByte(b)
}
return nil
}
+72
View File
@@ -0,0 +1,72 @@
package detect
import (
"bufio"
"bytes"
"io"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func Test_readUntilSafeBoundary(t *testing.T) {
// Arrange
cases := []struct {
name string
r io.Reader
expected string
}{
// Current split is fine, exit early.
{
name: "safe original split - LF",
r: strings.NewReader("abc\n\ndefghijklmnop\n\nqrstuvwxyz"),
expected: "abc\n\n",
},
{
name: "safe original split - CRLF",
r: strings.NewReader("a\r\n\r\nbcdefghijklmnop\n"),
expected: "a\r\n\r\n",
},
// Current split is bad, look for a better one.
{
name: "safe split - LF",
r: strings.NewReader("abcdefg\nhijklmnop\n\nqrstuvwxyz"),
expected: "abcdefg\nhijklmnop\n\n",
},
{
name: "safe split - CRLF",
r: strings.NewReader("abcdefg\r\nhijklmnop\r\n\r\nqrstuvwxyz"),
expected: "abcdefg\r\nhijklmnop\r\n\r\n",
},
{
name: "safe split - blank line",
r: strings.NewReader("abcdefg\nhijklmnop\n\t \t\nqrstuvwxyz"),
expected: "abcdefg\nhijklmnop\n\t \t\n",
},
// Current split is bad, exhaust options.
{
name: "no safe split",
r: strings.NewReader("abcdefg\nhijklmnopqrstuvwxyz"),
expected: "abcdefg\nhijklmnopqrstuvwx",
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
buf := make([]byte, 5)
n, err := c.r.Read(buf)
require.NoError(t, err)
// Act
reader := bufio.NewReader(c.r)
peekBuf := bytes.NewBuffer(buf[:n])
err = readUntilSafeBoundary(reader, n, 20, peekBuf)
require.NoError(t, err)
// Assert
t.Logf(peekBuf.String())
require.Equal(t, c.expected, string(peekBuf.Bytes()))
})
}
}
+13 -7
View File
@@ -2,6 +2,7 @@ package detect
import (
"bufio"
"bytes"
"io"
"github.com/zricethezav/gitleaks/v8/report"
@@ -10,18 +11,23 @@ import (
// DetectReader accepts an io.Reader and a buffer size for the reader in KB
func (d *Detector) DetectReader(r io.Reader, bufSize int) ([]report.Finding, error) {
reader := bufio.NewReader(r)
buf := make([]byte, 0, 1000*bufSize)
buf := make([]byte, 1000*bufSize)
findings := []report.Finding{}
for {
n, err := reader.Read(buf[:cap(buf)])
n, err := reader.Read(buf)
// "Callers should always process the n > 0 bytes returned before considering the error err."
// https://pkg.go.dev/io#Reader
if n > 0 {
buf = buf[:n]
// Try to split chunks across large areas of whitespace, if possible.
peekBuf := bytes.NewBuffer(buf[:n])
if readErr := readUntilSafeBoundary(reader, n, maxPeekSize, peekBuf); readErr != nil {
return findings, readErr
}
fragment := Fragment{
Raw: string(buf),
Raw: peekBuf.String(),
}
for _, finding := range d.Detect(fragment) {
findings = append(findings, finding)
@@ -32,10 +38,10 @@ func (d *Detector) DetectReader(r io.Reader, bufSize int) ([]report.Finding, err
}
if err != nil {
if err != io.EOF {
return findings, err
if err == io.EOF {
break
}
break
return findings, err
}
}
+8 -1
View File
@@ -1,11 +1,12 @@
package detect
import (
"github.com/stretchr/testify/require"
"io"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
)
@@ -13,11 +14,17 @@ const secret = "AKIAIRYLJVKMPEGZMPJS"
type mockReader struct {
data []byte
read bool
}
func (r *mockReader) Read(p []byte) (n int, err error) {
if r.read {
return 0, io.EOF
}
// Copy data to the provided buffer.
n = copy(p, r.data)
r.read = true
// Return io.EOF along with the bytes.
return n, io.EOF
+4
View File
@@ -190,3 +190,7 @@ func containsDigit(s string) bool {
}
return false
}
func isWhitespace(ch byte) bool {
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'
}
+11 -5
View File
@@ -2,9 +2,11 @@ module github.com/zricethezav/gitleaks/v8
go 1.23
toolchain go1.23.4
require (
github.com/BobuSumisu/aho-corasick v1.0.3
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/Masterminds/sprig/v3 v3.3.0
github.com/charmbracelet/lipgloss v0.5.0
github.com/fatih/semgroup v1.2.0
github.com/gitleaks/go-gitdiff v0.9.1
@@ -13,17 +15,17 @@ require (
github.com/rs/zerolog v1.26.1
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
)
require (
dario.cat/mergo v1.0.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
@@ -32,6 +34,9 @@ require (
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 // indirect
github.com/muesli/termenv v0.15.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/tetratelabs/wazero v1.8.2 // indirect
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
golang.org/x/crypto v0.29.0 // indirect
)
@@ -46,10 +51,11 @@ require (
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/wasilibs/go-re2 v1.8.0
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
+26 -10
View File
@@ -36,6 +36,8 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BobuSumisu/aho-corasick v1.0.3 h1:uuf+JHwU9CHP2Vx+wAy6jcksJThhJS9ehR8a+4nPE9g=
github.com/BobuSumisu/aho-corasick v1.0.3/go.mod h1:hm4jLcvZKI2vRF2WDU1N4p/jpWtpOzp3nLmi9AzX/XE=
@@ -43,10 +45,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
@@ -81,6 +83,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/semgroup v1.2.0 h1:h/OLXwEM+3NNyAdZEpMiH1OzfplU09i2qXPVThGZvyg=
github.com/fatih/semgroup v1.2.0/go.mod h1:1KAD4iIYfXjE4U13B48VM4z9QUwV5Tt8O4rS879kgm8=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
@@ -186,8 +190,6 @@ github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
@@ -198,11 +200,13 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb h1:w1g9wNDIE/pHSTmAaUhv4TZQuPBS6GV3mMz5hkgziIU=
@@ -255,12 +259,16 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=
github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
@@ -268,8 +276,9 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
@@ -284,10 +293,17 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4=
github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
github.com/wasilibs/go-re2 v1.8.0 h1:6wpqZ31vdoJRSOM41bWEd1AbSmRe161yQkTzoihqwEg=
github.com/wasilibs/go-re2 v1.8.0/go.mod h1:RjA3Y/yW6xFL8Iyz8f5sVhttLq5b5DRF8baZ7Sh+elk=
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 h1:OvLBa8SqJnZ6P+mjlzc2K7PM22rRUPE1x32G9DTPrC4=
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52/go.mod h1:jMeV4Vpbi8osrE/pKUxRZkVaA0EX7NZN0A9/oRzgpgY=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"os"
"text/template"
"github.com/Masterminds/sprig"
"github.com/Masterminds/sprig/v3"
)
type TemplateReporter struct {