mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
343e69399b | ||
|
|
0060ab636a | ||
|
|
025908808f | ||
|
|
088f8b8074 | ||
|
|
afdccad46f | ||
|
|
e002920355 | ||
|
|
d805fb9144 | ||
|
|
391d4d75f6 | ||
|
|
f77493274a |
No files matched your search
+1
-1
@@ -749,4 +749,4 @@ acce01f2338434a78f6a4a06a097b0fd23280484:README.md:aws-access-token:220
|
|||||||
111c8b47b65627db117bd20be85ff0aee8961eb9:detect/detect_test.go:private-key:567
|
111c8b47b65627db117bd20be85ff0aee8961eb9:detect/detect_test.go:private-key:567
|
||||||
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:512
|
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:512
|
||||||
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:513
|
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:513
|
||||||
|
69f161c0a0cc0f7858f7d0609d656f4edcedd84c:detect/detect_test.go:discord-api-token:326
|
||||||
+1
-1
@@ -28,7 +28,7 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
|
|||||||
func Beamer() *config.Rule {
|
func Beamer() *config.Rule {
|
||||||
// Define Rule
|
// Define Rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
// Human redable description of the rule
|
// Human readable description of the rule
|
||||||
Description: "Beamer API token",
|
Description: "Beamer API token",
|
||||||
|
|
||||||
// Unique ID for the rule
|
// Unique ID for the rule
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ cd gitleaks
|
|||||||
make build
|
make build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Github Action
|
### GitHub Action
|
||||||
|
|
||||||
Check out the official [Gitleaks GitHub Action](https://github.com/gitleaks/gitleaks-action)
|
Check out the official [Gitleaks GitHub Action](https://github.com/gitleaks/gitleaks-action)
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ jobs:
|
|||||||
```
|
```
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/zricethezav/gitleaks
|
- repo: https://github.com/zricethezav/gitleaks
|
||||||
rev: v8.12.0
|
rev: v8.15.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
```
|
```
|
||||||
@@ -370,7 +370,7 @@ stopwords = [
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/zricethezav/gitleaks/blob/master/README.md).
|
Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/zricethezav/gitleaks/blob/master/README.md) if you would like to contribute to the default configuration. Additionally, you can check out [this gitleaks blog post](https://blog.gitleaks.io/stop-leaking-secrets-configuration-2-3-aeed293b1fbf) which covers advanced configuration setups.
|
||||||
|
|
||||||
### Additional Configuration
|
### Additional Configuration
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ class CustomClass:
|
|||||||
|
|
||||||
#### .gitleaksignore
|
#### .gitleaksignore
|
||||||
|
|
||||||
You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. Note: this feature is expirmental and is subject to change in the future.
|
You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. Note: this feature is experimental and is subject to change in the future.
|
||||||
|
|
||||||
## Secured by Jit
|
## Secured by Jit
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
// ignore findings from the baseline (an existing report in json format generated earlier)
|
// ignore findings from the baseline (an existing report in json format generated earlier)
|
||||||
baselinePath, _ := cmd.Flags().GetString("baseline-path")
|
baselinePath, _ := cmd.Flags().GetString("baseline-path")
|
||||||
if baselinePath != "" {
|
if baselinePath != "" {
|
||||||
err = detector.AddBaseline(baselinePath)
|
err = detector.AddBaseline(baselinePath, source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Msgf("Could not load baseline. The path must point of a gitleaks report generated using the default format: %s", err)
|
log.Error().Msgf("Could not load baseline. The path must point of a gitleaks report generated using the default format: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ func main() {
|
|||||||
configRules = append(configRules, rules.GitHubOauth())
|
configRules = append(configRules, rules.GitHubOauth())
|
||||||
configRules = append(configRules, rules.GitHubApp())
|
configRules = append(configRules, rules.GitHubApp())
|
||||||
configRules = append(configRules, rules.GitHubRefresh())
|
configRules = append(configRules, rules.GitHubRefresh())
|
||||||
configRules = append(configRules, rules.Gitlab())
|
configRules = append(configRules, rules.GitlabPat())
|
||||||
|
configRules = append(configRules, rules.GitlabPipelineTriggerToken())
|
||||||
|
configRules = append(configRules, rules.GitlabRunnerRegistrationToken())
|
||||||
configRules = append(configRules, rules.GitterAccessToken())
|
configRules = append(configRules, rules.GitterAccessToken())
|
||||||
configRules = append(configRules, rules.GrafanaApiKey())
|
configRules = append(configRules, rules.GrafanaApiKey())
|
||||||
configRules = append(configRules, rules.GrafanaCloudApiToken())
|
configRules = append(configRules, rules.GrafanaCloudApiToken())
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ paths = [
|
|||||||
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket)$''',
|
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket)$''',
|
||||||
'''(go.mod|go.sum)$''',
|
'''(go.mod|go.sum)$''',
|
||||||
'''node_modules''',
|
'''node_modules''',
|
||||||
|
'''package-lock.json''',
|
||||||
'''vendor''',
|
'''vendor''',
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -57,4 +58,4 @@ keywords = [
|
|||||||
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
|
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
|
||||||
]
|
]
|
||||||
|
|
||||||
{{end}}{{end}}
|
{{end}}{{end}}
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Gitlab() *config.Rule {
|
func GitlabPat() *config.Rule {
|
||||||
// define rule
|
// define rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "GitLab Personal Access Token",
|
Description: "GitLab Personal Access Token",
|
||||||
@@ -22,3 +22,35 @@ func Gitlab() *config.Rule {
|
|||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GitlabPipelineTriggerToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "GitLab Pipeline Trigger Token",
|
||||||
|
RuleID: "gitlab-ptt",
|
||||||
|
Regex: regexp.MustCompile(`glptt-[0-9a-f]{40}`),
|
||||||
|
Keywords: []string{"glptt-"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("gitlab", "glptt-"+secrets.NewSecret(hex("40"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GitlabRunnerRegistrationToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "GitLab Runner Registration Token",
|
||||||
|
RuleID: "gitlab-rrt",
|
||||||
|
Regex: regexp.MustCompile(`GR1348941[0-9a-zA-Z\-\_]{20}`),
|
||||||
|
Keywords: []string{"GR1348941"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("gitlab", "GR1348941"+secrets.NewSecret(alphaNumeric("20"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
@@ -9,12 +9,12 @@ func JWT() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "JSON Web Token",
|
Description: "JSON Web Token",
|
||||||
RuleID: "jwt",
|
RuleID: "jwt",
|
||||||
Regex: generateUniqueTokenRegex(`ey[0-9a-z]{30,34}\.ey[0-9a-z-\/_]{30,500}\.[0-9a-zA-Z-\/_]{10,200}`),
|
Regex: generateUniqueTokenRegex(`ey[0-9a-z]{30,34}\.ey[0-9a-z-\/_]{30,500}\.[0-9a-zA-Z-\/_]{10,200}={0,2}`),
|
||||||
Keywords: []string{"ey"},
|
Keywords: []string{"ey"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{`eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0`, // gitleaks:allow
|
tps := []string{`eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0==`, // gitleaks:allow
|
||||||
`JWT := eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0`, // gitleaks:allow
|
`JWT := eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0`, // gitleaks:allow
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ func PrivateKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Private Key",
|
Description: "Private Key",
|
||||||
RuleID: "private-key",
|
RuleID: "private-key",
|
||||||
Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY----`),
|
Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY( BLOCK)?----`),
|
||||||
Keywords: []string{"-----BEGIN"},
|
Keywords: []string{"-----BEGIN"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +23,9 @@ anything
|
|||||||
abcdefghijklmnopqrstuvwxyz
|
abcdefghijklmnopqrstuvwxyz
|
||||||
-----END RSA PRIVATE KEY-----
|
-----END RSA PRIVATE KEY-----
|
||||||
`,
|
`,
|
||||||
|
`-----BEGIN PRIVATE KEY BLOCK-----
|
||||||
|
anything
|
||||||
|
-----END PRIVATE KEY BLOCK-----`,
|
||||||
} // gitleaks:allow
|
} // gitleaks:allow
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
+19
-2
@@ -17,6 +17,7 @@ paths = [
|
|||||||
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket)$''',
|
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket)$''',
|
||||||
'''(go.mod|go.sum)$''',
|
'''(go.mod|go.sum)$''',
|
||||||
'''node_modules''',
|
'''node_modules''',
|
||||||
|
'''package-lock.json''',
|
||||||
'''vendor''',
|
'''vendor''',
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2016,6 +2017,22 @@ keywords = [
|
|||||||
"glpat-",
|
"glpat-",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "GitLab Pipeline Trigger Token"
|
||||||
|
id = "gitlab-ptt"
|
||||||
|
regex = '''glptt-[0-9a-f]{40}'''
|
||||||
|
keywords = [
|
||||||
|
"glptt-",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "GitLab Runner Registration Token"
|
||||||
|
id = "gitlab-rrt"
|
||||||
|
regex = '''GR1348941[0-9a-zA-Z\-\_]{20}'''
|
||||||
|
keywords = [
|
||||||
|
"gr1348941",
|
||||||
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Gitter Access Token"
|
description = "Gitter Access Token"
|
||||||
id = "gitter-access-token"
|
id = "gitter-access-token"
|
||||||
@@ -2099,7 +2116,7 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "JSON Web Token"
|
description = "JSON Web Token"
|
||||||
id = "jwt"
|
id = "jwt"
|
||||||
regex = '''(?i)\b(ey[0-9a-z]{30,34}\.ey[0-9a-z-\/_]{30,500}\.[0-9a-zA-Z-\/_]{10,200})(?:['|\"|\n|\r|\s|\x60|;]|$)'''
|
regex = '''(?i)\b(ey[0-9a-z]{30,34}\.ey[0-9a-z-\/_]{30,500}\.[0-9a-zA-Z-\/_]{10,200}={0,2})(?:['|\"|\n|\r|\s|\x60|;]|$)'''
|
||||||
keywords = [
|
keywords = [
|
||||||
"ey",
|
"ey",
|
||||||
]
|
]
|
||||||
@@ -2411,7 +2428,7 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Private Key"
|
description = "Private Key"
|
||||||
id = "private-key"
|
id = "private-key"
|
||||||
regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY----'''
|
regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY( BLOCK)?----'''
|
||||||
keywords = [
|
keywords = [
|
||||||
"-----begin",
|
"-----begin",
|
||||||
]
|
]
|
||||||
|
|||||||
+20
-1
@@ -160,14 +160,33 @@ func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Detector) AddBaseline(baselinePath string) error {
|
func (d *Detector) AddBaseline(baselinePath string, source string) error {
|
||||||
if baselinePath != "" {
|
if baselinePath != "" {
|
||||||
|
absoluteSource, err := filepath.Abs(source)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
absoluteBaseline, err := filepath.Abs(baselinePath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
relativeBaseline, err := filepath.Rel(absoluteSource, absoluteBaseline)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
baseline, err := LoadBaseline(baselinePath)
|
baseline, err := LoadBaseline(baselinePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
d.baseline = baseline
|
d.baseline = baseline
|
||||||
|
baselinePath = relativeBaseline
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d.baselinePath = baselinePath
|
d.baselinePath = baselinePath
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-2
@@ -18,8 +18,9 @@ const repoBasePath = "../testdata/repos/"
|
|||||||
|
|
||||||
func TestDetect(t *testing.T) {
|
func TestDetect(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
cfgName string
|
cfgName string
|
||||||
fragment Fragment
|
baselinePath string
|
||||||
|
fragment Fragment
|
||||||
// NOTE: for expected findings, all line numbers will be 0
|
// NOTE: for expected findings, all line numbers will be 0
|
||||||
// because line deltas are added _after_ the finding is created.
|
// because line deltas are added _after_ the finding is created.
|
||||||
// I.e, if the finding is from a --no-git file, the line number will be
|
// I.e, if the finding is from a --no-git file, the line number will be
|
||||||
@@ -318,6 +319,15 @@ func TestDetect(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedFindings: []report.Finding{},
|
expectedFindings: []report.Finding{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
cfgName: "path_only",
|
||||||
|
baselinePath: ".baseline.json",
|
||||||
|
fragment: Fragment{
|
||||||
|
Raw: `const Discord_Public_Key = "e7322523fb86ed64c836a979cf8465fbd436378c653c1db38f9ae87bc62a6fd5"`,
|
||||||
|
FilePath: ".baseline.json",
|
||||||
|
},
|
||||||
|
expectedFindings: []report.Finding{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@@ -344,6 +354,7 @@ func TestDetect(t *testing.T) {
|
|||||||
assert.Equal(t, tt.wantError, err)
|
assert.Equal(t, tt.wantError, err)
|
||||||
}
|
}
|
||||||
d := NewDetector(cfg)
|
d := NewDetector(cfg)
|
||||||
|
d.baselinePath = tt.baselinePath
|
||||||
|
|
||||||
findings := d.Detect(tt.fragment)
|
findings := d.Detect(tt.fragment)
|
||||||
assert.ElementsMatch(t, tt.expectedFindings, findings)
|
assert.ElementsMatch(t, tt.expectedFindings, findings)
|
||||||
|
|||||||
+14
-1
@@ -102,6 +102,13 @@ func printFinding(f report.Finding) {
|
|||||||
matchInLineIDX := strings.Index(f.Line, f.Match)
|
matchInLineIDX := strings.Index(f.Line, f.Match)
|
||||||
secretInMatchIdx := strings.Index(f.Match, f.Secret)
|
secretInMatchIdx := strings.Index(f.Match, f.Secret)
|
||||||
|
|
||||||
|
skipColor := false
|
||||||
|
|
||||||
|
if matchInLineIDX == -1 {
|
||||||
|
skipColor = true
|
||||||
|
matchInLineIDX = 0
|
||||||
|
}
|
||||||
|
|
||||||
start := f.Line[0:matchInLineIDX]
|
start := f.Line[0:matchInLineIDX]
|
||||||
startMatchIdx := 0
|
startMatchIdx := 0
|
||||||
if matchInLineIDX > 20 {
|
if matchInLineIDX > 20 {
|
||||||
@@ -127,7 +134,13 @@ func printFinding(f report.Finding) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
finding := fmt.Sprintf("%s%s%s%s%s\n", strings.TrimPrefix(strings.TrimLeft(start, " "), "\n"), matchBeginning, secret, matchEnd, lineEnd)
|
finding := fmt.Sprintf("%s%s%s%s%s\n", strings.TrimPrefix(strings.TrimLeft(start, " "), "\n"), matchBeginning, secret, matchEnd, lineEnd)
|
||||||
fmt.Printf("%-12s %s", "Finding:", finding)
|
|
||||||
|
if skipColor {
|
||||||
|
fmt.Printf("%-12s %s\n", "Finding:", f.Match)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%-12s %s", "Finding:", finding)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("%-12s %s\n", "Secret:", secret)
|
fmt.Printf("%-12s %s\n", "Secret:", secret)
|
||||||
fmt.Printf("%-12s %s\n", "RuleID:", f.RuleID)
|
fmt.Printf("%-12s %s\n", "RuleID:", f.RuleID)
|
||||||
fmt.Printf("%-12s %f\n", "Entropy:", f.Entropy)
|
fmt.Printf("%-12s %f\n", "Entropy:", f.Entropy)
|
||||||
|
|||||||
Reference in new issue
Block a user