Skip to content

Commit

Permalink
[ASCII-1006] Fix scrubber misuses key for http:// in urls (#32503)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-cqrl authored Dec 24, 2024
1 parent 3f413d8 commit 407d013
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/util/scrubber/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ func AddDefaultReplacers(scrubber *Scrubber) {
// URI Generic Syntax
// https://tools.ietf.org/html/rfc3986
uriPasswordReplacer := Replacer{
Regex: regexp.MustCompile(`(?i)([a-z][a-z0-9+-.]+://|\b)([^:]+):([^\s|"]+)@`),
Regex: regexp.MustCompile(`(?i)([a-z][a-z0-9+-.]+://|\b)([^:\s]+):([^\s|"]+)@`),
Repl: []byte(`$1$2:********@`),

// https://github.com/DataDog/datadog-agent/pull/15959
LastUpdated: parseVersion("7.45.0"),
// https://github.com/DataDog/datadog-agent/pull/32503
LastUpdated: parseVersion("7.63.0"),
}

yamlPasswordReplacer := matchYAMLKeyPart(
`(pass(word)?|pwd)`,
[]string{"pass", "pwd"},
Expand Down
6 changes: 6 additions & 0 deletions pkg/util/scrubber/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ func TestConfigRCAppKey(t *testing.T) {
}

func TestConfigStripURLPassword(t *testing.T) {
assertClean(t,
`proxy: random_url_key: http://user:password@host:port`,
`proxy: random_url_key: http://user:********@host:port`)
assertClean(t,
`random_url_key http://user:password@host:port`,
`random_url_key http://user:********@host:port`)
assertClean(t,
`random_url_key: http://user:password@host:port`,
`random_url_key: http://user:********@host:port`)
Expand Down

0 comments on commit 407d013

Please sign in to comment.