Skip to main content

Local-first deterministic security and privacy scanning CLI

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

privscan-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

privscan-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file privscan-0.1.0.tar.gz.

File metadata

  • Download URL: privscan-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for privscan-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e9b6385f9070e82ec64605e53feda256237d2bc838c53f78504c3a0592696494
MD5 8d05f204c9a202f149a371214b106b6e
BLAKE2b-256 00adf3a6b02cb92d1d0841584fd225a54410c84302dc8ea1ddfe42f18f2e7ac8

See more details on using hashes here.

File details

Details for the file privscan-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: privscan-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for privscan-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2bef61e6f258d70d6b6f801e97fc7eeef1e4929910c26fbb5881634ad901310b
MD5 223d78f378424d8b822c634d3c2f4da7
BLAKE2b-256 5726df1eed8331d20da7e4ed6366d44f85a71e92b18db84251eb43fc70c18af3

See more details on using hashes here.

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