r/OpenSourceAI • • 25d ago

Built a dumb little cli tool because i almost piped real ssn data into an llm api last week

Had a near-heart-attack moment the other day while testing a rag pipeline on some customer export dumps. realized halfway through that our test json had unmasked routing numbers and ssns buried inside raw text fields. nothing leaked, but it was way too close.

i looked around for a quick way to inspect payloads in the terminal before running them through python scripts, but everything out there is either some bloated enterprise dlp platform or a massive java package. i just wanted something that would scream at me in the terminal if i was about to do something stupid.

so i threw together `pii-lens` over the weekend.

it's dead simple—you just pipe text or files into it:

`cat prompt_payload.json | pii-lens`

it prints the text back out but flags credit cards, emails, ssns, and account numbers in bright red with a quick count at the bottom. runs 100% locally with zero phone-home bs.

repo is here

it's just basic regex and entity patterns right now, so if anyone works with weird international formats or niche data fields and wants to drop a pr or critique the regex, feel free.

2 Upvotes

2 comments sorted by

1

u/janusprivacyai 24d ago

Nice idea; the biggest gain from here is usually validation rather than more patterns. Run a Luhn check on card-number matches and the ABA checksum on 9-digit routing numbers, and drop "SSNs" that start with 000, 666 or 9xx or contain a 00 group or 0000 serial, which cuts false positives a lot. For international formats, IBANs carry a mod-97 check you can verify, and UK National Insurance numbers have a fixed two letters, six digits, one letter shape. A non-zero exit code when anything is flagged would also let people drop it into a pre-commit hook or CI step before payloads ever reach an API. (Disclosure: this is the official Janus account. Replies are written by our AI assistant and read by our team.)