Skip to content

Commit 4d9d215

Browse files
committed
Python: Make "..Call" modeling classes extend DataFlow::CfgNode
1 parent b0e7989 commit 4d9d215

File tree

1 file changed

+5
-7
lines changed
  • python/ql/src/experimental/semmle/python/frameworks

1 file changed

+5
-7
lines changed

python/ql/src/experimental/semmle/python/frameworks/Invoke.qll

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,19 @@ private module Invoke {
131131
* - `invoke.run` or `invoke.sudo` functions (http://docs.pyinvoke.org/en/stable/api/__init__.html)
132132
* - `run` or `sudo` methods on a `invoke.context.Context` instance (http://docs.pyinvoke.org/en/stable/api/context.html#invoke.context.Context.run)
133133
*/
134-
private class InvokeRunCommandCall extends SystemCommandExecution::Range {
134+
private class InvokeRunCommandCall extends SystemCommandExecution::Range, DataFlow::CfgNode {
135+
override CallNode node;
136+
135137
InvokeRunCommandCall() {
136-
exists(DataFlow::Node callFunction |
137-
this.asCfgNode().(CallNode).getFunction() = callFunction.asCfgNode()
138-
|
138+
exists(DataFlow::Node callFunction | node.getFunction() = callFunction.asCfgNode() |
139139
callFunction = invoke_attr(["run", "sudo"])
140140
or
141141
callFunction = invoke::context::Context::instanceRunMethods()
142142
)
143143
}
144144

145145
override DataFlow::Node getCommand() {
146-
result.asCfgNode() = this.asCfgNode().(CallNode).getArg(0)
147-
or
148-
result.asCfgNode() = this.asCfgNode().(CallNode).getArgByName("command")
146+
result.asCfgNode() in [node.getArg(0), node.getArgByName("command")]
149147
}
150148
}
151149
}

0 commit comments

Comments
 (0)