@@ -277,6 +277,16 @@ module MakeModelGeneratorFactory<
277277 */
278278 predicate isAdditionalContentFlowStep ( Lang:: Node nodeFrom , Lang:: Node nodeTo ) ;
279279
280+ /**
281+ * Gets the access path limit for content flow analysis.
282+ */
283+ default int contentAccessPathLimit ( ) { result = 2 }
284+
285+ /**
286+ * Gets the internal access path limit for content flow analysis.
287+ */
288+ default int contentAccessPathLimitInternal ( ) { result = Lang:: accessPathLimit ( ) }
289+
280290 /**
281291 * Holds if the content set `c` is field like.
282292 */
@@ -650,7 +660,10 @@ module MakeModelGeneratorFactory<
650660 exists ( Type t | t = n .( NodeExtended ) .getType ( ) and not isRelevantType ( t ) )
651661 }
652662
653- int accessPathLimit ( ) { result = 2 }
663+ predicate accessPathLimit = SummaryModelGeneratorInput:: contentAccessPathLimit / 0 ;
664+
665+ predicate accessPathLimitInternal =
666+ SummaryModelGeneratorInput:: contentAccessPathLimitInternal / 0 ;
654667
655668 predicate isRelevantContent ( DataFlow:: ContentSet s ) { isRelevantContent0 ( s ) }
656669
@@ -703,14 +716,17 @@ module MakeModelGeneratorFactory<
703716 }
704717
705718 /**
706- * Holds if the access path `ap` is not a parameter or returnvalue of a callback
707- * stored in a field.
719+ * Holds if `ap` is valid for generating summary models.
720+ *
721+ * We currently don't include summaries that rely on parameters or return values
722+ * of callbacks stored in fields, as those are not supported by the data flow
723+ * library.
708724 *
709- * That is, we currently don't include summaries that rely on parameters or return values
710- * of callbacks stored in fields.
725+ * We also exclude access paths with contents not supported by `printContent`.
711726 */
712727 private predicate validateAccessPath ( PropagateContentFlow:: AccessPath ap ) {
713- not ( mentionsField ( ap ) and mentionsCallback ( ap ) )
728+ not ( mentionsField ( ap ) and mentionsCallback ( ap ) ) and
729+ forall ( int i | i in [ 0 .. ap .length ( ) - 1 ] | exists ( getContent ( ap , i ) ) )
714730 }
715731
716732 private predicate apiFlow (
@@ -720,7 +736,9 @@ module MakeModelGeneratorFactory<
720736 ) {
721737 PropagateContentFlow:: flow ( p , reads , returnNodeExt , stores , preservesValue ) and
722738 getEnclosingCallable ( returnNodeExt ) = api and
723- getEnclosingCallable ( p ) = api
739+ getEnclosingCallable ( p ) = api and
740+ validateAccessPath ( reads ) and
741+ validateAccessPath ( stores )
724742 }
725743
726744 /**
@@ -763,9 +781,7 @@ module MakeModelGeneratorFactory<
763781 PropagateContentFlow:: AccessPath reads , ReturnNodeExt returnNodeExt ,
764782 PropagateContentFlow:: AccessPath stores , boolean preservesValue
765783 ) {
766- PropagateContentFlow:: flow ( p , reads , returnNodeExt , stores , preservesValue ) and
767- getEnclosingCallable ( returnNodeExt ) = api and
768- getEnclosingCallable ( p ) = api and
784+ apiFlow ( api , p , reads , returnNodeExt , stores , preservesValue ) and
769785 p = api .getARelevantParameterNode ( )
770786 }
771787
@@ -956,8 +972,6 @@ module MakeModelGeneratorFactory<
956972 input = parameterNodeAsExactInput ( p ) + printReadAccessPath ( reads ) and
957973 output = getExactOutput ( returnNodeExt ) + printStoreAccessPath ( stores ) and
958974 input != output and
959- validateAccessPath ( reads ) and
960- validateAccessPath ( stores ) and
961975 (
962976 if mentionsField ( reads ) or mentionsField ( stores )
963977 then lift = false and api .isRelevant ( )
0 commit comments