@@ -48,7 +48,8 @@ class SubshellHeredocExecution extends SystemCommandExecution::Range {
48
48
/**
49
49
* A system command executed via the `Kernel.system` method.
50
50
* `Kernel.system` accepts three argument forms:
51
- * - A single string. If it contains no shell meta characters, keywords or builtins, it is executed directly in a subprocess.
51
+ * - A single string. If it contains no shell meta characters, keywords or
52
+ * builtins, it is executed directly in a subprocess.
52
53
* Otherwise, it is executed in a subshell.
53
54
* ```ruby
54
55
* system("cat foo.txt | tail")
@@ -63,7 +64,8 @@ class SubshellHeredocExecution extends SystemCommandExecution::Range {
63
64
* ```ruby
64
65
* system(["cat", "cat"], "foo.txt")
65
66
* ```
66
- * In addition, `Kernel.system` accepts an optional environment hash as the first argument and and optional options hash as the last argument.
67
+ * In addition, `Kernel.system` accepts an optional environment hash as the
68
+ * first argument and an optional options hash as the last argument.
67
69
* We don't yet distinguish between these arguments and the command arguments.
68
70
* ```ruby
69
71
* system({"FOO" => "BAR"}, "cat foo.txt | tail", {unsetenv_others: true})
@@ -110,11 +112,10 @@ class KernelExecCall extends SystemCommandExecution::Range {
110
112
// `Kernel.exec` can be reached via `Kernel.exec`, `Process.exec` or just `exec`
111
113
// (if there's no other method by the same name in scope).
112
114
(
113
- this = API:: getTopLevelMember ( "Kernel" ) .getAMethodCall ( "exec" )
115
+ this = API:: getTopLevelMember ( [ "Kernel" , "Process" ] ) .getAMethodCall ( "exec" )
114
116
or
115
- this = API:: getTopLevelMember ( "Process" ) .getAMethodCall ( "exec" )
116
- or
117
- // we assume that if there's no obvious target for this method call, then it must refer to Kernel.exec.
117
+ // we assume that if there's no obvious target for this method call, then
118
+ // it must refer to Kernel.exec.
118
119
not exists ( DataFlowCallable method , DataFlowCall call |
119
120
viableCallable ( call ) = method and call .getExpr ( ) = methodCall
120
121
)
@@ -131,7 +132,8 @@ class KernelExecCall extends SystemCommandExecution::Range {
131
132
132
133
/**
133
134
* A system command executed via the `Kernel.spawn` method.
134
- * `Kernel.spawn` takes the same argument forms as `Kernel.system`. See `KernelSystemCall` for details.
135
+ * `Kernel.spawn` takes the same argument forms as `Kernel.system`.
136
+ * See `KernelSystemCall` for details.
135
137
* Ruby documentation: https://docs.ruby-lang.org/en/3.0.0/Kernel.html#method-i-spawn
136
138
* TODO: document and handle the env and option arguments.
137
139
* ```
@@ -147,9 +149,7 @@ class KernelSpawnCall extends SystemCommandExecution::Range {
147
149
// `Kernel.spawn` can be reached via `Kernel.spawn`, `Process.spawn` or just `spawn`
148
150
// (if there's no other method by the same name in scope).
149
151
(
150
- this = API:: getTopLevelMember ( "Kernel" ) .getAMethodCall ( "spawn" )
151
- or
152
- this = API:: getTopLevelMember ( "Process" ) .getAMethodCall ( "spawn" )
152
+ this = API:: getTopLevelMember ( [ "Kernel" , "Process" ] ) .getAMethodCall ( "spawn" )
153
153
or
154
154
not exists ( DataFlowCallable method , DataFlowCall call |
155
155
viableCallable ( call ) = method and call .getExpr ( ) = methodCall
@@ -170,13 +170,12 @@ class Open3Call extends SystemCommandExecution::Range {
170
170
171
171
Open3Call ( ) {
172
172
this .asExpr ( ) .getExpr ( ) = methodCall and
173
- exists ( string methodName |
174
- methodName in [
175
- "popen3" , "popen2" , "popen2e" , "capture3" , "capture2" , "capture2e" , "pipeline_rw" ,
176
- "pipeline_r" , "pipeline_w" , "pipeline_start" , "pipeline"
177
- ] and
178
- this = API:: getTopLevelMember ( "Open3" ) .getAMethodCall ( methodName )
179
- )
173
+ this =
174
+ API:: getTopLevelMember ( "Open3" )
175
+ .getAMethodCall ( [
176
+ "popen3" , "popen2" , "popen2e" , "capture3" , "capture2" , "capture2e" , "pipeline_rw" ,
177
+ "pipeline_r" , "pipeline_w" , "pipeline_start" , "pipeline"
178
+ ] )
180
179
}
181
180
182
181
override DataFlow:: Node getAnArgument ( ) { result .asExpr ( ) .getExpr ( ) = methodCall .getAnArgument ( ) }
0 commit comments