diff --git a/internal/share/fuzz_test.go b/internal/share/fuzz_test.go index fedeef8..541ee9f 100644 --- a/internal/share/fuzz_test.go +++ b/internal/share/fuzz_test.go @@ -21,6 +21,8 @@ func FuzzRedact(f *testing.F) { f.Add("000\r\n\r\n", "0000000", "1111000000000000000000") // CI found this: compact To keeps a longer digit run in front of tel:. f.Add("0\r\nT: 4155550123tel:+14155550123\r\n\r\n", "4155550", "0") + // CI found this: compact To with digits glued to a tel: scheme. + f.Add("0\nT:4155550123tel:\n\n", "4155550", "0") f.Fuzz(func(t *testing.T, raw, to, from string) { ev := store.Event{ ReceivedAt: time.Now(), Action: score.ActionReject, From: from, To: to, diff --git a/internal/share/redact_test.go b/internal/share/redact_test.go index b43b841..77d266e 100644 --- a/internal/share/redact_test.go +++ b/internal/share/redact_test.go @@ -147,6 +147,28 @@ func TestRedactHidesFromWhenItContainsCalledDigits(t *testing.T) { } } +func TestRedactHidesCalledDigitsGluedToURIScheme(t *testing.T) { + // CI FuzzRedact on main: compact To is "4155550123tel:" and the + // called digits are a prefix of that run. redactNameAddr saw tel: + // and left the prefix. + ev := event() + ev.To = "4155550" + ev.From = "0" + ev.CallID = "0\nT:4155550123tel:\n\n" + ev.UserAgent = ev.To + ev.Switch = ev.To + ev.RawSIP = "0\nT:4155550123tel:\n\n" + ev.Reasons = []score.Reason{{Code: "x", Detail: ev.RawSIP}} + out := Redact(ev, []byte("k")) + fields := []string{out.To, out.From, out.CallID, out.UserAgent, out.Switch, out.RawSIP} + for _, r := range out.Reasons { + fields = append(fields, r.Detail) + } + if strings.Contains(strings.Join(fields, "\n"), "4155550") { + t.Fatalf("called digits leaked: %q", fields) + } +} + func TestRedactNonNumericSubscriber(t *testing.T) { ev := event() ev.To = "alice.ops"