Skip to content

Commit

Permalink
fix password leakage problem when password contains @ symbol (#4071)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored Sep 27, 2023
1 parent 0314e38 commit cda20c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func WithTimeout(f func() error, timeout time.Duration) error {
}

func RemovePassword(uri string) string {
p := strings.Index(uri, "@")
p := strings.LastIndex(uri, "@")
if p < 0 {
return uri
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ func TestRemovePassword(t *testing.T) {
{"redis://:password@localhost:6379/0",
"redis://:****@localhost:6379/0",
},
{"redis://:pass@word@localhost:6379/0",
"redis://:****@localhost:6379/0",
},
{":password@localhost:6379/0",
":****@localhost:6379/0",
},
Expand Down

0 comments on commit cda20c6

Please sign in to comment.