Skip to content

Commit cf2a8b1

Browse files
🐛 harden jfrog xray unified file parsing #13628 (#13632)
* 🐛 harden jfrog xray unified file parsing * fix
1 parent 1622df3 commit cf2a8b1

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

dojo/tools/jfrog_xray_unified/parser.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def get_item(vulnerability, test):
104104
else:
105105
title = vulnerability["summary"]
106106

107-
references = "\n".join(vulnerability["references"])
107+
references_str = vulnerability.get("references")
108+
references = "\n".join(references_str) if isinstance(references_str, list) else (references_str if isinstance(references_str, str) else "")
108109

109110
scan_time = datetime.strptime(
110111
vulnerability["artifact_scan_time"], "%Y-%m-%dT%H:%M:%S%z",
@@ -118,15 +119,18 @@ def get_item(vulnerability, test):
118119
# remove package type from component name
119120
component_name = component_name.split("://", 1)[1]
120121

121-
tags = ["packagetype_" + vulnerability["package_type"]]
122+
tags = []
123+
package_type = vulnerability.get("package_type")
124+
if package_type:
125+
tags.append("packagetype_" + package_type)
122126

123127
# create the finding object
124128
finding = Finding(
125129
title=title,
126130
test=test,
127131
severity=severity,
128132
description=(
129-
vulnerability["description"] + "\n\n" + extra_desc
133+
vulnerability.get("description", vulnerability.get("summary")) + "\n\n" + extra_desc
130134
).strip(),
131135
mitigation=mitigation,
132136
component_name=component_name,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"total_rows": 123,
3+
"rows": [
4+
{
5+
"cves": [
6+
{
7+
"cve": "CVE-2023-42282",
8+
"cvss_v3_score": 9.8,
9+
"cvss_v3_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
10+
}
11+
],
12+
"cvss3_max_score": 9.8,
13+
"severity": "Critical",
14+
"component_physical_path": "ip:2.0.0",
15+
"impact_path": [
16+
"somepath"
17+
],
18+
"fixed_versions": [
19+
"2.0.1",
20+
"1.1.9"
21+
],
22+
"issue_id": "XRAY-123",
23+
"project_keys": [
24+
"somepath"
25+
],
26+
"applicability": null,
27+
"applicability_result": "not_scanned",
28+
"summary": "The ip package before 1.1.9 for Node.js might allow SSRF because some IP addresses (such as 0x7f.1) are improperly categorized as globally routable via isPublic.",
29+
"vulnerable_component": "npm://ip:2.0.0",
30+
"impacted_artifact": "build://[some_artifact_id]",
31+
"path": "somepath",
32+
"published": "2024-02-09T16:30:10Z",
33+
"artifact_scan_time": "2025-11-03T11:42:09Z"
34+
}
35+
]
36+
}

unittests/tools/test_jfrog_xray_unified_parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,12 @@ def test_parse_file_with_another_report(self):
345345
findings = parser.get_findings(testfile, Test())
346346
testfile.close()
347347
self.assertEqual(7, len(findings))
348+
349+
def test_parse_file_issue_13628(self):
350+
testfile = (get_unit_tests_scans_path("jfrog_xray_unified") / "issue_13628.json").open(encoding="utf-8")
351+
parser = JFrogXrayUnifiedParser()
352+
findings = parser.get_findings(testfile, Test())
353+
testfile.close()
354+
self.assertEqual(1, len(findings))
355+
self.assertEqual("Critical", findings[0].severity)
356+
self.assertEqual("XRAY-123 - The ip package before 1.1.9 for Node.js might allow SSRF because some IP addresses (such as 0x7f.1) are improperly categorized as globally routable via isPublic.", findings[0].title)

0 commit comments

Comments
 (0)