Hi developer ππ»! This repository is a Proof of Concept (PoC) to integrate GitHub Advanced Security (GHAS) with DefectDojo. I tried to make it as simple as possible, so you can easily adapt it to your needs.
- GitHub Advanced Security (GHAS) - DefectDojo Integration
- Full GHAS Integration: Import all three types of GitHub Advanced Security alerts into DefectDojo
- Automated Workflows: GitHub Actions workflows ready to use
- Dependabot Alerts: Import using
GitHub Vulnerability Scanformat - Code Scanning Alerts: Import CodeQL results using
SARIFformat - Secret Scanning Alerts: Create findings directly via DefectDojo API
- Sample Flask App: Includes a vulnerable Flask application for testing
- Manual Workflow Triggers: All workflows now support
workflow_dispatchfor manual execution - Configurable Parameters:
engagement_idinput for CodeQL and Dependabot workflows (default:1)test_idinput for Secret Scanning workflow (default:1)
- Updated GitHub Actions:
actions/checkoutβ v6actions/upload-artifactβ v7github/codeql-actionβ v4
- Python 3.8+ - Main programming language
- Flask - Web framework for the sample vulnerable app
- GitHub Actions - CI/CD automation
- GitHub Advanced Security - Security scanning (Dependabot, CodeQL, Secret Scanning)
- DefectDojo - Vulnerability management platform
- Docker - Container support
- Git
- Docker & Docker Compose
- GitHub CLI (optional)
- A GitHub repository with GHAS enabled
- A GitHub App with
read:security_eventspermission (for secrets and dependabot alerts)
git clone https://github.com/0GiS0/import-ghas-to-defectdojo.git
cd import-ghas-to-defectdojoClone and run DefectDojo locally:
git clone https://github.com/DefectDojo/django-DefectDojo.git
cd django-DefectDojo
docker compose up -d
docker compose logs initializer | grep "Admin password:"Then you can log in to DefectDojo at http://localhost:8080 with username admin and the password from the logs.
You need a Product and an Engagement created in DefectDojo. You can create them using the API. Check the file requests/create_defectDojo_artifacts.http for examples.
Use a tunneling service like pinggy.io or ngrok:
# Using pinggy.io
ssh -p 443 -R0:localhost:8080 qr@a.pinggy.io
# Using ngrok
ngrok http 8080Add the following secrets to your GitHub repository:
| Secret | Description |
|---|---|
DEFECTDOJO_URL |
The URL exposed by the tunnel |
DEFECTDOJO_TOKEN |
DefectDojo API token (create it in your user profile) |
To get secrets and dependabot alerts, create a GitHub App with the read:security_events permission. Follow the official documentation.
π Congratulations! You are ready to go!
Dependabot alerts are imported using the GitHub Vulnerability Scan format (available since DefectDojo 2.4.0).
The workflow .github/workflows/send_dependabot_security_alerts.yml retrieves alerts via GraphQL API and sends them to DefectDojo:
curl -X POST "$DEFECTDOJO_URL/import-scan/" \
-H "Authorization: Token $DEFECTDOJO_TOKEN" \
-F 'product_name=YOUR_PRODUCT_NAME' \
-F 'engagement=ENGAGEMENT_ID' \
-F 'scan_type=Github Vulnerability Scan' \
-F 'file=@dependabot-security-alerts.json'Code Scanning alerts (CodeQL) are imported using the SARIF format.
The workflow .github/workflows/codeql_and_defectdojo.yml runs CodeQL analysis and uploads results:
curl -X POST "$DEFECTDOJO_URL/import-scan/" \
-H "Authorization: Token $DEFECTDOJO_TOKEN" \
-F 'product_name=YOUR_PRODUCT_NAME' \
-F 'engagement=ENGAGEMENT_ID' \
-F 'scan_type=SARIF' \
-F 'file=@results/python.sarif'Secret Scanning alerts are created directly as findings via the DefectDojo API.
The workflow .github/workflows/send_secrets_to_defectdojo.yml:
- Fetches secrets from GitHub REST API
- Transforms the data to DefectDojo format using
jq - Creates findings via POST to
/api/v2/findings/
# Get secrets from GitHub
curl -H "Authorization: Bearer $TOKEN" \
https://api.github.com/repos/OWNER/REPO/secret-scanning/alerts > secrets.json
# Transform and send to DefectDojo
curl -X POST "$DEFECTDOJO_URL/findings/" \
-H "Authorization: Token $DEFECTDOJO_TOKEN" \
-H "Content-Type: application/json" \
-d "$FINDING_DATA"import-ghas-to-defectdojo/
βββ .github/
β βββ dependabot.yml
β βββ workflows/
β βββ codeql_and_defectdojo.yml # CodeQL + SARIF upload
β βββ get_alerts.yml # Get GHAS alerts
β βββ send_dependabot_security_alerts.yml
β βββ send_secrets_to_defectdojo.yml
βββ flask_webgoat/ # Sample vulnerable Flask app
β βββ actions.py
β βββ auth.py
β βββ status.py
β βββ ui.py
β βββ users.py
β βββ templates/
βββ requests/ # HTTP request examples
β βββ create_defectDojo_artifacts.http
β βββ defectDojo.http
β βββ ghas_alerts_requests.http
β βββ send_*.http
βββ app.py
βββ Dockerfile
βββ requirements.txt
βββ README.md
If you found this project useful, don't forget to follow me on my social networks:
Happy hacking! π±βπ€
