Repository navigation
fix: PII scrubber keeps timestamps and IDs (Luhn-checked cards, formatted phones) (Fixes #205) - #217
Merged
Merged
Conversation
…phones (#205) - Card numbers: a 13-19 digit candidate (spaces/dashes allowed) is redacted only when it passes the Luhn check and starts with a card-network prefix (Visa, Mastercard incl. 2-series, Amex, Discover, JCB, Diners, UnionPay, Maestro). Epoch-ms timestamps, ns durations and long IDs are kept. - Phone numbers need separators or parentheses; a bare 10-digit run (epoch seconds, IDs) is kept. "(555) 123-4567" is now redacted whole. - tests/test_pii_scrubber.py: kept vs redacted cases for both. Fixes #205
Merged
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.
Fixes #205.
Problem
The scrubber runs on every log line and tool result before the LLM, Slack and storage see them, and it redacted any run of 13–16 digits as a card number. Investigating this found the phone rule had the same problem with any 10 digits:
ts=1732600000123(epoch ms)ts=[REDACTED_CARD]epoch=1732600000(epoch s)epoch=[REDACTED_PHONE]took 1234567890123 ns[REDACTED_CARD]order 12345678901234[REDACTED_CARD]call (555) 123-4567call ([REDACTED_PHONE](stray()call [REDACTED_PHONE]4111 1111 1111 1111[REDACTED_CARD][REDACTED_CARD]The agent was losing the timeline of every JSON log (Loki, CloudWatch) and the long request and order IDs it needs to correlate events.
Change (
services/pii_scrubber.py)1, so they never match.-,.or a space) or(xxx)are now required, with an optional+1. A bare 10-digit run isn't a phone number.Tests
tests/test_pii_scrubber.py, 23 tests:Full suite: 1471 passed, 4 skipped. Bandit is clean, and Flake8 (CI selection) is clean. The only other lint notes are on long lines that were already in the file.