remove trailing commas and quotes from snowflake passwords (#4078)
Co-authored-by: Kashif Khan <[email protected]>
This commit is contained in:
co-authored by
Kashif Khan
parent
92bf40a827
commit
b2ed7caeec
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user