@@ -35,14 +35,10 @@ newtype TApplicationModeEndpoint =
3535 arg = DataFlow:: getInstanceArgument ( call ) and
3636 not call instanceof ConstructorCall
3737 } or
38- TImplicitVarargsArray ( Call call , DataFlow:: Node arg , int idx ) {
38+ TImplicitVarargsArray ( Call call , DataFlow:: ImplicitVarargsArray arg , int idx ) {
3939 AutomodelJavaUtil:: isFromSource ( call ) and
40- exists ( Argument argExpr |
41- arg .asExpr ( ) = argExpr and
42- call .getArgument ( idx ) = argExpr and
43- argExpr .isVararg ( ) and
44- not exists ( int i | i < idx and call .getArgument ( i ) .( Argument ) .isVararg ( ) )
45- )
40+ call = arg .getCall ( ) and
41+ idx = call .getCallee ( ) .getVaragsParameterIndex ( )
4642 } or
4743 TMethodReturnValue ( Call call ) {
4844 AutomodelJavaUtil:: isFromSource ( call ) and
@@ -255,45 +251,74 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
255251 predicate isKnownKind = AutomodelJavaUtil:: isKnownKind / 2 ;
256252
257253 predicate isSink ( Endpoint e , string kind , string provenance ) {
258- exists ( string package , string type , string name , string signature , string ext , string input |
259- sinkSpec ( e , package , type , name , signature , ext , input ) and
260- ExternalFlow:: sinkModel ( package , type , _, name , [ signature , "" ] , ext , input , kind , provenance )
254+ exists (
255+ string package , string type , boolean subtypes , string name , string signature , string ext ,
256+ string input
257+ |
258+ sinkSpec ( e , package , type , subtypes , name , signature , ext , input ) and
259+ ExternalFlow:: sinkModel ( package , type , subtypes , name , [ signature , "" ] , ext , input , kind ,
260+ provenance )
261261 )
262262 or
263263 isCustomSink ( e , kind ) and provenance = "custom-sink"
264264 }
265265
266266 predicate isSource ( Endpoint e , string kind , string provenance ) {
267- exists ( string package , string type , string name , string signature , string ext , string output |
268- sourceSpec ( e , package , type , name , signature , ext , output ) and
269- ExternalFlow:: sourceModel ( package , type , _, name , [ signature , "" ] , ext , output , kind ,
267+ exists (
268+ string package , string type , boolean subtypes , string name , string signature , string ext ,
269+ string output
270+ |
271+ sourceSpec ( e , package , type , subtypes , name , signature , ext , output ) and
272+ ExternalFlow:: sourceModel ( package , type , subtypes , name , [ signature , "" ] , ext , output , kind ,
270273 provenance )
271274 )
272275 }
273276
274277 predicate isNeutral ( Endpoint e ) {
275- exists ( string package , string type , string name , string signature |
276- sinkSpec ( e , package , type , name , signature , _, _) and
277- ExternalFlow:: neutralModel ( package , type , name , [ signature , "" ] , "sink" , _)
278+ exists ( string package , string type , string name , string signature , string endpointType |
279+ sinkSpec ( e , package , type , _, name , signature , _, _) and
280+ endpointType = "sink"
281+ or
282+ sourceSpec ( e , package , type , _, name , signature , _, _) and
283+ endpointType = "source"
284+ |
285+ ExternalFlow:: neutralModel ( package , type , name , [ signature , "" ] , endpointType , _)
286+ )
287+ }
288+
289+ /**
290+ * Holds if the endpoint concerns a callable with the given package, type, name and signature.
291+ *
292+ * If `subtypes` is `false`, only the exact callable is considered. If `true`, the callable and
293+ * all its overrides are considered.
294+ */
295+ additional predicate endpointCallable (
296+ Endpoint e , string package , string type , boolean subtypes , string name , string signature
297+ ) {
298+ exists ( Callable c |
299+ c = e .getCallable ( ) and subtypes in [ true , false ]
300+ or
301+ e .getCallable ( ) .( Method ) .getSourceDeclaration ( ) .overrides + ( c ) and subtypes = true
302+ |
303+ c .hasQualifiedName ( package , type , name ) and
304+ signature = ExternalFlow:: paramsString ( c )
278305 )
279306 }
280307
281- // XXX how to extend to support sources?
282308 additional predicate sinkSpec (
283- Endpoint e , string package , string type , string name , string signature , string ext , string input
309+ Endpoint e , string package , string type , boolean subtypes , string name , string signature ,
310+ string ext , string input
284311 ) {
285- e .getCallable ( ) .hasQualifiedName ( package , type , name ) and
286- signature = ExternalFlow:: paramsString ( e .getCallable ( ) ) and
312+ endpointCallable ( e , package , type , subtypes , name , signature ) and
287313 ext = "" and
288314 input = e .getMaDInput ( )
289315 }
290316
291317 additional predicate sourceSpec (
292- Endpoint e , string package , string type , string name , string signature , string ext ,
293- string output
318+ Endpoint e , string package , string type , boolean subtypes , string name , string signature ,
319+ string ext , string output
294320 ) {
295- e .getCallable ( ) .hasQualifiedName ( package , type , name ) and
296- signature = ExternalFlow:: paramsString ( e .getCallable ( ) ) and
321+ endpointCallable ( e , package , type , subtypes , name , signature ) and
297322 ext = "" and
298323 output = e .getMaDOutput ( )
299324 }
0 commit comments