You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Help wanted: Improve and expand PII pattern coverage #75
@atomicpages — wanted to get your thoughts on this before I start turning it into smaller issues or putting any tooling around it.
We've got 500+ detection patterns across different countries, regions and identifier types. The initial work was on getting coverage in place. I think the next stage should run along two tracks:
Harden existing patterns
Work through existing patterns by country, region or identifier family and improve accuracy. Ideally this would include:
reviewing current regex and validator behaviour;
adding valid and invalid synthetic fixtures;
checking false positives and false negatives;
changing implementation only where tests demonstrate an improvement;
adding regression tests for changed behaviour.
Add missing patterns and regional coverage
Give contributors with local or domain knowledge a clear route to add identifiers we’re currently missing. Ideally new patterns would include:
a reference for the identifier format or specification;
regex and/or validator implementation;
valid synthetic examples;
invalid and edge-case examples;
tests.
My thought is that this issue could act as the starting point, then we create smaller help wanted issues for individual countries, regions or pattern families once we have a repeatable format.
I’d be interested in your thoughts on how best to structure the test harness and contribution workflow around the new package structure. I also want to make this approachable for contributors who know a particular country’s identifiers or data formats but don’t necessarily know the whole OpenRedaction codebase.
No rush on this one — mainly wanted to get the idea down and get your thoughts before we start building around it and before my 5 day hiatus.
For sure, I already have some ideas we can probably iterate on quickly:
Add integration tests that pass through OpenRedaction. The benefit here is
the contributor of focused on the outcome rather than the specifics of
adding/amending a new regex. Something like this:
exportinterfacePIIPattern{type: string;regex: RegExp;priority: number;validator?: (match: string,context: string)=>boolean;placeholder: string;description?: string;severity?: "critical"|"high"|"medium"|"low";// NEW:country?: string;// ISO 3166-1 alpha-2, e.g. "AE"region?: string;// "middle-east", "europe", etc.family?: string;// "national-id", "tax-id", "passport", etc.reference?: string;// URL to spec/standardexamples?: string[];// Valid synthetic examples (for docs + test gen)}
examples is particularly interesting sinc we could generate tests and folks
who add new examples get coverage for free. With a little rollup trickery
(i.e. AST traversal or regex post-processing) we can remove this field during
bundling too
Moving to describe.each and it.each on tests so we can go from:
it("should detect UAE Emirates ID",async()=>{constdetector=newOpenRedaction({patterns: ["UAE_EMIRATES_ID"]});constresult=awaitdetector.detect("Emirates ID: 784-1990-1234567-1");expect(result.detections.some((d)=>d.type==="UAE_EMIRATES_ID")).toBe(true,);});it("should detect UAE Emirates ID without dashes",async()=>{constdetector=newOpenRedaction({patterns: ["UAE_EMIRATES_ID"]});constresult=awaitdetector.detect("UAE ID 784199012345671");expect(result.detections.some((d)=>d.type==="UAE_EMIRATES_ID")).toBe(true,);});
to
it.each(["UAE ID 784199012345671","Emirates ID: 784-1990-1234567-1"])((str)=>{constdetector=newOpenRedaction({patterns: ["UAE_EMIRATES_ID"]});constresult=awaitdetector.detect(str);expect(result.detections.some((d)=>d.type==="UAE_EMIRATES_ID")).toBe(true,);});
moreover, this could replace the existing build-regex-audit (which isn't run anywhere)
More cleanup of monolithic validators
Code split validates (one per country) for even smaller bundles
That feels like a much better contributor experience than expecting people to understand the regex/validator stuff.
The metadata idea also feels like it could become the single source of truth. If we have country/family/reference/examples available, we can generate a lot of things from that over time (tests, docs, coverage, contributor guidance, etc.) rather than maintaining them separately. I agree this is probably the right foundation before we start breaking this into lots of smaller help wanted issues. Happy to iterate on the shape of it as we go, but your direction feels far more sensible.
I've got two sets of made-up text that could help the false-positive side of this: 1) Technical text (UUIDs, hashes, timestamps, version strings)
2) Everyday messages in 9 languages, all of which should stay quiet.
Would fixtures like that be useful as a starting point? Happy to open a PR with whichever fits best.
Both sets would be genuinely useful. I’d probably start with the technical fixtures, particularly UUIDs, hashes, timestamps and version strings, as we’ve already seen how easily those can trigger false positives.
The multilingual everyday messages would also be a great follow-up.
Ideally we’d keep these as reusable regression fixtures so future pattern changes can be tested against them.
Happy for you to open a PR for the technical set first. Really appreciate you offering to help again!
The technical set is up in #171. 396 made-up lines across UUIDs, hashes, timestamps and version strings, kept as regression fixtures like you said. 87 of them get flagged today, so those run as it.fails to keep CI green until they're fixed. I listed which shapes in the PR.
I'll start on the multilingual set next as its own PR.
Also, no worries on the extra help. It's really useful practice for me :D
Activity
atomicpages commentedon Jul 22, 2026
For sure, I already have some ideas we can probably iterate on quickly:
Add integration tests that pass through
OpenRedaction. The benefit here isthe contributor of focused on the outcome rather than the specifics of
adding/amending a new regex. Something like this:
Having a coverage report
examplesis particularly interesting sinc we could generate tests and folkswho add new examples get coverage for free. With a little rollup trickery
(i.e. AST traversal or regex post-processing) we can remove this field during
bundling too
Moving to
describe.eachandit.eachon tests so we can go from:to
moreover, this could replace the existing
build-regex-audit(which isn't run anywhere)More cleanup of monolithic validators
Code split validates (one per country) for even smaller bundles
sam247 commentedon Jul 26, 2026
That feels like a much better contributor experience than expecting people to understand the regex/validator stuff.
The metadata idea also feels like it could become the single source of truth. If we have country/family/reference/examples available, we can generate a lot of things from that over time (tests, docs, coverage, contributor guidance, etc.) rather than maintaining them separately. I agree this is probably the right foundation before we start breaking this into lots of smaller help wanted issues. Happy to iterate on the shape of it as we go, but your direction feels far more sensible.
fix: align roadmap Planned and Shipped with GitHub
BilliamBaSH commentedon Nov 14, 2026
I've got two sets of made-up text that could help the false-positive side of this: 1) Technical text (UUIDs, hashes, timestamps, version strings)
2) Everyday messages in 9 languages, all of which should stay quiet.
Would fixtures like that be useful as a starting point? Happy to open a PR with whichever fits best.
sam247 commentedon Nov 14, 2026
Thanks @BilliamBaSH, that would be brilliant!
Both sets would be genuinely useful. I’d probably start with the technical fixtures, particularly UUIDs, hashes, timestamps and version strings, as we’ve already seen how easily those can trigger false positives.
The multilingual everyday messages would also be a great follow-up.
Ideally we’d keep these as reusable regression fixtures so future pattern changes can be tested against them.
Happy for you to open a PR for the technical set first. Really appreciate you offering to help again!
BilliamBaSH commentedon Nov 15, 2026
Thanks @sam247!
The technical set is up in #171. 396 made-up lines across UUIDs, hashes, timestamps and version strings, kept as regression fixtures like you said. 87 of them get flagged today, so those run as
it.failsto keep CI green until they're fixed. I listed which shapes in the PR.I'll start on the multilingual set next as its own PR.
Also, no worries on the extra help. It's really useful practice for me :D
BilliamBaSH commentedon Nov 26, 2026
Baseline from #171: 87 technical lines flagged today, pinned by a test so it can only go down.