diff --git a/br/pkg/lightning/lightning.go b/br/pkg/lightning/lightning.go index d9ec7536dd8c4..5e1ee36a0c7ba 100644 --- a/br/pkg/lightning/lightning.go +++ b/br/pkg/lightning/lightning.go @@ -753,8 +753,7 @@ func (l *Lightning) handlePostTask(w http.ResponseWriter, req *http.Request) { writeJSONError(w, http.StatusBadRequest, "cannot read request", err) return } - filteredData := utils.HideSensitive(string(data)) - log.L().Info("received task config", zap.String("content", filteredData)) + log.L().Info("received task config") cfg := config.NewConfig() if err = cfg.LoadFromGlobal(l.globalCfg); err != nil { diff --git a/br/pkg/utils/BUILD.bazel b/br/pkg/utils/BUILD.bazel index 08b697946e243..4c1e14d2d7c91 100644 --- a/br/pkg/utils/BUILD.bazel +++ b/br/pkg/utils/BUILD.bazel @@ -20,7 +20,6 @@ go_library( "retry.go", "safe_point.go", "schema.go", - "sensitive.go", "store_manager.go", "suspend_importing.go", "worker.go", @@ -89,12 +88,11 @@ go_test( "retry_test.go", "safe_point_test.go", "schema_test.go", - "sensitive_test.go", "suspend_importing_test.go", ], embed = [":utils"], flaky = True, - shard_count = 38, + shard_count = 37, deps = [ "//br/pkg/errors", "//br/pkg/metautil", diff --git a/br/pkg/utils/sensitive.go b/br/pkg/utils/sensitive.go deleted file mode 100644 index fcc31ee30b78d..0000000000000 --- a/br/pkg/utils/sensitive.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0. - -package utils - -import ( - "regexp" -) - -var ( - passwordPatterns = `(password[\s]*=[\s]*(\\")?)(.*?)((\\")?\\n)` - - passwordRegexp *regexp.Regexp -) - -func init() { - passwordRegexp = regexp.MustCompile(passwordPatterns) -} - -// HideSensitive replace password with ******. -func HideSensitive(input string) string { - output := passwordRegexp.ReplaceAllString(input, "$1******$4") - return output -} diff --git a/br/pkg/utils/sensitive_test.go b/br/pkg/utils/sensitive_test.go deleted file mode 100644 index a14ce0619eb85..0000000000000 --- a/br/pkg/utils/sensitive_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0. - -package utils - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestHideSensitive(t *testing.T) { - strs := []struct { - old string - new string - }{ - { - `host = "127.0.0.1"\n user = "root"\n password = "/Q7B9DizNLLTTfiZHv9WoEAKamfpIUs="\n port = 3306\n`, - `host = "127.0.0.1"\n user = "root"\n password = ******\n port = 3306\n`, - }, - { - `host = "127.0.0.1"\n user = "root"\n password = ""\n port = 3306\n`, - `host = "127.0.0.1"\n user = "root"\n password = ******\n port = 3306\n`, - }, - { - `host = "127.0.0.1"\n user = "root"\n password= "/Q7B9DizNLLTTfiZHv9WoEAKamfpIUs="\n port = 3306\n`, - `host = "127.0.0.1"\n user = "root"\n password= ******\n port = 3306\n`, - }, - { - `host = "127.0.0.1"\n user = "root"\n password =""\n port = 3306\n`, - `host = "127.0.0.1"\n user = "root"\n password =******\n port = 3306\n`, - }, - { - `host = "127.0.0.1"\n user = "root"\n password=""\n port = 3306\n`, - `host = "127.0.0.1"\n user = "root"\n password=******\n port = 3306\n`, - }, - } - for i, str := range strs { - t.Logf("case #%d\n", i) - require.Equal(t, str.new, HideSensitive(str.old)) - } -}