A Python tool that automatically closes GitHub Advanced Security (GHAS) secret scanning alerts by matching them with previously triaged false positives from GitGuardian exports.
This tool solves the problem of having to re-triage thousands of security alerts when migrating from GitGuardian to GitHub Advanced Security. It matches GHAS secret scanning alerts with dismissed or resolved GitGuardian incidents by comparing secret types and values, then automatically closes matching alerts.
- Automated Alert Closure: Automatically closes GHAS secret scanning alerts that match GitGuardian false positives
- Multi-Secret Type Support: Handles various secret types including AWS keys, GitHub tokens, private keys, database connection strings, and more
- Robust Matching: Implements sophisticated matching algorithms for different secret formats
- GitGuardian CSV Integration: Processes GitGuardian CSV exports with "Show Secrets" option enabled
- Comprehensive Logging: Detailed logging for audit trails and debugging
- Batch Processing: Can process alerts across entire GitHub organizations
The tool currently supports matching for the following secret types:
- AWS Credentials: Access keys, secret keys, session tokens
- Private Keys: RSA, OpenSSH, PGP private keys
- Authentication: HTTP Basic/Bearer authentication headers
- API Keys: GitHub personal access tokens, Google API keys, JFrog tokens
- Database Connections: PostgreSQL connection strings
- Cloud Services: Google Cloud service account credentials, Databricks tokens
- Communication: Slack API tokens and webhook URLs
- Generic Secrets: High entropy secrets, passwords, bearer tokens
- Python 3.13+
- GitHub token with
security_events:writescope for the target organization (Secret Scanning Alerts r/w for fine-grained) - GitGuardian token with
Members:readandIncidents:readpermissions - GitGuardian CSV export with "Show Secrets" option enabled
- Clone the repository:
git clone <repository-url>
cd gitguardian-fp-importer- Compile and install dependencies:
# Compile requirements from .in files
./compile-requirements.sh
# Install production dependencies
pip install -r requirements.txt
# Or install development dependencies (includes production deps)
pip install -r requirements-dev.txtThis project uses pip-tools for dependency management:
- requirements.in: High-level production dependencies
- requirements-dev.in: Development dependencies (includes production)
- compile-requirements.sh: Script to generate locked requirements files
To update dependencies:
# Edit requirements.in or requirements-dev.in
# Then recompile
./compile-requirements.shSet the required environment variables:
export GITHUB_TOKEN="your_github_token_here"
export GITGUARDIAN_TOKEN="your_gitguardian_token_here"Process a single repository: (add --dismiss-alerts to actually close the GHAS alerts)
python update_ghas_secret_alerts_from_gitguardian_data.py \
--gitguardian-csv-file gitguardian_export.csv \
--gitguardian-api-url https://api.gitguardian.com/v1 \
--org your-org \
--repo your-repo Process all repositories in an organization:
python update_ghas_secret_alerts_from_gitguardian_data.py \
--gitguardian-csv-file gitguardian_export.csv \
--gitguardian-api-url https://api.gitguardian.com/v1 \
--org your-org \--org: GitHub organization name--gitguardian-csv-file: Path to GitGuardian CSV export file with secret info--gitguardian-api-url: GitGuardian API URL (e.g., https://api.gitguardian.com/v1)
--repo: Specific repository name (processes all repos in org if omitted)--dismiss-alerts: Actually dismiss alerts in GHAS (default is dry-run mode)--secret-type: Filter alerts by specific secret type (e.g., aws_secret_access_key)--matching-info-csv-output: CSV output file about which alerts matched--close-info-csv-output: CSV output file with information about alerts being closed--debug: Enable debug logging--debug-log-secrets: Enable debug logging of secrets (WARNING: outputs secrets to console)--alert: Specific secret alert number to process (useful for testing)--include-closed-alerts: Query closed GHAS alerts (useful for testing)
- Navigate to the GitGuardian Incidents page
- Apply filters for "Ignored" or "Resolved" incidents
- Select "Individual secret incidents without details about multiple occurrences"
- Important: Enable "Show Secrets" option
- Export to CSV
- Load GitGuardian Data: Parses the CSV export and organizes incidents by detector type
- Fetch GHAS Alerts: Retrieves open secret scanning alerts from GitHub
- Secret Matching: Uses specialized mappers to compare secrets:
- Simple Mapping: Direct value comparison for API keys and tokens
- Base64 Decoding: Handles authentication headers and encoded secrets
- Key Normalization: Strips metadata and formatting from private keys
- URL Parsing: Extracts components from database connection strings
- Alert Closure: Marks matching alerts as false positives with detailed reasoning
GitGuardianIncidentRow: Represents a single incident from the CSV exportGitGuardianIncidentDictionary: Organizes incidents by detector typeAbstractGitGuardianMapper: Base class for secret matching strategies- Specialized Mappers: Handle different secret formats and edge cases
update_ghas_secret_alerts_from_gitguardian_data.py: Main application logicgitguardian_mappers.py: Secret matching mapper classes and logiccrypto_utils.py: Utilities for handling malformed private keys and cryptographic datagitguardian_incident_info.py: Helper for GitGuardian API interactions
- Requires GitGuardian CSV export with secrets visible
- Some private key formats may not match due to GitGuardian encoding issues
- Limited to secret types with implemented mappers
- Cannot process secrets that GitGuardian failed to detect
- Fork the repository
- Create a feature branch
- Perform testing (automated tests don't exist but we would welcome some!)
- Submit a pull request
To add support for a new secret type:
- Create a new mapper class inheriting from
AbstractGitGuardianMapperingitguardian_mappers.py - Implement the
secret_present_in_rowmethod - Add the mapping to the
create_ghas_to_gitguardian_converters()function
The tool provides comprehensive logging:
- INFO: High-level progress and statistics
- DEBUG: Detailed matching attempts and API calls
- WARNING: Potential issues or unsupported secret types
- ERROR: Critical failures
- Store API tokens securely using environment variables
- Limit GitHub token permissions to minimum required scope
- Review logs for sensitive data before sharing
- The tool runs in dry-run mode by default - use
--dismiss-alertsto actually close alerts - Never use
--debug-log-secretsin production or shared environments as it outputs secrets to logs
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
For issues or questions:
- Check the existing issues on GitHub
- Review the research documentation
- Enable debug logging for troubleshooting
- Create a new issue with detailed information