fix_: correct sensitive regex (#6188)
This commit is contained in:
parent
08eee8a647
commit
75bdda2712
|
@ -37,7 +37,7 @@ var sensitiveKeys = []string{
|
|||
"gifs/api-key",
|
||||
}
|
||||
|
||||
var sensitiveRegexString = fmt.Sprintf(`(?i)(".*?(%s).*?")\s*:\s*("[^"]*")`, strings.Join(sensitiveKeys, "|"))
|
||||
var sensitiveRegexString = fmt.Sprintf(`(?i)("\w*?(%s)\w*?")\s*:\s*(".*?")`, strings.Join(sensitiveKeys, "|"))
|
||||
|
||||
var sensitiveRegex = regexp.MustCompile(sensitiveRegexString)
|
||||
|
||||
|
|
|
@ -49,6 +49,11 @@ func TestRemoveSensitiveInfo(t *testing.T) {
|
|||
input: `{"username":"user1","email":"user1@example.com"}`,
|
||||
expected: `{"username":"user1","email":"user1@example.com"}`,
|
||||
},
|
||||
{
|
||||
name: "should not match password substring in field names",
|
||||
input: `{"eventValue":{"flowType":"UserProfileCreatePassword","viewId":"UserProfileCreatePassword"}}`,
|
||||
expected: `{"eventValue":{"flowType":"UserProfileCreatePassword","viewId":"UserProfileCreatePassword"}}`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
|
Loading…
Reference in New Issue