Skip to content

Commit 8f8c064

Browse files
committed
Modify test
1 parent 3ac94c3 commit 8f8c064

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

python/ql/test/query-tests/Security/CWE-078-UnsafeShellCommandConstruction/src/unsafe_shell_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import os
22
import subprocess
3-
import shlex
43

54
def 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

5248
def 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

0 commit comments

Comments
 (0)