From 99f2386bd920c9459e777ddbafbcaf96c3e46c33 Mon Sep 17 00:00:00 2001 From: Markus Blaschke Date: Tue, 23 Jul 2019 15:45:04 +0200 Subject: [PATCH] remote_cache: Fix redis connstr parsing (#18204) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix redis connstr parsing * Don’t log the password (cherry picked from commit 31547597d317292307827d425a1470a8e5350e93) --- pkg/infra/remotecache/redis_storage.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/infra/remotecache/redis_storage.go b/pkg/infra/remotecache/redis_storage.go index 7219ddbc21b..c6cfdf4c757 100644 --- a/pkg/infra/remotecache/redis_storage.go +++ b/pkg/infra/remotecache/redis_storage.go @@ -22,8 +22,12 @@ func parseRedisConnStr(connStr string) (*redis.Options, error) { keyValueCSV := strings.Split(connStr, ",") options := &redis.Options{Network: "tcp"} for _, rawKeyValue := range keyValueCSV { - keyValueTuple := strings.Split(rawKeyValue, "=") + keyValueTuple := strings.SplitN(rawKeyValue, "=", 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) } connKey := keyValueTuple[0]