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.
- 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.
- Python 3.7 or higher
- Git
pip install git-guardian-cli- Clone the repository:
git clone https://github.com/yourusername/git-guardian-cli.git cd git-guardian-cli - Install the package:
pip install .
To scan a repository for secrets:
git-guardian scan /path/to/repo--outputor-o: Output format (cliorjson). Default:cli.git-guardian scan /path/to/repo --output json
To install a pre-commit hook that blocks commits with exposed secrets:
git-guardian install-hookYou 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}"
}
]
}By default, the following directories are ignored during scanning:
.gitnode_modulesvenv
git-guardian scan .git-guardian install-hook- Create a
.gitguardianrcfile with your custom rules. - Run the scan:
git-guardian scan /path/to/repo
- Clone the repository:
git clone https://github.com/000xs/git-guardian-cli.git cd git-guardian-cli - Install dependencies:
pip install -r requirements.txt
python -m pytest tests/ -vpython setup.py sdist bdist_wheelWe 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.
This project is licensed under the MIT License. See the LICENSE file for details.
- 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.
If you have any questions or need help, please open an issue on GitHub.
- Built with ❤️ by 000x.