๐ pii-radar
Scan any CSV, JSON, or Parquet file for Personally Identifiable Information โ in seconds.
Abstract
Data engineers and ML practitioners routinely work with datasets that silently contain Personally Identifiable Information (PII) โ emails, phone numbers, SSNs, credit card numbers, and IP addresses โ creating compliance risks under GDPR, CCPA, and HIPAA. pii-radar is a lightweight, zero-dependency-ML CLI tool that scans structured data files for PII using high-precision patterns, Luhn Mod-10 verification, and contextual heuristics, outputting results as rich terminal tables, JSON, or CSV reports. It integrates natively with pre-commit hooks and GitHub Actions to catch PII before it reaches production or version control.
โจ Features
- ๐ 6 PII types detected โ Email, Phone, SSN, Credit Card (Luhn validated), IP Address, Date of Birth (Heuristic)
- ๐ 3 file formats โ CSV, JSON, Parquet (
.parquet,.pq) - ๐ Folder scanning โ Recursively scan entire directories
- ๐จ Beautiful terminal output โ Rich tables with confidence scores
- ๐ค CI/CD native โ
--fail-on-detectexits with code 1 for pipeline gates - โก Row sampling โ
--sample 1000limit for rapid audit sampling on massive files - ๐ Auto-redaction โ
--redactcreates a sanitized copy of your data - ๐ CSV reports โ Save all findings to a structured report file
- โก Fast โ Pure regex + algorithmic validation, no heavy ML models
๐ฆ Installation
pip install pii-radar
Or install from source:
git clone https://github.com/nithin42/pii-radar.git
cd pii-radar
pip install -e ".[dev]"
๐ Quick Start
# Scan a CSV file
pii-radar scan data/customers.csv
# Fast sampling (scan only first 1,000 rows)
pii-radar scan data/large_file.csv --sample 1000
# Scan a JSON file
pii-radar scan logs/events.json
# Scan an entire directory
pii-radar scan data/
# Get JSON output (great for scripts)
pii-radar scan data.csv --output json
# Only show high-confidence detections
pii-radar scan data.csv --min-confidence 0.9
# Save a report to CSV
pii-radar scan data.csv --report pii_report.csv
# Create a redacted copy
pii-radar scan data.csv --redact data_clean.csv
# Use in CI/CD โ fails build if PII found
pii-radar scan data.csv --fail-on-detect
๐๏ธ Architecture
CLI Interface (cli.py)
โ
โโโบ scan_file / scan_directory (scanner.py)
โ โ
โ โโโบ File Readers (readers.py) โ CSV / JSON / Parquet Cell Stream
โ โ
โ โโโบ Heuristic Engine (detectors.py)
โ โโ Email (RFC-compliant regex)
โ โโ SSN (Format + Range Rejection)
โ โโ Credit Card (Luhn Mod-10 Checksum)
โ โโ Phone (Word-bounded pattern)
โ โโ IP Address (IPv4 0-255 Octet Validation)
โ โโ Date of Birth (Column-Name Heuristic + Format)
โ
โโโบ Reporting Layer (reporter.py)
โโ Rich Terminal Panel & Table
โโ JSON Pipeline Stream
โโ CSV Compliance Report
๐ Detection Capabilities & Validation
| PII Type | Verification Strategy | Accuracy / False Positive Defense |
|---|---|---|
| RFC-compliant regex | 99% โ Word boundary enforced | |
| SSN | Format + Area exclusion | 98% โ Rejects invalid 000, 666, 900+ ranges |
| CREDIT_CARD | Luhn Mod-10 Algorithm | 99% โ Eliminates random 16-digit number false positives |
| IP_ADDRESS | IPv4 + Octet range check | 95% โ Rejects 999.x.x.x and version strings |
| PHONE | US/International regex | 92% โ Enforces strict \b word boundaries |
| DATE_OF_BIRTH | Format + Column Heuristics | 95% โ Contextual matching (dob, birth, bday) |
๐งช Performance Benchmark
Run the reproducible benchmark script locally:
python examples/benchmark.py
- Dataset: 10,000 rows x 7 columns (70,000 cells)
- Throughput: ~45,000โ60,000 cells/second
- Memory Overhead: Minimal (generator-based cell streaming)
๐ง CI/CD Integration
GitHub Actions
- name: Scan for PII before merge
run: |
pip install pii-radar
pii-radar scan data/ --fail-on-detect --min-confidence 0.85
Pre-commit Hook
Add to .pre-commit-config.yaml:
- repo: local
hooks:
- id: pii-radar
name: PII Scanner
entry: pii-radar scan
args: [--fail-on-detect, --min-confidence, "0.9"]
language: python
types: [csv, json]
๐ Project Structure
pii-radar/
โโโ src/pii_radar/
โ โโโ cli.py โ Click CLI entry point (--sample, --fail-on-detect)
โ โโโ scanner.py โ Core scan orchestration with row limits
โ โโโ detectors.py โ Luhn + IPv4 range + DOB heuristics engine
โ โโโ readers.py โ CSV / JSON / Parquet readers
โ โโโ reporter.py โ Rich terminal + JSON + CSV output
โโโ tests/
โ โโโ conftest.py โ Shared fixtures
โ โโโ test_detectors.py
โ โโโ test_negative_cases.py โ False positive & Luhn unit tests
โ โโโ test_scanner.py
โ โโโ test_cli.py
โโโ examples/
โ โโโ sample.csv
โ โโโ sample.json
โ โโโ benchmark.py โ Performance benchmarking tool
โโโ .github/workflows/ โ CI/CD matrix (Ubuntu + Windows)
โโโ pyproject.toml
โโโ Makefile
โโโ README.md
๐ License
MIT โ see LICENSE.
๐ค Author
Nithin ยท github.com/nithin42 ยท kumbam.nithingoud@gmail.com
Part of an elite Data Science & Secure Computing portfolio. Focused on data privacy, reproducible ML, and secure systems engineering.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pii_radar-0.4.0.tar.gz.
File metadata
- Download URL: pii_radar-0.4.0.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca9526766dd21a1693028befc465b35a22e1db38eb680a58199d55975d3fcd1e
|
|
| MD5 |
ce5d41187b156cae503cc01d2ac88d58
|
|
| BLAKE2b-256 |
20c1b1e31f093a07d9e2c23589ce7d1ea891eb07afcfbe4e3d1db63eeea6b95a
|
Provenance
The following attestation bundles were made for pii_radar-0.4.0.tar.gz:
Publisher:
release.yml on nithin42/pii-radar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pii_radar-0.4.0.tar.gz -
Subject digest:
ca9526766dd21a1693028befc465b35a22e1db38eb680a58199d55975d3fcd1e - Sigstore transparency entry: 2302422312
- Sigstore integration time:
-
Permalink:
nithin42/pii-radar@e89aeecc17020a9e3aaf41de03afe21b8eed5648 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/nithin42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e89aeecc17020a9e3aaf41de03afe21b8eed5648 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pii_radar-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pii_radar-0.4.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a6e47f6f7ba65d68e7cff75994689c5dde7a8c360f81a97920e109728411964
|
|
| MD5 |
34ea3d91773355b37f5617a9c441eae4
|
|
| BLAKE2b-256 |
4769f1ade91e371030a799399b04027e498fd765882aec864921432e46461721
|
Provenance
The following attestation bundles were made for pii_radar-0.4.0-py3-none-any.whl:
Publisher:
release.yml on nithin42/pii-radar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pii_radar-0.4.0-py3-none-any.whl -
Subject digest:
9a6e47f6f7ba65d68e7cff75994689c5dde7a8c360f81a97920e109728411964 - Sigstore transparency entry: 2302422381
- Sigstore integration time:
-
Permalink:
nithin42/pii-radar@e89aeecc17020a9e3aaf41de03afe21b8eed5648 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/nithin42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e89aeecc17020a9e3aaf41de03afe21b8eed5648 -
Trigger Event:
push
-
Statement type: