Skip to content

Commit 27bde60

Browse files
committed
fix: remove computed unique_id_from_tool from IriusRisk parser
Per PR review feedback, parsers must not compute unique_id_from_tool. Removed SHA-256 hash generation and related tests. Deduplication now relies on DefectDojo's default hashcode algorithm. Updated docs to reflect the change. Authored by T. Walker - DefectDojo
1 parent adfdb99 commit 27bde60

3 files changed

Lines changed: 2 additions & 28 deletions

File tree

docs/content/supported_tools/parsers/file/iriusrisk.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ By default, DefectDojo identifies duplicate Findings using these [hashcode field
2525
- file_path
2626
- description
2727

28-
The parser also populates `unique_id_from_tool` with a SHA-256 hash of the Component, Threat, and Risk Response fields, providing an additional layer of deduplication across reimports.
29-
3028
### Sample Scan Data
3129

3230
Sample IriusRisk scans can be found in the [sample scan data folder](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/iriusrisk).
@@ -69,7 +67,6 @@ Sample IriusRisk scans can be found in the [sample scan data folder](https://git
6967
| Risk Response | mitigation | 94 | Mitigation status percentages from IriusRisk |
7068
| MITRE reference | cwe | 82-85 | When value matches CWE-NNN pattern, integer is extracted to cwe field |
7169
| MITRE reference | references | 86-87 | When value does not match CWE pattern, stored as references |
72-
| Component + Threat + Risk Response | unique_id_from_tool | 74-77 | SHA-256 hash used for deduplication across reimports |
7370

7471
</details>
7572

@@ -83,7 +80,6 @@ Sample IriusRisk scans can be found in the [sample scan data folder](https://git
8380
| static_finding | False | 97 | Threat model data is neither static nor dynamic analysis |
8481
| dynamic_finding | False | 98 | Threat model data is neither static nor dynamic analysis |
8582
| active | True (False when "Very low") | 96 | Set to False when Current Risk is "Very low" (fully mitigated) |
86-
| unique_id_from_tool | SHA-256 hash | 99 | Hash of Component, Threat, and Risk Response |
8783

8884
</details>
8985

@@ -142,8 +138,8 @@ Findings are set to active by default (line 96). When the "Current Risk" value i
142138

143139
### Deduplication
144140

145-
The parser generates a `unique_id_from_tool` by computing a SHA-256 hash of the Component, Threat, and Risk Response fields concatenated with pipe delimiters (lines 74-77). This ensures that each distinct combination of component, threat, and mitigation state produces a unique identifier. On reimport, findings with matching unique IDs are recognized as the same finding rather than being duplicated.
141+
Deduplication relies on DefectDojo's default hashcode algorithm, which uses the title, cwe, line, file_path, and description fields to identify duplicate findings.
146142

147143
### Duplicate Rows in Source Data
148144

149-
IriusRisk CSV exports can contain multiple rows with the same Component and Threat but different Risk Response values. These represent distinct countermeasure paths for the same threat. Each row is imported as a separate finding, distinguished by its unique ID which incorporates the Risk Response field.
145+
IriusRisk CSV exports can contain multiple rows with the same Component and Threat but different Risk Response values. These represent distinct countermeasure paths for the same threat. Each row is imported as a separate finding, distinguished by its description content which incorporates all CSV fields.

dojo/tools/iriusrisk/parser.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import csv
2-
import hashlib
32
import io
43
import re
54

@@ -71,11 +70,6 @@ def get_findings(self, filename, test):
7170
description_parts.append(f"**STRIDE-LM:** {stride_lm}")
7271
description = "\n".join(description_parts)
7372

74-
# Unique ID for deduplication across reimports
75-
unique_id = hashlib.sha256(
76-
f"{component}|{threat}|{risk_response}".encode(),
77-
).hexdigest()
78-
7973
# Extract CWE from MITRE reference if present
8074
cwe = None
8175
references = ""
@@ -96,7 +90,6 @@ def get_findings(self, filename, test):
9690
active=current_risk != "Very low",
9791
static_finding=False,
9892
dynamic_finding=False,
99-
unique_id_from_tool=unique_id,
10093
)
10194
if cwe:
10295
finding.cwe = cwe

unittests/tools/test_iriusrisk_parser.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,6 @@ def test_finding_static_finding(self):
112112
self.assertFalse(findings[0].static_finding)
113113
self.assertFalse(findings[0].dynamic_finding)
114114

115-
def test_finding_unique_id_from_tool(self):
116-
with (get_unit_tests_scans_path("iriusrisk") / "one_vuln.csv").open(encoding="utf-8") as testfile:
117-
parser = IriusriskParser()
118-
findings = parser.get_findings(testfile, Test())
119-
self.assertIsNotNone(findings[0].unique_id_from_tool)
120-
self.assertGreater(len(findings[0].unique_id_from_tool), 0)
121-
122-
def test_finding_unique_id_is_consistent(self):
123-
"""Parsing the same file twice should produce the same unique IDs."""
124-
with (get_unit_tests_scans_path("iriusrisk") / "one_vuln.csv").open(encoding="utf-8") as testfile:
125-
findings1 = IriusriskParser().get_findings(testfile, Test())
126-
with (get_unit_tests_scans_path("iriusrisk") / "one_vuln.csv").open(encoding="utf-8") as testfile:
127-
findings2 = IriusriskParser().get_findings(testfile, Test())
128-
self.assertEqual(findings1[0].unique_id_from_tool, findings2[0].unique_id_from_tool)
129-
130115
def test_finding_with_owner(self):
131116
with (get_unit_tests_scans_path("iriusrisk") / "many_vulns.csv").open(encoding="utf-8") as testfile:
132117
parser = IriusriskParser()

0 commit comments

Comments
 (0)