5
5
6
6
import javascript
7
7
8
- private predicate execApi ( string mod , string fn , int cmdArg , int optionsArg , boolean shell ) {
9
- mod = "cross-spawn" and
10
- fn = "sync" and
11
- cmdArg = 0 and
12
- shell = false and
13
- optionsArg = - 1
14
- or
15
- mod = "execa" and
16
- optionsArg = - 1 and
8
+ pragma [ noinline]
9
+ private predicate execApi (
10
+ string mod , string fn , int cmdArg , int optionsArg , boolean shell , boolean sync
11
+ ) {
12
+ sync = getSync ( fn ) and
17
13
(
14
+ mod = "cross-spawn" and
15
+ fn = "sync" and
16
+ cmdArg = 0 and
18
17
shell = false and
19
- (
20
- fn = "node" or
21
- fn = "stdout" or
22
- fn = "stderr" or
23
- fn = "sync"
24
- )
18
+ optionsArg = - 1
25
19
or
26
- shell = true and
20
+ mod = "execa" and
21
+ optionsArg = - 1 and
27
22
(
28
- fn = "command" or
29
- fn = "commandSync" or
30
- fn = "shell" or
31
- fn = "shellSync"
32
- )
33
- ) and
34
- cmdArg = 0
23
+ shell = false and
24
+ fn = [ "node" , "stdout" , "stderr" , "sync" ]
25
+ or
26
+ shell = true and
27
+ fn = [ "command" , "commandSync" , "shell" , "shellSync" ]
28
+ ) and
29
+ cmdArg = 0
30
+ )
35
31
}
36
32
37
33
private predicate execApi ( string mod , int cmdArg , int optionsArg , boolean shell ) {
@@ -61,17 +57,16 @@ private class SystemCommandExecutors extends SystemCommandExecution, DataFlow::I
61
57
SystemCommandExecutors ( ) {
62
58
exists ( string mod |
63
59
exists ( string fn |
64
- execApi ( mod , fn , cmdArg , optionsArg , shell ) and
65
- sync = getSync ( fn ) and
66
- this = API:: moduleImport ( mod ) .getMember ( fn ) .getReturn ( ) .getAUse ( )
60
+ execApi ( mod , fn , cmdArg , optionsArg , shell , sync ) and
61
+ this = API:: moduleImport ( mod ) .getMember ( fn ) .getAnInvocation ( )
67
62
)
68
63
or
69
64
execApi ( mod , cmdArg , optionsArg , shell ) and
70
65
sync = false and
71
- this = API:: moduleImport ( mod ) .getReturn ( ) . getAUse ( )
66
+ this = API:: moduleImport ( mod ) .getAnInvocation ( )
72
67
)
73
68
or
74
- this = API:: moduleImport ( "foreground-child" ) .getReturn ( ) . getAUse ( ) and
69
+ this = API:: moduleImport ( "foreground-child" ) .getACall ( ) and
75
70
cmdArg = 0 and
76
71
optionsArg = 1 and
77
72
shell = false and
@@ -115,19 +110,19 @@ private class RemoteCommandExecutor extends SystemCommandExecution, DataFlow::In
115
110
int cmdArg ;
116
111
117
112
RemoteCommandExecutor ( ) {
118
- this = API:: moduleImport ( "remote-exec" ) .getReturn ( ) . getAUse ( ) and
113
+ this = API:: moduleImport ( "remote-exec" ) .getACall ( ) and
119
114
cmdArg = 1
120
115
or
121
116
exists ( API:: Node ssh2 , API:: Node client |
122
117
ssh2 = API:: moduleImport ( "ssh2" ) and
123
118
client in [ ssh2 , ssh2 .getMember ( "Client" ) ] and
124
- this = client .getInstance ( ) .getMember ( "exec" ) .getReturn ( ) . getAUse ( ) and
119
+ this = client .getInstance ( ) .getMember ( "exec" ) .getACall ( ) and
125
120
cmdArg = 0
126
121
)
127
122
or
128
123
exists ( API:: Node ssh2stream |
129
124
ssh2stream = API:: moduleImport ( "ssh2-streams" ) .getMember ( "SSH2Stream" ) and
130
- this = ssh2stream .getInstance ( ) .getMember ( "exec" ) .getReturn ( ) . getAUse ( ) and
125
+ this = ssh2stream .getInstance ( ) .getMember ( "exec" ) .getACall ( ) and
131
126
cmdArg = 1
132
127
)
133
128
}
@@ -142,7 +137,7 @@ private class RemoteCommandExecutor extends SystemCommandExecution, DataFlow::In
142
137
}
143
138
144
139
private class Opener extends SystemCommandExecution , DataFlow:: InvokeNode {
145
- Opener ( ) { this = API:: moduleImport ( "opener" ) .getReturn ( ) . getAUse ( ) }
140
+ Opener ( ) { this = API:: moduleImport ( "opener" ) .getACall ( ) }
146
141
147
142
override DataFlow:: Node getACommandArgument ( ) { result = getOptionArgument ( 1 , "command" ) }
148
143
0 commit comments