Skip to content

Commit 5bf169e

Browse files
author
Suhas Vishwanath
committed
#404 Add comma separator in password detection pattern
1 parent fe13d1a commit 5bf169e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.talismanrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fileignoreconfig:
2121
- filename: detector/pattern/match_pattern_test.go
2222
checksum: c95b8106ced5ad34ec1d00773a05f8789715034a734197c93cdaa4ed5036c177
2323
- filename: detector/pattern/pattern_detector.go
24-
checksum: 98c4edddc95b4b974ed9b3e4f48079f2503b5c85309fadf37878a3d28de31e72
24+
checksum: 78cddc944d4092ae2e88535d04f05281784848a990fb55a9d38339f29080a239
2525
- filename: detector/pattern/pattern_detector_test.go
2626
checksum: 4d70b790f28f2d23d506f808d489aa43f1efd2514549ae6a83a535e1223382e3
2727
- filename: detector/pattern_detector_test.go

detector/pattern/pattern_detector.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type PatternDetector struct {
1818

1919
var (
2020
detectorPatterns = []*severity.PatternSeverity{
21-
{Pattern: regexp.MustCompile(`(?i)((.*)(password|passphrase|secret|key|pwd|pword|pass)(.*) *[:=>][^,;\n]{8,})`), Severity: severity.SeverityConfiguration["PasswordPhrasePattern"]},
21+
{Pattern: regexp.MustCompile(`(?i)((.*)(password|passphrase|secret|key|pwd|pword|pass)(.*) *[:=>,][^,;\n]{8,})`), Severity: severity.SeverityConfiguration["PasswordPhrasePattern"]},
2222
{Pattern: regexp.MustCompile(`(?i)((:)(password|passphrase|secret|key|pwd|pword|pass)(.*) *[ ][^,;\n]{8,})`), Severity: severity.SeverityConfiguration["PasswordPhrasePattern"]},
2323
{Pattern: regexp.MustCompile(`(?i)(['"_]?pw['"]? *[:=][^,;\n]{8,})`), Severity: severity.SeverityConfiguration["PasswordPhrasePattern"]},
2424
{Pattern: regexp.MustCompile(`(?i)(<ConsumerKey>\S*</ConsumerKey>)`), Severity: severity.SeverityConfiguration["ConsumerKeyPattern"]},

detector/pattern/pattern_detector_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ func TestShouldDetectPasswordPatterns(t *testing.T) {
2929
shouldPassDetectionOfSecretPattern(filename, []byte(values[i]+"=UnsafeString"), t)
3030
shouldPassDetectionOfSecretPattern(filename, []byte("."+values[i]+"=randomStringGoesHere}"), t)
3131
shouldPassDetectionOfSecretPattern(filename, []byte(":"+values[i]+" randomStringGoesHere"), t)
32+
shouldPassDetectionOfSecretPattern(filename, []byte(values[i]+" ,\"randomStringGoesHere\""), t)
33+
shouldPassDetectionOfSecretPattern(filename, []byte("'" + values[i]+"' ,\"randomStringGoesHere\""), t)
34+
shouldPassDetectionOfSecretPattern(filename, []byte("\"" + values[i]+"\" ,\"randomStringGoesHere\""), t)
3235
shouldPassDetectionOfSecretPattern(filename,
3336
[]byte("\"SERVER_"+strings.ToUpper(values[i])+"\" : UnsafeString"),
3437
t)
@@ -55,7 +58,7 @@ func TestShouldDetectPasswordPatterns(t *testing.T) {
5558

5659
shouldFailDetectionOfSecretPattern(filename, []byte("\"pAsSWoRD\" :1234567"), t)
5760
shouldFailDetectionOfSecretPattern(filename, []byte(`setPassword("12345678")`), t)
58-
shouldFailDetectionOfSecretPattern(filename, []byte(`setenv(password, "12345678")`), t)
61+
shouldFailDetectionOfSecretPattern(filename, []byte(`setenv(password,123456)`), t)
5962
shouldFailDetectionOfSecretPattern(filename, []byte(`random=12345678)`), t)
6063
}
6164

0 commit comments

Comments
 (0)