Merge pull request #13782 from jorgectf/jorgectf/shlex-quote

Python: Add `shlex.quote` as `py/shell-command-constructed-from-input` sanitizer
This commit is contained in:
yoff
2023-08-31 21:08:58 +02:00
committed by GitHub
4 changed files with 24 additions and 2 deletions

View File

@@ -46,4 +46,8 @@ def subprocess_flag (name):
subprocess.Popen("ping " + name, shell=unknownValue) # OK - shell assumed to be False
def intentional(command):
os.system("fish -ic " + command) # $result=OK - intentional
os.system("fish -ic " + command) # $result=OK - intentional
import shlex
def unsafe_shell_sanitized(name):
os.system("ping " + shlex.quote(name)) # $result=OK - sanitized