Skip to content

Commit 9ca780c

Browse files
Fix: Populate vulnerability_id field in BlackDuck Binary Analysis parser (#13973)
* Fix Tenable CSV import fails with 'Version of CPE not implemented' - Add exception handling around CPE parsing in TenableCSVParser - Log unsupported CPE versions at DEBUG level instead of crashing - Allows import to continue when encountering unsupported CPE formats - Fixes issue #11243 * Fix: Populate vulnerability_id field in BlackDuck Binary Analysis parser - Add unsaved_vulnerability_ids assignment when CVE is present - This ensures the vulnerability_id field is populated for de-duplication - Fixes #12442 * Test: Add assertions for vulnerability_id field in BlackDuck Binary Analysis parser tests - Verify unsaved_vulnerability_ids is populated with CVE value - Add specific assertion for single vuln test case - Add general assertion for multiple vulns test case - Related to #12442
1 parent 3c7c4d5 commit 9ca780c

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

dojo/tools/blackduck_binary_analysis/parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def ingest_findings(self, sorted_findings, test):
104104
finding.fix_available = True
105105
else:
106106
finding.fix_available = False
107+
# Add vulnerability ID for de-duplication
108+
if cve:
109+
finding.unsaved_vulnerability_ids = [str(cve)]
107110
findings[unique_finding_key] = finding
108111

109112
return list(findings.values())

unittests/tools/test_blackduck_binary_analysis_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def test_parse_one_vuln(self):
3838
self.assertIsNotNone(finding.vuln_id_from_tool)
3939
self.assertEqual("CVE-2023-45853", finding.vuln_id_from_tool)
4040
self.assertIsNotNone(finding.unique_id_from_tool)
41+
# Verify vulnerability_id is populated for de-duplication
42+
self.assertIsNotNone(finding.unsaved_vulnerability_ids)
43+
self.assertEqual(["CVE-2023-45853"], finding.unsaved_vulnerability_ids)
4144

4245
def test_parse_many_vulns(self):
4346
with (get_unit_tests_scans_path("blackduck_binary_analysis") / "many_vulns.csv").open(encoding="utf-8") as testfile:
@@ -53,3 +56,6 @@ def test_parse_many_vulns(self):
5356
self.assertIsNotNone(finding.file_path)
5457
self.assertIsNotNone(finding.vuln_id_from_tool)
5558
self.assertIsNotNone(finding.unique_id_from_tool)
59+
# Verify vulnerability_id is populated for de-duplication
60+
self.assertIsNotNone(finding.unsaved_vulnerability_ids)
61+
self.assertGreater(len(finding.unsaved_vulnerability_ids), 0)

0 commit comments

Comments
 (0)