A CLI tool to scan Git repositories for sensitive information
Project description
Git Guardian CLI
Git Guardian CLI is a security-focused command-line tool that scans Git repositories for sensitive information like API keys, passwords, and credentials. It helps prevent accidental exposure of secrets before pushing code to remote repositories.
Features
- Secret Detection: Uses regex patterns to detect sensitive information in files.
- Git Hook Integration: Automatically blocks commits containing exposed secrets.
- Cross-Platform: Works on Windows, macOS, and Linux.
- Custom Rules: Add your own regex patterns for secret detection.
- Detailed Reports: Provides structured output of scan results.
- Pre-Commit Hook: Prevents commits with exposed secrets.
Installation
Prerequisites
- Python 3.7 or higher
- Git
Install via pip
pip install git-guardian-cli
Install from Source
- Clone the repository:
git clone https://github.com/yourusername/git-guardian-cli.git cd git-guardian-cli
- Install the package:
pip install .
Usage
Scan a Repository
To scan a repository for secrets:
git-guardian scan /path/to/repo
Options
--outputor-o: Output format (cliorjson). Default:cli.git-guardian scan /path/to/repo --output json
Install Pre-Commit Hook
To install a pre-commit hook that blocks commits with exposed secrets:
git-guardian install-hook
Configuration
Custom Rules
You can add custom regex patterns for secret detection by creating a .gitguardianrc file in your repository:
{
"custom_rules": [
{
"name": "Custom API Key",
"pattern": "CUSTOM-[A-Z0-9]{20}"
}
]
}
Ignored Directories
By default, the following directories are ignored during scanning:
.gitnode_modulesvenv
Examples
Scan a Repository
git-guardian scan .
Install Pre-Commit Hook
git-guardian install-hook
Scan with Custom Rules
- Create a
.gitguardianrcfile with your custom rules. - Run the scan:
git-guardian scan /path/to/repo
Development
Setup
- Clone the repository:
git clone https://github.com/000xs/git-guardian-cli.git cd git-guardian-cli
- Install dependencies:
pip install -r requirements.txt
Run Tests
python -m pytest tests/ -v
Build the Package
python setup.py sdist bdist_wheel
Contributing
We welcome contributions! Here’s how you can help:
- Report Issues: If you find a bug or have a feature request, open an issue on GitHub.
- Submit Pull Requests: Fork the repository, make your changes, and submit a pull request.
- Improve Documentation: Help us improve the documentation by submitting updates.
Please read our Contributing Guidelines for more details.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Why Git Guardian CLI?
- Prevent Accidental Exposure: Catch sensitive information before it’s committed.
- Easy to Use: Simple CLI commands with detailed reports.
- Customizable: Add your own rules for secret detection.
- Cross-Platform: Works on Windows, macOS, and Linux.
Support
If you have any questions or need help, please open an issue on GitHub.
Acknowledgments
- Built with ❤️ by 000x.
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 git-guardian-cli-1.0.2.tar.gz.
File metadata
- Download URL: git-guardian-cli-1.0.2.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5798079834b35240eaaad940b8362334ac7edc192ad99091a6caec23f2a9a1af
|
|
| MD5 |
82d4b4457169c80887a41af98abc36b4
|
|
| BLAKE2b-256 |
b93e0285d1310b47e4eb0684242374e37cba3771e577ad22af6b815bcbcedb9c
|
File details
Details for the file git_guardian_cli-1.0.2-py3-none-any.whl.
File metadata
- Download URL: git_guardian_cli-1.0.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3462cc1bee39b66dae5b128a29fc854860f73ff696fd71488269ea44aa7e1934
|
|
| MD5 |
fab94c38a57645ca92724b822d9bada2
|
|
| BLAKE2b-256 |
763aef97285edfb88e4e1b58fe683359ab80dee196ed52e4daeb38eae12f21e5
|