@@ -146,7 +146,7 @@ predicate summaryModel(string row) { any(SummaryModelCsv s).row(row) }
146
146
/** Holds if a source model exists for the given parameters. */
147
147
predicate sourceModel (
148
148
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
149
- string output , string kind , string provenance
149
+ string output , string kind , string provenance , string model
150
150
) {
151
151
exists ( string row |
152
152
sourceModel ( row ) and
@@ -160,16 +160,20 @@ predicate sourceModel(
160
160
row .splitAt ( ";" , 6 ) = output and
161
161
row .splitAt ( ";" , 7 ) = kind
162
162
) and
163
- provenance = "manual"
163
+ provenance = "manual" and
164
+ model = ""
164
165
or
165
- Extensions:: sourceModel ( namespace , type , subtypes , name , signature , ext , output , kind , provenance ,
166
- _)
166
+ exists ( QlBuiltins:: ExtensionId madId |
167
+ Extensions:: sourceModel ( namespace , type , subtypes , name , signature , ext , output , kind ,
168
+ provenance , madId ) and
169
+ model = "MaD:" + madId .toString ( )
170
+ )
167
171
}
168
172
169
173
/** Holds if a sink model exists for the given parameters. */
170
174
predicate sinkModel (
171
175
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
172
- string input , string kind , string provenance
176
+ string input , string kind , string provenance , string model
173
177
) {
174
178
exists ( string row |
175
179
sinkModel ( row ) and
@@ -183,9 +187,14 @@ predicate sinkModel(
183
187
row .splitAt ( ";" , 6 ) = input and
184
188
row .splitAt ( ";" , 7 ) = kind
185
189
) and
186
- provenance = "manual"
190
+ provenance = "manual" and
191
+ model = ""
187
192
or
188
- Extensions:: sinkModel ( namespace , type , subtypes , name , signature , ext , input , kind , provenance , _)
193
+ exists ( QlBuiltins:: ExtensionId madId |
194
+ Extensions:: sinkModel ( namespace , type , subtypes , name , signature , ext , input , kind , provenance ,
195
+ madId ) and
196
+ model = "MaD:" + madId .toString ( )
197
+ )
189
198
}
190
199
191
200
/**
@@ -195,7 +204,7 @@ predicate sinkModel(
195
204
*/
196
205
private predicate summaryModel0 (
197
206
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
198
- string input , string output , string kind , string provenance
207
+ string input , string output , string kind , string provenance , string model
199
208
) {
200
209
exists ( string row |
201
210
summaryModel ( row ) and
@@ -210,10 +219,14 @@ private predicate summaryModel0(
210
219
row .splitAt ( ";" , 7 ) = output and
211
220
row .splitAt ( ";" , 8 ) = kind
212
221
) and
213
- provenance = "manual"
222
+ provenance = "manual" and
223
+ model = ""
214
224
or
215
- Extensions:: summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind ,
216
- provenance , _)
225
+ exists ( QlBuiltins:: ExtensionId madId |
226
+ Extensions:: summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind ,
227
+ provenance , madId ) and
228
+ model = "MaD:" + madId .toString ( )
229
+ )
217
230
}
218
231
219
232
/**
@@ -234,19 +247,20 @@ private predicate expandInputAndOutput(
234
247
*/
235
248
predicate summaryModel (
236
249
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
237
- string input , string output , string kind , string provenance
250
+ string input , string output , string kind , string provenance , string model
238
251
) {
239
252
exists ( string input0 , string output0 |
240
- summaryModel0 ( namespace , type , subtypes , name , signature , ext , input0 , output0 , kind , provenance ) and
253
+ summaryModel0 ( namespace , type , subtypes , name , signature , ext , input0 , output0 , kind ,
254
+ provenance , model ) and
241
255
expandInputAndOutput ( input0 , input , output0 , output ,
242
256
[ 0 .. Private:: getMaxElementContentIndirectionIndex ( ) - 1 ] )
243
257
)
244
258
}
245
259
246
260
private predicate relevantNamespace ( string namespace ) {
247
- sourceModel ( namespace , _, _, _, _, _, _, _, _) or
248
- sinkModel ( namespace , _, _, _, _, _, _, _, _) or
249
- summaryModel ( namespace , _, _, _, _, _, _, _, _, _)
261
+ sourceModel ( namespace , _, _, _, _, _, _, _, _, _ ) or
262
+ sinkModel ( namespace , _, _, _, _, _, _, _, _, _ ) or
263
+ summaryModel ( namespace , _, _, _, _, _, _, _, _, _, _ )
250
264
}
251
265
252
266
private predicate namespaceLink ( string shortns , string longns ) {
@@ -276,25 +290,25 @@ predicate modelCoverage(string namespace, int namespaces, string kind, string pa
276
290
part = "source" and
277
291
n =
278
292
strictcount ( string subns , string type , boolean subtypes , string name , string signature ,
279
- string ext , string output , string provenance |
293
+ string ext , string output , string provenance , string model |
280
294
canonicalNamespaceLink ( namespace , subns ) and
281
- sourceModel ( subns , type , subtypes , name , signature , ext , output , kind , provenance )
295
+ sourceModel ( subns , type , subtypes , name , signature , ext , output , kind , provenance , model )
282
296
)
283
297
or
284
298
part = "sink" and
285
299
n =
286
300
strictcount ( string subns , string type , boolean subtypes , string name , string signature ,
287
- string ext , string input , string provenance |
301
+ string ext , string input , string provenance , string model |
288
302
canonicalNamespaceLink ( namespace , subns ) and
289
- sinkModel ( subns , type , subtypes , name , signature , ext , input , kind , provenance )
303
+ sinkModel ( subns , type , subtypes , name , signature , ext , input , kind , provenance , model )
290
304
)
291
305
or
292
306
part = "summary" and
293
307
n =
294
308
strictcount ( string subns , string type , boolean subtypes , string name , string signature ,
295
309
string ext , string input , string output , string provenance |
296
310
canonicalNamespaceLink ( namespace , subns ) and
297
- summaryModel ( subns , type , subtypes , name , signature , ext , input , output , kind , provenance )
311
+ summaryModel ( subns , type , subtypes , name , signature , ext , input , output , kind , provenance , _ )
298
312
)
299
313
)
300
314
}
@@ -303,9 +317,9 @@ predicate modelCoverage(string namespace, int namespaces, string kind, string pa
303
317
module CsvValidation {
304
318
private string getInvalidModelInput ( ) {
305
319
exists ( string pred , AccessPath input , string part |
306
- sinkModel ( _, _, _, _, _, _, input , _, _) and pred = "sink"
320
+ sinkModel ( _, _, _, _, _, _, input , _, _, _ ) and pred = "sink"
307
321
or
308
- summaryModel ( _, _, _, _, _, _, input , _, _, _) and pred = "summary"
322
+ summaryModel ( _, _, _, _, _, _, input , _, _, _, _ ) and pred = "summary"
309
323
|
310
324
(
311
325
invalidSpecComponent ( input , part ) and
@@ -322,9 +336,9 @@ module CsvValidation {
322
336
323
337
private string getInvalidModelOutput ( ) {
324
338
exists ( string pred , string output , string part |
325
- sourceModel ( _, _, _, _, _, _, output , _, _) and pred = "source"
339
+ sourceModel ( _, _, _, _, _, _, output , _, _, _ ) and pred = "source"
326
340
or
327
- summaryModel ( _, _, _, _, _, _, _, output , _, _) and pred = "summary"
341
+ summaryModel ( _, _, _, _, _, _, _, output , _, _, _ ) and pred = "summary"
328
342
|
329
343
invalidSpecComponent ( output , part ) and
330
344
not part = "" and
@@ -334,11 +348,11 @@ module CsvValidation {
334
348
}
335
349
336
350
private module KindValConfig implements SharedModelVal:: KindValidationConfigSig {
337
- predicate summaryKind ( string kind ) { summaryModel ( _, _, _, _, _, _, _, _, kind , _) }
351
+ predicate summaryKind ( string kind ) { summaryModel ( _, _, _, _, _, _, _, _, kind , _, _ ) }
338
352
339
- predicate sinkKind ( string kind ) { sinkModel ( _, _, _, _, _, _, _, kind , _) }
353
+ predicate sinkKind ( string kind ) { sinkModel ( _, _, _, _, _, _, _, kind , _, _ ) }
340
354
341
- predicate sourceKind ( string kind ) { sourceModel ( _, _, _, _, _, _, _, kind , _) }
355
+ predicate sourceKind ( string kind ) { sourceModel ( _, _, _, _, _, _, _, kind , _, _ ) }
342
356
}
343
357
344
358
private module KindVal = SharedModelVal:: KindValidation< KindValConfig > ;
@@ -379,11 +393,11 @@ module CsvValidation {
379
393
380
394
private string getInvalidModelSignature ( ) {
381
395
exists ( string pred , string namespace , string type , string name , string signature , string ext |
382
- sourceModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "source"
396
+ sourceModel ( namespace , type , _, name , signature , ext , _, _, _, _ ) and pred = "source"
383
397
or
384
- sinkModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "sink"
398
+ sinkModel ( namespace , type , _, name , signature , ext , _, _, _, _ ) and pred = "sink"
385
399
or
386
- summaryModel ( namespace , type , _, name , signature , ext , _, _, _, _) and pred = "summary"
400
+ summaryModel ( namespace , type , _, name , signature , ext , _, _, _, _, _ ) and pred = "summary"
387
401
|
388
402
not namespace .regexpMatch ( "[a-zA-Z0-9_\\.:]*" ) and
389
403
result = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
@@ -415,9 +429,9 @@ module CsvValidation {
415
429
private predicate elementSpec (
416
430
string namespace , string type , boolean subtypes , string name , string signature , string ext
417
431
) {
418
- sourceModel ( namespace , type , subtypes , name , signature , ext , _, _, _) or
419
- sinkModel ( namespace , type , subtypes , name , signature , ext , _, _, _) or
420
- summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _, _)
432
+ sourceModel ( namespace , type , subtypes , name , signature , ext , _, _, _, _ ) or
433
+ sinkModel ( namespace , type , subtypes , name , signature , ext , _, _, _, _ ) or
434
+ summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _, _, _ )
421
435
}
422
436
423
437
/** Gets the fully templated version of `f`. */
@@ -867,9 +881,9 @@ private module Cached {
867
881
* model.
868
882
*/
869
883
cached
870
- predicate sourceNode ( DataFlow:: Node node , string kind ) {
884
+ predicate sourceNode ( DataFlow:: Node node , string kind , string model ) {
871
885
exists ( SourceSinkInterpretationInput:: InterpretNode n |
872
- isSourceNode ( n , kind , _ ) and n .asNode ( ) = node // TODO
886
+ isSourceNode ( n , kind , model ) and n .asNode ( ) = node
873
887
)
874
888
}
875
889
@@ -878,40 +892,57 @@ private module Cached {
878
892
* model.
879
893
*/
880
894
cached
881
- predicate sinkNode ( DataFlow:: Node node , string kind ) {
895
+ predicate sinkNode ( DataFlow:: Node node , string kind , string model ) {
882
896
exists ( SourceSinkInterpretationInput:: InterpretNode n |
883
- isSinkNode ( n , kind , _ ) and n .asNode ( ) = node // TODO
897
+ isSinkNode ( n , kind , model ) and n .asNode ( ) = node
884
898
)
885
899
}
886
900
}
887
901
888
902
import Cached
889
903
904
+ /**
905
+ * Holds if `node` is specified as a source with the given kind in a MaD flow
906
+ * model.
907
+ */
908
+ predicate sourceNode ( DataFlow:: Node node , string kind ) { sourceNode ( node , kind , _) }
909
+
910
+ /**
911
+ * Holds if `node` is specified as a sink with the given kind in a MaD flow
912
+ * model.
913
+ */
914
+ predicate sinkNode ( DataFlow:: Node node , string kind ) { sinkNode ( node , kind , _) }
915
+
890
916
private predicate interpretSummary (
891
- Function f , string input , string output , string kind , string provenance
917
+ Function f , string input , string output , string kind , string provenance , string model
892
918
) {
893
919
exists (
894
920
string namespace , string type , boolean subtypes , string name , string signature , string ext
895
921
|
896
- summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , provenance ) and
922
+ summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , provenance ,
923
+ model ) and
897
924
f = interpretElement ( namespace , type , subtypes , name , signature , ext )
898
925
)
899
926
}
900
927
901
928
// adapter class for converting Mad summaries to `SummarizedCallable`s
902
929
private class SummarizedCallableAdapter extends SummarizedCallable {
903
- SummarizedCallableAdapter ( ) { interpretSummary ( this , _, _, _, _) }
930
+ SummarizedCallableAdapter ( ) { interpretSummary ( this , _, _, _, _, _ ) }
904
931
905
- private predicate relevantSummaryElementManual ( string input , string output , string kind ) {
932
+ private predicate relevantSummaryElementManual (
933
+ string input , string output , string kind , string model
934
+ ) {
906
935
exists ( Provenance provenance |
907
- interpretSummary ( this , input , output , kind , provenance ) and
936
+ interpretSummary ( this , input , output , kind , provenance , model ) and
908
937
provenance .isManual ( )
909
938
)
910
939
}
911
940
912
- private predicate relevantSummaryElementGenerated ( string input , string output , string kind ) {
941
+ private predicate relevantSummaryElementGenerated (
942
+ string input , string output , string kind , string model
943
+ ) {
913
944
exists ( Provenance provenance |
914
- interpretSummary ( this , input , output , kind , provenance ) and
945
+ interpretSummary ( this , input , output , kind , provenance , model ) and
915
946
provenance .isGenerated ( )
916
947
)
917
948
}
@@ -920,18 +951,17 @@ private class SummarizedCallableAdapter extends SummarizedCallable {
920
951
string input , string output , boolean preservesValue , string model
921
952
) {
922
953
exists ( string kind |
923
- this .relevantSummaryElementManual ( input , output , kind )
954
+ this .relevantSummaryElementManual ( input , output , kind , model )
924
955
or
925
- not this .relevantSummaryElementManual ( _, _, _) and
926
- this .relevantSummaryElementGenerated ( input , output , kind )
956
+ not this .relevantSummaryElementManual ( _, _, _, _ ) and
957
+ this .relevantSummaryElementGenerated ( input , output , kind , model )
927
958
|
928
959
if kind = "value" then preservesValue = true else preservesValue = false
929
- ) and
930
- model = "" // TODO
960
+ )
931
961
}
932
962
933
963
override predicate hasProvenance ( Provenance provenance ) {
934
- interpretSummary ( this , _, _, _, provenance )
964
+ interpretSummary ( this , _, _, _, provenance , _ )
935
965
}
936
966
}
937
967
0 commit comments