@@ -15,7 +15,7 @@ module ShellJS {
15
15
.getMember ( [
16
16
"exec" , "cd" , "cp" , "touch" , "chmod" , "pushd" , "find" , "ls" , "ln" , "mkdir" , "mv" ,
17
17
"rm" , "cat" , "head" , "sort" , "tail" , "uniq" , "grep" , "sed" , "to" , "toEnd" , "echo" ,
18
- "which" ,
18
+ "which" , "cmd" , "asyncExec"
19
19
] )
20
20
.getReturn ( )
21
21
}
@@ -154,16 +154,27 @@ module ShellJS {
154
154
}
155
155
156
156
/**
157
- * A call to `shelljs.exec()` modeled as command execution.
157
+ * A call to `shelljs.exec()`, `shelljs.cmd()`, or `async-shelljs.asyncExec()` modeled as command execution.
158
158
*/
159
159
private class ShellJSExec extends SystemCommandExecution , ShellJSCall {
160
- ShellJSExec ( ) { name = "exec" }
161
-
162
- override DataFlow:: Node getACommandArgument ( ) { result = this .getArgument ( 0 ) }
160
+ ShellJSExec ( ) { name = [ "exec" , "cmd" , "asyncExec" ] }
161
+
162
+ override DataFlow:: Node getACommandArgument ( ) {
163
+ if name = "cmd"
164
+ then
165
+ result = this .getArgument ( _) and
166
+ not (
167
+ result = this .getLastArgument ( ) and
168
+ exists ( this .getOptionsArg ( ) )
169
+ )
170
+ else
171
+ // For exec/asyncExec: only first argument is command
172
+ result = this .getArgument ( 0 )
173
+ }
163
174
164
175
override predicate isShellInterpreted ( DataFlow:: Node arg ) { arg = this .getACommandArgument ( ) }
165
176
166
- override predicate isSync ( ) { none ( ) }
177
+ override predicate isSync ( ) { name = "cmd" }
167
178
168
179
override DataFlow:: Node getOptionsArg ( ) {
169
180
result = this .getLastArgument ( ) and
0 commit comments