1- from codemodder .codemods .test import BaseIntegrationTest
1+ from codemodder .codemods .test . integration_utils import BaseRemediationIntegrationTest
22from codemodder .dependency import Security
33from core_codemods .process_creation_sandbox import ProcessSandbox
44
55
6- class TestProcessSandbox (BaseIntegrationTest ):
6+ class TestProcessSandbox (BaseRemediationIntegrationTest ):
77 codemod = ProcessSandbox
88 original_code = """
99 import subprocess
@@ -22,17 +22,15 @@ class TestProcessSandbox(BaseIntegrationTest):
2222
2323 var = "hello"
2424 """
25- replacement_lines = [
26- (2 , """from security import safe_command\n \n """ ),
27- (5 , """safe_command.run(subprocess.run, cmd, shell=True)\n """ ),
28- (6 , """safe_command.run(subprocess.run, [cmd, "-l"])\n """ ),
29- (8 , """safe_command.run(subprocess.call, cmd, shell=True)\n """ ),
30- (9 , """safe_command.run(subprocess.call, [cmd, "-l"])\n """ ),
25+ expected_diff_per_change = [
26+ '--- \n +++ \n @@ -1,8 +1,9 @@\n import subprocess\n +from security import safe_command\n \n cmd = " ".join(["ls"])\n \n -subprocess.run(cmd, shell=True)\n +safe_command.run(subprocess.run, cmd, shell=True)\n subprocess.run([cmd, "-l"])\n \n subprocess.call(cmd, shell=True)\n ' ,
27+ '--- \n +++ \n @@ -1,9 +1,10 @@\n import subprocess\n +from security import safe_command\n \n cmd = " ".join(["ls"])\n \n subprocess.run(cmd, shell=True)\n -subprocess.run([cmd, "-l"])\n +safe_command.run(subprocess.run, [cmd, "-l"])\n \n subprocess.call(cmd, shell=True)\n subprocess.call([cmd, "-l"])\n ' ,
28+ '--- \n +++ \n @@ -1,11 +1,12 @@\n import subprocess\n +from security import safe_command\n \n cmd = " ".join(["ls"])\n \n subprocess.run(cmd, shell=True)\n subprocess.run([cmd, "-l"])\n \n -subprocess.call(cmd, shell=True)\n +safe_command.run(subprocess.call, cmd, shell=True)\n subprocess.call([cmd, "-l"])\n \n subprocess.check_output([cmd, "-l"])\n ' ,
29+ '--- \n +++ \n @@ -1,4 +1,5 @@\n import subprocess\n +from security import safe_command\n \n cmd = " ".join(["ls"])\n \n @@ -6,7 +7,7 @@\n subprocess.run([cmd, "-l"])\n \n subprocess.call(cmd, shell=True)\n -subprocess.call([cmd, "-l"])\n +safe_command.run(subprocess.call, [cmd, "-l"])\n \n subprocess.check_output([cmd, "-l"])\n \n ' ,
3130 ]
32- expected_diff = '--- \n +++ \n @@ -1,12 +1,13 @@ \n import subprocess \n +from security import safe_command \n \n cmd = " ".join(["ls"]) \n \n -subprocess.run(cmd, shell=True) \n -subprocess.run([cmd, "-l"]) \n +safe_command.run(subprocess.run, cmd, shell=True) \n +safe_command.run(subprocess.run, [cmd, "-l"]) \n \n -subprocess.call(cmd, shell=True) \n -subprocess.call([cmd, "-l"]) \n +safe_command.run(subprocess.call, cmd, shell=True) \n +safe_command.run(subprocess.call, [cmd, "-l"]) \n \n subprocess.check_output([cmd, "-l"]) \n \n '
33- expected_line_change = "5"
31+
32+ expected_lines_changed = [ 5 , 6 , 8 , 9 ]
3433 num_changes = 4
35- num_changed_files = 2
3634 change_description = ProcessSandbox .change_description
3735
3836 requirements_file_name = "requirements.txt"
0 commit comments