@@ -10,6 +10,8 @@ import python
1010import semmle.python.security.TaintTracking
1111import semmle.python.security.strings.Untrusted
1212
13+ /** Abstract taint sink that is potentially vulnerable to malicious shell commands. */
14+ abstract class CommandSink extends TaintSink { }
1315
1416private ModuleObject osOrPopenModule ( ) {
1517 result .getName ( ) = "os" or
@@ -20,7 +22,7 @@ private Object makeOsCall() {
2022 exists ( string name |
2123 result = ModuleObject:: named ( "subprocess" ) .attr ( name ) |
2224 name = "Popen" or
23- name = "call" or
25+ name = "call" or
2426 name = "check_call" or
2527 name = "check_output" or
2628 name = "run"
@@ -61,7 +63,7 @@ class FirstElementFlow extends DataFlowExtension::DataFlowNode {
6163/** A taint sink that is potentially vulnerable to malicious shell commands.
6264 * The `vuln` in `subprocess.call(shell=vuln)` and similar calls.
6365 */
64- class ShellCommand extends TaintSink {
66+ class ShellCommand extends CommandSink {
6567
6668 override string toString ( ) { result = "shell command" }
6769
@@ -100,7 +102,7 @@ class ShellCommand extends TaintSink {
100102/** A taint sink that is potentially vulnerable to malicious shell commands.
101103 * The `vuln` in `subprocess.call(vuln, ...)` and similar calls.
102104 */
103- class OsCommandFirstArgument extends TaintSink {
105+ class OsCommandFirstArgument extends CommandSink {
104106
105107 override string toString ( ) { result = "OS command first argument" }
106108
0 commit comments