Commit 31547597 by Markus Blaschke Committed by Sofia Papagiannaki

remote_cache: Fix redis connstr parsing (#18204)

* Fix redis connstr parsing

* Don’t log the password
parent d16fd58b
...@@ -22,8 +22,12 @@ func parseRedisConnStr(connStr string) (*redis.Options, error) { ...@@ -22,8 +22,12 @@ func parseRedisConnStr(connStr string) (*redis.Options, error) {
keyValueCSV := strings.Split(connStr, ",") keyValueCSV := strings.Split(connStr, ",")
options := &redis.Options{Network: "tcp"} options := &redis.Options{Network: "tcp"}
for _, rawKeyValue := range keyValueCSV { for _, rawKeyValue := range keyValueCSV {
keyValueTuple := strings.Split(rawKeyValue, "=") keyValueTuple := strings.SplitN(rawKeyValue, "=", 2)
if len(keyValueTuple) != 2 { if len(keyValueTuple) != 2 {
if strings.HasPrefix(rawKeyValue, "password") {
// don't log the password
rawKeyValue = "password******"
}
return nil, fmt.Errorf("incorrect redis connection string format detected for '%v', format is key=value,key=value", rawKeyValue) return nil, fmt.Errorf("incorrect redis connection string format detected for '%v', format is key=value,key=value", rawKeyValue)
} }
connKey := keyValueTuple[0] connKey := keyValueTuple[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment