File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
ruby/ql/lib/codeql/ruby/frameworks/stdlib Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides modeling for the `Process` library.
3
+ */
4
+
5
+ private import codeql.ruby.Concepts
6
+ private import codeql.ruby.DataFlow
7
+ private import codeql.ruby.controlflow.CfgNodes
8
+ private import codeql.ruby.frameworks.core.Kernel
9
+
10
+ /**
11
+ * Provides modeling for the `Process` library.
12
+ */
13
+ module Process {
14
+ /**
15
+ * A call to `Process.spawn`.
16
+ * ```rb
17
+ * Process.spawn("tar xf ruby-2.0.0-p195.tar.bz2")
18
+ * Process.spawn({"ENV" => "VAR"}, "echo", "hi")
19
+ * ```
20
+ */
21
+ class SpawnCall extends SystemCommandExecution:: Range instanceof DataFlow:: CallNode {
22
+ SpawnCall ( ) { this = DataFlow:: getConstant ( [ "Process" , "PTY" ] ) .getAMethodCall ( "spawn" ) }
23
+
24
+ // The command can be argument 0 or 1
25
+ // Options can be specified after the command, and we want to exclude those.
26
+ override DataFlow:: Node getAnArgument ( ) {
27
+ result = super .getArgument ( [ 0 , 1 ] ) and not result .asExpr ( ) instanceof ExprNodes:: PairCfgNode
28
+ }
29
+
30
+ override predicate isShellInterpreted ( DataFlow:: Node arg ) {
31
+ // Process.spawn invokes a subshell if you provide a single string as argument
32
+ super .getNumberOfArguments ( ) = 1 and arg = this .getAnArgument ( )
33
+ }
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments