|
| 1 | +/** |
| 2 | + * Provides classes modeling security-relevant aspects of the `pexpect` PyPI package. |
| 3 | + * See https://pypi.org/project/pexpect/. |
| 4 | + */ |
| 5 | + |
| 6 | +private import python |
| 7 | +private import semmle.python.dataflow.new.DataFlow |
| 8 | +private import semmle.python.dataflow.new.RemoteFlowSources |
| 9 | +private import semmle.python.Concepts |
| 10 | +private import semmle.python.ApiGraphs |
| 11 | + |
| 12 | +/** |
| 13 | + * Provides models for the `pexpect` PyPI package. |
| 14 | + * See https://pypi.org/project/pexpect/. |
| 15 | + */ |
| 16 | +private module Pexpect { |
| 17 | + /** |
| 18 | + * The calls to `pexpect.*` functions that execute commands |
| 19 | + * See https://pexpect.readthedocs.io/en/stable/api/pexpect.html#pexpect.spawn |
| 20 | + * See https://pexpect.readthedocs.io/en/stable/api/pexpect.html#pexpect.run |
| 21 | + */ |
| 22 | + class PexpectCommandExec extends SystemCommandExecution::Range, API::CallNode { |
| 23 | + PexpectCommandExec() { |
| 24 | + this = API::moduleImport("pexpect").getMember(["run", "runu", "spawn", "spawnu"]).getACall() |
| 25 | + } |
| 26 | + |
| 27 | + override DataFlow::Node getCommand() { result = this.getParameter(0, "command").asSink() } |
| 28 | + |
| 29 | + override predicate isShellInterpreted(DataFlow::Node arg) { none() } |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * A call to `pexpect.popen_spawn.PopenSpawn` |
| 34 | + * See https://pexpect.readthedocs.io/en/stable/api/popen_spawn.html#pexpect.popen_spawn.PopenSpawn |
| 35 | + */ |
| 36 | + class PexpectPopenSpawn extends SystemCommandExecution::Range, API::CallNode { |
| 37 | + PexpectPopenSpawn() { |
| 38 | + this = |
| 39 | + API::moduleImport("pexpect").getMember("popen_spawn").getMember("PopenSpawn").getACall() |
| 40 | + } |
| 41 | + |
| 42 | + override DataFlow::Node getCommand() { result = this.getParameter(0, "cmd").asSink() } |
| 43 | + |
| 44 | + override predicate isShellInterpreted(DataFlow::Node arg) { none() } |
| 45 | + } |
| 46 | +} |
0 commit comments