diff --git a/detect/detect.go b/detect/detect.go index e3322c3b..6bcef851 100644 --- a/detect/detect.go +++ b/detect/detect.go @@ -72,7 +72,7 @@ func DetectFindings(cfg config.Config, b []byte, filePath string, commit string) Tags: r.Tags, } - if r.Allowlist.RegexAllowed(f.Secret) { + if r.Allowlist.RegexAllowed(f.Secret) || cfg.Allowlist.RegexAllowed(f.Secret) { continue } diff --git a/detect/detect_test.go b/detect/detect_test.go index 8b7abd02..71ad40b4 100644 --- a/detect/detect_test.go +++ b/detect/detect_test.go @@ -118,6 +118,12 @@ func TestDetectFindings(t *testing.T) { filePath: filepath.Join(configPath, "simple.toml"), expectedFindings: []report.Finding{}, }, + { + cfgName: "allow_global_aws_re", + bytes: []byte(`awsToken := \"AKIALALEMEL33243OLIA\"`), + filePath: "tmp.go", + expectedFindings: []report.Finding{}, + }, } for _, tt := range tests { diff --git a/testdata/config/allow_global_aws_re.toml b/testdata/config/allow_global_aws_re.toml new file mode 100644 index 00000000..7b7c3eee --- /dev/null +++ b/testdata/config/allow_global_aws_re.toml @@ -0,0 +1,8 @@ +[[rules]] + description = "AWS Access Key" + id = "aws-access-key" + regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}''' + tags = ["key", "AWS"] + +[allowlist] + regexes = ['''AKIALALEMEL33243OLIA''']