Skip to content

Commit be24f60

Browse files
authored
[PROF-14281] Ensure API key redaction in flares (#49417)
### What does this PR do? - Adds `dd-api-key` to the flare scrubber's key-name-aware replacers - Removes a debug log that printed the full generated OTel config, which included arbitrary `AdditionalHTTPHeaders` values the scrubber cannot pattern-match ### Motivation The Host Profiler and OTel exporters write their effective config to flare bundles via `runtime.cfg`, which includes `dd-api-key` headers. While these values are always standard 32-char hex API keys caught by the value-pattern scrubber, `dd-api-key` should also be recognized as sensitive by key name; consistent with other known headers already in the list. ### Describe how you validated your changes Added a `assertClean` case in `pkg/util/scrubber/default_test.go` covering a non-hex `dd-api-key` value. ### Additional Notes Co-authored-by: theo.demagalhaes <theo.demagalhaes@datadoghq.com>
1 parent 57f18de commit be24f60

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

comp/host-profiler/collector/impl/agentprovider/config_builder.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/DataDog/datadog-agent/comp/host-profiler/collector/impl/extensions/hpflareextension"
1616
"github.com/DataDog/datadog-agent/comp/host-profiler/collector/impl/params"
1717
"github.com/DataDog/datadog-agent/comp/host-profiler/version"
18-
"github.com/DataDog/datadog-agent/pkg/util/log"
1918
)
2019

2120
type confMap = map[string]any
@@ -199,7 +198,5 @@ func buildConfig(agent configManager, p params.CollectorParams) confMap {
199198
}
200199
_ = converters.Set(config, "service::extensions", serviceExtensions)
201200

202-
log.Debugf("Generated configuration: %+v", config)
203-
204201
return config
205202
}

pkg/util/scrubber/default.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ func AddDefaultReplacers(scrubber *Scrubber) {
276276

277277
// Exact key matches for specific API keys and auth tokens
278278
exactKeyReplacer := matchYAMLKey(
279-
`(auth-tenantid|authority|cainzapp-api-key|cms-svc-api-key|lodauth|sec-websocket-key|statuskey|cookie|private-token|kong-admin-token|accesstoken|session_token)`,
280-
[]string{"auth-tenantid", "authority", "cainzapp-api-key", "cms-svc-api-key", "lodauth", "sec-websocket-key", "statuskey", "cookie", "private-token", "kong-admin-token", "accesstoken", "session_token"},
279+
`(auth-tenantid|authority|cainzapp-api-key|cms-svc-api-key|dd-api-key|lodauth|sec-websocket-key|statuskey|cookie|private-token|kong-admin-token|accesstoken|session_token)`,
280+
[]string{"auth-tenantid", "authority", "cainzapp-api-key", "cms-svc-api-key", "dd-api-key", "lodauth", "sec-websocket-key", "statuskey", "cookie", "private-token", "kong-admin-token", "accesstoken", "session_token"},
281281
[]byte(`$1 "********"`),
282282
)
283283
exactKeyReplacer.LastUpdated = parseVersion("7.70.2")

pkg/util/scrubber/default_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,9 @@ func TestNewHTTPHeaderAndExactKeys(t *testing.T) {
995995
assertClean(t,
996996
`cms-svc-api-key: cmskey789`,
997997
`cms-svc-api-key: "********"`)
998+
assertClean(t,
999+
`dd-api-key: someapikey123`,
1000+
`dd-api-key: "********"`)
9981001
assertClean(t,
9991002
`lodauth: lodauth123`,
10001003
`lodauth: "********"`)

0 commit comments

Comments
 (0)