Redact sensitive values before logging them (#33829)

* use a common way to redact sensitive values before logging them

* fix panic on missing testCase.err, simplify require checks

* fix a silly typo

* combine readConfig and buildConnectionString methods, as they are closely related
This commit is contained in:
Serge Zaitsev
2021-05-10 17:03:10 +02:00
committed by GitHub
parent 5c13820bba
commit da13f88862
6 changed files with 77 additions and 94 deletions

View File

@@ -28,7 +28,7 @@ func parseRedisConnStr(connStr string) (*redis.Options, error) {
if len(keyValueTuple) != 2 {
if strings.HasPrefix(rawKeyValue, "password") {
// don't log the password
rawKeyValue = "password******"
rawKeyValue = "password" + setting.RedactedPassword
}
return nil, fmt.Errorf("incorrect redis connection string format detected for '%v', format is key=value,key=value", rawKeyValue)
}