Skip to content

Commit c9abc65

Browse files
authored
Importer: Correct logic bug for empty scan reports (#10645)
* Importer: Correct logic bug for empty scan reports When importing an empty scan report through the import endpoint, it is possible for two tests to be created during a single request * Separate logic based on import vs reimport
1 parent bb24b6f commit c9abc65

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

dojo/importers/base_importer.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,12 @@ def parse_findings(
212212
"""
213213
Determine how to parse the findings based on the presence of the
214214
`get_tests` function on the parser object
215+
216+
This function will vary by importer, so it is marked as
217+
abstract with a prohibitive exception raised if the
218+
method is attempted to to be used by the BaseImporter class
215219
"""
216-
# Attempt any preprocessing before generating findings
217-
if len(self.parsed_findings) == 0 or self.test is None:
218-
scan = self.process_scan_file(scan)
219-
if hasattr(parser, 'get_tests'):
220-
self.parsed_findings = self.parse_findings_dynamic_test_type(scan, parser)
221-
else:
222-
self.parsed_findings = self.parse_findings_static_test_type(scan, parser)
223-
return self.parsed_findings
220+
self.check_child_implementation_exception()
224221

225222
def sync_process_findings(
226223
self,

dojo/importers/default_importer.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,24 @@ def close_old_findings(
293293

294294
return old_findings
295295

296+
def parse_findings(
297+
self,
298+
scan: TemporaryUploadedFile,
299+
parser: Parser,
300+
) -> List[Finding]:
301+
"""
302+
Determine how to parse the findings based on the presence of the
303+
`get_tests` function on the parser object
304+
"""
305+
# Attempt any preprocessing before generating findings
306+
if len(self.parsed_findings) == 0 and self.test is None:
307+
scan = self.process_scan_file(scan)
308+
if hasattr(parser, 'get_tests'):
309+
self.parsed_findings = self.parse_findings_dynamic_test_type(scan, parser)
310+
else:
311+
self.parsed_findings = self.parse_findings_static_test_type(scan, parser)
312+
return self.parsed_findings
313+
296314
def parse_findings_static_test_type(
297315
self,
298316
scan: TemporaryUploadedFile,

dojo/importers/default_reimporter.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,24 @@ def close_old_findings(
277277

278278
return mitigated_findings
279279

280+
def parse_findings(
281+
self,
282+
scan: TemporaryUploadedFile,
283+
parser: Parser,
284+
) -> List[Finding]:
285+
"""
286+
Determine how to parse the findings based on the presence of the
287+
`get_tests` function on the parser object
288+
"""
289+
# Attempt any preprocessing before generating findings
290+
if len(self.parsed_findings) == 0 or self.test is None:
291+
scan = self.process_scan_file(scan)
292+
if hasattr(parser, 'get_tests'):
293+
self.parsed_findings = self.parse_findings_dynamic_test_type(scan, parser)
294+
else:
295+
self.parsed_findings = self.parse_findings_static_test_type(scan, parser)
296+
return self.parsed_findings
297+
280298
def parse_findings_static_test_type(
281299
self,
282300
scan: TemporaryUploadedFile,

0 commit comments

Comments
 (0)