@@ -35,14 +35,10 @@ newtype TApplicationModeEndpoint =
35
35
arg = DataFlow:: getInstanceArgument ( call ) and
36
36
not call instanceof ConstructorCall
37
37
} or
38
- TImplicitVarargsArray ( Call call , DataFlow:: Node arg , int idx ) {
38
+ TImplicitVarargsArray ( Call call , DataFlow:: ImplicitVarargsArray arg , int idx ) {
39
39
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 ( )
46
42
} or
47
43
TMethodReturnValue ( Call call ) {
48
44
AutomodelJavaUtil:: isFromSource ( call ) and
@@ -255,45 +251,74 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
255
251
predicate isKnownKind = AutomodelJavaUtil:: isKnownKind / 2 ;
256
252
257
253
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 )
261
261
)
262
262
or
263
263
isCustomSink ( e , kind ) and provenance = "custom-sink"
264
264
}
265
265
266
266
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 ,
270
273
provenance )
271
274
)
272
275
}
273
276
274
277
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 )
278
305
)
279
306
}
280
307
281
- // XXX how to extend to support sources?
282
308
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
284
311
) {
285
- e .getCallable ( ) .hasQualifiedName ( package , type , name ) and
286
- signature = ExternalFlow:: paramsString ( e .getCallable ( ) ) and
312
+ endpointCallable ( e , package , type , subtypes , name , signature ) and
287
313
ext = "" and
288
314
input = e .getMaDInput ( )
289
315
}
290
316
291
317
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
294
320
) {
295
- e .getCallable ( ) .hasQualifiedName ( package , type , name ) and
296
- signature = ExternalFlow:: paramsString ( e .getCallable ( ) ) and
321
+ endpointCallable ( e , package , type , subtypes , name , signature ) and
297
322
ext = "" and
298
323
output = e .getMaDOutput ( )
299
324
}
0 commit comments