← All sheets
GL-R-019Sheet 019AS BUILTR · RECORD · AS BUILT

(415) 555-0142 is invisible to most redaction.

AS BUILT · PHONE DETECTION · REDACTION ENGINE · 0.5.7 → 0.7.0

Drawing sheet 019: (415) 555-0142 is invisible to most redaction.

General notes

  1. 01The standard phone library needs a country code to be sure. "+1 415 555 0142" is a phone number. "(415) 555-0142" is a guess, so it says nothing.
  2. 02National-format numbers, the way people actually type them, were passing through unredacted. Green tests only prove what you thought to test.
  3. 03Fix: a region hint. Better fix: several regions at once, because a browser extension sees traffic from everywhere.
3Detail · multi-region detectorAs shipped in 0.7.0
// one PHONE detector, three national formats, de-duplicated by span
createMultiRegionPhoneDetector(['US', 'GB', 'NG'])
// (415) 555-0142  ·  07700 900123  ·  a Lagos mobile in national format  all caught in one pass

As posted

I found a hole in my own redaction engine by typing a phone number the way a normal person types it.

The library everyone uses to parse phone numbers needs a country code to be sure. Give it +1 415 555 0142 and it knows. Give it (415) 555-0142 and it shrugs. That string is a valid number in one country and noise in another, so the safe answer is to say nothing.

Which meant national-format numbers, the way people actually write them in a support ticket, were passing straight through to the model. Unredacted. The test suite was green, because I had written the tests the way an engineer writes numbers: with the country code on.

The first fix was a region hint. Tell the detector which country to assume. The better fix came from the browser extension, where traffic arrives from everywhere at once: one detector, several regions, results de-duplicated by position. A US number, a UK number and a Nigerian number in the same paragraph, all caught in one pass.

Two lessons I keep relearning.

Detection gaps do not announce themselves. Green tests only prove what you thought to test.

Write the test that would have failed, then make it pass. The gap and the fix ship together, and the fix cannot quietly regress.

Sheet 019. As built.

Read with

  • Sheet 010 · A phone number that can never ring.
  • Sheet 039 · Production-ready is a number, not an adjective.