@@ -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"
@@ -1692,6 +1694,27 @@ def test_import_reimport_vulnerability_ids(self):
16921694 self .assertEqual ("GHSA-v6rh-hp5x-86rv" , findings [3 ].vulnerability_ids [0 ])
16931695 self .assertEqual ("CVE-2021-44420" , findings [3 ].vulnerability_ids [1 ])
16941696
1697+ def test_import_reimport_fix_available (self ):
1698+ import0 = self .import_scan_with_params (self .anchore_grype_file_name_fix_not_available , scan_type = self .anchore_grype_scan_type )
1699+ test_id = import0 ["test" ]
1700+ test = Test .objects .get (id = test_id )
1701+ findings = Finding .objects .filter (test = test )
1702+ self .assertEqual (1 , len (findings ))
1703+ self .assertEqual (False , findings [0 ].fix_available )
1704+ test_type = Test_Type .objects .get (name = self .anchore_grype_scan_type )
1705+ reimport_test = Test (
1706+ engagement = test .engagement ,
1707+ test_type = test_type ,
1708+ scan_type = self .anchore_grype_scan_type ,
1709+ target_start = datetime .now (timezone .get_current_timezone ()),
1710+ target_end = datetime .now (timezone .get_current_timezone ()),
1711+ )
1712+ reimport_test .save ()
1713+ self .reimport_scan_with_params (reimport_test .id , self .anchore_grype_file_name_fix_available , scan_type = self .anchore_grype_scan_type )
1714+ findings = Finding .objects .filter (test = reimport_test )
1715+ self .assertEqual (1 , len (findings ))
1716+ self .assertEqual (True , findings [0 ].fix_available )
1717+
16951718 def test_import_history_reactivated_and_untouched_findings_do_not_mix (self ):
16961719 import0 = self .import_scan_with_params (self .generic_import_1 , scan_type = self .scan_type_generic )
16971720 test_id = import0 ["test" ]
0 commit comments