@@ -66,6 +66,12 @@ signature module ModelGeneratorInputSig<LocationSig Location, InputSig<Location>
6666 * Gets the enclosing callable of this node.
6767 */
6868 Callable getEnclosingCallable ( ) ;
69+
70+ /**
71+ * Gets the parameter position of the delegate callable for this
72+ * delegate call node.
73+ */
74+ int getParameterPosition ( ) ;
6975 }
7076
7177 /**
@@ -282,8 +288,11 @@ module MakeModelGenerator<
282288 private DataFlow:: ReturnKindExt kind ;
283289
284290 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+ )
287296 }
288297
289298 /**
@@ -295,20 +304,22 @@ module MakeModelGenerator<
295304 bindingset [ c]
296305 private signature string printCallableParamSig ( Callable c , DataFlow:: ParameterPosition p ) ;
297306
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
301310 result = "ReturnValue"
302311 or
303312 exists ( DataFlow:: ParameterPosition pos |
304- pos = node .getKind ( ) .( DataFlow:: ParamUpdateReturnKind ) .getPosition ( ) and
313+ pos = node .( ReturnNodeExt ) . getKind ( ) .( DataFlow:: ParamUpdateReturnKind ) .getPosition ( ) and
305314 result = printCallableParam ( returnNodeEnclosingCallable ( node ) , pos )
306315 )
316+ or
317+ result = "Argument[" + node .( DelegateCallNode ) .getParameterPosition ( ) + "]"
307318 }
308319 }
309320
310321 string getOutput ( ReturnNodeExt node ) {
311- result = PrintReturnNodeExt < paramReturnNodeAsOutput / 2 > :: getOutput ( node )
322+ result = PrintSinkNode < paramReturnNodeAsOutput / 2 > :: getOutput ( node )
312323 }
313324
314325 final private class SummaryTargetApiFinal = SummaryTargetApi ;
@@ -538,6 +549,7 @@ module MakeModelGenerator<
538549
539550 private module PropagateContentFlowConfig implements ContentDataFlow:: ConfigSig {
540551 predicate isSource ( DataFlow:: Node source ) {
552+ // TODO: We also need to consider delegate calls as source nodes.
541553 source instanceof DataFlow:: ParameterNode and
542554 source .( NodeExtended ) .getEnclosingCallable ( ) instanceof DataFlowSummaryTargetApi
543555 }
@@ -574,8 +586,8 @@ module MakeModelGenerator<
574586
575587 private module ContentModelPrinting = Printing:: ModelPrinting< ContentModelPrintingInput > ;
576588
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 )
579591 }
580592
581593 /**
@@ -615,11 +627,12 @@ module MakeModelGenerator<
615627
616628 private predicate apiFlow (
617629 DataFlowSummaryTargetApi api , DataFlow:: ParameterNode p ,
618- PropagateContentFlow:: AccessPath reads , ReturnNodeExt returnNodeExt ,
630+ PropagateContentFlow:: AccessPath reads , NodeExtended returnNodeExt ,
619631 PropagateContentFlow:: AccessPath stores , boolean preservesValue
620632 ) {
621633 PropagateContentFlow:: flow ( p , reads , returnNodeExt , stores , preservesValue ) and
622634 returnNodeExt .getEnclosingCallable ( ) = api and
635+ // TODO: We also need to consider delegate calls within an API to be sources.
623636 p .( NodeExtended ) .getEnclosingCallable ( ) = api
624637 }
625638
@@ -641,7 +654,7 @@ module MakeModelGenerator<
641654 ContentDataFlowSummaryTargetApi ( ) {
642655 count ( string input , string output |
643656 exists (
644- PropagateContentFlow:: AccessPath reads , ReturnNodeExt returnNodeExt ,
657+ PropagateContentFlow:: AccessPath reads , NodeExtended returnNodeExt ,
645658 PropagateContentFlow:: AccessPath stores
646659 |
647660 apiFlow ( this , parameter , reads , returnNodeExt , stores , _) and
@@ -712,7 +725,7 @@ module MakeModelGenerator<
712725 Type t1 , PropagateContentFlow:: AccessPath read , Type t2 ,
713726 PropagateContentFlow:: AccessPath store
714727 ) {
715- exists ( DataFlow:: ParameterNode p , ReturnNodeExt returnNodeExt |
728+ exists ( DataFlow:: ParameterNode p , NodeExtended returnNodeExt |
716729 p .( NodeExtended ) .getType ( ) = t1 and
717730 returnNodeExt .getType ( ) = t2 and
718731 apiContentFlow ( _, p , read , returnNodeExt , store , _)
@@ -829,7 +842,7 @@ module MakeModelGenerator<
829842 */
830843 private predicate apiRelevantContentFlow (
831844 ContentDataFlowSummaryTargetApi api , DataFlow:: ParameterNode p ,
832- PropagateContentFlow:: AccessPath read , ReturnNodeExt returnNodeExt ,
845+ PropagateContentFlow:: AccessPath read , NodeExtended returnNodeExt ,
833846 PropagateContentFlow:: AccessPath store , boolean preservesValue
834847 ) {
835848 apiContentFlow ( api , p , read , returnNodeExt , store , preservesValue ) and
@@ -847,7 +860,7 @@ module MakeModelGenerator<
847860 boolean lift
848861 ) {
849862 exists (
850- DataFlow:: ParameterNode p , ReturnNodeExt returnNodeExt ,
863+ DataFlow:: ParameterNode p , NodeExtended returnNodeExt ,
851864 PropagateContentFlow:: AccessPath reads , PropagateContentFlow:: AccessPath stores
852865 |
853866 apiRelevantContentFlow ( api , p , reads , returnNodeExt , stores , preservesValue ) and
0 commit comments