Skip to main content

PrivScan 🔐

Local-First Deterministic Security & Privacy Scanner (CLI)

PrivScan is a local-first, deterministic, rule-based security and privacy auditing CLI tool that scans source code and configuration files to detect secrets, credentials, and PII (Personally Identifiable Information) using transparent YAML-driven rules.

Built for developers, security engineers, and CI/CD pipelines.

✨ Features

  • 🔒 Secrets Detection

    • API keys (Stripe, GitHub, AWS, generic)
    • Passwords & tokens
  • 🧾 PII Detection (India + Global)

    • Aadhaar, PAN, Driving License
    • Email addresses
    • Phone numbers (India & international)
    • Credit cards, passports, US SSN
  • 📍 Exact Location Reporting

    • File path
    • Line number
    • Matched value
  • 📊 Multiple Output Formats

    • Rich CLI table (default)
    • Summary
    • JSON (machine-readable)
  • 🚫 Noise Control

    • Ignores virtualenvs, site-packages, build outputs
  • ⚙️ Severity Filtering

  • 🚦 CI/CD-Ready Exit Codes

  • 📦 pip-installable CLI

📦 Installation (PyPI)

From pypi

pip install privscan

*Local / Development install:

git clone https://github.com/KNIHAL/PrivScan.git
pip install -e .

Verify installation:

privscan --help

🚀 Usage

Basic Scan

privscan .

Scan Specific Directory

privscan src/

Minimum Severity Filter

privscan . --severity high

Summary Output

privscan . --format summary

JSON Output (Automation / CI)

privscan . --format json --output report.json

🤖 CI / Automation Mode

Fail pipeline if findings are detected:

privscan . --severity high --fail-on-findings

Exit codes:

  • 0 → No findings
  • 1 → Findings detected

Compatible with:

  • GitHub Actions
  • GitLab CI
  • Jenkins
  • Pre-commit hooks

📊 Example Output (CLI Table)

PrivScan Findings
┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Severity ┃ Rule ID           ┃ File                               ┃ Line ┃ Match                               ┃ Description                    ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ HIGH     │ SECRET_STRIPE_KEY │ examples/sample_repo/app.py        │    1 │ sk_test_1234567890abcdef            │ Stripe secret API key detected │
│ HIGH     │ SECRET_API_KEY    │ examples/sample_repo/app.py        │    1 │ API_KEY="sk_test_1234567890abcdef"  │ Hardcoded API key detected     │
│ HIGH     │ SECRET_PASSWORD   │ examples/sample_repo/config.env    │    1 │ DB_PASSWORD="supersecret123"        │ Hardcoded password detected    │
└──────────┴───────────────────┴────────────────────────────────────┴──────┴─────────────────────────────────────┴────────────────────────────────┘

🧪 Example Repository

PrivScan includes an example repository for demonstration:

privscan examples/sample_repo

This validates:

  • real-world secret detection
  • accurate line numbers
  • low false positives

🧠 How It Works

Directory Scanner
        ↓
Safe File Reader
        ↓
YAML Rule Engine
        ↓
Secret / PII Detectors
        ↓
Location Enrichment
        ↓
Reporters (Table / Summary / JSON)
        ↓
Exit Codes
  • Deterministic
  • Explainable
  • Fully offline

📁 Project Structure

privscan/
├── privscan/
│   ├── cli/
│   ├── scanner/
│   ├── rules/
│   ├── detectors/
│   ├── engine/
│   └── reporter/
├── examples/
│   └── sample_repo/
├── tests/
├── pyproject.toml
└── README.md

🔐 Rule Design Philosophy

  • Prefix-based secrets (low false positives)
  • Assignment-only detection
  • Length & boundary checks
  • Country-aware + global PII
  • No entropy guessing
  • No ML black boxes

📌 Project Status

Status: Stable / Complete (v1)

PrivScan is a finished, production-ready CLI tool.

Future additions (optional): - more rule packs - organization-specific policies

📜 License

MIT License

👤 Author

Kumar Nihal Built as a demonstration of applied security engineering, deterministic rule engines, and professional CLI design.

Metadata

Release files for privscan 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for privscan 0.1.0
File Size Uploaded Provenance Actions
privscan-0.1.0.tar.gz 10.8 kB Without provenance Details for privscan-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for privscan 0.1.0
File Interpreter ABI Platform Actions
privscan-0.1.0-py3-none-any.whl Python 3 none any Details for privscan-0.1.0-py3-none-any.whl

Total release size: 22.4 kB

Release files / privscan-0.1.0.tar.gz

Download URL privscan-0.1.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e9b6385f9070e82ec64605e53feda256237d2bc838c53f78504c3a0592696494
BLAKE2b-256 checksum
How to use checksums
00adf3a6b02cb92d1d0841584fd225a54410c84302dc8ea1ddfe42f18f2e7ac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / privscan-0.1.0-py3-none-any.whl

Download URL privscan-0.1.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bef61e6f258d70d6b6f801e97fc7eeef1e4929910c26fbb5881634ad901310b
BLAKE2b-256 checksum
How to use checksums
5726df1eed8331d20da7e4ed6366d44f85a71e92b18db84251eb43fc70c18af3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for privscan 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page