Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/CWE-078/CommandInjectionAudit.ql
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ import semmle.python.dataflow.new.BarrierGuards
private import semmle.python.security.dataflow.CommandInjectionCustomizations

from DataFlow::Node sink
where sink instanceof CommandInjection::Sink
where sink instanceof CommandInjection::Sink and sink.getScope().inSource()
select sink, "Usage of command line"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| cmdi.py:7:17:7:17 | ControlFlowNode for i | Usage of command line |
| cmdi.py:9:17:9:17 | ControlFlowNode for i | Usage of command line |
| cmdi.py:11:17:11:30 | ControlFlowNode for Fstring | Usage of command line |
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CWE-078/CommandInjectionAudit.ql
11 changes: 11 additions & 0 deletions tests/python-tests/CWE-078/audit/cmdi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
import subprocess

i = input("Enter command: ")

# direct input
subprocess.call(i, shell=True)
# direct input, no shell
subprocess.call(i)
# format string
subprocess.call(f"bash -c {i}", shell=True)
1 change: 1 addition & 0 deletions tests/python-tests/CWE-078/audit/options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
semmle-extractor-options: --max-import-depth=0