Skip to content

Commit ef44cb8

Browse files
committed
remove FPs related to parameters that are meant to be commands
1 parent e9ebba3 commit ef44cb8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

python/ql/lib/semmle/python/security/dataflow/UnsafeShellCommandConstructionCustomizations.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ module UnsafeShellCommandConstruction {
2121

2222
/** An input parameter to a gem seen as a source. */
2323
private class LibraryInputAsSource extends Source instanceof DataFlow::ParameterNode {
24-
LibraryInputAsSource() { this = Setuptools::getALibraryInput() }
24+
LibraryInputAsSource() {
25+
this = Setuptools::getALibraryInput() and
26+
not this.getParameter().getName().matches(["cmd%", "command%", "%_command", "%_cmd"])
27+
}
2528
}
2629

2730
/** A sink for shell command constructed from library input vulnerabilities. */

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ def indirect(flag, x):
4343

4444
indirect(True, name)
4545

46-
subprocess.Popen("ping " + name, shell=unknownValue) # OK - shell assumed to be False
46+
subprocess.Popen("ping " + name, shell=unknownValue) # OK - shell assumed to be False
47+
48+
def intentional(command):
49+
os.system("fish -ic " + command) # $result=OK - intentional

0 commit comments

Comments
 (0)