@@ -64,8 +64,6 @@ abstract private class ApplicationModeEndpoint extends TApplicationModeEndpoint
6464 */
6565 abstract Callable getCallable ( ) ;
6666
67- abstract Call getCall ( ) ;
68-
6967 /**
7068 * Gets the input (if any) for this endpoint, eg.: `Argument[0]`.
7169 *
@@ -111,50 +109,50 @@ abstract private class ApplicationModeEndpoint extends TApplicationModeEndpoint
111109 abstract string toString ( ) ;
112110}
113111
112+ class TCallArgument = TExplicitArgument or TInstanceArgument or TImplicitVarargsArray ;
113+
114114/**
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.
116117 */
117- class ExplicitArgument extends ApplicationModeEndpoint , TExplicitArgument {
118+ abstract class CallArgument extends ApplicationModeEndpoint , TCallArgument {
118119 Call call ;
119120 DataFlow:: Node arg ;
120121
121- ExplicitArgument ( ) { this = TExplicitArgument ( call , arg ) }
122-
123122 override Callable getCallable ( ) { result = call .getCallee ( ) .getSourceDeclaration ( ) }
124123
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-
131124 override string getMaDOutput ( ) { none ( ) }
132125
133- override Top asTop ( ) { result = arg .asExpr ( ) }
134-
135126 override DataFlow:: Node asNode ( ) { result = arg }
136127
128+ Call getCall ( ) { result = call }
129+
137130 override string toString ( ) { result = arg .toString ( ) }
138131}
139132
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 ) }
143138
144- InstanceArgument ( ) { this = TInstanceArgument ( call , arg ) }
139+ private int getArgIndex ( ) { this . asTop ( ) = call . getArgument ( result ) }
145140
146- override Callable getCallable ( ) { result = call . getCallee ( ) . getSourceDeclaration ( ) }
141+ override string getMaDInput ( ) { result = "Argument[" + this . getArgIndex ( ) + "]" }
147142
148- override Call getCall ( ) { result = call }
143+ override Top asTop ( ) { result = arg .asExpr ( ) }
144+ }
149145
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 ) }
151151
152- override string getMaDOutput ( ) { none ( ) }
152+ override string getMaDInput ( ) { result = "Argument[this]" }
153153
154154 override Top asTop ( ) { if exists ( arg .asExpr ( ) ) then result = arg .asExpr ( ) else result = call }
155155
156- override DataFlow:: Node asNode ( ) { result = arg }
157-
158156 override string toString ( ) { result = arg .toString ( ) }
159157}
160158
@@ -167,26 +165,14 @@ class InstanceArgument extends ApplicationModeEndpoint, TInstanceArgument {
167165 * In order to be able to distinguish between varargs endpoints and regular endpoints, we export the `isVarargsArray`
168166 * meta data field in the extraction queries.
169167 */
170- class ImplicitVarargsArray extends ApplicationModeEndpoint , TImplicitVarargsArray {
171- Call call ;
172- DataFlow:: Node vararg ;
168+ class ImplicitVarargsArray extends CallArgument , TImplicitVarargsArray {
173169 int idx ;
174170
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 ) }
180172
181173 override string getMaDInput ( ) { result = "Argument[" + idx + "]" }
182174
183- override string getMaDOutput ( ) { none ( ) }
184-
185175 override Top asTop ( ) { result = call }
186-
187- override DataFlow:: Node asNode ( ) { result = vararg }
188-
189- override string toString ( ) { result = vararg .toString ( ) }
190176}
191177
192178/**
@@ -200,8 +186,6 @@ class MethodReturnValue extends ApplicationModeEndpoint, TMethodReturnValue {
200186
201187 override Callable getCallable ( ) { result = call .getCallee ( ) .getSourceDeclaration ( ) }
202188
203- override Call getCall ( ) { result = call }
204-
205189 override string getMaDInput ( ) { none ( ) }
206190
207191 override string getMaDOutput ( ) { result = "ReturnValue" }
@@ -231,8 +215,6 @@ class OverriddenParameter extends ApplicationModeEndpoint, TOverriddenParameter
231215 result = overriddenMethod .getSourceDeclaration ( )
232216 }
233217
234- override Call getCall ( ) { none ( ) }
235-
236218 private int getArgIndex ( ) { p .getCallable ( ) .getParameter ( result ) = p }
237219
238220 override string getMaDInput ( ) { none ( ) }
@@ -338,7 +320,7 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
338320 */
339321 RelatedLocation getRelatedLocation ( Endpoint e , RelatedLocationType type ) {
340322 type = CallContext ( ) and
341- result = e .getCall ( )
323+ result = e .( CallArgument ) . getCall ( )
342324 or
343325 type = MethodDoc ( ) and
344326 result = e .getCallable ( ) .( Documentable ) .getJavadoc ( )
@@ -560,9 +542,9 @@ private class OtherArgumentToModeledMethodCharacteristic extends Characteristics
560542 override predicate appliesToEndpoint ( Endpoint e ) {
561543 e .getExtensibleType ( ) = "sinkModel" and
562544 not ApplicationCandidatesImpl:: isSink ( e , _, _) and
563- exists ( Endpoint otherSink |
545+ exists ( CallArgument otherSink |
564546 ApplicationCandidatesImpl:: isSink ( otherSink , _, "manual" ) and
565- e .getCall ( ) = otherSink .getCall ( ) and
547+ e .( CallArgument ) . getCall ( ) = otherSink .getCall ( ) and
566548 e != otherSink
567549 )
568550 }
0 commit comments