@@ -37,19 +37,19 @@ def test_close_old_same_engagement(self):
3737 "scan_type" : scan_type ,
3838 }
3939 # Import first test
40- with open (get_unit_tests_scans_path ("acunetix" ) / "many_findings.xml" , "r+" , encoding = "utf-8" ) as many_findings_scan :
40+ with (get_unit_tests_scans_path ("acunetix" ) / "many_findings.xml" ). open ( "r+" , encoding = "utf-8" ) as many_findings_scan :
4141 importer = DefaultImporter (close_old_findings = False , ** import_options )
4242 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (many_findings_scan )
4343 self .assertEqual (4 , len_new_findings )
4444 self .assertEqual (0 , len_closed_findings )
4545 # Import same test, should close no findings
46- with open (get_unit_tests_scans_path ("acunetix" ) / "many_findings.xml" , "r+" , encoding = "utf-8" ) as many_findings_scan :
46+ with (get_unit_tests_scans_path ("acunetix" ) / "many_findings.xml" ). open ( "r+" , encoding = "utf-8" ) as many_findings_scan :
4747 importer = DefaultImporter (close_old_findings = True , ** import_options )
4848 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (many_findings_scan )
4949 self .assertEqual (4 , len_new_findings )
5050 self .assertEqual (0 , len_closed_findings )
5151 # Import test with only one finding. Remaining findings should close
52- with open (get_unit_tests_scans_path ("acunetix" ) / "one_finding.xml" , "r+" , encoding = "utf-8" ) as single_finding_scan :
52+ with (get_unit_tests_scans_path ("acunetix" ) / "one_finding.xml" ). open ( "r+" , encoding = "utf-8" ) as single_finding_scan :
5353 importer = DefaultImporter (close_old_findings = True , ** import_options )
5454 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (single_finding_scan )
5555 self .assertEqual (1 , len_new_findings )
@@ -95,19 +95,19 @@ def test_close_old_same_product_scan(self):
9595 "scan_type" : scan_type ,
9696 }
9797 # Import first test
98- with open (get_unit_tests_scans_path ("acunetix" ) / "many_findings.xml" , "r+" , encoding = "utf-8" ) as many_findings_scan :
98+ with (get_unit_tests_scans_path ("acunetix" ) / "many_findings.xml" ). open ( "r+" , encoding = "utf-8" ) as many_findings_scan :
9999 importer = DefaultImporter (engagement = engagement1 , close_old_findings = False , ** import_options )
100100 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (many_findings_scan )
101101 self .assertEqual (4 , len_new_findings )
102102 self .assertEqual (0 , len_closed_findings )
103103 # Import same test, should close no findings
104- with open (get_unit_tests_scans_path ("acunetix" ) / "many_findings.xml" , "r+" , encoding = "utf-8" ) as many_findings_scan :
104+ with (get_unit_tests_scans_path ("acunetix" ) / "many_findings.xml" ). open ( "r+" , encoding = "utf-8" ) as many_findings_scan :
105105 importer = DefaultImporter (engagement = engagement2 , close_old_findings = True , ** import_options )
106106 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (many_findings_scan )
107107 self .assertEqual (4 , len_new_findings )
108108 self .assertEqual (0 , len_closed_findings )
109109 # Import test with only one finding. Remaining findings should close
110- with open (get_unit_tests_scans_path ("acunetix" ) / "one_finding.xml" , "r+" , encoding = "utf-8" ) as single_finding_scan :
110+ with (get_unit_tests_scans_path ("acunetix" ) / "one_finding.xml" ). open ( "r+" , encoding = "utf-8" ) as single_finding_scan :
111111 importer = DefaultImporter (engagement = engagement3 , close_old_findings = True , ** import_options )
112112 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (single_finding_scan )
113113 self .assertEqual (1 , len_new_findings )
@@ -153,20 +153,20 @@ def test_close_old_same_product_scan_matching_with_unique_id_from_tool(self):
153153 "scan_type" : scan_type ,
154154 }
155155 # Import first test
156- with open (get_unit_tests_scans_path ("semgrep" ) / "close_old_findings_report_line31.json" , "r+" , encoding = "utf-8" ) as many_findings_scan :
156+ with (get_unit_tests_scans_path ("semgrep" ) / "close_old_findings_report_line31.json" ). open ( "r+" , encoding = "utf-8" ) as many_findings_scan :
157157 importer = DefaultImporter (engagement = engagement1 , close_old_findings = False , ** import_options )
158158 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (many_findings_scan )
159159 self .assertEqual (1 , len_new_findings )
160160 self .assertEqual (0 , len_closed_findings )
161161 # Import separate report with different line number. Before this change, the legacy dedupe algorithm would calculate a different
162162 # hash code and close of the findings. Now that we are matching on unique ID from tool, we should no close anything, and create one
163- with open (get_unit_tests_scans_path ("semgrep" ) / "close_old_findings_report_second_run_line24.json" , "r+" , encoding = "utf-8" ) as many_findings_scan :
163+ with (get_unit_tests_scans_path ("semgrep" ) / "close_old_findings_report_second_run_line24.json" ). open ( "r+" , encoding = "utf-8" ) as many_findings_scan :
164164 importer = DefaultImporter (engagement = engagement2 , close_old_findings = True , ** import_options )
165165 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (many_findings_scan )
166166 self .assertEqual (1 , len_new_findings )
167167 self .assertEqual (0 , len_closed_findings )
168168 # This scan has a different unique ID from tool, so we should have one new finding, and one closed finding
169- with open (get_unit_tests_scans_path ("semgrep" ) / "close_old_findings_report_third_run_different_unique_id.json" , "r+" , encoding = "utf-8" ) as many_findings_scan :
169+ with (get_unit_tests_scans_path ("semgrep" ) / "close_old_findings_report_third_run_different_unique_id.json" ). open ( "r+" , encoding = "utf-8" ) as many_findings_scan :
170170 importer = DefaultImporter (engagement = engagement3 , close_old_findings = True , ** import_options )
171171 _ , _ , len_new_findings , len_closed_findings , _ , _ , _ = importer .process_scan (many_findings_scan )
172172 self .assertEqual (1 , len_new_findings )
0 commit comments