@@ -113,76 +113,85 @@ abstract class ActiveExperimentalModels extends string {
113
113
*/
114
114
predicate sourceModel (
115
115
string package , string type , boolean subtypes , string name , string signature , string ext ,
116
- string output , string kind , string provenance
116
+ string output , string kind , string provenance , QlBuiltins :: ExtensionId madId
117
117
) {
118
118
Extensions:: experimentalSourceModel ( package , type , subtypes , name , signature , ext , output , kind ,
119
- provenance , this )
119
+ provenance , this , madId )
120
120
}
121
121
122
122
/**
123
123
* Holds if an experimental sink model exists for the given parameters.
124
124
*/
125
125
predicate sinkModel (
126
126
string package , string type , boolean subtypes , string name , string signature , string ext ,
127
- string output , string kind , string provenance
127
+ string output , string kind , string provenance , QlBuiltins :: ExtensionId madId
128
128
) {
129
129
Extensions:: experimentalSinkModel ( package , type , subtypes , name , signature , ext , output , kind ,
130
- provenance , this )
130
+ provenance , this , madId )
131
131
}
132
132
133
133
/**
134
134
* Holds if an experimental summary model exists for the given parameters.
135
135
*/
136
136
predicate summaryModel (
137
137
string package , string type , boolean subtypes , string name , string signature , string ext ,
138
- string input , string output , string kind , string provenance
138
+ string input , string output , string kind , string provenance , QlBuiltins :: ExtensionId madId
139
139
) {
140
140
Extensions:: experimentalSummaryModel ( package , type , subtypes , name , signature , ext , input ,
141
- output , kind , provenance , this )
141
+ output , kind , provenance , this , madId )
142
142
}
143
143
}
144
144
145
145
/** Holds if a source model exists for the given parameters. */
146
146
predicate sourceModel (
147
147
string package , string type , boolean subtypes , string name , string signature , string ext ,
148
- string output , string kind , string provenance
148
+ string output , string kind , string provenance , QlBuiltins :: ExtensionId madId
149
149
) {
150
- Extensions:: sourceModel ( package , type , subtypes , name , signature , ext , output , kind , provenance )
151
- or
152
- any ( ActiveExperimentalModels q )
153
- .sourceModel ( package , type , subtypes , name , signature , ext , output , kind , provenance )
150
+ (
151
+ Extensions:: sourceModel ( package , type , subtypes , name , signature , ext , output , kind , provenance ,
152
+ madId )
153
+ or
154
+ any ( ActiveExperimentalModels q )
155
+ .sourceModel ( package , type , subtypes , name , signature , ext , output , kind , provenance , madId )
156
+ )
154
157
}
155
158
156
159
/** Holds if a sink model exists for the given parameters. */
157
160
predicate sinkModel (
158
161
string package , string type , boolean subtypes , string name , string signature , string ext ,
159
- string input , string kind , string provenance
162
+ string input , string kind , string provenance , QlBuiltins :: ExtensionId madId
160
163
) {
161
- Extensions:: sinkModel ( package , type , subtypes , name , signature , ext , input , kind , provenance )
162
- or
163
- any ( ActiveExperimentalModels q )
164
- .sinkModel ( package , type , subtypes , name , signature , ext , input , kind , provenance )
164
+ (
165
+ Extensions:: sinkModel ( package , type , subtypes , name , signature , ext , input , kind , provenance ,
166
+ madId )
167
+ or
168
+ any ( ActiveExperimentalModels q )
169
+ .sinkModel ( package , type , subtypes , name , signature , ext , input , kind , provenance , madId )
170
+ )
165
171
}
166
172
167
173
/** Holds if a summary model exists for the given parameters. */
168
174
predicate summaryModel (
169
175
string package , string type , boolean subtypes , string name , string signature , string ext ,
170
- string input , string output , string kind , string provenance
176
+ string input , string output , string kind , string provenance , QlBuiltins :: ExtensionId madId
171
177
) {
172
- Extensions:: summaryModel ( package , type , subtypes , name , signature , ext , input , output , kind ,
173
- provenance )
174
- or
175
- any ( ActiveExperimentalModels q )
176
- .summaryModel ( package , type , subtypes , name , signature , ext , input , output , kind , provenance )
178
+ (
179
+ Extensions:: summaryModel ( package , type , subtypes , name , signature , ext , input , output , kind ,
180
+ provenance , madId )
181
+ or
182
+ any ( ActiveExperimentalModels q )
183
+ .summaryModel ( package , type , subtypes , name , signature , ext , input , output , kind ,
184
+ provenance , madId )
185
+ )
177
186
}
178
187
179
188
/** Holds if a neutral model exists for the given parameters. */
180
189
predicate neutralModel = Extensions:: neutralModel / 6 ;
181
190
182
191
private predicate relevantPackage ( string package ) {
183
- sourceModel ( package , _, _, _, _, _, _, _, _) or
184
- sinkModel ( package , _, _, _, _, _, _, _, _) or
185
- summaryModel ( package , _, _, _, _, _, _, _, _, _)
192
+ sourceModel ( package , _, _, _, _, _, _, _, _, _ ) or
193
+ sinkModel ( package , _, _, _, _, _, _, _, _, _ ) or
194
+ summaryModel ( package , _, _, _, _, _, _, _, _, _, _ )
186
195
}
187
196
188
197
private predicate packageLink ( string shortpkg , string longpkg ) {
@@ -212,23 +221,24 @@ predicate modelCoverage(string package, int pkgs, string kind, string part, int
212
221
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
213
222
string ext , string output , string provenance |
214
223
canonicalPkgLink ( package , subpkg ) and
215
- sourceModel ( subpkg , type , subtypes , name , signature , ext , output , kind , provenance )
224
+ sourceModel ( subpkg , type , subtypes , name , signature , ext , output , kind , provenance , _ )
216
225
)
217
226
or
218
227
part = "sink" and
219
228
n =
220
229
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
221
230
string ext , string input , string provenance |
222
231
canonicalPkgLink ( package , subpkg ) and
223
- sinkModel ( subpkg , type , subtypes , name , signature , ext , input , kind , provenance )
232
+ sinkModel ( subpkg , type , subtypes , name , signature , ext , input , kind , provenance , _ )
224
233
)
225
234
or
226
235
part = "summary" and
227
236
n =
228
237
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
229
238
string ext , string input , string output , string provenance |
230
239
canonicalPkgLink ( package , subpkg ) and
231
- summaryModel ( subpkg , type , subtypes , name , signature , ext , input , output , kind , provenance )
240
+ summaryModel ( subpkg , type , subtypes , name , signature , ext , input , output , kind , provenance ,
241
+ _)
232
242
)
233
243
)
234
244
}
@@ -238,10 +248,10 @@ module ModelValidation {
238
248
private import codeql.dataflow.internal.AccessPathSyntax as AccessPathSyntax
239
249
240
250
private predicate getRelevantAccessPath ( string path ) {
241
- summaryModel ( _, _, _, _, _, _, path , _, _, _) or
242
- summaryModel ( _, _, _, _, _, _, _, path , _, _) or
243
- sinkModel ( _, _, _, _, _, _, path , _, _) or
244
- sourceModel ( _, _, _, _, _, _, path , _, _)
251
+ summaryModel ( _, _, _, _, _, _, path , _, _, _, _ ) or
252
+ summaryModel ( _, _, _, _, _, _, _, path , _, _, _ ) or
253
+ sinkModel ( _, _, _, _, _, _, path , _, _, _ ) or
254
+ sourceModel ( _, _, _, _, _, _, path , _, _, _ )
245
255
}
246
256
247
257
private module MkAccessPath = AccessPathSyntax:: AccessPath< getRelevantAccessPath / 1 > ;
@@ -252,9 +262,9 @@ module ModelValidation {
252
262
253
263
private string getInvalidModelInput ( ) {
254
264
exists ( string pred , AccessPath input , AccessPathToken part |
255
- sinkModel ( _, _, _, _, _, _, input , _, _) and pred = "sink"
265
+ sinkModel ( _, _, _, _, _, _, input , _, _, _ ) and pred = "sink"
256
266
or
257
- summaryModel ( _, _, _, _, _, _, input , _, _, _) and pred = "summary"
267
+ summaryModel ( _, _, _, _, _, _, input , _, _, _, _ ) and pred = "summary"
258
268
|
259
269
(
260
270
invalidSpecComponent ( input , part ) and
@@ -274,9 +284,9 @@ module ModelValidation {
274
284
275
285
private string getInvalidModelOutput ( ) {
276
286
exists ( string pred , AccessPath output , AccessPathToken part |
277
- sourceModel ( _, _, _, _, _, _, output , _, _) and pred = "source"
287
+ sourceModel ( _, _, _, _, _, _, output , _, _, _ ) and pred = "source"
278
288
or
279
- summaryModel ( _, _, _, _, _, _, _, output , _, _) and pred = "summary"
289
+ summaryModel ( _, _, _, _, _, _, _, output , _, _, _ ) and pred = "summary"
280
290
|
281
291
(
282
292
invalidSpecComponent ( output , part ) and
@@ -291,11 +301,11 @@ module ModelValidation {
291
301
}
292
302
293
303
private module KindValConfig implements SharedModelVal:: KindValidationConfigSig {
294
- predicate summaryKind ( string kind ) { summaryModel ( _, _, _, _, _, _, _, _, kind , _) }
304
+ predicate summaryKind ( string kind ) { summaryModel ( _, _, _, _, _, _, _, _, kind , _, _ ) }
295
305
296
- predicate sinkKind ( string kind ) { sinkModel ( _, _, _, _, _, _, _, kind , _) }
306
+ predicate sinkKind ( string kind ) { sinkModel ( _, _, _, _, _, _, _, kind , _, _ ) }
297
307
298
- predicate sourceKind ( string kind ) { sourceModel ( _, _, _, _, _, _, _, kind , _) }
308
+ predicate sourceKind ( string kind ) { sourceModel ( _, _, _, _, _, _, _, kind , _, _ ) }
299
309
300
310
predicate neutralKind ( string kind ) { neutralModel ( _, _, _, _, kind , _) }
301
311
}
@@ -307,11 +317,11 @@ module ModelValidation {
307
317
string pred , string package , string type , string name , string signature , string ext ,
308
318
string provenance
309
319
|
310
- sourceModel ( package , type , _, name , signature , ext , _, _, provenance ) and pred = "source"
320
+ sourceModel ( package , type , _, name , signature , ext , _, _, provenance , _ ) and pred = "source"
311
321
or
312
- sinkModel ( package , type , _, name , signature , ext , _, _, provenance ) and pred = "sink"
322
+ sinkModel ( package , type , _, name , signature , ext , _, _, provenance , _ ) and pred = "sink"
313
323
or
314
- summaryModel ( package , type , _, name , signature , ext , _, _, _, provenance ) and
324
+ summaryModel ( package , type , _, name , signature , ext , _, _, _, provenance , _ ) and
315
325
pred = "summary"
316
326
or
317
327
neutralModel ( package , type , name , signature , _, provenance ) and
@@ -352,11 +362,11 @@ pragma[nomagic]
352
362
private predicate elementSpec (
353
363
string package , string type , boolean subtypes , string name , string signature , string ext
354
364
) {
355
- sourceModel ( package , type , subtypes , name , signature , ext , _, _, _)
365
+ sourceModel ( package , type , subtypes , name , signature , ext , _, _, _, _ )
356
366
or
357
- sinkModel ( package , type , subtypes , name , signature , ext , _, _, _)
367
+ sinkModel ( package , type , subtypes , name , signature , ext , _, _, _, _ )
358
368
or
359
- summaryModel ( package , type , subtypes , name , signature , ext , _, _, _, _)
369
+ summaryModel ( package , type , subtypes , name , signature , ext , _, _, _, _, _ )
360
370
or
361
371
neutralModel ( package , type , name , signature , _, _) and ext = "" and subtypes = false
362
372
}
@@ -494,9 +504,9 @@ private module Cached {
494
504
* model.
495
505
*/
496
506
cached
497
- predicate sourceNode ( Node node , string kind ) {
507
+ predicate sourceNode ( Node node , string kind , string model ) {
498
508
exists ( SourceSinkInterpretationInput:: InterpretNode n |
499
- isSourceNode ( n , kind ) and n .asNode ( ) = node
509
+ isSourceNode ( n , kind , model ) and n .asNode ( ) = node
500
510
)
501
511
}
502
512
@@ -505,29 +515,45 @@ private module Cached {
505
515
* model.
506
516
*/
507
517
cached
508
- predicate sinkNode ( Node node , string kind ) {
518
+ predicate sinkNode ( Node node , string kind , string model ) {
509
519
exists ( SourceSinkInterpretationInput:: InterpretNode n |
510
- isSinkNode ( n , kind ) and n .asNode ( ) = node
520
+ isSinkNode ( n , kind , model ) and n .asNode ( ) = node
511
521
)
512
522
}
513
523
}
514
524
515
525
import Cached
516
526
527
+ /**
528
+ * Holds if `node` is specified as a source with the given kind in a MaD flow
529
+ * model.
530
+ */
531
+ predicate sourceNode ( Node node , string kind ) { sourceNode ( node , kind , _) }
532
+
533
+ /**
534
+ * Holds if `node` is specified as a sink with the given kind in a MaD flow
535
+ * model.
536
+ */
537
+ predicate sinkNode ( Node node , string kind ) { sinkNode ( node , kind , _) }
538
+
517
539
// adapter class for converting Mad summaries to `SummarizedCallable`s
518
540
private class SummarizedCallableAdapter extends SummarizedCallable {
519
- SummarizedCallableAdapter ( ) { summaryElement ( this , _, _, _, _) }
541
+ SummarizedCallableAdapter ( ) { summaryElement ( this , _, _, _, _, _ ) }
520
542
521
- private predicate relevantSummaryElementManual ( string input , string output , string kind ) {
543
+ private predicate relevantSummaryElementManual (
544
+ string input , string output , string kind , string model
545
+ ) {
522
546
exists ( Provenance provenance |
523
- summaryElement ( this , input , output , kind , provenance ) and
547
+ summaryElement ( this , input , output , kind , provenance , model ) and
524
548
provenance .isManual ( )
525
549
)
526
550
}
527
551
528
- private predicate relevantSummaryElementGenerated ( string input , string output , string kind ) {
552
+ private predicate relevantSummaryElementGenerated (
553
+ string input , string output , string kind , string model
554
+ ) {
529
555
exists ( Provenance provenance |
530
- summaryElement ( this , input , output , kind , provenance ) and
556
+ summaryElement ( this , input , output , kind , provenance , model ) and
531
557
provenance .isGenerated ( )
532
558
) and
533
559
not exists ( Provenance provenance |
@@ -536,19 +562,21 @@ private class SummarizedCallableAdapter extends SummarizedCallable {
536
562
)
537
563
}
538
564
539
- override predicate propagatesFlow ( string input , string output , boolean preservesValue ) {
565
+ override predicate propagatesFlow (
566
+ string input , string output , boolean preservesValue , string model
567
+ ) {
540
568
exists ( string kind |
541
- this .relevantSummaryElementManual ( input , output , kind )
569
+ this .relevantSummaryElementManual ( input , output , kind , model )
542
570
or
543
- not this .relevantSummaryElementManual ( _, _, _) and
544
- this .relevantSummaryElementGenerated ( input , output , kind )
571
+ not this .relevantSummaryElementManual ( _, _, _, _ ) and
572
+ this .relevantSummaryElementGenerated ( input , output , kind , model )
545
573
|
546
574
if kind = "value" then preservesValue = true else preservesValue = false
547
575
)
548
576
}
549
577
550
578
override predicate hasProvenance ( Provenance provenance ) {
551
- summaryElement ( this , _, _, _, provenance )
579
+ summaryElement ( this , _, _, _, provenance , _ )
552
580
}
553
581
}
554
582
0 commit comments