@@ -102,6 +102,8 @@ def __init__(self, *args, **kwargs):
102102 self .scan_type_gitlab_dast = "GitLab DAST Report"
103103
104104 self .anchore_grype_file_name = get_unit_tests_scans_path ("anchore_grype" ) / "check_all_fields.json"
105+ self .anchore_grype_file_name_fix_not_available = get_unit_tests_scans_path ("anchore_grype" ) / "fix_not_available.json"
106+ self .anchore_grype_file_name_fix_available = get_unit_tests_scans_path ("anchore_grype" ) / "fix_available.json"
105107 self .anchore_grype_scan_type = "Anchore Grype"
106108
107109 self .checkmarx_one_open_and_false_positive = get_unit_tests_scans_path ("checkmarx_one" ) / "one-open-one-false-positive.json"
@@ -1693,6 +1695,27 @@ def test_import_reimport_vulnerability_ids(self):
16931695 self .assertEqual ("GHSA-v6rh-hp5x-86rv" , findings [3 ].vulnerability_ids [0 ])
16941696 self .assertEqual ("CVE-2021-44420" , findings [3 ].vulnerability_ids [1 ])
16951697
1698+ def test_import_reimport_fix_available (self ):
1699+ import0 = self .import_scan_with_params (self .anchore_grype_file_name_fix_not_available , scan_type = self .anchore_grype_scan_type )
1700+ test_id = import0 ["test" ]
1701+ test = Test .objects .get (id = test_id )
1702+ findings = Finding .objects .filter (test = test )
1703+ self .assertEqual (1 , len (findings ))
1704+ self .assertEqual (False , findings [0 ].fix_available )
1705+ test_type = Test_Type .objects .get (name = self .anchore_grype_scan_type )
1706+ reimport_test = Test (
1707+ engagement = test .engagement ,
1708+ test_type = test_type ,
1709+ scan_type = self .anchore_grype_scan_type ,
1710+ target_start = datetime .now (timezone .get_current_timezone ()),
1711+ target_end = datetime .now (timezone .get_current_timezone ()),
1712+ )
1713+ reimport_test .save ()
1714+ self .reimport_scan_with_params (reimport_test .id , self .anchore_grype_file_name_fix_available , scan_type = self .anchore_grype_scan_type )
1715+ findings = Finding .objects .filter (test = reimport_test )
1716+ self .assertEqual (1 , len (findings ))
1717+ self .assertEqual (True , findings [0 ].fix_available )
1718+
16961719 def test_import_history_reactivated_and_untouched_findings_do_not_mix (self ):
16971720 import0 = self .import_scan_with_params (self .generic_import_1 , scan_type = self .scan_type_generic )
16981721 test_id = import0 ["test" ]
0 commit comments