remove trailing commas and quotes from snowflake passwords (#4078)

Co-authored-by: Kashif Khan <[email protected]>
This commit is contained in:
Abdul Basit
2025-04-23 15:21:18 +05:00
committed by GitHub
co-authored by Kashif Khan
parent 92bf40a827
commit b2ed7caeec
2 changed files with 27 additions and 5 deletions
+2 -2
View File
@@ -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 res
+25 -3
View File
@@ -70,10 +70,20 @@ func TestUsernameRegexCheck(t *testing.T) {
testString := `username = "johnsmith123"
username='johnsmith123'
username:="johnsmith123"
username:="johnsmith123",
username:="johnsmith123";
username = johnsmith123
username=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))