@@ -57,8 +57,9 @@ const (
57
57
)
58
58
59
59
var (
60
- secretsRegexpOnce sync.Once
61
- secretsRegexp * regexp.Regexp
60
+ secretsRegexpOnce sync.Once
61
+ secretsRegexp * regexp.Regexp
62
+ secretsAllowRegexp * regexp.Regexp
62
63
)
63
64
64
65
var nonEnvArgs = map [string ]struct {}{
@@ -2445,7 +2446,7 @@ func validateBaseImagePlatform(name string, expected, actual ocispecs.Platform,
2445
2446
}
2446
2447
}
2447
2448
2448
- func getSecretsRegex () * regexp.Regexp {
2449
+ func getSecretsRegex () ( * regexp.Regexp , * regexp. Regexp ) {
2449
2450
// Check for either full value or first/last word.
2450
2451
// Examples: api_key, DATABASE_PASSWORD, GITHUB_TOKEN, secret_MESSAGE, AUTH
2451
2452
// Case insensitive.
@@ -2464,13 +2465,19 @@ func getSecretsRegex() *regexp.Regexp {
2464
2465
}
2465
2466
pattern := `(?i)(?:_|^)(?:` + strings .Join (secretTokens , "|" ) + `)(?:_|$)`
2466
2467
secretsRegexp = regexp .MustCompile (pattern )
2468
+
2469
+ allowTokens := []string {
2470
+ "public" ,
2471
+ }
2472
+ allowPattern := `(?i)(?:_|^)(?:` + strings .Join (allowTokens , "|" ) + `)(?:_|$)`
2473
+ secretsAllowRegexp = regexp .MustCompile (allowPattern )
2467
2474
})
2468
- return secretsRegexp
2475
+ return secretsRegexp , secretsAllowRegexp
2469
2476
}
2470
2477
2471
2478
func validateNoSecretKey (instruction , key string , location []parser.Range , lint * linter.Linter ) {
2472
- pattern := getSecretsRegex ()
2473
- if pattern .MatchString (key ) {
2479
+ deny , allow := getSecretsRegex ()
2480
+ if deny . MatchString ( key ) && ! allow .MatchString (key ) {
2474
2481
msg := linter .RuleSecretsUsedInArgOrEnv .Format (instruction , key )
2475
2482
lint .Run (& linter .RuleSecretsUsedInArgOrEnv , location , msg )
2476
2483
}
0 commit comments