@@ -64,8 +64,6 @@ abstract private class ApplicationModeEndpoint extends TApplicationModeEndpoint
64
64
*/
65
65
abstract Callable getCallable ( ) ;
66
66
67
- abstract Call getCall ( ) ;
68
-
69
67
/**
70
68
* Gets the input (if any) for this endpoint, eg.: `Argument[0]`.
71
69
*
@@ -111,50 +109,50 @@ abstract private class ApplicationModeEndpoint extends TApplicationModeEndpoint
111
109
abstract string toString ( ) ;
112
110
}
113
111
112
+ class TCallArgument = TExplicitArgument or TInstanceArgument or TImplicitVarargsArray ;
113
+
114
114
/**
115
- * A class representing nodes that are arguments to calls.
115
+ * An endpoint that represents an "argument" to a call in a broad sense, including
116
+ * both explicit arguments and the instance argument.
116
117
*/
117
- class ExplicitArgument extends ApplicationModeEndpoint , TExplicitArgument {
118
+ abstract class CallArgument extends ApplicationModeEndpoint , TCallArgument {
118
119
Call call ;
119
120
DataFlow:: Node arg ;
120
121
121
- ExplicitArgument ( ) { this = TExplicitArgument ( call , arg ) }
122
-
123
122
override Callable getCallable ( ) { result = call .getCallee ( ) .getSourceDeclaration ( ) }
124
123
125
- override Call getCall ( ) { result = call }
126
-
127
- private int getArgIndex ( ) { this .asTop ( ) = call .getArgument ( result ) }
128
-
129
- override string getMaDInput ( ) { result = "Argument[" + this .getArgIndex ( ) + "]" }
130
-
131
124
override string getMaDOutput ( ) { none ( ) }
132
125
133
- override Top asTop ( ) { result = arg .asExpr ( ) }
134
-
135
126
override DataFlow:: Node asNode ( ) { result = arg }
136
127
128
+ Call getCall ( ) { result = call }
129
+
137
130
override string toString ( ) { result = arg .toString ( ) }
138
131
}
139
132
140
- class InstanceArgument extends ApplicationModeEndpoint , TInstanceArgument {
141
- Call call ;
142
- DataFlow:: Node arg ;
133
+ /**
134
+ * An endpoint that represents an explicit argument to a call.
135
+ */
136
+ class ExplicitArgument extends CallArgument , TExplicitArgument {
137
+ ExplicitArgument ( ) { this = TExplicitArgument ( call , arg ) }
143
138
144
- InstanceArgument ( ) { this = TInstanceArgument ( call , arg ) }
139
+ private int getArgIndex ( ) { this . asTop ( ) = call . getArgument ( result ) }
145
140
146
- override Callable getCallable ( ) { result = call . getCallee ( ) . getSourceDeclaration ( ) }
141
+ override string getMaDInput ( ) { result = "Argument[" + this . getArgIndex ( ) + "]" }
147
142
148
- override Call getCall ( ) { result = call }
143
+ override Top asTop ( ) { result = arg .asExpr ( ) }
144
+ }
149
145
150
- override string getMaDInput ( ) { result = "Argument[this]" }
146
+ /**
147
+ * An endpoint that represents the instance argument to a call.
148
+ */
149
+ class InstanceArgument extends CallArgument , TInstanceArgument {
150
+ InstanceArgument ( ) { this = TInstanceArgument ( call , arg ) }
151
151
152
- override string getMaDOutput ( ) { none ( ) }
152
+ override string getMaDInput ( ) { result = "Argument[this]" }
153
153
154
154
override Top asTop ( ) { if exists ( arg .asExpr ( ) ) then result = arg .asExpr ( ) else result = call }
155
155
156
- override DataFlow:: Node asNode ( ) { result = arg }
157
-
158
156
override string toString ( ) { result = arg .toString ( ) }
159
157
}
160
158
@@ -167,26 +165,14 @@ class InstanceArgument extends ApplicationModeEndpoint, TInstanceArgument {
167
165
* In order to be able to distinguish between varargs endpoints and regular endpoints, we export the `isVarargsArray`
168
166
* meta data field in the extraction queries.
169
167
*/
170
- class ImplicitVarargsArray extends ApplicationModeEndpoint , TImplicitVarargsArray {
171
- Call call ;
172
- DataFlow:: Node vararg ;
168
+ class ImplicitVarargsArray extends CallArgument , TImplicitVarargsArray {
173
169
int idx ;
174
170
175
- ImplicitVarargsArray ( ) { this = TImplicitVarargsArray ( call , vararg , idx ) }
176
-
177
- override Callable getCallable ( ) { result = call .getCallee ( ) .getSourceDeclaration ( ) }
178
-
179
- override Call getCall ( ) { result = call }
171
+ ImplicitVarargsArray ( ) { this = TImplicitVarargsArray ( call , arg , idx ) }
180
172
181
173
override string getMaDInput ( ) { result = "Argument[" + idx + "]" }
182
174
183
- override string getMaDOutput ( ) { none ( ) }
184
-
185
175
override Top asTop ( ) { result = call }
186
-
187
- override DataFlow:: Node asNode ( ) { result = vararg }
188
-
189
- override string toString ( ) { result = vararg .toString ( ) }
190
176
}
191
177
192
178
/**
@@ -200,8 +186,6 @@ class MethodReturnValue extends ApplicationModeEndpoint, TMethodReturnValue {
200
186
201
187
override Callable getCallable ( ) { result = call .getCallee ( ) .getSourceDeclaration ( ) }
202
188
203
- override Call getCall ( ) { result = call }
204
-
205
189
override string getMaDInput ( ) { none ( ) }
206
190
207
191
override string getMaDOutput ( ) { result = "ReturnValue" }
@@ -231,8 +215,6 @@ class OverriddenParameter extends ApplicationModeEndpoint, TOverriddenParameter
231
215
result = overriddenMethod .getSourceDeclaration ( )
232
216
}
233
217
234
- override Call getCall ( ) { none ( ) }
235
-
236
218
private int getArgIndex ( ) { p .getCallable ( ) .getParameter ( result ) = p }
237
219
238
220
override string getMaDInput ( ) { none ( ) }
@@ -338,7 +320,7 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
338
320
*/
339
321
RelatedLocation getRelatedLocation ( Endpoint e , RelatedLocationType type ) {
340
322
type = CallContext ( ) and
341
- result = e .getCall ( )
323
+ result = e .( CallArgument ) . getCall ( )
342
324
or
343
325
type = MethodDoc ( ) and
344
326
result = e .getCallable ( ) .( Documentable ) .getJavadoc ( )
@@ -560,9 +542,9 @@ private class OtherArgumentToModeledMethodCharacteristic extends Characteristics
560
542
override predicate appliesToEndpoint ( Endpoint e ) {
561
543
e .getExtensibleType ( ) = "sinkModel" and
562
544
not ApplicationCandidatesImpl:: isSink ( e , _, _) and
563
- exists ( Endpoint otherSink |
545
+ exists ( CallArgument otherSink |
564
546
ApplicationCandidatesImpl:: isSink ( otherSink , _, "manual" ) and
565
- e .getCall ( ) = otherSink .getCall ( ) and
547
+ e .( CallArgument ) . getCall ( ) = otherSink .getCall ( ) and
566
548
e != otherSink
567
549
)
568
550
}
0 commit comments