GitHub Advanced Security Executor¶
Category: Source Code Analysis
Script: github_security.py
Integration: REST API
Faraday Plugin: Raw JSON
Website: https://docs.github.com/en/rest/security-advisories
Description¶
Imports the GitHub Advanced Security alerts of one repository into Faraday: code scanning, secret scanning and Dependabot alerts. The repository becomes a host and each alert a vulnerability prefixed with [CODE], [SECRETS] or [SCA].
Prerequisites¶
- A GitHub personal access token (classic or fine-grained) or GitHub App installation token with read access to the alerts you import:
security_eventsfor code scanningsecret_scanning_alertsfor secret scanning- the "Dependabot alerts" repository permission for Dependabot
- GitHub Advanced Security features enabled on the repository
- For GitHub Enterprise Server, the URL of its REST API
Configuration¶
Environment Variables (Setup)¶
| Variable | Required | Description |
|---|---|---|
GH_HOST |
No | GitHub REST API URL (default: https://api.github.com). For GitHub Enterprise Server use e.g. https://github.example.com/api/v3. |
GH_TOKEN |
Yes | GitHub access token |
These variables are also accepted as execution arguments, so a single run can override them.
Execution Arguments¶
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
GH_OWNER |
string | Yes | Owner of the repository (user or organization) |
GH_REPO |
string | Yes | Repository name, without the owner |
GH_SCAN_TYPES |
string | No | Comma-separated alert types to import: code, secrets, dependabot (default: all three) |
GH_MIN_SEVERITY |
string | No | Minimum severity to import: info, low, medium, high or critical (default: info) |
YAML Configuration Example¶
executors:
github_security:
repo_executor: github_security.py
max_size: 65536
varenvs:
GH_HOST: "https://api.github.com"
GH_TOKEN: "<gh_token>"
params:
GH_OWNER:
mandatory: true
type: string
base: string
GH_REPO:
mandatory: true
type: string
base: string
GH_SCAN_TYPES:
mandatory: false
type: string
base: string
GH_MIN_SEVERITY:
mandatory: false
type: string
base: string
How It Works¶
- Authenticates with
Authorization: Bearer <GH_TOKEN> - For each selected scan type, reads the alerts of
GH_OWNER/GH_REPOwith the GitHub REST API, following the pagination links (100 per page):code:/code-scanning/alerts(open alerts only)secrets:/secret-scanning/alertsdependabot:/dependabot/alerts
- Maps each alert to a Faraday vulnerability:
- Severity: the alert's severity. Secret scanning alerts have none and are imported as
high. - Status: open alerts are open; fixed, resolved and auto-dismissed alerts are closed; dismissed alerts are risk-accepted
- Details: rule or advisory description, file location, affected package, CVEs, CWEs and references
- Severity: the alert's severity. Secret scanning alerts have none and are imported as
- Drops alerts below
GH_MIN_SEVERITYand creates one host for the repository
Notes¶
- The host has the synthetic IP
0.0.0.0and the hostname<owner>/<repo>, because alerts belong to a repository rather than an IP address. - If the token lacks a permission, or a feature is disabled for the repository, that scan type is skipped and the error is written to the agent log. The other scan types still run.
- No host is created when there are no alerts.
- TLS certificates are not verified.
- The shared agent parameters (
AGENT_CONFIG_*tags and severity filters) are not applied by this executor. UseGH_MIN_SEVERITYto filter by severity.