A tool to prevent you from pushing sensitive files to your repository.
Project description
🛡️ PyGitGuard
PyGitGuard is a Git security scanner designed to prevent accidental commits of sensitive data by scanning for:
- 🧪 Exposed credentials
- 📁 Potentially sensitive files
- 📄 Missing best practice files
📦 Version History
1.0.3
- Fix: "Do not block commits in cases of recommendations."
- Adding context message after run
- Docs: "Documenting some files to maintain consistency."
1.0.2
- Refactor: Standarize a bit lines with black linter.
1.0.1
- Fix: pip install support.
- Fix: pre-commit support.
- Fix: Improvements to config in .pre-commit-config.yaml.
- Fix: Add pre-commit to requirements.txt.
- Fix: Creating config files if they do not exist.
- Fix: Remove interactive mode with input (not supported with pre-commit).
1.0.0 – Initial release with core features
✅ Features
- 🚫 Detect sensitive content via regex (e.g., passwords, tokens, API keys)
- 🔍 Scan for sensitive filenames like
.env,.pem,id_rsa - 📏 Enforce maximum file size policies
- 📚 Recommend best practice files (e.g.,
README.md,.gitignore,LICENSE) - 🔄 Auto-generate configuration files
- 🪝 Pre-commit hook support
🚀 Quick Start Guide
1. Install PyGitGuard
pip install git+https://github.com/digo5ds/pygitguard.git
2. Install and Configure pre-commit
If you haven't already:
pip install pre-commit
pre-commit install
To manually run a scan:
pygitguard
To scan a specific path:
pygitguard --path <your_repository>
With pre-commit configured, the scan runs automatically before each commit.
To bypass a scan for a commit:
git commit -m "your message" --no-verify
⚙️ Configuration
On the first run, .pygitguard.yaml and .pre-commit-config.yaml is created (if not exists). This file allows customization of scan behavior.
📌 Using with .pre-commit-config.yaml
If you're already using pre-commit, add this to your config:
repos:
- repo: https://github.com/digo5ds/pygitguard
rev: 1.0.1 # Replace with the latest release
hooks:
- id: pygitguard-scan
name: PyGitGuard Scan
entry: pygitguard
language: system
types: [python]
stages: [pre-commit]
Example .pygitguard.yaml
SENSITIVE_PATTERNS:
- .*\.env.*$
- .*\.pem.*$
- .*\.key.*$
- .*\.crt.*$
- .*\.sqlite.*$
- .*\.db.*$
- .*secret.*$
- .*credential.*$
- .*id_rsa.*$
- .*password.*$
- .*token.*$
- .*ACCESS_KEY.*$
SENSITIVE_CONTENT:
- \b\w*password\w*\s*=\s*['"`].+['"`]
- \b\w*token\w*\s*=\s*['"`].+['"`]
- \b\w*api[_-]?key\w*\s*=\s*['"`].+['"`]
- \b\w*user(name)?\w*\s*=\s*['"`].+['"`]
- \b\w*ACCESS_KEY\w*\s*=\s*['"`].+['"`]
BEST_PRACTICES_FILES:
- .gitignore
- README.md
- LICENSE
- requirements.txt
- pyproject.toml
- Dockerfile: .dockerignore
- docker-compose.yml: .dockerignore
- __version__.py # Recommended
MAX_FILE_SIZE_MB: 1
💡 Tips
- Add
__version__.pytoBEST_PRACTICES_FILESto track versioning. - Customize
MAX_FILE_SIZE_MBfor your project's sensitivity.
🔧 Local Hook Example
To use as a local hook:
- repo: local
hooks:
- id: pygitguard
name: pygitguard
entry: pygitguard_cli
language: system
types: [python]
📄 License
MIT License
🤝 Contributing
Pull requests and issue reports are welcome!
📬 Contact
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 pygitguard-1.0.2.tar.gz.
File metadata
- Download URL: pygitguard-1.0.2.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a639771f5f701139fc3171e780d67783bf001168d022df7a3b2716b5f7167df
|
|
| MD5 |
4da7011aec2ecedeb110610f22b68e1d
|
|
| BLAKE2b-256 |
65a7ee0b4262cc8ed9c980fd61780f2444e54b81c4c56e201e631a023b2f432d
|
File details
Details for the file pygitguard-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pygitguard-1.0.2-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22469981379741eaa518124457f6e5018ed94c659a28503283dacd1ee04c5a00
|
|
| MD5 |
b945b18a0c99680aa9436981e3bafaf9
|
|
| BLAKE2b-256 |
633b8f381007e59c32fc59c86181c446daa6d31c08dcd96c2f7a8f06b2275fe6
|