Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/share/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 22 additions & 0 deletions internal/share/redact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading