Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
remove trailing commas and quotes from snowflake passwords (#4078)
Abdul Basitb2ed7caeec8c
diff --git a/pkg/common/patterns.go b/pkg/common/patterns.goindex 7de020384..6ee68b522 100644--- a/pkg/common/patterns.go+++ b/pkg/common/patterns.go@@ -48,9 +48,9 @@ func (r RegexState) Matches(data []byte) []string {res := make([]string, 0, len(matches))- // trim off spaces and different quote types ('").+ // trim off all white spaces and different quote types ('"") & some special characters (,;).for i := range matches {- res = append(res, strings.Trim(matches[i][1], `"' )`))+ res = append(res, strings.Trim(strings.TrimSpace(matches[i][1]), `"' ),;`))}return resdiff --git a/pkg/common/patterns_test.go b/pkg/common/patterns_test.goindex 7f78736e4..a52f517e0 100644--- a/pkg/common/patterns_test.go+++ b/pkg/common/patterns_test.go@@ -70,10 +70,20 @@ func TestUsernameRegexCheck(t *testing.T) {testString := `username = "johnsmith123"username='johnsmith123'username:="johnsmith123"+ username:="johnsmith123",+ username:="johnsmith123";username = johnsmith123username=johnsmith123`- expectedStr := []string{"johnsmith123", "johnsmith123", "johnsmith123", "johnsmith123", "johnsmith123"}+ expectedStr := []string{+ "johnsmith123",+ "johnsmith123",+ "johnsmith123",+ "johnsmith123",+ "johnsmith123",+ "johnsmith123",+ "johnsmith123",+ }usernameRegexMatches := usernameRegexPat.Matches([]byte(testString))@@ -90,12 +100,24 @@ func TestPasswordRegexCheck(t *testing.T) {testString := `password = "johnsmith123$!"password='johnsmith123$!'password:="johnsmith123$!"+ password:="johnsmith123$!",+ password:="johnsmith123$!";+ password:="johnsmi',th123$!";password = johnsmith123$!password=johnsmith123$!PasswordAuthenticator(username, "johnsmith123$!")`- expectedStr := []string{"johnsmith123$!", "johnsmith123$!", "johnsmith123$!", "johnsmith123$!", "johnsmith123$!",- "johnsmith123$!"}+ expectedStr := []string{+ "johnsmith123$!",+ "johnsmith123$!",+ "johnsmith123$!",+ "johnsmith123$!",+ "johnsmith123$!",+ "johnsmi',th123$!",+ "johnsmith123$!",+ "johnsmith123$!",+ "johnsmith123$!",+ }passwordRegexMatches := passwordRegexPat.Matches([]byte(testString))