diff --git a/unittests/scans/generic/test_import_report1.json b/unittests/scans/generic/test_import_report1.json new file mode 100644 index 00000000000..d3904face82 --- /dev/null +++ b/unittests/scans/generic/test_import_report1.json @@ -0,0 +1,38 @@ +{ + "name": "Unicorn", + "type": "Unicorn", + "findings": [ + { + "title": "Henry Smith", + "description": "small", + "severity": "Critical", + "active": false, + "verified": false, + "is_mitigated": true + }, + { + "title": "Emma Jones", + "description": "small", + "severity": "Critical", + "active": false, + "verified": false, + "is_mitigated": true + }, + { + "title": "Emma Jones", + "description": "small", + "severity": "Critical", + "active": true, + "verified": true, + "is_mitigated": false + }, + { + "title": "Emma Jones", + "description": "small", + "severity": "Critical", + "active": false, + "verified": false, + "is_mitigated": true + } + ] +} \ No newline at end of file diff --git a/unittests/scans/generic/test_import_report2.json b/unittests/scans/generic/test_import_report2.json new file mode 100644 index 00000000000..7cb918277ff --- /dev/null +++ b/unittests/scans/generic/test_import_report2.json @@ -0,0 +1,38 @@ +{ + "name": "Unicorn", + "type": "Unicorn", + "findings": [ + { + "title": "Henry Smith", + "description": "small", + "severity": "Critical", + "active": false, + "verified": false, + "is_mitigated": true + }, + { + "title": "Henry Smith", + "description": "small", + "severity": "Critical", + "active": false, + "verified": false, + "is_mitigated": true + }, + { + "title": "Henry Smith", + "description": "small", + "severity": "Critical", + "active": false, + "verified": false, + "is_mitigated": true + }, + { + "title": "Henry Smith", + "description": "small", + "severity": "Critical", + "active": true, + "verified": true, + "is_mitigated": false + } + ] +} \ No newline at end of file diff --git a/unittests/test_import_reimport.py b/unittests/test_import_reimport.py index 342e771c65b..c2e3aadf568 100644 --- a/unittests/test_import_reimport.py +++ b/unittests/test_import_reimport.py @@ -85,7 +85,10 @@ def __init__(self, *args, **kwargs): self.clair_empty = self.scans_path + 'clair/clair_empty.json' self.scan_type_clair = 'Clair Scan' + self.scan_type_generic = "Generic Findings Import" self.generic_filename_with_file = self.scans_path + "generic/test_with_image.json" + self.generic_import_1 = self.scans_path + "generic/test_import_report1.json" + self.generic_import_2 = self.scans_path + "generic/test_import_report2.json" self.aws_prowler_file_name = self.scans_path + 'aws_prowler/many_vuln.json' self.aws_prowler_file_name_plus_one = self.scans_path + 'aws_prowler/many_vuln_plus_one.json' @@ -1445,6 +1448,15 @@ def test_import_reimport_vulnerability_ids(self): self.assertEqual('GHSA-v6rh-hp5x-86rv', findings[3].vulnerability_ids[0]) self.assertEqual('CVE-2021-44420', findings[3].vulnerability_ids[1]) + def test_import_history_reactivated_and_untouched_findings_do_not_mix(self): + import0 = self.import_scan_with_params(self.generic_import_1, scan_type=self.scan_type_generic) + test_id = import0['test'] + # reimport the second report + self.reimport_scan_with_params(test_id, self.generic_import_2, scan_type=self.scan_type_generic) + # reimport the first report again + self.reimport_scan_with_params(test_id, self.generic_import_1, scan_type=self.scan_type_generic) + # Passing this test means an exception does not occur + class ImportReimportTestAPI(DojoAPITestCase, ImportReimportMixin): fixtures = ['dojo_testdata.json']