1
- import hashlib
2
1
import logging
3
2
import re
4
3
@@ -36,31 +35,9 @@ def extract_reference_link(text):
36
35
match = re .search (r"(https?://[^\s)]+)" , text )
37
36
return match .group (1 ) if match else None
38
37
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
-
58
38
@staticmethod
59
39
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."""
64
41
findings_list = []
65
42
if not libraries_data :
66
43
return findings_list
@@ -132,11 +109,6 @@ def parse_libraries(libraries_data, test):
132
109
full_description = "\n " .join (description_parts )
133
110
references = source_url if source_url != "N/A" else None
134
111
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
-
140
112
finding = Finding (
141
113
test = test ,
142
114
title = title ,
@@ -149,7 +121,6 @@ def parse_libraries(libraries_data, test):
149
121
component_version = lib_version ,
150
122
static_finding = True ,
151
123
dynamic_finding = False ,
152
- unique_id_from_tool = unique_id ,
153
124
vuln_id_from_tool = vuln_name ,
154
125
references = references ,
155
126
active = True , # Always set as active since we don't have status from Wiz
@@ -212,11 +183,6 @@ def parse_secrets(secrets_data, test):
212
183
full_description = "\n " .join (description_parts )
213
184
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."
214
185
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
-
220
186
finding = Finding (
221
187
test = test ,
222
188
title = title ,
@@ -227,7 +193,6 @@ def parse_secrets(secrets_data, test):
227
193
line = line_number if line_number is not None else 0 ,
228
194
static_finding = True ,
229
195
dynamic_finding = False ,
230
- unique_id_from_tool = unique_id ,
231
196
active = True , # Always set as active since we don't have status from Wiz
232
197
)
233
198
findings_list .append (finding )
@@ -293,11 +258,6 @@ def parse_os_packages(os_packages_data, test):
293
258
full_description = "\n " .join (description_parts )
294
259
references = source_url if source_url != "N/A" else None
295
260
296
- # Generate unique ID using stable components
297
- unique_id = WizcliParsers ._generate_unique_id (
298
- [pkg_name , pkg_version , vuln_name ],
299
- )
300
-
301
261
finding = Finding (
302
262
test = test ,
303
263
title = title ,
@@ -306,7 +266,8 @@ def parse_os_packages(os_packages_data, test):
306
266
mitigation = mitigation ,
307
267
static_finding = True ,
308
268
dynamic_finding = False ,
309
- unique_id_from_tool = unique_id ,
269
+ component_name = pkg_name ,
270
+ component_version = pkg_version ,
310
271
vuln_id_from_tool = vuln_name ,
311
272
references = references ,
312
273
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):
408
369
409
370
full_description = "\n " .join (description_parts )
410
371
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
-
416
372
finding = Finding (
417
373
test = test ,
418
374
title = title ,
@@ -424,7 +380,6 @@ def parse_rule_matches(rule_matches_data, test):
424
380
component_name = resource_name , # Use resource name as component
425
381
static_finding = True ,
426
382
dynamic_finding = False ,
427
- unique_id_from_tool = unique_id ,
428
383
vuln_id_from_tool = rule_id , # Use rule ID as the identifier
429
384
references = references ,
430
385
active = True , # Always set as active since we don't have status from Wiz
0 commit comments