Skip to content

Commit b2ca310

Browse files
authored
[INC-49255][AGENTRUN-1163]Scrub new appkey format (#48085)
Ref the generator: dd-source/domains/aaa/apps/ace/internal/credentials/keyminter.go Co-authored-by: nathan.baker <nathan.baker@datadoghq.com>
1 parent 1924f1f commit b2ca310

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pkg/util/scrubber/default.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ func AddDefaultReplacers(scrubber *Scrubber) {
6161

6262
LastUpdated: defaultVersion,
6363
}
64+
prefixedAPPKeyReplacer := Replacer{
65+
Regex: regexp.MustCompile(`ddapp_[a-zA-Z0-9]{28}_[a-zA-Z0-9]([a-zA-Z0-9]{4})`),
66+
Hints: []string{"ddapp_"},
67+
Repl: []byte(`************************************$1`),
68+
69+
LastUpdated: parseVersion("7.78.0"),
70+
}
6471

6572
// replacers are check one by one in order. We first try to scrub 64 bytes token, keeping the last 5 digit. If
6673
// the token has a different size we scrub it entirely.
@@ -288,6 +295,7 @@ func AddDefaultReplacers(scrubber *Scrubber) {
288295

289296
scrubber.AddReplacer(SingleLine, hintedAPIKeyReplacer)
290297
scrubber.AddReplacer(SingleLine, hintedAPPKeyReplacer)
298+
scrubber.AddReplacer(SingleLine, prefixedAPPKeyReplacer)
291299
scrubber.AddReplacer(SingleLine, hintedBearerReplacer)
292300
scrubber.AddReplacer(SingleLine, hintedBearerInvalidReplacer)
293301
scrubber.AddReplacer(SingleLine, httpHeaderKeyReplacer)

pkg/util/scrubber/default_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ func TestConfigAppKey(t *testing.T) {
100100
` app_key: '************************************bbbb' `)
101101
}
102102

103+
func TestConfigPrefixedAppKey(t *testing.T) {
104+
// Identifiable app key format: ddapp_<random28>_<checksum5> (40 chars total)
105+
// Last 4 chars of the checksum are preserved in output
106+
assertClean(t,
107+
`ddapp_aaaaaaaaaaaaaaaaaaaaaaaaaaaa_Abcde`,
108+
`************************************bcde`)
109+
assertClean(t,
110+
`app_key: ddapp_aaaaaaaaaaaaaaaaaaaaaaaaaaaa_Abcde`,
111+
`app_key: ************************************bcde`)
112+
assertClean(t,
113+
`config with ddapp_AAAAAAAAAAAAAAAAAAAAAAAAAAAA_aBCDE in the middle`,
114+
`config with ************************************BCDE in the middle`)
115+
}
116+
103117
func TestConfigRCAppKey(t *testing.T) {
104118
assertClean(t,
105119
`key: "DDRCM_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCDE"`,

0 commit comments

Comments
 (0)