Settings: Redact token keyword (#97395)

* Settings: Redact token keyword

* Be more specific

* Given section is part of key, be more specific

* Fix test
This commit is contained in:
Gabriel MABILLE 2024-12-04 16:58:29 +01:00 committed by GitHub
parent f78cd0761b
commit ef79450065
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -599,6 +599,13 @@ func RedactedValue(key, value string) string {
"CLIENT_SECRET",
"ENTERPRISE_LICENSE",
"GF_ENTITY_API_DB_PASS",
"ID_FORWARDING_TOKEN$",
"AUTHENTICATION_TOKEN$",
"AUTH_TOKEN$",
"RENDERER_TOKEN$",
"API_TOKEN$",
"WEBHOOK_TOKEN$",
"INSTALL_TOKEN$",
} {
if match, err := regexp.MatchString(pattern, uppercased); match && err == nil {
return RedactedPassword

View File

@ -528,6 +528,12 @@ func TestRedactedValue(t *testing.T) {
value: "",
expected: "",
},
{
desc: "authentication_token",
key: "my_authentication_token",
value: "test",
expected: RedactedPassword,
},
}
for _, tc := range testCases {