Feat/allowlist regex target (#1107)

* adding regexTarget entry in allowlist

* update readme

* add globalregextarget to check

* update readme
This commit is contained in:
Zachary Rice authored and GitHub committed 2023-02-26 08:51:59 -06:00
1 parent 343e69399b
commit 4b5e8e1829
4 files changed
+51 -19

No files matched your search

+18 -3
View File
@@ -284,9 +284,24 @@ func (d *Detector) detectRule(fragment Fragment, rule config.Rule) []report.Find
continue
}
// check if the secret is in the allowlist
if rule.Allowlist.RegexAllowed(finding.Secret) ||
d.Config.Allowlist.RegexAllowed(finding.Secret) {
// check if the regexTarget is defined in the allowlist "regexes" entry
allowlistTarget := 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
}