@@ -111,60 +111,38 @@ 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 , Provenance p |
124+ summaryModel ( path , input_ , output_ , kind , p , madId ) and
125+ f .getCanonicalPath ( ) = path
126+ |
127+ this = f and isExact_ = true and p_ = p
142128 or
143- provenance = other and isInherited = true
129+ this .implements ( f ) and
130+ isExact_ = false and
131+ // making inherited models generated means that source code definitions and
132+ // exact generated models take precedence
133+ p_ = "hq-generated"
144134 )
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 , _, _)
153135 }
154136
155137 override predicate propagatesFlow (
156- string input , string output , boolean preservesValue , string model
138+ string input , string output , boolean preservesValue , Provenance p , boolean isExact , string model
157139 ) {
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- )
140+ input = input_ and
141+ output = output_ and
142+ ( if kind = "value" then preservesValue = true else preservesValue = false ) and
143+ p = p_ and
144+ isExact = isExact_ and
145+ model = "MaD:" + madId .toString ( )
168146 }
169147}
170148
@@ -211,7 +189,7 @@ private module Debug {
211189 private predicate relevantManualModel ( SummarizedCallableImpl sc , string can ) {
212190 exists ( Provenance manual |
213191 can = sc .getCanonicalPath ( ) and
214- summaryModelRelevant ( sc , _, _, _, manual , false , _) and
192+ sc . ( SummarizedCallableFromModel ) . propagatesFlow ( _, _, _, manual , true , _) and
215193 manual .isManual ( )
216194 )
217195 }
@@ -221,7 +199,7 @@ private module Debug {
221199 ) {
222200 exists ( RustDataFlow:: ParameterPosition pos , TypeMention tm |
223201 relevantManualModel ( sc , can ) and
224- sc .propagatesFlow ( input , _, _, _) and
202+ sc .propagatesFlow ( input , _, _, _, _ , _ ) and
225203 input .head ( ) = SummaryComponent:: argument ( pos ) and
226204 p = pos .getParameterIn ( sc .getParamList ( ) ) and
227205 tm .resolveType ( ) instanceof RefType and
@@ -238,7 +216,7 @@ private module Debug {
238216 ) {
239217 exists ( TypeMention tm |
240218 relevantManualModel ( sc , can ) and
241- sc .propagatesFlow ( _, output , _, _) and
219+ sc .propagatesFlow ( _, output , _, _, _ , _ ) and
242220 tm .resolveType ( ) instanceof RefType and
243221 output .head ( ) = SummaryComponent:: return ( _) and
244222 not output .tail ( ) .head ( ) =
0 commit comments