Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
df6c839
Refactor GithubVulnerability parser and add GithubSAST parser
Logicmn Jul 10, 2025
9331265
More GithubVulnerability and GithubSAST parser improvements
Logicmn Jul 10, 2025
4eb0c57
Add documentation
Logicmn Jul 10, 2025
e3897ae
Add tests, update docs, and add hash code fields
Logicmn Jul 10, 2025
841acfb
Fix Github vulnerability parser unit test
Logicmn Jul 10, 2025
bfe18b5
Unit tests and parser tweaks
Logicmn Jul 10, 2025
2222451
Rm files pushed by mistake
Logicmn Jul 10, 2025
bc00531
Revert certain removals from unit test
Logicmn Jul 11, 2025
ae03b73
Add EPSS field population and update unit tests
Logicmn Jul 11, 2025
b33bcfb
Removed some unnecessary comments and formatting
Logicmn Jul 11, 2025
a040125
Ruff formatting
Logicmn Jul 11, 2025
0d8b091
Fix unit tests
Logicmn Jul 11, 2025
e84ad29
Ruff formatting
Logicmn Jul 14, 2025
12bee6f
Fix unit test
Logicmn Jul 15, 2025
26663af
Github Vulnerability parser and docs tweaks, and upgrade instructions
Logicmn Jul 16, 2025
0ec4541
Politeness
Logicmn Jul 16, 2025
092d94d
Fix dependabot update pr link parsing
Logicmn Jul 18, 2025
1930107
Backwards compatability
Logicmn Aug 2, 2025
82ed3f8
Revert 2.49 docs change and add 2.51
Sep 27, 2025
13a9895
Add 2.51 upgrade doc
Sep 27, 2025
f3a40d9
Merge branch 'dev' into github-vuln-parser-improvements
Logicmn Sep 27, 2025
8bd074d
Smol 2.51 upgrade doc fix
Logicmn Sep 27, 2025
31f7a8a
Move imports to top
Logicmn Sep 27, 2025
809cd6b
Merge branch 'github-vuln-parser-improvements' of github.com:Logicmn/…
Logicmn Sep 27, 2025
34e9364
Ruff lint fix
Logicmn Sep 27, 2025
d9b525c
Merge branch 'dev' into github-vuln-parser-improvements
valentijnscholten Sep 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Github SAST Scan"
toc_hide: true
---
Import findings in JSON format from Github Code Scanning REST API:
<https://docs.github.com/en/rest/code-scanning/code-scanning>

### Sample Scan Data
Sample Github SAST scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/github_sast).
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Github Vulnerability"
title: "Github Vulnerability Scan"
toc_hide: true
---
Import findings from Github vulnerability scan (GraphQL Query):
Expand All @@ -15,6 +15,8 @@ vulnerabilityAlerts (RepositoryVulnerabilityAlert object)
+ createdAt (optional)
+ vulnerableManifestPath
+ state (optional)
+ dependabotUpdate (DependabotUpdate object) (optional)
+ pullRequest (PullRequest object) (optional)
+ securityVulnerability (SecurityVulnerability object)
+ severity (CRITICAL/HIGH/LOW/MODERATE)
+ package (optional)
Expand All @@ -27,10 +29,17 @@ vulnerabilityAlerts (RepositoryVulnerabilityAlert object)
+ value
+ references (optional)
+ url (optional)
+ cvss (optional)
+ cvss (optional - deprecated, use cvssSeverities instead)
+ score (optional)
+ vectorString (optional)
+ cvssSeverities (optional)
+ cvssV3 (CVSS object) (optional)
+ score (optional)
+ vectorString (optional)
+ cwes (optional)
+ epss (EPSS object) (optional)
+ percentage (optional)
+ percentile (optional)
```

References:
Expand Down
7 changes: 7 additions & 0 deletions docs/content/en/open_source/upgrading/2.51.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ The following Helm chart values have been modified in this release:
- **Enhanced probe configuration for Celery**: Added support for customizing liveness, readiness, and startup probes in both Celery beat and worker deployments.
- **Enhanced environment variable management**: All deployments now include `extraEnv` support for adding custom environment variables. For backwards compatibility, `.Values.extraEnv` can be used to inject common environment variables to all workloads.

## GitHub Scan Type and Parser Updates
The Github Vulnerability scan type and parser has been split into two disctinct scan types:
- [Github Vulnerability](https://github.com/DefectDojo/django-DefectDojo/blob/master/docs/content/en/connecting_your_tools/parsers/file/github_vulnerability.md) (original)
- [Github SAST](https://github.com/DefectDojo/django-DefectDojo/blob/master/docs/content/en/connecting_your_tools/parsers/file/github_sast.md)

The original Github Vulnerability scan type will continue to accept SCA vulnerabilities uploaded in GitHub's GraphQL format, as it has always done. It will also continue to accept SAST uploads, however we recommend upgrading to the new Github SAST scan type for uploading these types of vulnerabilities going forward. This new scan type will accept the raw JSON response from [GitHub's REST API for code scanning alerts](https://docs.github.com/en/rest/code-scanning/code-scanning). Sample Github SAST scan data can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/github_sast).

### Other changes

- **Celery pod annotations**: Now we can add annotations to Celery beat/worker pods separately.
Expand Down
2 changes: 2 additions & 0 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ def saml2_attrib_map_format(din):
"JFrog Xray On Demand Binary Scan": ["title", "component_name", "component_version"],
"Scout Suite Scan": ["file_path", "vuln_id_from_tool"], # for now we use file_path as there is no attribute for "service"
"Meterian Scan": ["cwe", "component_name", "component_version", "description", "severity"],
"Github SAST Scan": ["vuln_id_from_tool", "severity", "file_path", "line"],
"Github Vulnerability Scan": ["title", "severity", "component_name", "vulnerability_ids", "file_path"],
"Solar Appscreener Scan": ["title", "file_path", "line", "severity"],
"pip-audit Scan": ["vuln_id_from_tool", "component_name", "component_version"],
Expand Down Expand Up @@ -1550,6 +1551,7 @@ def saml2_attrib_map_format(din):
"Scout Suite Scan": DEDUPE_ALGO_HASH_CODE,
"AWS Security Hub Scan": DEDUPE_ALGO_UNIQUE_ID_FROM_TOOL,
"Meterian Scan": DEDUPE_ALGO_HASH_CODE,
"Github SAST Scan": DEDUPE_ALGO_HASH_CODE,
"Github Vulnerability Scan": DEDUPE_ALGO_HASH_CODE,
"Cloudsploit Scan": DEDUPE_ALGO_HASH_CODE,
"SARIF": DEDUPE_ALGO_UNIQUE_ID_FROM_TOOL_OR_HASH_CODE,
Expand Down
Empty file.
84 changes: 84 additions & 0 deletions dojo/tools/github_sast/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import json
from urllib.parse import urlparse

from dojo.models import Finding


class GithubSASTParser:
def get_scan_types(self):
return ["Github SAST Scan"]

def get_label_for_scan_types(self, scan_type):
return scan_type

def get_description_for_scan_types(self, scan_type):
return "GitHub SAST report file can be imported in JSON format."

def get_findings(self, filename, test):
data = json.load(filename)
if not isinstance(data, list):
error_msg = "Invalid SAST report format, expected a JSON list of alerts."
raise TypeError(error_msg)

findings = []
for vuln in data:
rule = vuln.get("rule", {})
inst = vuln.get("most_recent_instance", {})
loc = inst.get("location", {})
html_url = vuln.get("html_url")
rule_id = rule.get("id")
title = f"{rule.get('description')} ({rule_id})"
severity = rule.get("security_severity_level", "Info").title()
active = vuln.get("state") == "open"

# Build description with context
desc_lines = []
if html_url:
desc_lines.append(f"GitHub Alert: [{html_url}]({html_url})")
owner = repo = None
commit_sha = inst.get("commit_sha")
if html_url:
parsed = urlparse(html_url)
parts = parsed.path.strip("/").split("/")
# URL is /<owner>/<repo>/security/... so parts[0]=owner, parts[1]=repo
if len(parts) >= 2:
owner, repo = parts[0], parts[1]
if owner and repo and commit_sha and loc.get("path") and loc.get("start_line"):
file_link = (
f"{parsed.scheme}://{parsed.netloc}/"
f"{owner}/{repo}/blob/{commit_sha}/"
f"{loc['path']}#L{loc['start_line']}"
)
desc_lines.append(f"Location: [{loc['path']}:{loc['start_line']}]({file_link})")
elif loc.get("path") and loc.get("start_line"):
# fallback if something is missing
desc_lines.append(f"Location: {loc['path']}:{loc['start_line']}")
msg = inst.get("message", {}).get("text")
if msg:
desc_lines.append(f"Message: {msg}")
if severity:
desc_lines.append(f"Rule Severity: {severity}")
if rule.get("full_description"):
desc_lines.append(f"Description: {rule.get('full_description')}")
description = "\n".join(desc_lines)

finding = Finding(
title=title,
test=test,
description=description,
severity=severity,
active=active,
static_finding=True,
dynamic_finding=False,
vuln_id_from_tool=rule_id,
)

# File path & line
finding.file_path = loc.get("path")
finding.line = loc.get("start_line")

if html_url:
finding.url = html_url

findings.append(finding)
return findings
Loading