AI Code Security Scanner with Human-in-the-Loop Feedback
Project description
โ CheckMate - AI Code Security Scanner with Human-in-the-Loop Feedback
Human-in-the-loop anomaly detection for AI-generated code. A professional CLI tool that scans code for security vulnerabilities, enables human review, and learns from feedback to improve detection accuracy.
๐ฏ The Problem
AI-generated code is powerful but risky:
- โ Hardcoded secrets (API keys, passwords)
- โ Code execution vulnerabilities (eval, exec, pickle)
- โ SQL injection patterns
- โ No built-in security checks
CheckMate solves this with automated detection + human judgment.
๐ What Makes CheckMate Different
Human-in-the-Loop Learning
Scan โ Review Flags โ Mark as Valid/False Positive โ System Learns โ Better Scans
- ๐ Before/After Metrics - See precision improve in real-time
- โ Human Feedback Loop - Mark false positives, build whitelist
- ๐ฏ 31 Detection Rules - Across secrets, code execution, SQL injection
- ๐พ Persistent Learning - Whitelist saves automatically
- ๐ Multi-Language - Python & JavaScript support
โก Quick Start
1. Install (30 seconds)
pip install checkmate-ai
2. Start Dashboard (in Terminal 1)
checkmate dashboard
Browser opens automatically to http://localhost:3000 showing "Waiting for scan..."
3. Run Scanner (in Terminal 2)
checkmate scan demo.py
The dashboard updates automatically showing detected flags.
4. Review & Provide Feedback
- See code with syntax highlighting
- Read security explanations
- Click "Mark as Safe" to whitelist patterns
- View suggested fixes
5. Rescan & Watch Improvement
checkmate scan demo.py
Metrics page shows precision improvement (e.g., 62% โ 84%)
๐ All CLI Commands
| Command | Purpose |
|---|---|
checkmate dashboard |
Start web UI + backend server |
checkmate scan <file> |
Scan single file |
checkmate scan file1.py file2.js |
Scan multiple files |
checkmate scan . |
Scan all .py and .js in current directory |
checkmate whitelist |
View current whitelist |
checkmate reset |
Clear all data (fresh start) |
checkmate version |
Show version info |
๐ Hackathon Scoring Alignment (100 Points)
CheckMate scores on all 6 evaluation categories:
| Category | Evidence |
|---|---|
| Problem Definition | AI code security + human review = clear, valuable problem |
| Anomaly Detection | 31 rules across 3 categories (secrets, code exec, SQL injection) |
| Human-in-Loop | Users mark valid/false positive โ whitelist updates โ system learns |
| Before/After Improvement | Metrics page shows precision improvement (tracked over time) |
| Explainability | Each flag shows: explanation, severity, suggested fix, line number |
| Presentation | Professional CLI, web dashboard, polished UX |
| TOTAL | **Production-ready, ship-worthy |
๐จ Dashboard Features
Results Page (/)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CheckMate - Security Scan Results โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ File: demo.py โ
โ Total Flags: 5 โ
โ โ
โ [CRITICAL] Hardcoded API Key (Line 15) โ
โ sk-1234567890abcdef โ
โ Use: os.environ.get('OPENAI_API_KEY') โ
โ [Mark as Safe] [Copy Fix] โ
โ โ
โ [DANGER] eval() Usage (Line 28) โ
โ eval("user_input") โ
โ Use: ast.literal_eval() instead โ
โ [Mark as Safe] [Copy Fix] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Metrics Page (/metrics)
- Precision Trend - Line chart showing improvement over time
- Stat Cards - Total scans, total flags, precision %, improvement %
- Before/After Card - Visual improvement comparison
- Per-Rule Breakdown - Accuracy by detection rule
๐ Detection Rules (31 Total)
Category 1: Secrets (10 rules) ๐ด CRITICAL
- OpenAI API keys (
sk-...) - AWS Access Keys (
AKIA...) - Hardcoded passwords
- Private tokens, JWT secrets
- Firebase API keys
- Stripe API keys
- GitHub tokens
- And more...
Category 2: Code Execution (14 rules) ๐ DANGER
eval()usageexec()usagepickle.loads()deserializationsubprocesswith shell=Trueos.system()calls- Dynamic imports
- And more...
Category 3: SQL Injection (7 rules) ๐ก HIGH RISK
- F-string SQL queries
- String concatenation in queries
- Variable interpolation in SQL
- And more...
๐ How the Feedback Loop Works
Step 1: Initial Scan
checkmate scan code.py
# Detects: 5 flags
# Metrics: 3 valid, 2 false positives
# Precision: 60%
Step 2: Human Review
- Dashboard shows each flag
- User reads explanation: "eval() can execute arbitrary code"
- User decides: "This is a false positive (test code)"
- Clicks: "Mark as Safe"
Step 3: Whitelist Update
- Backend saves to
whitelist.json - Pattern added:
eval("test_value") - Next scan will skip this pattern
Step 4: Rescan & Improvement
checkmate scan code.py
# Detects: 4 flags (1 skipped via whitelist)
# Metrics: 3 valid, 1 false positive (whitelisted)
# Precision: 75% (improved!)
Step 5: Persistent Learning
- Precision tracked over time
- Metrics page shows trend: 60% โ 75% โ 84%
- Team learns what their codebase's real risks are
๐๏ธ Architecture
Tech Stack
- CLI: Python 3.11+ with Click framework
- Detection: Regex-based (31 rules, no ML)
- Backend: FastAPI (lightweight API)
- Dashboard: Next.js 14 + React 18 + TypeScript
- UI Components: shadcn/ui + Tailwind CSS
- Data: SQLite database + JSON files
Data Flow
Terminal (User)
โ
[checkmate scan file.py]
โ
CLI Scanner (runs detectors)
โ
FastAPI Backend (saves to DB)
โ
Browser (Next.js Dashboard)
โ
User Reviews & Marks Safe/False Positive
โ
Backend Updates Whitelist + Metrics
โ
Next Scan Reads Whitelist (skips patterns)
โ
Precision Improves โ
๐ฆ Installation & Setup
For detailed setup instructions, see SETUP.md
Quick Install
# From PyPI (recommended)
pip install checkmate-ai
checkmate dashboard
# From source
git clone https://github.com/yourusername/checkmate
cd checkmate
pip install -e .
checkmate dashboard
๐ฌ Demo Walkthrough
-
Open Terminal 1
checkmate dashboardBrowser shows: "Waiting for scan..."
-
Open Terminal 2
checkmate scan samples/vulnerable_1.py
-
See Results (browser auto-refreshes)
- 5 flags detected
- Severity badges, code snippets, suggestions
-
Provide Feedback
- Click "Mark as Safe" on false positive
- Watch whitelist update in real-time
-
Rescan
checkmate scan samples/vulnerable_1.py
- Flag count decreased
- Metrics page shows precision improved
-
View Metrics
- Navigate to
/metrics - See precision trend chart
- Before: 60% | After: 84%
- Navigate to
๐ Project Structure
checkmate/
โโโ README.md # This file
โโโ SETUP.md # Installation guide
โโโ setup.py # PyPI packaging
โโโ pyproject.toml # Modern Python standard
โ
โโโ checkmate/ # Main package
โ โโโ cli.py # CLI entry point
โ โโโ scanner.py # Detection engine
โ โโโ detectors/ # 31 detection rules
โ
โโโ backend/
โ โโโ main.py # FastAPI server
โ โโโ database.py # SQLite operations
โ โโโ models.py # Data models
โ โโโ routes/ # API endpoints
โ
โโโ dashboard/ # Next.js web UI
โ โโโ app/ # Pages (/, /metrics)
โ โโโ components/ # UI components
โ
โโโ data/ # JSON storage
โ โโโ scan_results.json
โ โโโ whitelist.json
โ โโโ feedback.json
โ โโโ metrics.json
โ
โโโ samples/ # Example vulnerable files
โโโ vulnerable_1.py
โโโ vulnerable_2.py
โโโ vulnerable_3.js
๐ Links
- ๐ฆ PyPI Package: https://pypi.org/project/checkmate-ai/
- ๐ GitHub Repository: https://github.com/yourusername/checkmate
- ๐ Setup Guide: SETUP.md
- ๐ Hackathon Rubric Alignment: See PRD.md
Running the Demo
# Terminal 1
checkmate dashboard
# Terminal 2 (wait 3 seconds)
checkmate scan samples/vulnerable_1.py
# Browser shows results automatically
# Mark a false positive as safe
# Rescan to see improvement
Time needed: 2 minutes total
๐ค Contributing
Found a bug? Have a rule idea? Open a GitHub issue or PR!
๐ License
MIT License - See LICENSE file for details
๐ก Future Enhancements
- Machine learning for adaptive rules
- More language support (Go, Java, Rust)
- Integration with CI/CD pipelines
- API for programmatic scanning
- Rule customization UI
CheckMate - Making AI-generated code safer, one scan at a time.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file checkmate_ai-1.0.2.tar.gz.
File metadata
- Download URL: checkmate_ai-1.0.2.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64db0f2dd99bc108fdb7caf5f937ea36f5f21142b3d5439da8fcf5b4a07d2fd7
|
|
| MD5 |
d9c3e3a668f9edd56a2ef3ddbcedfb95
|
|
| BLAKE2b-256 |
db2d590415acd0a70b2f018be95f917ebfa8198f93dafbb8faa9b330926524a7
|
File details
Details for the file checkmate_ai-1.0.2-py3-none-any.whl.
File metadata
- Download URL: checkmate_ai-1.0.2-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae9cfa2cb663e15fe56cd976f49872301966ad8fa62a7142c0501a2ceba194cc
|
|
| MD5 |
64839bb1d8e5c57d9faac7354302eb38
|
|
| BLAKE2b-256 |
fcf4727b0dc9266fc6b646291e954a76eb5fca329493efd2571a5d8bb7fd37f8
|