Skip to content

Commit

Permalink
Merge 8f0b920 into cbb3882
Browse files Browse the repository at this point in the history
  • Loading branch information
mrngm committed Oct 29, 2019
2 parents cbb3882 + 8f0b920 commit dd20673
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions detector/match_pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

var (
testRegexpPassword = regexp.MustCompile(`(?i)(['|"|_]?password['|"]? *[:|=][^,|;]{8,})`)
testRegexpPw = regexp.MustCompile(`(?i)(['|"|_]?pw['|"]? *[:|=][^,|;]{8,})`)
testRegexpPassword = regexp.MustCompile(`(?i)(['"_]?password['"]? *[:=][^,;]{8,})`)
testRegexpPw = regexp.MustCompile(`(?i)(['"_]?pw['"]? *[:=][^,;]{8,})`)
)

func TestShouldReturnEmptyStringWhenDoesNotMatchAnyRegex(t *testing.T) {
Expand Down
18 changes: 9 additions & 9 deletions detector/pattern_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ type PatternDetector struct {

var (
detectorPatterns = []*regexp.Regexp{
regexp.MustCompile("(?i)(['|\"|_]?password['|\"]? *[:|=][^,|;|\n]{8,})"),
regexp.MustCompile("(?i)(['|\"|_]?pw['|\"]? *[:|=][^,|;|\n]{8,})"),
regexp.MustCompile("(?i)(['|\"|_]?pwd['|\"]? *[:|=][^,|;|\n]{8,})"),
regexp.MustCompile("(?i)(['|\"|_]?pass['|\"]? *[:|=][^,|;|\n]{8,})"),
regexp.MustCompile("(?i)(['|\"|_]?pword['|\"]? *[:|=][^,|;|\n]{8,})"),
regexp.MustCompile("(?i)(['|\"|_]?adminPassword['|\"]? *[:|=|\n][^,|;]{8,})"),
regexp.MustCompile("(?i)(['|\"|_]?passphrase['|\"]? *[:|=|\n][^,|;]{8,})"),
regexp.MustCompile("(?i)(['\"_]?password['\"]? *[:=][^,;\n]{8,})"),
regexp.MustCompile("(?i)(['\"_]?pw['\"]? *[:=][^,;\n]{8,})"),
regexp.MustCompile("(?i)(['\"_]?pwd['\"]? *[:=][^,;\n]{8,})"),
regexp.MustCompile("(?i)(['\"_]?pass['\"]? *[:=][^,;\n]{8,})"),
regexp.MustCompile("(?i)(['\"_]?pword['\"]? *[:=][^,;\n]{8,})"),
regexp.MustCompile("(?i)(['\"_]?adminPassword['\"]? *[:=\n][^,;]{8,})"),
regexp.MustCompile("(?i)(['\"_]?passphrase['\"]? *[:=\n][^,;]{8,})"),
regexp.MustCompile("(<[^(><.)]?password[^(><.)]*?>[^(><.)]+</[^(><.)]?password[^(><.)]*?>)"),
regexp.MustCompile("(<[^(><.)]?passphrase[^(><.)]*?>[^(><.)]+</[^(><.)]?passphrase[^(><.)]*?>)"),
regexp.MustCompile("(?i)(<ConsumerKey>\\S*<\\/ConsumerKey>)"),
regexp.MustCompile("(?i)(<ConsumerSecret>\\S*<\\/ConsumerSecret>)"),
regexp.MustCompile("(?i)(AWS[ |\\w]+key[ |\\w]+[:|=])"),
regexp.MustCompile("(?i)(AWS[ |\\w]+secret[ |\\w]+[:|=])"),
regexp.MustCompile("(?i)(AWS[ \\w]+key[ \\w]+[:=])"),
regexp.MustCompile("(?i)(AWS[ \\w]+secret[ \\w]+[:=])"),
regexp.MustCompile("(?s)(BEGIN RSA PRIVATE KEY.*END RSA PRIVATE KEY)"),
}
)
Expand Down

0 comments on commit dd20673

Please sign in to comment.