Skip to content

Commit 8a1992c

Browse files
🎉 Add fix_available information to blackduck component risk #12633 (#13201)
1 parent cb01b7d commit 8a1992c

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

dojo/tools/blackduck_component_risk/parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def ingest_findings(self, components, securities, sources, test):
6767
description = self.license_description(component, source)
6868
severity = "High"
6969
mitigation = self.license_mitigation(component)
70+
fix_available = bool(mitigation)
7071
impact = "N/A"
7172
references = self.license_references(component)
7273
finding = Finding(
@@ -79,6 +80,7 @@ def ingest_findings(self, components, securities, sources, test):
7980
references=references,
8081
static_finding=True,
8182
unique_id_from_tool=component_id,
83+
fix_available=fix_available,
8284
)
8385
license_risk.append(finding)
8486
elif "None" not in self.license_severity(component):
@@ -88,6 +90,7 @@ def ingest_findings(self, components, securities, sources, test):
8890
description = self.license_description(component, source)
8991
severity = self.license_severity(component)
9092
mitigation = self.license_mitigation(component, violation=False)
93+
fix_available = bool(mitigation)
9194
impact = "N/A"
9295
references = self.license_references(component)
9396
finding = Finding(
@@ -100,6 +103,7 @@ def ingest_findings(self, components, securities, sources, test):
100103
references=references,
101104
static_finding=True,
102105
unique_id_from_tool=component_id,
106+
fix_available=fix_available,
103107
)
104108
license_risk.append(finding)
105109
items.extend(license_risk)
@@ -111,10 +115,10 @@ def ingest_findings(self, components, securities, sources, test):
111115
description = self.security_description(vulns)
112116
severity = self.security_severity(vulns)
113117
mitigation = self.security_mitigation(vulns)
118+
fix_available = bool(mitigation)
114119
impact = self.security_impact(vulns)
115120
references = self.security_references(vulns)
116121
file_path = self.security_filepath(vulns)
117-
118122
finding = Finding(
119123
title=title,
120124
test=test,
@@ -126,6 +130,7 @@ def ingest_findings(self, components, securities, sources, test):
126130
static_finding=True,
127131
file_path=file_path,
128132
unique_id_from_tool=component_id,
133+
fix_available=fix_available,
129134
)
130135
security_risk.append(finding)
131136
items.extend(security_risk)

unittests/tools/test_blackduck_component_risk_parser.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ def test_blackduck_enhanced_zip_upload(self):
1010
parser = BlackduckComponentRiskParser()
1111
findings = parser.get_findings(testfile, Test())
1212
self.assertEqual(12, len(findings))
13+
findings = list(findings)
14+
self.assertEqual("License Risk: xmldom:0.1.21", findings[0].title)
15+
self.assertEqual(True, findings[0].fix_available)
16+
self.assertEqual("Package has a license that is In Violation and should not be used: xmldom:0.1.21. Please use another component with an acceptable license.", findings[0].mitigation)
17+
self.assertEqual("High", findings[0].severity)
18+
self.assertEqual("N/A", findings[0].impact)
19+
self.assertEqual("**Project:** foo-project ID-355b2cb252662e07153802b82041e8322ccef144-1.0.0\n", findings[0].references)
20+
self.assertEqual(None, findings[0].file_path)

0 commit comments

Comments
 (0)