Compare commits

..
2 Commits
Author SHA1 Message Date
Zachary Rice f93e5dc844 adding a ton of stopwords to the generic rule only as that is the loudest rule (#851) 2022-04-21 17:01:21 -05:00
Zachary Rice 8481f0e9cd adding stopwords (#849)
* adding stopwords

* format readme, update default config
2022-04-21 08:31:58 -05:00
65 changed files with 3158 additions and 127 deletions

No files matched your search

+25 -12
View File
@@ -233,9 +233,9 @@ entropy = 3.5
# either be part of the idenitifer or unique strings specific to the rule's regex # either be part of the idenitifer or unique strings specific to the rule's regex
# (introduced in v8.6.0) # (introduced in v8.6.0)
keywords = [ keywords = [
"auth", "auth",
"password", "password",
"token", "token",
] ]
# You can include an allowlist table for a single rule to reduce false positives or ignore commits # You can include an allowlist table for a single rule to reduce false positives or ignore commits
@@ -244,13 +244,20 @@ keywords = [
description = "ignore commit A" description = "ignore commit A"
commits = [ "commit-A", "commit-B"] commits = [ "commit-A", "commit-B"]
paths = [ paths = [
'''go\.mod''', '''go\.mod''',
'''go\.sum''' '''go\.sum'''
] ]
regexes = [ regexes = [
'''process''', '''process''',
'''getenv''', '''getenv''',
] ]
# note: stopwords targets the extracted secret, not the entire regex match
# like 'regexes' does. (stopwords introduced in 8.8.0)
stopwords = [
'''client''',
'''endpoint''',
]
# This is a global allowlist which has a higher order of precedence than rule-specific allowlists. # This is a global allowlist which has a higher order of precedence than rule-specific allowlists.
# If a commit listed in the `commits` field below is encountered then that commit will be skipped and no # If a commit listed in the `commits` field below is encountered then that commit will be skipped and no
@@ -259,13 +266,19 @@ regexes = [
description = "global allow list" description = "global allow list"
commits = [ "commit-A", "commit-B", "commit-C"] commits = [ "commit-A", "commit-B", "commit-C"]
paths = [ paths = [
'''gitleaks\.toml''', '''gitleaks\.toml''',
'''(.*?)(jpg|gif|doc)''' '''(.*?)(jpg|gif|doc)'''
] ]
regexes = [ regexes = [
'''219-09-9999''', '''219-09-9999''',
'''078-05-1120''', '''078-05-1120''',
'''(9[0-9]{2}|666)-\d{2}-\d{4}''', '''(9[0-9]{2}|666)-\d{2}-\d{4}''',
]
# note: stopwords targets the extracted secret, not the entire regex match
# like 'regexes' does. (stopwords introduced in 8.8.0)
stopwords = [
'''client''',
'''endpoint''',
] ]
``` ```
Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples and advice on writing regular expressions for secret detection. Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples and advice on writing regular expressions for secret detection.
+1 -4
View File
@@ -50,7 +50,6 @@ func main() {
configRules = append(configRules, rules.FlutterwaveSecretKey()) configRules = append(configRules, rules.FlutterwaveSecretKey())
configRules = append(configRules, rules.FlutterwaveSecretKey()) configRules = append(configRules, rules.FlutterwaveSecretKey())
configRules = append(configRules, rules.FrameIO()) configRules = append(configRules, rules.FrameIO())
configRules = append(configRules, rules.GenericCredential())
configRules = append(configRules, rules.GoCardless()) configRules = append(configRules, rules.GoCardless())
// TODO figure out what makes sense for GCP // TODO figure out what makes sense for GCP
// configRules = append(configRules, rules.GCPServiceAccount()) // configRules = append(configRules, rules.GCPServiceAccount())
@@ -101,6 +100,7 @@ func main() {
configRules = append(configRules, rules.TwitchAPIToken()) configRules = append(configRules, rules.TwitchAPIToken())
configRules = append(configRules, rules.Twitter()) configRules = append(configRules, rules.Twitter())
configRules = append(configRules, rules.Typeform()) configRules = append(configRules, rules.Typeform())
configRules = append(configRules, rules.GenericCredential())
config := config.Config{ config := config.Config{
Rules: configRules, Rules: configRules,
@@ -117,6 +117,3 @@ func main() {
tmpl.Execute(f, config) tmpl.Execute(f, config)
} }
// TODO introduce skiplists:
// https://github.com/danielmiessler/SecLists/blob/master/Miscellaneous/wordlist-skipfish.fuzz.txt
+2 -2
View File
@@ -19,7 +19,7 @@ func AdobeClientID() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("adobe", secrets.NewSecret(hex("32"))), generateSampleSecret("adobe", secrets.NewSecret(hex("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func AdobeClientSecret() *config.Rule { func AdobeClientSecret() *config.Rule {
@@ -35,5 +35,5 @@ func AdobeClientSecret() *config.Rule {
tps := []string{ tps := []string{
"adobeClient := \"p8e-" + secrets.NewSecret(hex("32")) + "\"", "adobeClient := \"p8e-" + secrets.NewSecret(hex("32")) + "\"",
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -19,5 +19,5 @@ func AgeSecretKey() *config.Rule {
tps := []string{ tps := []string{
`apiKey := "AGE-SECRET-KEY-1QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ`, // gitleaks:allow `apiKey := "AGE-SECRET-KEY-1QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ`, // gitleaks:allow
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+2 -2
View File
@@ -18,7 +18,7 @@ func AlibabaAccessKey() *config.Rule {
tps := []string{ tps := []string{
"alibabaKey := \"LTAI" + secrets.NewSecret(hex("20")) + "\"", "alibabaKey := \"LTAI" + secrets.NewSecret(hex("20")) + "\"",
} }
return validate(r, tps) return validate(r, tps, nil)
} }
// TODO // TODO
@@ -37,5 +37,5 @@ func AlibabaSecretKey() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("alibaba", secrets.NewSecret(alphaNumeric("30"))), generateSampleSecret("alibaba", secrets.NewSecret(alphaNumeric("30"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+3 -2
View File
@@ -19,7 +19,7 @@ func AsanaClientID() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("asana", secrets.NewSecret(numeric("16"))), generateSampleSecret("asana", secrets.NewSecret(numeric("16"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func AsanaClientSecret() *config.Rule { func AsanaClientSecret() *config.Rule {
@@ -28,6 +28,7 @@ func AsanaClientSecret() *config.Rule {
Description: "Asana Client Secret", Description: "Asana Client Secret",
RuleID: "asana-client-secret", RuleID: "asana-client-secret",
Regex: generateSemiGenericRegex([]string{"asana"}, alphaNumeric("32")), Regex: generateSemiGenericRegex([]string{"asana"}, alphaNumeric("32")),
SecretGroup: 1,
Keywords: []string{"asana"}, Keywords: []string{"asana"},
} }
@@ -35,5 +36,5 @@ func AsanaClientSecret() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("asana", secrets.NewSecret(alphaNumeric("32"))), generateSampleSecret("asana", secrets.NewSecret(alphaNumeric("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func Atlassian() *config.Rule {
generateSampleSecret("atlassian", secrets.NewSecret(alphaNumeric("24"))), generateSampleSecret("atlassian", secrets.NewSecret(alphaNumeric("24"))),
generateSampleSecret("confluence", secrets.NewSecret(alphaNumeric("24"))), generateSampleSecret("confluence", secrets.NewSecret(alphaNumeric("24"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -27,5 +27,5 @@ func AWS() *config.Rule {
// validate // validate
tps := []string{generateSampleSecret("AWS", "AKIALALEMEL33243OLIB")} // gitleaks:allow tps := []string{generateSampleSecret("AWS", "AKIALALEMEL33243OLIB")} // gitleaks:allow
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func Beamer() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("beamer", "b_"+secrets.NewSecret(alphaNumericExtended("44"))), generateSampleSecret("beamer", "b_"+secrets.NewSecret(alphaNumericExtended("44"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+2 -2
View File
@@ -19,7 +19,7 @@ func BitBucketClientID() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("bitbucket", secrets.NewSecret(alphaNumeric("32"))), generateSampleSecret("bitbucket", secrets.NewSecret(alphaNumeric("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func BitBucketClientSecret() *config.Rule { func BitBucketClientSecret() *config.Rule {
@@ -36,5 +36,5 @@ func BitBucketClientSecret() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("bitbucket", secrets.NewSecret(alphaNumeric("64"))), generateSampleSecret("bitbucket", secrets.NewSecret(alphaNumeric("64"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func Clojars() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("clojars", "CLOJARS_"+secrets.NewSecret(alphaNumeric("60"))), generateSampleSecret("clojars", "CLOJARS_"+secrets.NewSecret(alphaNumeric("60"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+13 -1
View File
@@ -18,7 +18,19 @@ paths = [
] ]
{{ range $i, $rule := .Rules }}[[rules]] {{ range $i, $rule := .Rules }}[[rules]]
{{ if and $rule.SecretGroup $rule.Entropy }}description = "{{$rule.Description}}" {{ if and $rule.SecretGroup $rule.Entropy $rule.Allowlist.StopWords }}description = "{{$rule.Description}}"
id = "{{$rule.RuleID}}"
regex = '''{{$rule.Regex}}'''
secretGroup = {{ $rule.SecretGroup }}
entropy = {{ $rule.Entropy}}
keywords = [
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
]
[rules.allowlist]
stopwords= [{{ range $j, $stopword := $rule.Allowlist.StopWords }}
"{{$stopword}}",{{end}}
]
{{ else if and $rule.SecretGroup $rule.Entropy }}description = "{{$rule.Description}}"
id = "{{$rule.RuleID}}" id = "{{$rule.RuleID}}"
regex = '''{{$rule.Regex}}''' regex = '''{{$rule.Regex}}'''
secretGroup = {{ $rule.SecretGroup }} secretGroup = {{ $rule.SecretGroup }}
+1 -1
View File
@@ -20,5 +20,5 @@ func Contentful() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("contentful", secrets.NewSecret(alphaNumeric("43"))), generateSampleSecret("contentful", secrets.NewSecret(alphaNumeric("43"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -18,5 +18,5 @@ func Databricks() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("databricks", "dapi"+secrets.NewSecret(hex("32"))), generateSampleSecret("databricks", "dapi"+secrets.NewSecret(hex("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+3 -3
View File
@@ -19,7 +19,7 @@ func DiscordAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("discord", secrets.NewSecret(hex("64"))), generateSampleSecret("discord", secrets.NewSecret(hex("64"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func DiscordClientID() *config.Rule { func DiscordClientID() *config.Rule {
@@ -36,7 +36,7 @@ func DiscordClientID() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("discord", secrets.NewSecret(numeric("18"))), generateSampleSecret("discord", secrets.NewSecret(numeric("18"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func DiscordClientSecret() *config.Rule { func DiscordClientSecret() *config.Rule {
@@ -53,5 +53,5 @@ func DiscordClientSecret() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("discord", secrets.NewSecret(numeric("32"))), generateSampleSecret("discord", secrets.NewSecret(numeric("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,7 +20,7 @@ func Doppler() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("doppler", "dp.pt."+secrets.NewSecret(alphaNumeric("43"))), generateSampleSecret("doppler", "dp.pt."+secrets.NewSecret(alphaNumeric("43"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
// TODO add additional doppler formats: // TODO add additional doppler formats:
+1 -1
View File
@@ -19,7 +19,7 @@ func DropBoxAPISecret() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("dropbox", secrets.NewSecret(alphaNumeric("15"))), generateSampleSecret("dropbox", secrets.NewSecret(alphaNumeric("15"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func DropBoxShortLivedAPIToken() *config.Rule { func DropBoxShortLivedAPIToken() *config.Rule {
+1 -1
View File
@@ -20,5 +20,5 @@ func Duffel() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("duffel", "duffel_test_"+secrets.NewSecret(alphaNumericExtended("43"))), generateSampleSecret("duffel", "duffel_test_"+secrets.NewSecret(alphaNumericExtended("43"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func Dynatrace() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("dynatrace", "dt0c01."+secrets.NewSecret(alphaNumeric("24"))+"."+secrets.NewSecret(alphaNumeric("64"))), generateSampleSecret("dynatrace", "dt0c01."+secrets.NewSecret(alphaNumeric("24"))+"."+secrets.NewSecret(alphaNumeric("64"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+2 -2
View File
@@ -20,7 +20,7 @@ func EasyPost() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("EZAK", "EZAK"+secrets.NewSecret(alphaNumeric("54"))), generateSampleSecret("EZAK", "EZAK"+secrets.NewSecret(alphaNumeric("54"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func EasyPostTestAPI() *config.Rule { func EasyPostTestAPI() *config.Rule {
@@ -36,5 +36,5 @@ func EasyPostTestAPI() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("EZTK", "EZTK"+secrets.NewSecret(alphaNumeric("54"))), generateSampleSecret("EZTK", "EZTK"+secrets.NewSecret(alphaNumeric("54"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -19,5 +19,5 @@ func Facebook() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("facebook", secrets.NewSecret(hex("32"))), generateSampleSecret("facebook", secrets.NewSecret(hex("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -19,5 +19,5 @@ func FastlyAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("fastly", secrets.NewSecret(alphaNumericExtended("32"))), generateSampleSecret("fastly", secrets.NewSecret(alphaNumericExtended("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+2 -2
View File
@@ -19,7 +19,7 @@ func FinicityClientSecret() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("finicity", secrets.NewSecret(alphaNumeric("20"))), generateSampleSecret("finicity", secrets.NewSecret(alphaNumeric("20"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func FinicityAPIToken() *config.Rule { func FinicityAPIToken() *config.Rule {
@@ -36,5 +36,5 @@ func FinicityAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("finicity", secrets.NewSecret(hex("32"))), generateSampleSecret("finicity", secrets.NewSecret(hex("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+3 -3
View File
@@ -20,7 +20,7 @@ func FlutterwavePublicKey() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("flutterwavePubKey", "FLWPUBK_TEST-"+secrets.NewSecret(hex("32"))+"-X"), generateSampleSecret("flutterwavePubKey", "FLWPUBK_TEST-"+secrets.NewSecret(hex("32"))+"-X"),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func FlutterwaveSecretKey() *config.Rule { func FlutterwaveSecretKey() *config.Rule {
@@ -36,7 +36,7 @@ func FlutterwaveSecretKey() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(hex("32"))+"-X"), generateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(hex("32"))+"-X"),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func FlutterwaveEncKey() *config.Rule { func FlutterwaveEncKey() *config.Rule {
@@ -52,5 +52,5 @@ func FlutterwaveEncKey() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(hex("12"))), generateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(hex("12"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func FrameIO() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("frameio", "fio-u-"+secrets.NewSecret(alphaNumericExtended("64"))), generateSampleSecret("frameio", "fio-u-"+secrets.NewSecret(alphaNumericExtended("64"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func GCPServiceAccount() *config.Rule {
tps := []string{ tps := []string{
`"type": "service_account"`, `"type": "service_account"`,
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+8 -3
View File
@@ -30,7 +30,10 @@ func GenericCredential() *config.Rule {
"password", "password",
"auth", "auth",
}, },
Entropy: 3.7, Entropy: 3.5,
Allowlist: config.Allowlist{
StopWords: DefaultStopWords,
},
} }
// validate // validate
@@ -39,7 +42,9 @@ func GenericCredential() *config.Rule {
generateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"), generateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"),
`"client_id" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`, `"client_id" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`,
`"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",`, `"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",`,
// TODO add more
} }
return validate(r, tps) fps := []string{
`client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.client-vpn-endpoint.id`,
}
return validate(r, tps, fps)
} }
+4 -4
View File
@@ -20,7 +20,7 @@ func GitHubPat() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("github", "ghp_"+secrets.NewSecret(alphaNumeric("36"))), generateSampleSecret("github", "ghp_"+secrets.NewSecret(alphaNumeric("36"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func GitHubOauth() *config.Rule { func GitHubOauth() *config.Rule {
@@ -36,7 +36,7 @@ func GitHubOauth() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("github", "gho_"+secrets.NewSecret(alphaNumeric("36"))), generateSampleSecret("github", "gho_"+secrets.NewSecret(alphaNumeric("36"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func GitHubApp() *config.Rule { func GitHubApp() *config.Rule {
@@ -53,7 +53,7 @@ func GitHubApp() *config.Rule {
generateSampleSecret("github", "ghu_"+secrets.NewSecret(alphaNumeric("36"))), generateSampleSecret("github", "ghu_"+secrets.NewSecret(alphaNumeric("36"))),
generateSampleSecret("github", "ghs_"+secrets.NewSecret(alphaNumeric("36"))), generateSampleSecret("github", "ghs_"+secrets.NewSecret(alphaNumeric("36"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func GitHubRefresh() *config.Rule { func GitHubRefresh() *config.Rule {
@@ -69,5 +69,5 @@ func GitHubRefresh() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("github", "ghr_"+secrets.NewSecret(alphaNumeric("36"))), generateSampleSecret("github", "ghr_"+secrets.NewSecret(alphaNumeric("36"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func Gitlab() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("gitlab", "glpat-"+secrets.NewSecret(alphaNumeric("20"))), generateSampleSecret("gitlab", "glpat-"+secrets.NewSecret(alphaNumeric("20"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+2 -1
View File
@@ -11,6 +11,7 @@ func GoCardless() *config.Rule {
RuleID: "gocardless-api-token", RuleID: "gocardless-api-token",
Description: "GoCardless API token", Description: "GoCardless API token",
Regex: generateSemiGenericRegex([]string{"gocardless"}, `live_(?i)[a-z0-9\-_=]{40}`), Regex: generateSemiGenericRegex([]string{"gocardless"}, `live_(?i)[a-z0-9\-_=]{40}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"live_", "live_",
"gocardless", "gocardless",
@@ -21,5 +22,5 @@ func GoCardless() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("gocardless", "live_"+secrets.NewSecret(alphaNumericExtended("40"))), generateSampleSecret("gocardless", "live_"+secrets.NewSecret(alphaNumericExtended("40"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func Hashicorp() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("hashicorpToken", secrets.NewSecret(hex("14"))+".atlasv1."+secrets.NewSecret(alphaNumericExtended("60,70"))), generateSampleSecret("hashicorpToken", secrets.NewSecret(hex("14"))+".atlasv1."+secrets.NewSecret(alphaNumericExtended("60,70"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -19,5 +19,5 @@ func Heroku() *config.Rule {
tps := []string{ tps := []string{
`const HEROKU_KEY = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow `const HEROKU_KEY = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -19,5 +19,5 @@ func HubSpot() *config.Rule {
tps := []string{ tps := []string{
`const hubspotKey = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow `const hubspotKey = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -19,5 +19,5 @@ func Intercom() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("intercom", secrets.NewSecret(alphaNumericExtended("60"))), generateSampleSecret("intercom", secrets.NewSecret(alphaNumericExtended("60"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+3 -2
View File
@@ -20,7 +20,7 @@ func LinearAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("linear", "lin_api_"+secrets.NewSecret(alphaNumeric("40"))), generateSampleSecret("linear", "lin_api_"+secrets.NewSecret(alphaNumeric("40"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func LinearClientSecret() *config.Rule { func LinearClientSecret() *config.Rule {
@@ -30,11 +30,12 @@ func LinearClientSecret() *config.Rule {
RuleID: "linear-client-secret", RuleID: "linear-client-secret",
Regex: generateSemiGenericRegex([]string{"linear"}, hex("32")), Regex: generateSemiGenericRegex([]string{"linear"}, hex("32")),
Keywords: []string{"linear"}, Keywords: []string{"linear"},
SecretGroup: 1,
} }
// validate // validate
tps := []string{ tps := []string{
generateSampleSecret("linear", secrets.NewSecret(hex("32"))), generateSampleSecret("linear", secrets.NewSecret(hex("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+2 -2
View File
@@ -25,7 +25,7 @@ func LinkedinClientSecret() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("linkedin", secrets.NewSecret(alphaNumeric("16"))), generateSampleSecret("linkedin", secrets.NewSecret(alphaNumeric("16"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func LinkedinClientID() *config.Rule { func LinkedinClientID() *config.Rule {
@@ -48,5 +48,5 @@ func LinkedinClientID() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("linkedin", secrets.NewSecret(alphaNumeric("14"))), generateSampleSecret("linkedin", secrets.NewSecret(alphaNumeric("14"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+4 -2
View File
@@ -11,6 +11,7 @@ func LobPubAPIToken() *config.Rule {
Description: "Lob Publishable API Key", Description: "Lob Publishable API Key",
RuleID: "lob-pub-api-key", RuleID: "lob-pub-api-key",
Regex: generateSemiGenericRegex([]string{"lob"}, `(test|live)_pub_[a-f0-9]{31}`), Regex: generateSemiGenericRegex([]string{"lob"}, `(test|live)_pub_[a-f0-9]{31}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"test_pub", "test_pub",
"live_pub", "live_pub",
@@ -22,7 +23,7 @@ func LobPubAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("lob", "test_pub_"+secrets.NewSecret(hex("31"))), generateSampleSecret("lob", "test_pub_"+secrets.NewSecret(hex("31"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func LobAPIToken() *config.Rule { func LobAPIToken() *config.Rule {
@@ -35,11 +36,12 @@ func LobAPIToken() *config.Rule {
"test_", "test_",
"live_", "live_",
}, },
SecretGroup: 1,
} }
// validate // validate
tps := []string{ tps := []string{
generateSampleSecret("lob", "test_"+secrets.NewSecret(hex("35"))), generateSampleSecret("lob", "test_"+secrets.NewSecret(hex("35"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -21,5 +21,5 @@ func MailChimp() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("mailchimp", secrets.NewSecret(hex("32"))+"-us20"), generateSampleSecret("mailchimp", secrets.NewSecret(hex("32"))+"-us20"),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+3 -3
View File
@@ -21,7 +21,7 @@ func MailGunPrivateAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("mailgun", "key-"+secrets.NewSecret(hex("32"))), generateSampleSecret("mailgun", "key-"+secrets.NewSecret(hex("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func MailGunPubAPIToken() *config.Rule { func MailGunPubAPIToken() *config.Rule {
@@ -40,7 +40,7 @@ func MailGunPubAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("mailgun", "pubkey-"+secrets.NewSecret(hex("32"))), generateSampleSecret("mailgun", "pubkey-"+secrets.NewSecret(hex("32"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func MailGunSigningKey() *config.Rule { func MailGunSigningKey() *config.Rule {
@@ -59,5 +59,5 @@ func MailGunSigningKey() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("mailgun", secrets.NewSecret(hex("32"))+"-00001111-22223333"), generateSampleSecret("mailgun", secrets.NewSecret(hex("32"))+"-00001111-22223333"),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -19,5 +19,5 @@ func MapBox() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("mapbox", "pk."+secrets.NewSecret(alphaNumeric("60"))+"."+secrets.NewSecret(alphaNumeric("22"))), generateSampleSecret("mapbox", "pk."+secrets.NewSecret(alphaNumeric("60"))+"."+secrets.NewSecret(alphaNumeric("22"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+2 -2
View File
@@ -29,7 +29,7 @@ func MessageBirdAPIToken() *config.Rule {
generateSampleSecret("message-bird", secrets.NewSecret(alphaNumeric("25"))), generateSampleSecret("message-bird", secrets.NewSecret(alphaNumeric("25"))),
generateSampleSecret("message_bird", secrets.NewSecret(alphaNumeric("25"))), generateSampleSecret("message_bird", secrets.NewSecret(alphaNumeric("25"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func MessageBirdClientID() *config.Rule { func MessageBirdClientID() *config.Rule {
@@ -54,5 +54,5 @@ func MessageBirdClientID() *config.Rule {
tps := []string{ tps := []string{
`const MessageBirdClientID = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow `const MessageBirdClientID = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+3 -3
View File
@@ -25,7 +25,7 @@ func NewRelicUserID() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("new-relic", "NRAK-"+secrets.NewSecret(alphaNumeric("27"))), generateSampleSecret("new-relic", "NRAK-"+secrets.NewSecret(alphaNumeric("27"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func NewRelicUserKey() *config.Rule { func NewRelicUserKey() *config.Rule {
@@ -50,7 +50,7 @@ func NewRelicUserKey() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("new-relic", secrets.NewSecret(alphaNumeric("64"))), generateSampleSecret("new-relic", secrets.NewSecret(alphaNumeric("64"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func NewRelicBrowserAPIKey() *config.Rule { func NewRelicBrowserAPIKey() *config.Rule {
@@ -73,5 +73,5 @@ func NewRelicBrowserAPIKey() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("new-relic", "NRJS-"+secrets.NewSecret(hex("19"))), generateSampleSecret("new-relic", "NRJS-"+secrets.NewSecret(hex("19"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -21,5 +21,5 @@ func NPM() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("npmAccessToken", "npm_"+secrets.NewSecret(alphaNumeric("36"))), generateSampleSecret("npmAccessToken", "npm_"+secrets.NewSecret(alphaNumeric("36"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+2 -2
View File
@@ -21,7 +21,7 @@ func PlanetScalePassword() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("43"))), generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("43"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func PlanetScaleToken() *config.Rule { func PlanetScaleToken() *config.Rule {
@@ -40,5 +40,5 @@ func PlanetScaleToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("43"))), generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("43"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -21,5 +21,5 @@ func PostManAPI() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("postmanAPItoken", "PMAK-"+secrets.NewSecret(hex("24"))+"-"+secrets.NewSecret(hex("34"))), generateSampleSecret("postmanAPItoken", "PMAK-"+secrets.NewSecret(hex("24"))+"-"+secrets.NewSecret(hex("34"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -19,5 +19,5 @@ func PrivateKey() *config.Rule {
tps := []string{`-----BEGIN PRIVATE KEY----- tps := []string{`-----BEGIN PRIVATE KEY-----
anything anything
-----END PRIVATE KEY-----`} // gitleaks:allow -----END PRIVATE KEY-----`} // gitleaks:allow
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -21,5 +21,5 @@ func PulumiAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("pulumi-api-token", "pul-"+secrets.NewSecret(hex("40"))), generateSampleSecret("pulumi-api-token", "pul-"+secrets.NewSecret(hex("40"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -22,5 +22,5 @@ func PyPiUploadToken() *config.Rule {
// validate // validate
tps := []string{"pypiToken := \"pypi-AgEIcHlwaS5vcmc" + secrets.NewSecret(hex("32")) + tps := []string{"pypiToken := \"pypi-AgEIcHlwaS5vcmc" + secrets.NewSecret(hex("32")) +
secrets.NewSecret(hex("32")) + "\""} secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -21,5 +21,5 @@ func RubyGemsAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("rubygemsAPIToken", "rubygems_"+secrets.NewSecret(hex("48"))), generateSampleSecret("rubygemsAPIToken", "rubygems_"+secrets.NewSecret(hex("48"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+7 -2
View File
@@ -54,7 +54,7 @@ func generateSampleSecret(identifier string, secret string) string {
return fmt.Sprintf("%s_api_token = \"%s\"", identifier, secret) return fmt.Sprintf("%s_api_token = \"%s\"", identifier, secret)
} }
func validate(r config.Rule, truePositives []string) *config.Rule { func validate(r config.Rule, truePositives []string, falsePositives []string) *config.Rule {
// normalize keywords like in the config package // normalize keywords like in the config package
var keywords []string var keywords []string
for _, k := range r.Keywords { for _, k := range r.Keywords {
@@ -68,7 +68,12 @@ func validate(r config.Rule, truePositives []string) *config.Rule {
}) })
for _, tp := range truePositives { for _, tp := range truePositives {
if len(d.DetectString(tp)) != 1 { if len(d.DetectString(tp)) != 1 {
log.Fatal().Msgf("Failed to validate %s", r.RuleID) log.Fatal().Msgf("Failed to validate (tp) %s %s", r.RuleID, tp)
}
}
for _, fp := range falsePositives {
if len(d.DetectString(fp)) != 0 {
log.Fatal().Msgf("Failed to validate (fp) %s", r.RuleID)
} }
} }
return &r return &r
+1 -1
View File
@@ -21,5 +21,5 @@ func SendGridAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("sengridAPIToken", "SG."+secrets.NewSecret(alphaNumericExtended("66"))), generateSampleSecret("sengridAPIToken", "SG."+secrets.NewSecret(alphaNumericExtended("66"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -21,5 +21,5 @@ func SendInBlueAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("sendinblue", "xkeysib-"+secrets.NewSecret(hex("64"))+"-"+secrets.NewSecret(alphaNumeric("16"))), generateSampleSecret("sendinblue", "xkeysib-"+secrets.NewSecret(hex("64"))+"-"+secrets.NewSecret(alphaNumeric("16"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -22,5 +22,5 @@ func ShippoAPIToken() *config.Rule {
generateSampleSecret("shippo", "shippo_live_"+secrets.NewSecret(hex("40"))), generateSampleSecret("shippo", "shippo_live_"+secrets.NewSecret(hex("40"))),
generateSampleSecret("shippo", "shippo_test_"+secrets.NewSecret(hex("40"))), generateSampleSecret("shippo", "shippo_test_"+secrets.NewSecret(hex("40"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+4 -4
View File
@@ -18,7 +18,7 @@ func ShopifySharedSecret() *config.Rule {
// validate // validate
tps := []string{"shopifySecret := \"shpss_" + secrets.NewSecret(hex("32")) + "\""} tps := []string{"shopifySecret := \"shpss_" + secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps) return validate(r, tps, nil)
} }
func ShopifyAccessToken() *config.Rule { func ShopifyAccessToken() *config.Rule {
@@ -32,7 +32,7 @@ func ShopifyAccessToken() *config.Rule {
// validate // validate
tps := []string{"shopifyToken := \"shpat_" + secrets.NewSecret(hex("32")) + "\""} tps := []string{"shopifyToken := \"shpat_" + secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps) return validate(r, tps, nil)
} }
func ShopifyCustomAccessToken() *config.Rule { func ShopifyCustomAccessToken() *config.Rule {
@@ -46,7 +46,7 @@ func ShopifyCustomAccessToken() *config.Rule {
// validate // validate
tps := []string{"shopifyToken := \"shpca_" + secrets.NewSecret(hex("32")) + "\""} tps := []string{"shopifyToken := \"shpca_" + secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps) return validate(r, tps, nil)
} }
func ShopifyPrivateAppAccessToken() *config.Rule { func ShopifyPrivateAppAccessToken() *config.Rule {
@@ -60,5 +60,5 @@ func ShopifyPrivateAppAccessToken() *config.Rule {
// validate // validate
tps := []string{"shopifyToken := \"shppa_" + secrets.NewSecret(hex("32")) + "\""} tps := []string{"shopifyToken := \"shppa_" + secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps) return validate(r, tps, nil)
} }
+3 -3
View File
@@ -27,7 +27,7 @@ func SlackAccessToken() *config.Rule {
tps := []string{ tps := []string{
"\"slackToken\": \"xoxb-" + secrets.NewSecret(alphaNumeric("30")) + "\"", "\"slackToken\": \"xoxb-" + secrets.NewSecret(alphaNumeric("30")) + "\"",
} }
return validate(r, tps) return validate(r, tps, nil)
} }
func SlackWebHook() *config.Rule { func SlackWebHook() *config.Rule {
@@ -44,7 +44,7 @@ func SlackWebHook() *config.Rule {
// validate // validate
tps := []string{ tps := []string{
"https://hooks.slack.com/services/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", // gitleaks:allow "https://hooks.slack.com/services/" + secrets.NewSecret(alphaNumeric("44")), // gitleaks:allow
} }
return validate(r, tps) return validate(r, tps, nil)
} }
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -23,5 +23,5 @@ func StripeAccessToken() *config.Rule {
// validate // validate
tps := []string{"stripeToken := \"sk_test_" + secrets.NewSecret(alphaNumeric("30")) + "\""} tps := []string{"stripeToken := \"sk_test_" + secrets.NewSecret(alphaNumeric("30")) + "\""}
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func Twilio() *config.Rule {
tps := []string{ tps := []string{
"twilioAPIKey := \"SK" + secrets.NewSecret(hex("32")) + "\"", "twilioAPIKey := \"SK" + secrets.NewSecret(hex("32")) + "\"",
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -21,5 +21,5 @@ func TwitchAPIToken() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("twitch", secrets.NewSecret(alphaNumeric("30"))), generateSampleSecret("twitch", secrets.NewSecret(alphaNumeric("30"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -20,5 +20,5 @@ func Twitter() *config.Rule {
"twitterToken := \"" + secrets.NewSecret(hex("36")) + "aaaa\"", "twitterToken := \"" + secrets.NewSecret(hex("36")) + "aaaa\"",
"twitterToken := `" + secrets.NewSecret(hex("36")) + "aaaa`", "twitterToken := `" + secrets.NewSecret(hex("36")) + "aaaa`",
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+1 -1
View File
@@ -22,5 +22,5 @@ func Typeform() *config.Rule {
tps := []string{ tps := []string{
generateSampleSecret("typeformAPIToken", "tfp_"+secrets.NewSecret(alphaNumericExtended("59"))), generateSampleSecret("typeformAPIToken", "tfp_"+secrets.NewSecret(alphaNumericExtended("59"))),
} }
return validate(r, tps) return validate(r, tps, nil)
} }
+19 -1
View File
@@ -1,6 +1,9 @@
package config package config
import "regexp" import (
"regexp"
"strings"
)
// Allowlist allows a rule to be ignored for specific // Allowlist allows a rule to be ignored for specific
// regexes, paths, and/or commits // regexes, paths, and/or commits
@@ -16,6 +19,11 @@ type Allowlist struct {
// Commits is a slice of commit SHAs that are allowed to be ignored. // Commits is a slice of commit SHAs that are allowed to be ignored.
Commits []string Commits []string
// StopWords is a slice of stop words that are allowed to be ignored.
// This targets the _secret_, not the content of the regex match like the
// Regexes slice.
StopWords []string
} }
// CommitAllowed returns true if the commit is allowed to be ignored. // CommitAllowed returns true if the commit is allowed to be ignored.
@@ -40,3 +48,13 @@ func (a *Allowlist) PathAllowed(path string) bool {
func (a *Allowlist) RegexAllowed(s string) bool { func (a *Allowlist) RegexAllowed(s string) bool {
return anyRegexMatch(s, a.Regexes) return anyRegexMatch(s, a.Regexes)
} }
func (a *Allowlist) ContainsStopWord(s string) bool {
s = strings.ToLower(s)
for _, stopWord := range a.StopWords {
if strings.Contains(s, strings.ToLower(stopWord)) {
return true
}
}
return false
}
+16 -12
View File
@@ -26,15 +26,17 @@ type ViperConfig struct {
Tags []string Tags []string
Allowlist struct { Allowlist struct {
Regexes []string Regexes []string
Paths []string Paths []string
Commits []string Commits []string
StopWords []string
} }
} }
Allowlist struct { Allowlist struct {
Regexes []string Regexes []string
Paths []string Paths []string
Commits []string Commits []string
StopWords []string
} }
} }
@@ -96,9 +98,10 @@ func (vc *ViperConfig) Translate() (Config, error) {
Tags: r.Tags, Tags: r.Tags,
Keywords: r.Keywords, Keywords: r.Keywords,
Allowlist: Allowlist{ Allowlist: Allowlist{
Regexes: allowlistRegexes, Regexes: allowlistRegexes,
Paths: allowlistPaths, Paths: allowlistPaths,
Commits: r.Allowlist.Commits, Commits: r.Allowlist.Commits,
StopWords: r.Allowlist.StopWords,
}, },
} }
if r.Regex != nil && r.SecretGroup > r.Regex.NumSubexp() { if r.Regex != nil && r.SecretGroup > r.Regex.NumSubexp() {
@@ -118,9 +121,10 @@ func (vc *ViperConfig) Translate() (Config, error) {
Description: vc.Description, Description: vc.Description,
Rules: rules, Rules: rules,
Allowlist: Allowlist{ Allowlist: Allowlist{
Regexes: allowlistRegexes, Regexes: allowlistRegexes,
Paths: allowlistPaths, Paths: allowlistPaths,
Commits: vc.Allowlist.Commits, Commits: vc.Allowlist.Commits,
StopWords: vc.Allowlist.StopWords,
}, },
Keywords: keywords, Keywords: keywords,
}, nil }, nil
+1489 -10
View File
File diff suppressed because it is too large. Load diff
+6
View File
@@ -217,6 +217,12 @@ func (d *Detector) detectRule(fragment Fragment, rule *config.Rule) []report.Fin
finding.Secret = secret finding.Secret = secret
} }
// check if the secret is in the list of stopwords
if rule.Allowlist.ContainsStopWord(finding.Secret) ||
d.Config.Allowlist.ContainsStopWord(finding.Secret) {
continue
}
// check entropy // check entropy
entropy := shannonEntropy(finding.Secret) entropy := shannonEntropy(finding.Secret)
finding.Entropy = float32(entropy) finding.Entropy = float32(entropy)