@@ -66,6 +66,12 @@ signature module ModelGeneratorInputSig<LocationSig Location, InputSig<Location>
66
66
* Gets the enclosing callable of this node.
67
67
*/
68
68
Callable getEnclosingCallable ( ) ;
69
+
70
+ /**
71
+ * Gets the parameter position of the delegate callable for this
72
+ * delegate call node.
73
+ */
74
+ int getParameterPosition ( ) ;
69
75
}
70
76
71
77
/**
@@ -282,8 +288,11 @@ module MakeModelGenerator<
282
288
private DataFlow:: ReturnKindExt kind ;
283
289
284
290
ReturnNodeExt ( ) {
285
- kind = DataFlow:: getValueReturnPosition ( this ) .getKind ( ) or
286
- kind = DataFlow:: getParamReturnPosition ( this , _) .getKind ( )
291
+ not this instanceof DelegateCallNode and
292
+ (
293
+ kind = DataFlow:: getValueReturnPosition ( this ) .getKind ( ) or
294
+ kind = DataFlow:: getParamReturnPosition ( this , _) .getKind ( )
295
+ )
287
296
}
288
297
289
298
/**
@@ -295,20 +304,22 @@ module MakeModelGenerator<
295
304
bindingset [ c]
296
305
private signature string printCallableParamSig ( Callable c , DataFlow:: ParameterPosition p ) ;
297
306
298
- private module PrintReturnNodeExt < printCallableParamSig / 2 printCallableParam> {
299
- string getOutput ( ReturnNodeExt node ) {
300
- node .getKind ( ) instanceof DataFlow:: ValueReturnKind and
307
+ private module PrintSinkNode < printCallableParamSig / 2 printCallableParam> {
308
+ string getOutput ( NodeExtended node ) {
309
+ node .( ReturnNodeExt ) . getKind ( ) instanceof DataFlow:: ValueReturnKind and
301
310
result = "ReturnValue"
302
311
or
303
312
exists ( DataFlow:: ParameterPosition pos |
304
- pos = node .getKind ( ) .( DataFlow:: ParamUpdateReturnKind ) .getPosition ( ) and
313
+ pos = node .( ReturnNodeExt ) . getKind ( ) .( DataFlow:: ParamUpdateReturnKind ) .getPosition ( ) and
305
314
result = printCallableParam ( returnNodeEnclosingCallable ( node ) , pos )
306
315
)
316
+ or
317
+ result = "Argument[" + node .( DelegateCallNode ) .getParameterPosition ( ) + "]"
307
318
}
308
319
}
309
320
310
321
string getOutput ( ReturnNodeExt node ) {
311
- result = PrintReturnNodeExt < paramReturnNodeAsOutput / 2 > :: getOutput ( node )
322
+ result = PrintSinkNode < paramReturnNodeAsOutput / 2 > :: getOutput ( node )
312
323
}
313
324
314
325
final private class SummaryTargetApiFinal = SummaryTargetApi ;
@@ -538,6 +549,7 @@ module MakeModelGenerator<
538
549
539
550
private module PropagateContentFlowConfig implements ContentDataFlow:: ConfigSig {
540
551
predicate isSource ( DataFlow:: Node source ) {
552
+ // TODO: We also need to consider delegate calls as source nodes.
541
553
source instanceof DataFlow:: ParameterNode and
542
554
source .( NodeExtended ) .getEnclosingCallable ( ) instanceof DataFlowSummaryTargetApi
543
555
}
@@ -574,8 +586,8 @@ module MakeModelGenerator<
574
586
575
587
private module ContentModelPrinting = Printing:: ModelPrinting< ContentModelPrintingInput > ;
576
588
577
- private string getContentOutput ( ReturnNodeExt node ) {
578
- result = PrintReturnNodeExt < paramReturnNodeAsContentOutput / 2 > :: getOutput ( node )
589
+ private string getContentOutput ( NodeExtended node ) {
590
+ result = PrintSinkNode < paramReturnNodeAsContentOutput / 2 > :: getOutput ( node )
579
591
}
580
592
581
593
/**
@@ -615,11 +627,12 @@ module MakeModelGenerator<
615
627
616
628
private predicate apiFlow (
617
629
DataFlowSummaryTargetApi api , DataFlow:: ParameterNode p ,
618
- PropagateContentFlow:: AccessPath reads , ReturnNodeExt returnNodeExt ,
630
+ PropagateContentFlow:: AccessPath reads , NodeExtended returnNodeExt ,
619
631
PropagateContentFlow:: AccessPath stores , boolean preservesValue
620
632
) {
621
633
PropagateContentFlow:: flow ( p , reads , returnNodeExt , stores , preservesValue ) and
622
634
returnNodeExt .getEnclosingCallable ( ) = api and
635
+ // TODO: We also need to consider delegate calls within an API to be sources.
623
636
p .( NodeExtended ) .getEnclosingCallable ( ) = api
624
637
}
625
638
@@ -641,7 +654,7 @@ module MakeModelGenerator<
641
654
ContentDataFlowSummaryTargetApi ( ) {
642
655
count ( string input , string output |
643
656
exists (
644
- PropagateContentFlow:: AccessPath reads , ReturnNodeExt returnNodeExt ,
657
+ PropagateContentFlow:: AccessPath reads , NodeExtended returnNodeExt ,
645
658
PropagateContentFlow:: AccessPath stores
646
659
|
647
660
apiFlow ( this , parameter , reads , returnNodeExt , stores , _) and
@@ -712,7 +725,7 @@ module MakeModelGenerator<
712
725
Type t1 , PropagateContentFlow:: AccessPath read , Type t2 ,
713
726
PropagateContentFlow:: AccessPath store
714
727
) {
715
- exists ( DataFlow:: ParameterNode p , ReturnNodeExt returnNodeExt |
728
+ exists ( DataFlow:: ParameterNode p , NodeExtended returnNodeExt |
716
729
p .( NodeExtended ) .getType ( ) = t1 and
717
730
returnNodeExt .getType ( ) = t2 and
718
731
apiContentFlow ( _, p , read , returnNodeExt , store , _)
@@ -829,7 +842,7 @@ module MakeModelGenerator<
829
842
*/
830
843
private predicate apiRelevantContentFlow (
831
844
ContentDataFlowSummaryTargetApi api , DataFlow:: ParameterNode p ,
832
- PropagateContentFlow:: AccessPath read , ReturnNodeExt returnNodeExt ,
845
+ PropagateContentFlow:: AccessPath read , NodeExtended returnNodeExt ,
833
846
PropagateContentFlow:: AccessPath store , boolean preservesValue
834
847
) {
835
848
apiContentFlow ( api , p , read , returnNodeExt , store , preservesValue ) and
@@ -847,7 +860,7 @@ module MakeModelGenerator<
847
860
boolean lift
848
861
) {
849
862
exists (
850
- DataFlow:: ParameterNode p , ReturnNodeExt returnNodeExt ,
863
+ DataFlow:: ParameterNode p , NodeExtended returnNodeExt ,
851
864
PropagateContentFlow:: AccessPath reads , PropagateContentFlow:: AccessPath stores
852
865
|
853
866
apiRelevantContentFlow ( api , p , reads , returnNodeExt , stores , preservesValue ) and
0 commit comments