Skip to main content

๐Ÿ” pii-radar

Scan any CSV, JSON, or Parquet file for Personally Identifiable Information โ€” in seconds.

CI Coverage PyPI version Python License: MIT PRs Welcome


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-detect exits with code 1 for pipeline gates
  • โšก Row sampling โ€” --sample 1000 limit for rapid audit sampling on massive files
  • ๐Ÿ”’ Auto-redaction โ€” --redact creates 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
EMAIL 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

pii_radar-0.4.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pii_radar-0.4.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

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

Hashes for pii_radar-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ca9526766dd21a1693028befc465b35a22e1db38eb680a58199d55975d3fcd1e
MD5 ce5d41187b156cae503cc01d2ac88d58
BLAKE2b-256 20c1b1e31f093a07d9e2c23589ce7d1ea891eb07afcfbe4e3d1db63eeea6b95a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pii_radar-0.4.0.tar.gz:

Publisher: release.yml on nithin42/pii-radar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pii_radar-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a6e47f6f7ba65d68e7cff75994689c5dde7a8c360f81a97920e109728411964
MD5 34ea3d91773355b37f5617a9c441eae4
BLAKE2b-256 4769f1ade91e371030a799399b04027e498fd765882aec864921432e46461721

See more details on using hashes here.

Provenance

The following attestation bundles were made for pii_radar-0.4.0-py3-none-any.whl:

Publisher: release.yml on nithin42/pii-radar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page