Configure Repository Settings
Manage Trufflehog scanning and other security settings for your repositories.
How It Works
Trufflehog scanning operates at two key points in the development workflow:Pre-Push Hook Scanning
When you push code to a repository, Trufflehog automatically scans all modified and added files for potential secrets before the push completes. The scanning process:- File Detection - Identifies all files that have been added, modified, or changed in the push
- Pattern Filtering - Applies
.trufflehogignore
patterns to exclude files that shouldn’t be scanned - Secret Scanning - Runs Trufflehog with comprehensive detection rules for verified, unknown, and unverified secrets
- Push Control - Blocks the push if potential secrets are detected, allowing you to review and remediate
Agent Commit Scanning
When Codegen agents create commits using the signed commit feature, Trufflehog scans all files before the commit is created. Agent scanning includes:- Automatic Detection - Scans all files being committed without manual intervention
- Configurable Bypass - Agents can skip scanning for confirmed false positives using the
skip_trufflehog
parameter - Error Reporting - Provides detailed feedback about detected secrets with remediation guidance
Configuration
Ignore Patterns
Create a.trufflehogignore
file in your repository root to exclude files from scanning:
- Glob patterns for matching file paths
- Regular expressions for complex matching rules
- Comments using
#
for documentation - Directory exclusions with trailing slashes
Scanning Scope
Trufflehog scans for multiple types of secrets:- API Keys - AWS, Google Cloud, Azure, and hundreds of other services
- Database Credentials - Connection strings, passwords, and authentication tokens
- Private Keys - SSH keys, SSL certificates, and cryptographic material
- Authentication Tokens - JWT tokens, OAuth secrets, and session identifiers
Working with Detections
When Trufflehog Blocks a Push
If Trufflehog detects potential secrets during a push, you’ll see output similar to:- Review the detected secrets - Examine the flagged content carefully
- Remove actual secrets - Replace real credentials with environment variables or configuration
- Update ignore patterns - Add false positives to
.trufflehogignore
if appropriate - Bypass if necessary - Use
git push --no-verify
only for confirmed false positives
Agent Commit Handling
When agents encounter Trufflehog detections, they receive detailed error messages:skip_trufflehog=true
parameter, but this should only be used for confirmed false positives.
Best Practices
Repository Setup
- Add
.trufflehogignore
early - Configure ignore patterns when setting up repositories - Document exceptions - Comment ignore patterns to explain why files are excluded
- Regular reviews - Periodically audit ignore patterns to ensure they’re still appropriate
Secret Management
- Use environment variables - Store secrets in environment variables or secure configuration systems
- Implement secret rotation - Regularly rotate API keys and credentials
- Monitor for exposure - Set up alerts for any secrets that might be accidentally committed
Team Workflow
- Educate developers - Ensure team members understand how Trufflehog works and why it’s important
- Handle false positives - Establish clear processes for dealing with false positive detections
- Emergency procedures - Have plans for handling actual secret exposures if they occur
Never use
--no-verify
or skip_trufflehog=true
to bypass real secret
detections. These options should only be used for confirmed false positives
after careful review.Troubleshooting
Common Issues
High false positive rate:- Review and update
.trufflehogignore
patterns - Consider excluding test files, documentation, or configuration templates
- Large repositories may experience slower push times
- Consider excluding build artifacts and generated files
- Review the specific detection details in error messages
- Update code to use proper secret management practices
- Use
skip_trufflehog=true
only for confirmed false positives
Getting Help
If you encounter persistent issues with Trufflehog scanning:- Check ignore patterns - Verify
.trufflehogignore
syntax and coverage - Review detection details - Examine the specific content flagged by Trufflehog
- Contact support - Reach out to Codegen support for assistance with configuration
Trufflehog integration helps maintain security best practices by preventing
accidental secret exposure, but it should be part of a comprehensive security
strategy that includes proper secret management and regular security reviews.