From 8765ca17583b9800014cb4e71dcbb303e87e26fe Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 16 Nov 2026 03:38:44 +0800 Subject: [PATCH] redact: TestMoreKinds' gone check looks past the made-up user name (#4345) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestMoreKinds checks that each masked value is no longer in what is sent, after taking out the {{KIND_…}} placeholders. A user name goes as a made-up name instead, eight lowercase letters from a key that is new each run, and that name can spell a short user name: on ubuntu CI at 500f39886, "ops" was still in "scp a.txt zpxopsat@{{HOSTNAME_…}}". The check now takes out the made-up name for the value first; the test still checks separately that the made-up name is what was sent. The other tests that check a user name is gone use names of eight or more letters (developer, rinakato), which eight random letters spell with odds around 26^-8, so they are left as they are. Run on mote at this head (origin/main 256910f17): - A probe test searched for a key whose made-up name for "ops" contains "ops" (key 2207: dopsubnz), set it, and ran TestMoreKinds: red with the old check ("ops" still in "dopsubnz@…", CI's red), ok with this one. The probe is not committed. - go test -count=1 ./internal/redact: ok. gofmt -l clean. Fixes #4345. --- internal/redact/more_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/redact/more_test.go b/internal/redact/more_test.go index 40f1e71f8..e5af54328 100644 --- a/internal/redact/more_test.go +++ b/internal/redact/more_test.go @@ -93,7 +93,10 @@ func TestMoreKinds(t *testing.T) { t.Errorf("%q: %d masked, want %d: %q", c.in, n, len(c.gone), out) } for _, g := range c.gone { - if strings.Contains(unmarked(out), g.value) { + // The made-up name is eight random letters, a new key each + // run, and can spell a short user name: "ops" was still in + // "zpxopsat@…" on ubuntu CI at 500f39886 (#4345). + if strings.Contains(strings.ReplaceAll(unmarked(out), standInOf(g.value), ""), g.value) { t.Errorf("%q: %q still in %q", c.in, g.value, out) } p := placeholder(g.kind, g.value)