File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
python/ql/test/query-tests/Security/CWE-078-UnsafeShellCommandConstruction/src Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 11import os
22import subprocess
3- import shlex
43
54def unsafe_shell_one(name):
65 os.system("ping " + name) # $result=BAD
76
8- # shlex.quote sanitizer
9- os.system("ping " + shlex.quote(name)) # $result=OK
10-
117 # f-strings
128 os.system(f"ping {name}") # $result=BAD
139
@@ -50,4 +46,8 @@ def indirect(flag, x):
5046 subprocess.Popen("ping " + name, shell=unknownValue) # OK - shell assumed to be False
5147
5248def intentional(command):
53- os.system("fish -ic " + command) # $result=OK - intentional
49+ os.system("fish -ic " + command) # $result=OK - intentional
50+
51+ import shlex
52+ def unsafe_shell_sanitized(name):
53+ os.system("ping " + shlex.quote(name)) # $result=OK - sanitized
You can’t perform that action at this time.
0 commit comments