@@ -111,60 +111,36 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
111111 )
112112}
113113
114- private predicate summaryModel (
115- Function f , string input , string output , string kind , Provenance provenance , boolean isInherited ,
116- QlBuiltins:: ExtensionId madId
117- ) {
118- exists ( string path , Function f0 |
119- summaryModel ( path , input , output , kind , provenance , madId ) and
120- f0 .getCanonicalPath ( ) = path
121- |
122- f = f0 and
123- isInherited = false
124- or
125- f .implements ( f0 ) and
126- isInherited = true
127- )
128- }
129-
130- private predicate summaryModelRelevant (
131- Function f , string input , string output , string kind , Provenance provenance , boolean isInherited ,
132- QlBuiltins:: ExtensionId madId
133- ) {
134- summaryModel ( f , input , output , kind , provenance , isInherited , madId ) and
135- // Only apply generated or inherited models to functions in library code and
136- // when no strictly better model exists
137- if provenance .isGenerated ( ) or isInherited = true
138- then
139- not f .fromSource ( ) and
140- not exists ( Provenance other | summaryModel ( f , _, _, _, other , false , _) |
141- provenance .isGenerated ( ) and other .isManual ( )
114+ private class SummarizedCallableFromModel extends SummarizedCallable:: Range {
115+ string input_ ;
116+ string output_ ;
117+ string kind ;
118+ Provenance p_ ;
119+ boolean isExact_ ;
120+ QlBuiltins:: ExtensionId madId ;
121+
122+ SummarizedCallableFromModel ( ) {
123+ exists ( string path , Function f |
124+ summaryModel ( path , input_ , output_ , kind , p_ , madId ) and
125+ f .getCanonicalPath ( ) = path
126+ |
127+ this = f and isExact_ = true
142128 or
143- provenance = other and isInherited = true
129+ this .implements ( f ) and
130+ isExact_ = false and
131+ not this .fromSource ( )
144132 )
145- else any ( )
146- }
147-
148- private class SummarizedCallableFromModel extends SummarizedCallable:: Range {
149- SummarizedCallableFromModel ( ) { summaryModelRelevant ( this , _, _, _, _, _, _) }
150-
151- override predicate hasProvenance ( Provenance provenance ) {
152- summaryModelRelevant ( this , _, _, _, provenance , _, _)
153133 }
154134
155135 override predicate propagatesFlow (
156- string input , string output , boolean preservesValue , string model
136+ string input , string output , boolean preservesValue , Provenance p , boolean isExact , string model
157137 ) {
158- exists ( string kind , QlBuiltins:: ExtensionId madId |
159- summaryModelRelevant ( this , input , output , kind , _, _, madId ) and
160- model = "MaD:" + madId .toString ( )
161- |
162- kind = "value" and
163- preservesValue = true
164- or
165- kind = "taint" and
166- preservesValue = false
167- )
138+ input = input_ and
139+ output = output_ and
140+ ( if kind = "value" then preservesValue = true else preservesValue = false ) and
141+ p = p_ and
142+ isExact = isExact_ and
143+ model = "MaD:" + madId .toString ( )
168144 }
169145}
170146
@@ -211,7 +187,7 @@ private module Debug {
211187 private predicate relevantManualModel ( SummarizedCallableImpl sc , string can ) {
212188 exists ( Provenance manual |
213189 can = sc .getCanonicalPath ( ) and
214- summaryModelRelevant ( sc , _, _, _, manual , false , _) and
190+ sc . ( SummarizedCallableFromModel ) . propagatesFlow ( _, _, _, manual , true , _) and
215191 manual .isManual ( )
216192 )
217193 }
@@ -221,7 +197,7 @@ private module Debug {
221197 ) {
222198 exists ( RustDataFlow:: ParameterPosition pos , TypeMention tm |
223199 relevantManualModel ( sc , can ) and
224- sc .propagatesFlow ( input , _, _, _) and
200+ sc .propagatesFlow ( input , _, _, _, _ , _ ) and
225201 input .head ( ) = SummaryComponent:: argument ( pos ) and
226202 p = pos .getParameterIn ( sc .getParamList ( ) ) and
227203 tm .resolveType ( ) instanceof RefType and
@@ -238,7 +214,7 @@ private module Debug {
238214 ) {
239215 exists ( TypeMention tm |
240216 relevantManualModel ( sc , can ) and
241- sc .propagatesFlow ( _, output , _, _) and
217+ sc .propagatesFlow ( _, output , _, _, _ , _ ) and
242218 tm .resolveType ( ) instanceof RefType and
243219 output .head ( ) = SummaryComponent:: return ( _) and
244220 not output .tail ( ) .head ( ) =
0 commit comments