Zero-Trust DLP · Apache-2.0 · Zero Core Dependencies

pii-screenshot-guard

A Python Zero-Trust Data Loss Prevention (DLP) CLI, library, and GitHub Pull Request API auditor that catches LGPD/GDPR PII, API keys, database passwords, and internal RFC 1918 IPs across logs, PR diffs, and screenshots before they leak.

Checksum-Verified PII

Validates Brazilian CPF & CNPJ (mod-11 check digits) and payment cards (Luhn) to cut false positives in production logs.

GitHub REST API PR Auditor

Fetches unified PR diffs via the GitHub API, scans only newly added lines with exact file/line mapping, and posts masked reports.

Zero-Exposure Reporting

Raw credentials are never echoed in terminal or PR comments - every match renders as a truncated safe preview (e.g., AKI***LE).

Screenshot Vision & OCR

Includes pluggable TesseractOCRAnalyzer (offline) and GeminiVisionAnalyzer for multimodal image auditing.

Quick Start (CLI)

pip install git+https://github.com/gavicoding/pii-screenshot-guard.git

# Scan files, directories, or piped diffs
pii-guard scan ./logs --fail-on medium --format markdown
git diff | pii-guard scan -

# Redact sensitive spans deterministically
pii-guard redact app.log -o app.sanitized.log

GitHub REST API Pull Request Integration

Run pii-guard github-pr in CI or locally to audit Pull Request diffs directly against the GitHub REST API (GET /repos/{owner}/{repo}/pulls/{pr}) and optionally post a masked comment via POST /repos/{owner}/{repo}/issues/{pr}/comments.

export GITHUB_TOKEN="ghp_..."
pii-guard github-pr --repo gavicoding/pii-screenshot-guard --pr 1 --format markdown --comment

Key Detection Rules

Rule IDScopeSeverityValidation
PRIVATE_KEY_BLOCKSecretsCRITICALPEM private key header
AWS_ACCESS_KEYSecretsCRITICALAKIA / ASIA 20-char identifier
GITHUB_TOKENSecretsCRITICALGitHub PAT / fine-grained token prefix
DB_CONNECTION_STRINGSecretsCRITICALURI containing user:pass@host
CREDIT_CARDPCI / PIIHIGHLuhn checksum verified
BR_CPFLGPD PIIHIGHOfficial mod-11 check digits
BR_CNPJLGPD CorpMEDIUMOfficial mod-11 check digits
INTERNAL_IPV4Infra LeakMEDIUMStrict RFC 1918 private subnets