Skip to content

Commit 2fe00d6

Browse files
🎉 Add fix_available information to mend #12633 (#13142)
* 🎉 Add fix_available information to mend #12633 * fix
1 parent 00ac181 commit 2fe00d6

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

dojo/tools/mend/parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def _build_common_output(node, lib_name=None):
7777
ransomware_used = node.get("malicious", None)
7878
known_exploited = node.get("exploitable", None)
7979
component_path = node["component"].get("path", None)
80+
fix_available = False
8081
if component_path:
8182
locations.append(component_path)
8283
if "topFix" in node:
@@ -91,6 +92,7 @@ def _build_common_output(node, lib_name=None):
9192
+ topfix_node.get("fixResolution", "")
9293
+ "\n"
9394
)
95+
fix_available = True
9496
except Exception:
9597
logger.exception("Error handling topFix node.")
9698
elif "library" in node:
@@ -116,17 +118,20 @@ def _build_common_output(node, lib_name=None):
116118
component_name = node["library"].get("artifactId")
117119
component_version = node["library"].get("version")
118120
cvss3_score = node.get("cvss3_score", None)
121+
fix_available = False
119122
if "topFix" in node:
120123
try:
121124
topfix_node = node.get("topFix")
122125
mitigation = "**Resolution** ({}): {}\n".format(
123126
topfix_node.get("date"),
124127
topfix_node.get("fixResolution"),
125128
)
129+
fix_available = True
126130
except Exception:
127131
logger.exception("Error handling topFix node.")
128132
else:
129133
description = node.get("description", "Unknown")
134+
fix_available = False
130135

131136
cve = node.get("name")
132137
title = "CVE-None | " + lib_name if cve is None else cve + " | " + lib_name
@@ -208,6 +213,7 @@ def _build_common_output(node, lib_name=None):
208213
impact=impact if impact is not None else None,
209214
steps_to_reproduce="**Locations Found**: " + ", ".join(locations) if locations is not None else None,
210215
kev_date=kev_date if kev_date is not None else None,
216+
fix_available=fix_available,
211217
)
212218
# only overwrite default values if they are not None #12989
213219
if known_exploited is not None:

unittests/tools/test_mend_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def test_parse_file_with_one_vuln_has_one_findings(self):
2121
self.assertEqual("CVE-2019-9658", finding.unsaved_vulnerability_ids[0])
2222
self.assertEqual("CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N", finding.cvssv3)
2323
self.assertEqual(5.3, finding.cvssv3_score)
24+
self.assertEqual(True, finding.fix_available)
2425

2526
def test_parse_file_with_multiple_vuln_has_multiple_finding(self):
2627
with (get_unit_tests_scans_path("mend") / "okhttp_many_vuln.json").open(encoding="utf-8") as testfile:
@@ -44,6 +45,7 @@ def test_parse_file_with_one_sca_vuln_finding(self):
4445
finding = list(findings)[0]
4546
self.assertEqual("**Locations Found**: D:\\MendRepo\\test-product\\test-project\\test-project-subcomponent\\path\\to\\the\\Java\\commons-codec-1.6_donotuse.jar", finding.steps_to_reproduce)
4647
self.assertEqual("WS-2019-0379 | commons-codec-1.6.jar", finding.title)
48+
self.assertEqual(True, finding.fix_available)
4749

4850
def test_parse_file_with_no_vuln_has_no_findings_platform(self):
4951
with (get_unit_tests_scans_path("mend") / "mend-sca-platform-api3-no-findings.json").open(encoding="utf-8") as testfile:

0 commit comments

Comments
 (0)