importosdirectory="/tmp"# Use of unsanitized data to create a processos.spawnl(os.P_WAIT,"/bin/ls")os.spawnle(os.P_WAIT,"/bin/ls")os.spawnlp(os.P_WAIT,"/bin/ls")os.spawnlpe(os.P_WAIT,"/bin/ls")os.spawnv(os.P_WAIT,"/bin/ls")os.spawnve(os.P_WAIT,"/bin/ls")os.spawnvp(os.P_WAIT,"/bin/ls")os.spawnvpe(os.P_WAIT,"/bin/ls")os.spawnvpe(os.P_WAIT,"/bin/ls "+directory)
Compliant Code Examples
importosimportshlex# Use of shlex() to sanitize dataos.spawnl(os.P_WAIT,shlex.escape("/bin/ls"))
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
How to use this rule
1
2
rulesets:- python-security # Rules to enforce Python security.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Analysis scans to your CI pipelines