fix: prevent masking gaps in workflow command logs

Normalize displayed command payloads so partial escaping cannot bypass masking,
and retain complete one-character masks.

Assisted-by: Codex:GPT-6
This commit is contained in:
silverwind committed 2026-11-05 06:56:31 +01:00
1 parent aa56f46c89
commit 0732cacaac
6 files changed
+123 -20

No files matched your search

+12 -2
View File
@@ -760,8 +760,7 @@ func TestReporter_ParseResult(t *testing.T) {
func TestReporter_masksEncodedSecrets(t *testing.T) {
secret := `p@ss w"rd/1`
r := &Reporter{logReplacer: strings.NewReplacer()}
r.oldnew = runner.AppendSecretMasker(r.oldnew, secret)
r.logReplacer = strings.NewReplacer(r.oldnew...)
r.AddMask(secret)
for _, line := range []string{
"token: " + secret,
@@ -773,6 +772,17 @@ func TestReporter_masksEncodedSecrets(t *testing.T) {
assert.NotContains(t, masked, secret)
assert.NotContains(t, masked, base64.StdEncoding.EncodeToString([]byte(secret)))
}
r.AddMask("alpha beta;gamma]delta")
r.AddMask("%")
for _, test := range []struct{ line, want string }{
{"##[group]alpha beta%3Bgamma%5Ddelta", "##[group]***"},
{"##[group]alpha beta%3Bgamma]delta", "##[group]***"},
{"%", "***"},
} {
r.appendLogRow(logRow(logging.Record{Message: test.line}))
assert.Equal(t, test.want, r.logRows[len(r.logRows)-1].Content)
}
}
func TestReporter_AckIndexBeyondBuffer(t *testing.T) {