keyvan / screenshot-guard
Secret scanner with OCR superpowers - finds secrets in code AND screenshots
Package info
github.com/Keyvanhardani/screenshot-guard
Language:Python
pkg:composer/keyvan/screenshot-guard
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2026-03-05 01:11:39 UTC
README
Screenshot Guard
๐ Secret Scanner with OCR Superpowers
The first secret scanner that finds secrets in code AND screenshots.
Powered by german-ocr
๐จ The Problem
Developers take screenshots. Screenshots of terminals, dashboards, documentation.
And sometimes those screenshots contain secrets:
| ๐ฑ Scenario | ๐ธ Impact |
|---|---|
| AWS keys in terminal output | $47,000 cloud bill |
| API tokens in dashboard screenshots | Data breach |
| "Example" credentials that are actually real | Account compromise |
Regular secret scanners miss all of this.
๐ก The Solution
Screenshot Guard scans your code AND your images using OCR.
# Install pip install screenshot-guard[ocr] # Scan screenshot-guard scan ./your-project
โจ Features
| Feature | Description |
|---|---|
| ๐ OCR-powered | Finds secrets in PNG, JPG, GIF, BMP, WebP images |
| ๐ฏ 50+ patterns | AWS, Azure, GCP, GitHub, Stripe, Slack, and more |
| ๐ Local processing | No cloud, no data leaves your machine |
| ๐ค GitHub Action | Easy CI/CD integration with SARIF support |
| ๐ช Pre-commit hook | Catch secrets before they're committed |
๐ฆ Installation
๐ Pythonpip install screenshot-guard[ocr] |
๐ฆ Node.jsnpm install screenshot-guard |
๐ PHPcomposer require keyvan/screenshot-guard |
Python Installation Options
| Command | What's installed |
|---|---|
pip install screenshot-guard |
Text scanning only (no OCR) |
pip install screenshot-guard[ocr] |
+ german-ocr with llama.cpp |
pip install screenshot-guard[ollama] |
+ german-ocr with Ollama backend |
๐ก Note: You don't need to install german-ocr separately - it comes automatically with
[ocr]!
โก Quick Start
๐ป CLI Usage
# Scan current directory screenshot-guard scan . # Scan with JSON output screenshot-guard scan ./src --format json --output report.json # Only critical and high severity screenshot-guard scan . --severity high # Disable OCR (faster, but misses images) screenshot-guard scan . --no-ocr # Use Ollama backend for OCR screenshot-guard scan . --backend ollama
๐ค GitHub Action
name: Security Scan on: [push, pull_request] jobs: secrets: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Scan for secrets uses: Keyvanhardani/screenshot-guard@v1 with: path: '.' severity: 'medium' ocr: 'true' fail-on-findings: 'true'
๐ช Pre-commit Hook
# .pre-commit-config.yaml repos: - repo: https://github.com/Keyvanhardani/screenshot-guard rev: v0.1.0 hooks: - id: screenshot-guard args: ['--severity', 'high', '--no-ocr']
๐ฏ Supported Patterns
# List all patterns
screenshot-guard patterns
๐ Output Formats
Table (default)
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโ
โ File โ Line โ Type โ Severity โ Source โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโค
โ screenshot.png โ 3 โ AWS Access Key ID โ CRITICAL โ OCR โ
โ config.yaml โ 12 โ Database URL โ CRITICAL โ Text โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโ
Export Options
| Format | Command | Use Case |
|---|---|---|
| ๐ JSON | --format json |
CI/CD pipelines |
| ๐ SARIF | --format sarif |
GitHub Security |
| ๐ Markdown | --format markdown |
Documentation |
๐ง OCR Backends
| Backend | Speed | Setup | GPU |
|---|---|---|---|
llamacpp |
โก Fast | pip install screenshot-guard[ocr] |
Optional |
ollama |
โก Fast | Requires Ollama | Optional |
cloud |
โกโก Fastest | API key required | N/A |
# Use specific backend screenshot-guard scan . --backend llamacpp screenshot-guard scan . --backend ollama
๐ API Usage
๐ Python
from screenshot_guard import Scanner, SecretDetector, OCREngine # Initialize detector = SecretDetector(min_severity="high") ocr = OCREngine(backend="llamacpp") scanner = Scanner(detector=detector, ocr_engine=ocr) # Scan findings = scanner.scan("./your-project") for finding in findings: print(f"{finding.file_path}:{finding.line_number} - {finding.pattern_name}") print(f" Severity: {finding.severity}") print(f" From OCR: {finding.from_ocr}")
๐ฆ Node.js
const { scan } = require('screenshot-guard'); // Scan a directory const findings = await scan({ path: './your-project', severity: 'high', ocr: true }); findings.forEach(finding => { console.log(`${finding.file}:${finding.line} - ${finding.type}`); console.log(` Severity: ${finding.severity}`); });
๐ PHP
use ScreenshotGuard\Client; $guard = new Client(); $findings = $guard->scan('./your-project', [ 'severity' => 'high' ]); foreach ($findings as $finding) { echo "{$finding['file_path']}:{$finding['line_number']} - {$finding['pattern_name']}\n"; }
๐ Ignoring Files
Create .screenshotguardignore in your project root:
# Ignore test fixtures tests/fixtures/* # Ignore vendor vendor/ # Ignore specific files docs/example-config.yaml
๐ฑ Why OCR?
Real examples where OCR would have helped:
| Incident | Secret Exposed | Cost |
|---|---|---|
| ๐ธ Terminal screenshot in docs | AWS Access Key | $47,000 cloud bill |
| ๐ Dashboard screenshot in README | "Example" API key (was real) | 2 months exposed |
| ๐ฌ Slack screenshot in GitHub issue | GitHub token | Repository compromised |
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md.
๐ License
Apache 2.0 - see LICENSE
๐ค Author
Keyvan Hardani
Made with โค๏ธ for security
