Pre-commit hook for detecting security issues in AI-generated code
Project description
PolicyGuard catches common security vulnerabilities in your Python code, especially those often introduced by AI coding assistants like GitHub Copilot.
✨ Features
- 🚨 Detects hardcoded secrets - passwords, API keys, tokens
- 💉 Prevents SQL injection - finds string concatenation in queries
- 🎯 Catches dangerous functions - eval(), exec(), pickle.load()
- 🤖 AI-specific patterns - TODOs for passwords, example keys
- ⚡ Fast - typically <100ms per file
- 🎨 Beautiful output - color-coded, with context
- 🔧 Git pre-commit hook - catch issues before they're committed
- 📦 Zero dependencies - minimal requirements
🚀 Quick Start
Install
pip install policyguard
Initialize in your repo
cd your-python-project
policyguard init
That's it!
PolicyGuard will now check your Python files before each commit.
📋 What It Catches
Security Issues
- Hardcoded passwords and secrets
- SQL injection vulnerabilities
- Command injection risks
- Insecure deserialization (pickle)
- Weak random number generation
- Dangerous eval/exec usage
AI-Specific Patterns
# TODO: change passwordcomments- Example API keys (sk-xxx, AKIA-xxx)
- Placeholder emails (test@test.com)
- Localhost URLs in production code
🔧 Usage
Scan manually
# Scan current directory
policyguard scan
# Scan specific file
policyguard scan auth.py
# Output as JSON
policyguard scan --json
View all rules
policyguard rules
🤝 Contributing
We love contributions! Please see our contributing guidelines.
📄 License
MIT - see LICENSE
Built with ❤️ to keep AI-generated code secure
Project details
Release history Release notifications | RSS feed
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 policyguard_paolovella-0.1.0.tar.gz.
File metadata
- Download URL: policyguard_paolovella-0.1.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54de9d7a6597fa32be37278826ed784f14df645c0ee28dc9625503b861b29a26
|
|
| MD5 |
ad723ab0e013051e61282ae44acce4d0
|
|
| BLAKE2b-256 |
631c2d0576ee937bdd3fe175d001a11f896d0b521c0230ee127b655b08932880
|
File details
Details for the file policyguard_paolovella-0.1.0-py3-none-any.whl.
File metadata
- Download URL: policyguard_paolovella-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a8dc80de6f9cab4dd0fa3e83743bb067aab33c2c149a137891052d60f1ba1ca
|
|
| MD5 |
57170d1b5c1c9bb45372f7ac90ea5950
|
|
| BLAKE2b-256 |
4b6bdd3fa2e522d529a4a6ab11da40cc2b4e07396105ddb720efa31aff83eb0b
|