Skip to content

Commit b7c429c

Browse files
committed
Switch dedup method
1 parent 53ef8bb commit b7c429c

3 files changed

Lines changed: 7 additions & 16 deletions

File tree

dojo/settings/settings.dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ def saml2_attrib_map_format(din):
16591659
"Cyberwatch scan (Galeax)": DEDUPE_ALGO_HASH_CODE,
16601660
"OpenVAS Parser v2": DEDUPE_ALGO_HASH_CODE,
16611661
"Snyk Issue API Scan": DEDUPE_ALGO_HASH_CODE,
1662-
"OpenReports": DEDUPE_ALGO_UNIQUE_ID_FROM_TOOL,
1662+
"OpenReports": DEDUPE_ALGO_UNIQUE_ID_FROM_TOOL_OR_HASH_CODE,
16631663
}
16641664

16651665
# Override the hardcoded settings here via the env var

dojo/tools/openreports/parser.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,9 @@ def _create_finding_from_result(self, test, result, service_name, report_name, r
268268
if policy.startswith("CVE-"):
269269
finding.unsaved_vulnerability_ids = [policy]
270270

271-
# Create unique_id_from_tool for deduplication
272-
# Use the report UID if available (from metadata.uid), otherwise fall back to service_name
273-
# Format: report_uid:policy:package_name (preferred) or policy:package_name:service_name (fallback)
274-
# This uses the stable UID from the OpenReports API that won't change on reimport
275-
unique_id_components = [report_uid, policy, pkg_name] if report_uid else [policy, pkg_name, service_name]
276-
finding.unique_id_from_tool = ":".join(unique_id_components)
271+
# Set vuln_id_from_tool to the policy field for deduplication
272+
# This allows using DEDUPE_ALGO_UNIQUE_ID_FROM_TOOL_OR_HASH_CODE
273+
finding.vuln_id_from_tool = policy
277274

278275
return finding # noqa: TRY300 - This is intentional
279276

unittests/tools/test_openreports_parser.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ def test_single_report(self):
3434
self.assertTrue(finding1.fix_available)
3535
self.assertEqual(1, len(finding1.unsaved_vulnerability_ids))
3636
self.assertEqual("CVE-2025-9232", finding1.unsaved_vulnerability_ids[0])
37-
self.assertEqual(
38-
"b1fcca57-2efd-44d3-89e9-949e29b61936:CVE-2025-9232:libcrypto3",
39-
finding1.unique_id_from_tool,
40-
)
37+
self.assertEqual("CVE-2025-9232", finding1.vuln_id_from_tool)
4138
self.assertIn("vulnerability scan", finding1.tags)
4239
self.assertIn("image-scanner", finding1.tags)
4340
self.assertIn("Deployment", finding1.tags)
@@ -56,7 +53,7 @@ def test_single_report(self):
5653
self.assertTrue(finding2.fix_available)
5754
self.assertEqual(1, len(finding2.unsaved_vulnerability_ids))
5855
self.assertEqual("CVE-2025-47907", finding2.unsaved_vulnerability_ids[0])
59-
self.assertEqual("b1fcca57-2efd-44d3-89e9-949e29b61936:CVE-2025-47907:stdlib", finding2.unique_id_from_tool)
56+
self.assertEqual("CVE-2025-47907", finding2.vuln_id_from_tool)
6057

6158
# Test third finding (non-CVE policy, fail/low severity)
6259
finding3 = findings[2]
@@ -72,10 +69,7 @@ def test_single_report(self):
7269
self.assertTrue(finding3.fix_available)
7370
# Non-CVE policies should not have vulnerability IDs
7471
self.assertIsNone(finding3.unsaved_vulnerability_ids)
75-
self.assertEqual(
76-
"b1fcca57-2efd-44d3-89e9-949e29b61936:CIS-BENCH-001:web-server",
77-
finding3.unique_id_from_tool,
78-
)
72+
self.assertEqual("CIS-BENCH-001", finding3.vuln_id_from_tool)
7973
self.assertIn("compliance check", finding3.tags)
8074
self.assertIn("compliance-scanner", finding3.tags)
8175
self.assertIn("Deployment", finding3.tags)

0 commit comments

Comments
 (0)