Repository navigation
fix(truthbench): match digit-only canaries within one numeric run - #408
Merged
Merged
Conversation
The digit-only variant projected a whole leaf to its concatenated digits, so
in long prose or HTML a 7-digit canary could match digits from unrelated
tokens ("a555b01c23" -> "5550123") and report a leak that no value holds.
Digit-only patterns of _MIN_DIGIT_ONLY_LENGTH digits or more now match only
inside a numeric run: digit groups joined by at most three whitespace, ".",
"-", "/" or parenthesis characters, taken from the literal, HTML-unescaped,
URL-decoded, NFKC and zero-width-removed forms. Reformatted numbers such as
"555 0123", "(555) 0123" and "555 0123" are still found; the last one was
previously missed because the entity's digits joined the stream.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The TruthBench PII scanner checks each canary in several normalized forms. For the
digit-onlyform it compared the canary's digits with all digits of the scanned leaf joined together. In a long prose or HTML leaf, that joined stream mixes digits from unrelated tokens, so a 7-digit canary could match by chance and report a leak that no value in the sink contains. For example,"token 3fa555b01c23"projects to...5550123.... Because the digits come from whatever else is in the leaf, this showed up as an occasional, non-reproducibleraw_pii_leakagefailure.Change
_MIN_DIGIT_ONLY_LENGTH(6) digits or more now match only inside a single numeric run: digit groups joined by at most three whitespace,.,-,/or parenthesis characters.Reformatted numbers are still detected:
555-0123,5550123,555 0123,(555) 0123,555.0123,555/0123, a non-breaking or zero-width space between groups, and contiguous digits inside a longer token. One case is newly detected:555 0123was missed before, because the entity's own digits (32) were joined into the stream.Tests
New cases in
tests/truthbench/test_privacy.pyput each value in the middle of a long prose leaf that contains other numbers:Against the previous
privacy.py, 6 of these fail: the 5 separate-token cases and555 0123.Verification
tests/truthbench: 265 passed on Python 3.9 / pandas 1.5.3 and Python 3.12 / pandas 2.3.3ruff checkandmypy --python-version 3.9 benchmarks/truthbench/privacy.py: cleanmake truthbench-pr(release profile, pandas/polars/duckdb, 2 repeats, regression check): overall PASS;cleaning:raw_pii_leakageandparity:raw_pii_leakagepass with 0 failures; no gate-level changes vs baseline