mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b5e8e1829 |
No files matched your search
@@ -335,6 +335,10 @@ paths = [
|
|||||||
'''go\.mod''',
|
'''go\.mod''',
|
||||||
'''go\.sum'''
|
'''go\.sum'''
|
||||||
]
|
]
|
||||||
|
# note: (rule) regexTarget defaults to check the _Secret_ in the finding.
|
||||||
|
# if regexTarget is not specified then _Secret_ will be used.
|
||||||
|
# Acceptable values for regexTarget are "match" and "line"
|
||||||
|
regexTarget = "match"
|
||||||
regexes = [
|
regexes = [
|
||||||
'''process''',
|
'''process''',
|
||||||
'''getenv''',
|
'''getenv''',
|
||||||
@@ -357,6 +361,12 @@ paths = [
|
|||||||
'''gitleaks\.toml''',
|
'''gitleaks\.toml''',
|
||||||
'''(.*?)(jpg|gif|doc)'''
|
'''(.*?)(jpg|gif|doc)'''
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# note: (global) regexTarget defaults to check the _Secret_ in the finding.
|
||||||
|
# if regexTarget is not specified then _Secret_ will be used.
|
||||||
|
# Acceptable values for regexTarget are "match" and "line"
|
||||||
|
regexTarget = "match"
|
||||||
|
|
||||||
regexes = [
|
regexes = [
|
||||||
'''219-09-9999''',
|
'''219-09-9999''',
|
||||||
'''078-05-1120''',
|
'''078-05-1120''',
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ type Allowlist struct {
|
|||||||
// Regexes is slice of content regular expressions that are allowed to be ignored.
|
// Regexes is slice of content regular expressions that are allowed to be ignored.
|
||||||
Regexes []*regexp.Regexp
|
Regexes []*regexp.Regexp
|
||||||
|
|
||||||
|
// RegexTarget
|
||||||
|
RegexTarget string
|
||||||
|
|
||||||
// Paths is a slice of path regular expressions that are allowed to be ignored.
|
// Paths is a slice of path regular expressions that are allowed to be ignored.
|
||||||
Paths []*regexp.Regexp
|
Paths []*regexp.Regexp
|
||||||
|
|
||||||
|
|||||||
+20
-16
@@ -36,17 +36,19 @@ type ViperConfig struct {
|
|||||||
Tags []string
|
Tags []string
|
||||||
|
|
||||||
Allowlist struct {
|
Allowlist struct {
|
||||||
Regexes []string
|
RegexTarget string
|
||||||
Paths []string
|
Regexes []string
|
||||||
Commits []string
|
Paths []string
|
||||||
StopWords []string
|
Commits []string
|
||||||
|
StopWords []string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Allowlist struct {
|
Allowlist struct {
|
||||||
Regexes []string
|
RegexTarget string
|
||||||
Paths []string
|
Regexes []string
|
||||||
Commits []string
|
Paths []string
|
||||||
StopWords []string
|
Commits []string
|
||||||
|
StopWords []string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,10 +124,11 @@ func (vc *ViperConfig) Translate() (Config, error) {
|
|||||||
Tags: r.Tags,
|
Tags: r.Tags,
|
||||||
Keywords: r.Keywords,
|
Keywords: r.Keywords,
|
||||||
Allowlist: Allowlist{
|
Allowlist: Allowlist{
|
||||||
Regexes: allowlistRegexes,
|
RegexTarget: r.Allowlist.RegexTarget,
|
||||||
Paths: allowlistPaths,
|
Regexes: allowlistRegexes,
|
||||||
Commits: r.Allowlist.Commits,
|
Paths: allowlistPaths,
|
||||||
StopWords: r.Allowlist.StopWords,
|
Commits: r.Allowlist.Commits,
|
||||||
|
StopWords: r.Allowlist.StopWords,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
orderedRules = append(orderedRules, r.RuleID)
|
orderedRules = append(orderedRules, r.RuleID)
|
||||||
@@ -148,10 +151,11 @@ func (vc *ViperConfig) Translate() (Config, error) {
|
|||||||
Extend: vc.Extend,
|
Extend: vc.Extend,
|
||||||
Rules: rulesMap,
|
Rules: rulesMap,
|
||||||
Allowlist: Allowlist{
|
Allowlist: Allowlist{
|
||||||
Regexes: allowlistRegexes,
|
RegexTarget: vc.Allowlist.RegexTarget,
|
||||||
Paths: allowlistPaths,
|
Regexes: allowlistRegexes,
|
||||||
Commits: vc.Allowlist.Commits,
|
Paths: allowlistPaths,
|
||||||
StopWords: vc.Allowlist.StopWords,
|
Commits: vc.Allowlist.Commits,
|
||||||
|
StopWords: vc.Allowlist.StopWords,
|
||||||
},
|
},
|
||||||
Keywords: keywords,
|
Keywords: keywords,
|
||||||
orderedRules: orderedRules,
|
orderedRules: orderedRules,
|
||||||
|
|||||||
+18
-3
@@ -284,9 +284,24 @@ func (d *Detector) detectRule(fragment Fragment, rule config.Rule) []report.Find
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the secret is in the allowlist
|
// check if the regexTarget is defined in the allowlist "regexes" entry
|
||||||
if rule.Allowlist.RegexAllowed(finding.Secret) ||
|
allowlistTarget := finding.Secret
|
||||||
d.Config.Allowlist.RegexAllowed(finding.Secret) {
|
switch rule.Allowlist.RegexTarget {
|
||||||
|
case "match":
|
||||||
|
allowlistTarget = finding.Match
|
||||||
|
case "line":
|
||||||
|
allowlistTarget = finding.Line
|
||||||
|
}
|
||||||
|
|
||||||
|
globalAllowlistTarget := finding.Secret
|
||||||
|
switch d.Config.Allowlist.RegexTarget {
|
||||||
|
case "match":
|
||||||
|
globalAllowlistTarget = finding.Match
|
||||||
|
case "line":
|
||||||
|
globalAllowlistTarget = finding.Line
|
||||||
|
}
|
||||||
|
if rule.Allowlist.RegexAllowed(allowlistTarget) ||
|
||||||
|
d.Config.Allowlist.RegexAllowed(globalAllowlistTarget) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user