API Key Detector is a sophisticated security tool designed to prevent accidental exposure of sensitive credentials during Git commits. By implementing intelligent scanning mechanisms, the tool helps developers maintain robust security practices and protect confidential access tokens.
- Multi-pattern secret identification
- Comprehensive scanning of staged Git files
- Support for various credential formats (API keys, tokens, environment variables)
- Configurable detection strategies
- Seamless Git pre-commit hook integration
- Command-line interface for manual scanning
- Lightweight and non-intrusive design
- Automatic exclusion of large files
- Skip logic for binary and non-source files
- Configurable ignore patterns
- Python 3.8+
- Git 2.0+
# Clone the repository
git clone https://github.com/hey-granth/api-detection-tool.git
# Navigate to project directory
cd api-detection-tool
# Install the package
pip install .Customize secret detection by modifying patterns in src/core.py. The default configuration supports:
- Generic long-string patterns
- Service-specific key formats (Stripe, AWS)
- Environment variable detection
- URL-based key identification
- Copy the pre-commit hook script:
cp git_hooks/pre_commit.py .git/hooks/pre_commit
chmod +x .git/hooks/pre_commit- Automatically runs before each commit
- Blocks commits containing potential secrets
- Provides detailed error messages
# Scan staged files
python -m api-detection-tool
# Bypass detection (use with caution)
git commit --no-verify- Always review detected potential secrets
- Use environment variable management tools
- Rotate credentials regularly
- Never commit sensitive information directly
- False positives in detection
- Performance with large repositories
- Compatibility with different Git workflows
Solution: Customize detection patterns and filtering logic in the configuration files.
- Fork the repository
- Create a feature branch
- Implement your changes
- Write comprehensive tests
- Submit a pull request
- Use GitHub Issues
- Provide detailed reproduction steps
- Include relevant configuration and environment details
This tool is designed to enhance security awareness. It is not a comprehensive security solution and should be used as part of a broader security strategy.
Maintainer: Granth Agarwal
Email: heygranth@gmail.com