Skip to content

Commit f9c7365

Browse files
committed
removed unique id generation and use
1 parent 7ed4298 commit f9c7365

File tree

1 file changed

+3
-48
lines changed

1 file changed

+3
-48
lines changed

dojo/tools/wizcli_common_parsers/parsers.py

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import hashlib
21
import logging
32
import re
43

@@ -36,31 +35,9 @@ def extract_reference_link(text):
3635
match = re.search(r"(https?://[^\s)]+)", text)
3736
return match.group(1) if match else None
3837

39-
@staticmethod
40-
def _generate_unique_id(components: list) -> str:
41-
"""
42-
Generates a stable unique ID for findings.
43-
44-
Args:
45-
components: List of components to use for ID generation
46-
47-
"""
48-
# Filter out None and empty values
49-
filtered_components = [str(c).strip() for c in components if c is not None and str(c).strip()]
50-
51-
# Sort components for consistent order regardless of input order
52-
filtered_components = sorted(filtered_components)
53-
54-
id_string = "|".join(filtered_components)
55-
hash_object = hashlib.sha256(id_string.encode("utf-8"))
56-
return hash_object.hexdigest()
57-
5838
@staticmethod
5939
def parse_libraries(libraries_data, test):
60-
"""
61-
Parses library vulnerability data into granular DefectDojo findings.
62-
Creates one finding per unique vulnerability (CVE/ID) per library instance (name/version/path).
63-
"""
40+
"""Parses library vulnerability data into granular DefectDojo findings."""
6441
findings_list = []
6542
if not libraries_data:
6643
return findings_list
@@ -132,11 +109,6 @@ def parse_libraries(libraries_data, test):
132109
full_description = "\n".join(description_parts)
133110
references = source_url if source_url != "N/A" else None
134111

135-
# Generate unique ID using stable components including file path
136-
unique_id = WizcliParsers._generate_unique_id(
137-
[lib_name, lib_version, vuln_name, lib_path],
138-
)
139-
140112
finding = Finding(
141113
test=test,
142114
title=title,
@@ -149,7 +121,6 @@ def parse_libraries(libraries_data, test):
149121
component_version=lib_version,
150122
static_finding=True,
151123
dynamic_finding=False,
152-
unique_id_from_tool=unique_id,
153124
vuln_id_from_tool=vuln_name,
154125
references=references,
155126
active=True, # Always set as active since we don't have status from Wiz
@@ -212,11 +183,6 @@ def parse_secrets(secrets_data, test):
212183
full_description = "\n".join(description_parts)
213184
mitigation = "Rotate the exposed secret immediately. Remove the secret from the specified file path and line. Store secrets securely using a secrets management solution. Review commit history."
214185

215-
# Generate unique ID using stable components
216-
unique_id = WizcliParsers._generate_unique_id(
217-
[secret_type, file_path, str(line_number) if line_number is not None else "0"],
218-
)
219-
220186
finding = Finding(
221187
test=test,
222188
title=title,
@@ -227,7 +193,6 @@ def parse_secrets(secrets_data, test):
227193
line=line_number if line_number is not None else 0,
228194
static_finding=True,
229195
dynamic_finding=False,
230-
unique_id_from_tool=unique_id,
231196
active=True, # Always set as active since we don't have status from Wiz
232197
)
233198
findings_list.append(finding)
@@ -293,11 +258,6 @@ def parse_os_packages(os_packages_data, test):
293258
full_description = "\n".join(description_parts)
294259
references = source_url if source_url != "N/A" else None
295260

296-
# Generate unique ID using stable components
297-
unique_id = WizcliParsers._generate_unique_id(
298-
[pkg_name, pkg_version, vuln_name],
299-
)
300-
301261
finding = Finding(
302262
test=test,
303263
title=title,
@@ -306,7 +266,8 @@ def parse_os_packages(os_packages_data, test):
306266
mitigation=mitigation,
307267
static_finding=True,
308268
dynamic_finding=False,
309-
unique_id_from_tool=unique_id,
269+
component_name=pkg_name,
270+
component_version=pkg_version,
310271
vuln_id_from_tool=vuln_name,
311272
references=references,
312273
active=True, # Always set as active since we don't have status from Wiz
@@ -408,11 +369,6 @@ def parse_rule_matches(rule_matches_data, test):
408369

409370
full_description = "\n".join(description_parts)
410371

411-
# Generate unique ID using stable components for IAC
412-
unique_id = WizcliParsers._generate_unique_id(
413-
[rule_id, resource_name, file_name, str(line_number) if line_number is not None else "0"], # Only use rule ID and resource name for deduplication
414-
)
415-
416372
finding = Finding(
417373
test=test,
418374
title=title,
@@ -424,7 +380,6 @@ def parse_rule_matches(rule_matches_data, test):
424380
component_name=resource_name, # Use resource name as component
425381
static_finding=True,
426382
dynamic_finding=False,
427-
unique_id_from_tool=unique_id,
428383
vuln_id_from_tool=rule_id, # Use rule ID as the identifier
429384
references=references,
430385
active=True, # Always set as active since we don't have status from Wiz

0 commit comments

Comments
 (0)