To learn more, read about the GitGuardian risk score
By default, this script only updates incidents with "unknown" severity. This design preserves severities that may have been:
- Set manually by users
- Configured via the Severity Rules Engine
If you want to override all severities (including those set by users or the Severity Rules Engine), use the --force flag.
This application assumes the following:
- A *nix or bash-like environment for execution (For Windows users we recommend Git Bash, or WSL)
- A working, non-eol
python3,pip, andvenvinstallation. - A GitGuardian SaaS account in good standing - risk scores are not currently supported in On-Prem installs.
Please note that only "Open" Incidents will be mapped. Incidents in the Resolved or Ignored state will be left as-is.
-
Create a virtual python environment (Optional, Recommended):
cd risk-to-severity-mapping/ # **this directory** python3 -m venv --prompt risk-mapping .venv
-
Activate environment and install requirements:
source .venv/bin/activate pip install -r requirements.txt -
Acquire an API key:
- Use a Service Access Token (SAT) for higher rate-limits.
- Set the scope to
Incidents:write, Incidents:read - See the GitGuardian Documentation for more info.
-
OPTIONAL: Configure your mapping values in the script:
Edit lines 26 thru 30 of the script to customize your mapping values
SEVERITY_MAPPING = { "critical": 85, # Risk score >= 85 "high": 60, # Risk score >= 60 and < 85 "medium": 40, # Risk score >= 40 and < 60 "low": 26, # Risk score >= 26 and < 40 "info": 0, # Risk score 0-25 }
-
Activate the environment (if not already active) set your variables, and run the script:
# Activate the environment source .venv/bin/activate # Set up Your GitGuardian API key in the environment. export GITGUARDIAN_API_KEY="your_api_key_here" # OPTIONAL: Set the API URL (defaults to US region) export GITGUARDIAN_API_URL="https://api.gitguardian.com" # US Region # For EU region, use: https://api.eu1.gitguardian.com # Test run without making changes (only updates "unknown" severities) python3 sync_risk_to_severity.py # OPTIONAL: Set DRY_RUN to false to enable updating (report only by default) export DRY_RUN="false" # Live run (n.b: we set DRY_RUN inline here) DRY_RUN=false python3 sync_risk_to_severity.py # Force update ALL severities (overrides Severity Rules Engine and manual settings) DRY_RUN=false python3 sync_risk_to_severity.py --force
Starting risk score to severity sync - 2025-12-18T10:30:00.000000
Mode: DRY RUN
Update mode: UNKNOWN severity only
API Base URL: https://api.gitguardian.com
--------------------------------------------------------------------------------
Incident 22404169: Risk Score=20 | Current=unknown → Target=low
Incident 23139880: Risk Score=86 | Current=unknown → Target=critical
================================================================================
EXECUTION SUMMARY
================================================================================
Total incidents processed: 2325
Incidents updated: 1773
Incidents skipped: 552
Errors: 0
================================================================================