1313
1414# can't use a string literal with spaces in the tags of an InlineExpectationsTest, so using variables :|
1515
16- os .popen ("cmd1; cmd2" ) # $SystemCommandExecution_getCommand ="cmd1; cmd2"
17- os .system ("cmd1; cmd2" ) # $SystemCommandExecution_getCommand ="cmd1; cmd2"
16+ os .popen ("cmd1; cmd2" ) # $getCommand ="cmd1; cmd2"
17+ os .system ("cmd1; cmd2" ) # $getCommand ="cmd1; cmd2"
1818
1919
2020def os_members ():
@@ -24,8 +24,8 @@ def os_members():
2424 # :|
2525 from os import popen , system
2626
27- popen ("cmd1; cmd2" ) # $SystemCommandExecution_getCommand ="cmd1; cmd2"
28- system ("cmd1; cmd2" ) # $SystemCommandExecution_getCommand ="cmd1; cmd2"
27+ popen ("cmd1; cmd2" ) # $getCommand ="cmd1; cmd2"
28+ system ("cmd1; cmd2" ) # $getCommand ="cmd1; cmd2"
2929
3030
3131########################################
@@ -36,92 +36,92 @@ def os_members():
3636# clever in our analysis that discards that code, I used `if UNKNOWN` instead
3737if UNKNOWN :
3838 env = {"FOO" : "foo" }
39- os .execl ("executable" , "<progname>" , "arg0" ) # $SystemCommandExecution_getCommand ="executable"
40- os .execle ("executable" , "<progname>" , "arg0" , env ) # $SystemCommandExecution_getCommand ="executable"
41- os .execlp ("executable" , "<progname>" , "arg0" ) # $SystemCommandExecution_getCommand ="executable"
42- os .execlpe ("executable" , "<progname>" , "arg0" , env ) # $SystemCommandExecution_getCommand ="executable"
43- os .execv ("executable" , ["<progname>" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
44- os .execve ("executable" , ["<progname>" , "arg0" ], env ) # $SystemCommandExecution_getCommand ="executable"
45- os .execvp ("executable" , ["<progname>" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
46- os .execvpe ("executable" , ["<progname>" , "arg0" ], env ) # $SystemCommandExecution_getCommand ="executable"
39+ os .execl ("executable" , "<progname>" , "arg0" ) # $getCommand ="executable"
40+ os .execle ("executable" , "<progname>" , "arg0" , env ) # $getCommand ="executable"
41+ os .execlp ("executable" , "<progname>" , "arg0" ) # $getCommand ="executable"
42+ os .execlpe ("executable" , "<progname>" , "arg0" , env ) # $getCommand ="executable"
43+ os .execv ("executable" , ["<progname>" , "arg0" ]) # $getCommand ="executable"
44+ os .execve ("executable" , ["<progname>" , "arg0" ], env ) # $getCommand ="executable"
45+ os .execvp ("executable" , ["<progname>" , "arg0" ]) # $getCommand ="executable"
46+ os .execvpe ("executable" , ["<progname>" , "arg0" ], env ) # $getCommand ="executable"
4747
4848
4949########################################
5050# https://docs.python.org/3.8/library/os.html#os.spawnl
5151env = {"FOO" : "foo" }
52- os .spawnl (os .P_WAIT , "executable" , "<progname>" , "arg0" ) # $SystemCommandExecution_getCommand ="executable"
53- os .spawnle (os .P_WAIT , "executable" , "<progname>" , "arg0" , env ) # $SystemCommandExecution_getCommand ="executable"
54- os .spawnlp (os .P_WAIT , "executable" , "<progname>" , "arg0" ) # $SystemCommandExecution_getCommand ="executable"
55- os .spawnlpe (os .P_WAIT , "executable" , "<progname>" , "arg0" , env ) # $SystemCommandExecution_getCommand ="executable"
56- os .spawnv (os .P_WAIT , "executable" , ["<progname>" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
57- os .spawnve (os .P_WAIT , "executable" , ["<progname>" , "arg0" ], env ) # $SystemCommandExecution_getCommand ="executable"
58- os .spawnvp (os .P_WAIT , "executable" , ["<progname>" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
59- os .spawnvpe (os .P_WAIT , "executable" , ["<progname>" , "arg0" ], env ) # $SystemCommandExecution_getCommand ="executable"
52+ os .spawnl (os .P_WAIT , "executable" , "<progname>" , "arg0" ) # $getCommand ="executable"
53+ os .spawnle (os .P_WAIT , "executable" , "<progname>" , "arg0" , env ) # $getCommand ="executable"
54+ os .spawnlp (os .P_WAIT , "executable" , "<progname>" , "arg0" ) # $getCommand ="executable"
55+ os .spawnlpe (os .P_WAIT , "executable" , "<progname>" , "arg0" , env ) # $getCommand ="executable"
56+ os .spawnv (os .P_WAIT , "executable" , ["<progname>" , "arg0" ]) # $getCommand ="executable"
57+ os .spawnve (os .P_WAIT , "executable" , ["<progname>" , "arg0" ], env ) # $getCommand ="executable"
58+ os .spawnvp (os .P_WAIT , "executable" , ["<progname>" , "arg0" ]) # $getCommand ="executable"
59+ os .spawnvpe (os .P_WAIT , "executable" , ["<progname>" , "arg0" ], env ) # $getCommand ="executable"
6060
6161# Added in Python 3.8
62- os .posix_spawn ("executable" , ["<progname>" , "arg0" ], env ) # $SystemCommandExecution_getCommand ="executable"
63- os .posix_spawnp ("executable" , ["<progname>" , "arg0" ], env ) # $SystemCommandExecution_getCommand ="executable"
62+ os .posix_spawn ("executable" , ["<progname>" , "arg0" ], env ) # $getCommand ="executable"
63+ os .posix_spawnp ("executable" , ["<progname>" , "arg0" ], env ) # $getCommand ="executable"
6464
6565########################################
6666
6767import subprocess
6868
69- subprocess .Popen ("cmd1; cmd2" , shell = True ) # $SystemCommandExecution_getCommand ="cmd1; cmd2"
70- subprocess .Popen ("cmd1; cmd2" , shell = "truthy string" ) # $SystemCommandExecution_getCommand ="cmd1; cmd2"
71- subprocess .Popen (["cmd1; cmd2" , "shell-arg" ], shell = True ) # $SystemCommandExecution_getCommand ="cmd1; cmd2"
72- subprocess .Popen ("cmd1; cmd2" , shell = True , executable = "/bin/bash" ) # $SystemCommandExecution_getCommand ="cmd1; cmd2" $SystemCommandExecution_getCommand ="/bin/bash"
69+ subprocess .Popen ("cmd1; cmd2" , shell = True ) # $getCommand ="cmd1; cmd2"
70+ subprocess .Popen ("cmd1; cmd2" , shell = "truthy string" ) # $getCommand ="cmd1; cmd2"
71+ subprocess .Popen (["cmd1; cmd2" , "shell-arg" ], shell = True ) # $getCommand ="cmd1; cmd2"
72+ subprocess .Popen ("cmd1; cmd2" , shell = True , executable = "/bin/bash" ) # $getCommand ="cmd1; cmd2" $getCommand ="/bin/bash"
7373
74- subprocess .Popen ("executable" ) # $SystemCommandExecution_getCommand ="executable"
75- subprocess .Popen (["executable" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
76- subprocess .Popen ("<progname>" , executable = "executable" ) # $SystemCommandExecution_getCommand ="executable"
77- subprocess .Popen (["<progname>" , "arg0" ], executable = "executable" ) # $SystemCommandExecution_getCommand ="executable"
74+ subprocess .Popen ("executable" ) # $getCommand ="executable"
75+ subprocess .Popen (["executable" , "arg0" ]) # $getCommand ="executable"
76+ subprocess .Popen ("<progname>" , executable = "executable" ) # $getCommand ="executable"
77+ subprocess .Popen (["<progname>" , "arg0" ], executable = "executable" ) # $getCommand ="executable"
7878
7979# call/check_call/check_output/run all work like Popen from a command execution point of view
80- subprocess .call (["executable" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
81- subprocess .check_call (["executable" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
82- subprocess .check_output (["executable" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
83- subprocess .run (["executable" , "arg0" ]) # $SystemCommandExecution_getCommand ="executable"
80+ subprocess .call (["executable" , "arg0" ]) # $getCommand ="executable"
81+ subprocess .check_call (["executable" , "arg0" ]) # $getCommand ="executable"
82+ subprocess .check_output (["executable" , "arg0" ]) # $getCommand ="executable"
83+ subprocess .run (["executable" , "arg0" ]) # $getCommand ="executable"
8484
8585
8686########################################
8787# actively using known shell as the executable
8888
89- subprocess .Popen (["/bin/sh" , "-c" , "vuln" ]) # $SystemCommandExecution_getCommand ="/bin/sh" $f-:SystemCommandExecution_getCommand ="vuln"
90- subprocess .Popen (["/bin/bash" , "-c" , "vuln" ]) # $SystemCommandExecution_getCommand ="/bin/bash" $f-:SystemCommandExecution_getCommand ="vuln"
91- subprocess .Popen (["/bin/dash" , "-c" , "vuln" ]) # $SystemCommandExecution_getCommand ="/bin/dash" $f-:SystemCommandExecution_getCommand ="vuln"
92- subprocess .Popen (["/bin/zsh" , "-c" , "vuln" ]) # $SystemCommandExecution_getCommand ="/bin/zsh" $f-:SystemCommandExecution_getCommand ="vuln"
89+ subprocess .Popen (["/bin/sh" , "-c" , "vuln" ]) # $getCommand ="/bin/sh" $f-:getCommand ="vuln"
90+ subprocess .Popen (["/bin/bash" , "-c" , "vuln" ]) # $getCommand ="/bin/bash" $f-:getCommand ="vuln"
91+ subprocess .Popen (["/bin/dash" , "-c" , "vuln" ]) # $getCommand ="/bin/dash" $f-:getCommand ="vuln"
92+ subprocess .Popen (["/bin/zsh" , "-c" , "vuln" ]) # $getCommand ="/bin/zsh" $f-:getCommand ="vuln"
9393
94- subprocess .Popen (["sh" , "-c" , "vuln" ]) # $SystemCommandExecution_getCommand ="sh" $f-:SystemCommandExecution_getCommand ="vuln"
95- subprocess .Popen (["bash" , "-c" , "vuln" ]) # $SystemCommandExecution_getCommand ="bash" $f-:SystemCommandExecution_getCommand ="vuln"
96- subprocess .Popen (["dash" , "-c" , "vuln" ]) # $SystemCommandExecution_getCommand ="dash" $f-:SystemCommandExecution_getCommand ="vuln"
97- subprocess .Popen (["zsh" , "-c" , "vuln" ]) # $SystemCommandExecution_getCommand ="zsh" $f-:SystemCommandExecution_getCommand ="vuln"
94+ subprocess .Popen (["sh" , "-c" , "vuln" ]) # $getCommand ="sh" $f-:getCommand ="vuln"
95+ subprocess .Popen (["bash" , "-c" , "vuln" ]) # $getCommand ="bash" $f-:getCommand ="vuln"
96+ subprocess .Popen (["dash" , "-c" , "vuln" ]) # $getCommand ="dash" $f-:getCommand ="vuln"
97+ subprocess .Popen (["zsh" , "-c" , "vuln" ]) # $getCommand ="zsh" $f-:getCommand ="vuln"
9898
9999# Check that we don't consider ANY argument a command injection sink
100- subprocess .Popen (["sh" , "/bin/python" ]) # $SystemCommandExecution_getCommand ="sh"
100+ subprocess .Popen (["sh" , "/bin/python" ]) # $getCommand ="sh"
101101
102- subprocess .Popen (["cmd.exe" , "/c" , "vuln" ]) # $SystemCommandExecution_getCommand ="cmd.exe" $f-:SystemCommandExecution_getCommand ="vuln"
103- subprocess .Popen (["cmd.exe" , "/C" , "vuln" ]) # $SystemCommandExecution_getCommand ="cmd.exe" $f-:SystemCommandExecution_getCommand ="vuln"
104- subprocess .Popen (["cmd" , "/c" , "vuln" ]) # $SystemCommandExecution_getCommand ="cmd" $f-:SystemCommandExecution_getCommand ="vuln"
105- subprocess .Popen (["cmd" , "/C" , "vuln" ]) # $SystemCommandExecution_getCommand ="cmd" $f-:SystemCommandExecution_getCommand ="vuln"
102+ subprocess .Popen (["cmd.exe" , "/c" , "vuln" ]) # $getCommand ="cmd.exe" $f-:getCommand ="vuln"
103+ subprocess .Popen (["cmd.exe" , "/C" , "vuln" ]) # $getCommand ="cmd.exe" $f-:getCommand ="vuln"
104+ subprocess .Popen (["cmd" , "/c" , "vuln" ]) # $getCommand ="cmd" $f-:getCommand ="vuln"
105+ subprocess .Popen (["cmd" , "/C" , "vuln" ]) # $getCommand ="cmd" $f-:getCommand ="vuln"
106106
107- subprocess .Popen (["<progname>" , "-c" , "vuln" ], executable = "/bin/bash" ) # $SystemCommandExecution_getCommand ="/bin/bash" $f-:SystemCommandExecution_getCommand ="vuln"
107+ subprocess .Popen (["<progname>" , "-c" , "vuln" ], executable = "/bin/bash" ) # $getCommand ="/bin/bash" $f-:getCommand ="vuln"
108108
109109if UNKNOWN :
110- os .execl ("/bin/sh" , "<progname>" , "-c" , "vuln" ) # $SystemCommandExecution_getCommand ="/bin/sh" $f-:SystemCommandExecution_getCommand ="vuln"
110+ os .execl ("/bin/sh" , "<progname>" , "-c" , "vuln" ) # $getCommand ="/bin/sh" $f-:getCommand ="vuln"
111111
112- os .spawnl (os .P_WAIT , "/bin/sh" , "<progname>" , "-c" , "vuln" ) # $SystemCommandExecution_getCommand ="/bin/sh" $f-:SystemCommandExecution_getCommand ="vuln"
112+ os .spawnl (os .P_WAIT , "/bin/sh" , "<progname>" , "-c" , "vuln" ) # $getCommand ="/bin/sh" $f-:getCommand ="vuln"
113113
114114
115115########################################
116116# Passing arguments by reference
117117
118118args = ["/bin/sh" , "-c" , "vuln" ]
119- subprocess .Popen (args ) # $SystemCommandExecution_getCommand =args
119+ subprocess .Popen (args ) # $getCommand =args
120120
121121args = "<progname>"
122122use_shell = False
123123exe = "executable"
124- subprocess .Popen (args , shell = use_shell , executable = exe ) # $f+:SystemCommandExecution_getCommand =args $SystemCommandExecution_getCommand =exe
124+ subprocess .Popen (args , shell = use_shell , executable = exe ) # $f+:getCommand =args $getCommand =exe
125125
126126
127127################################################################################
0 commit comments