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 (IPv4 & IPv6), 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

# Base installation (Lightweight)
pip install pii-radar

# With Parquet support
pip install "pii-radar[parquet]"

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.1.tar.gz (18.7 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.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file pii_radar-0.4.1.tar.gz.

File metadata

  • Download URL: pii_radar-0.4.1.tar.gz
  • Upload date:
  • Size: 18.7 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.1.tar.gz
Algorithm Hash digest
SHA256 c73db68d26fb1abd9dcc52342afc937b497bb31a1266f44656c0f5b07a37bed2
MD5 f693fa52fec58306279ddd2b99d285d0
BLAKE2b-256 5b0c56524b93e93f52a8ada036b91af9fdc21f07eb4870a402407c74cb2c3766

See more details on using hashes here.

Provenance

The following attestation bundles were made for pii_radar-0.4.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pii_radar-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 15.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c9ebae189b360dad97d2c5313c4467702f86c526d8e5136ef9d7135fb1b97bd
MD5 d2bd1d2a7447318d1edeae6d47321cc4
BLAKE2b-256 2fc7881a9824ddbff0fae86bdf3dc3c8a04bec48d23dd58fde8556775e685cde

See more details on using hashes here.

Provenance

The following attestation bundles were made for pii_radar-0.4.1-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