Skip to content
Merged
1 change: 1 addition & 0 deletions .2ms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1383,3 +1383,4 @@ ignore-result:
- fcaf9a97bbcf85b33f88738b1e817e098e9c37e1 # unit test from e2e_test.go
- fe08c7c6c7f8bb715022aa4cd16ae1c69906ebba # test data from expectedReportWithValidation.json
- 5858849b35c4d0c6061a61c28c39e28b98844333 # unit test from rule_test.go
- 93a8246bc5d82a9d47d8b683b4343b51dc3bb918 # unit test from generic_credential_test.go
6 changes: 3 additions & 3 deletions engine/rules/ruledefine/generic_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var genericCredentialRegex = generateSemiGenericRegexIncludingXml([]string{
"passw(?:or)?d",
"secret",
"token",
}, `[\w.=-]{10,150}|[a-z0-9][a-z0-9+/]{11,}={0,3}`, true).String()
}, `[\w.=\-~?!:@]{10,150}|[a-z0-9][a-z0-9+/]{11,}={0,3}`, true).String()

func GenericCredential() *Rule {
return &Rule{
Expand All @@ -42,7 +42,7 @@ func GenericCredential() *Rule {
// NOTE: this is a goofy hack to get around the fact there golang's regex engine does not support positive lookaheads.
// Ideally we would want to ensure the secret contains both numbers and alphabetical characters, not just alphabetical characters.
Regexes: []string{
regexp.MustCompile(`^[a-zA-Z_.-]+$`).String(),
regexp.MustCompile(`^[a-zA-Z_.-]+:?$`).String(),
},
},
{
Expand All @@ -60,7 +60,7 @@ func GenericCredential() *Rule {
`|rapid|capital` + // common words containing "api"
`|[a-z0-9-]*?api[a-z0-9-]*?:jar:` + // Maven META-INF dependencies that contain "api" in the name.
// Auth
`|author` +
`|\bauthor\b` +
`|X-MS-Exchange-Organization-Auth` + // email header
`|Authentication-Results` + // email header
// Credentials
Expand Down
1 change: 1 addition & 0 deletions engine/rules/ruledefine/generic_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestGenericCredential(t *testing.T) {
" utils.GetEnvOrDefault(\"api_token\", \"dafa7817-e246-48f3-91a7-e87653d587b8\")",
// xml cases
"<key>API_KEY</key>\n<string>AIzaSyATDL7Wz3Ze6BU31Yv3fVVth30Skyib29g</string>",
"Authorization.ClientSecret: e55wsdasfsgs-sdsdas_2sdasjVM~ggadASaADASsad",
Comment thread
cx-jose-fernandes marked this conversation as resolved.
},
falsePositives: []string{
Comment thread
cx-jose-fernandes marked this conversation as resolved.
"issuerKeyHash=npmXsmT2_C1iJZ-SD7RuL8exZ=6ucd",
Expand Down
Loading