Skip to content

Commit 582800b

Browse files
🎉 Add fix_available to AnchoreEngine (#13060)
1 parent 3a51fca commit 582800b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

dojo/tools/anchore_engine/parser.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def get_findings_with_metadata(self, data, test):
4646
severity = "Info"
4747

4848
mitigation = "No fix available."
49-
49+
fix_available = False
5050
if item.get("fixAvailable") and item["fixAvailable"] != "None":
5151
mitigation = f"Upgrade to: {' or '.join(item['fixAvailable'].split(','))}\n\n"
5252
mitigation += f"URL: {item.get('link', 'None')}"
53+
fix_available = True
5354
cvssv3_base_score = item.get("nvdCvssBaseScore")
54-
5555
if isinstance(cvssv3_base_score, str) and cvssv3_base_score.replace(".", "", 1).isdigit():
5656
cvssv3_base_score = float(cvssv3_base_score)
5757
elif not isinstance(cvssv3_base_score, int | float):
@@ -87,6 +87,7 @@ def get_findings_with_metadata(self, data, test):
8787
static_finding=True,
8888
dynamic_finding=False,
8989
vuln_id_from_tool=vulnerability_id,
90+
fix_available=fix_available,
9091
)
9192

9293
if vulnerability_id:
@@ -142,7 +143,9 @@ def get_findings_without_metadata(self, data, test):
142143
"Upgrade to " + item["package_name"] + " " + item["fix"] + "\n"
143144
)
144145
mitigation += "URL: " + item["url"] + "\n"
145-
146+
fix_available = True
147+
if item["fix"] == "None":
148+
fix_available = False
146149
cvssv3_base_score = None
147150
if item["feed"] == "nvdv2" or item["feed"] == "vulnerabilities":
148151
if "nvd_data" in item and len(item["nvd_data"]) > 0:
@@ -213,6 +216,7 @@ def get_findings_without_metadata(self, data, test):
213216
static_finding=True,
214217
dynamic_finding=False,
215218
vuln_id_from_tool=item.get("vuln"),
219+
fix_available=fix_available,
216220
)
217221
if vulnerability_id:
218222
find.unsaved_vulnerability_ids = [vulnerability_id]

unittests/tools/test_anchore_engine_parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def test_anchore_engine_parser_has_many_findings(self):
2121
parser = AnchoreEngineParser()
2222
findings = parser.get_findings(testfile, Test())
2323
self.assertEqual(23, len(findings))
24+
finding = findings[5]
25+
self.assertEqual(finding.fix_available, True)
2426

2527
def test_anchore_engine_parser_has_many_findings_2_4_1(self):
2628
with (get_unit_tests_scans_path("anchore_engine") / "many_vulns_2.4.1.json").open(encoding="utf-8") as testfile:
@@ -34,6 +36,7 @@ def test_anchore_engine_parser_has_many_findings_2_4_1(self):
3436
self.assertEqual(6.7, finding.cvssv3_score)
3537
self.assertEqual(1, len(finding.unsaved_vulnerability_ids))
3638
self.assertEqual("CVE-2020-13776", finding.unsaved_vulnerability_ids[0])
39+
self.assertEqual(finding.fix_available, False)
3740

3841
def test_anchore_engine_parser_new_fomrat_issue_11552(self):
3942
with (get_unit_tests_scans_path("anchore_engine") / "new_format_issue_11552.json").open(encoding="utf-8") as testfile:

0 commit comments

Comments
 (0)