1
1
/**
2
2
* INTERNAL use only. This is an experimental API subject to change without notice.
3
3
*
4
- * Provides classes and predicates for dealing with flow models specified in CSV format .
4
+ * Provides classes and predicates for dealing with flow models specified in extensible predicates .
5
5
*
6
- * The CSV specification has the following columns:
6
+ * The extensible predicates have the following columns:
7
7
* - Sources:
8
- * `type; path; kind`
8
+ * `type, path, kind`
9
9
* - Sinks:
10
- * `type; path; kind`
10
+ * `type, path, kind`
11
11
* - Summaries:
12
- * `type; path; input; output; kind`
12
+ * `type, path, input, output, kind`
13
13
* - Types:
14
- * `type1; type2; path`
14
+ * `type1, type2, path`
15
15
*
16
16
* The interpretation of a row is similar to API-graphs with a left-to-right
17
17
* reading.
@@ -80,7 +80,7 @@ module ModelInput {
80
80
*
81
81
* Extend this class to add additional source definitions.
82
82
*/
83
- class SourceModelCsv extends Unit {
83
+ deprecated class SourceModelCsv extends Unit {
84
84
/**
85
85
* Holds if `row` specifies a source definition.
86
86
*
@@ -93,15 +93,15 @@ module ModelInput {
93
93
*
94
94
* The kind `remote` represents a general remote flow source.
95
95
*/
96
- abstract predicate row ( string row ) ;
96
+ abstract deprecated predicate row ( string row ) ;
97
97
}
98
98
99
99
/**
100
100
* A unit class for adding additional sink model rows.
101
101
*
102
102
* Extend this class to add additional sink definitions.
103
103
*/
104
- class SinkModelCsv extends Unit {
104
+ deprecated class SinkModelCsv extends Unit {
105
105
/**
106
106
* Holds if `row` specifies a sink definition.
107
107
*
@@ -112,15 +112,15 @@ module ModelInput {
112
112
* indicates that the value at `(type, path)` should be seen as a sink
113
113
* of the given `kind`.
114
114
*/
115
- abstract predicate row ( string row ) ;
115
+ abstract deprecated predicate row ( string row ) ;
116
116
}
117
117
118
118
/**
119
119
* A unit class for adding additional summary model rows.
120
120
*
121
121
* Extend this class to add additional flow summary definitions.
122
122
*/
123
- class SummaryModelCsv extends Unit {
123
+ deprecated class SummaryModelCsv extends Unit {
124
124
/**
125
125
* Holds if `row` specifies a summary definition.
126
126
*
@@ -134,15 +134,15 @@ module ModelInput {
134
134
* `kind` should be either `value` or `taint`, for value-preserving or taint-preserving steps,
135
135
* respectively.
136
136
*/
137
- abstract predicate row ( string row ) ;
137
+ abstract deprecated predicate row ( string row ) ;
138
138
}
139
139
140
140
/**
141
141
* A unit class for adding additional type model rows.
142
142
*
143
143
* Extend this class to add additional type definitions.
144
144
*/
145
- class TypeModelCsv extends Unit {
145
+ deprecated class TypeModelCsv extends Unit {
146
146
/**
147
147
* Holds if `row` specifies a type definition.
148
148
*
@@ -152,7 +152,7 @@ module ModelInput {
152
152
* ```
153
153
* indicates that `(type2, path)` should be seen as an instance of `type1`.
154
154
*/
155
- abstract predicate row ( string row ) ;
155
+ abstract deprecated predicate row ( string row ) ;
156
156
}
157
157
158
158
/**
@@ -187,7 +187,7 @@ module ModelInput {
187
187
/**
188
188
* A unit class for adding additional type variable model rows.
189
189
*/
190
- class TypeVariableModelCsv extends Unit {
190
+ deprecated class TypeVariableModelCsv extends Unit {
191
191
/**
192
192
* Holds if `row` specifies a path through a type variable.
193
193
*
@@ -197,7 +197,7 @@ module ModelInput {
197
197
* ```
198
198
* means `path` can be substituted for a token `TypeVar[name]`.
199
199
*/
200
- abstract predicate row ( string row ) ;
200
+ abstract deprecated predicate row ( string row ) ;
201
201
}
202
202
}
203
203
@@ -216,27 +216,88 @@ abstract class TestAllModels extends Unit { }
216
216
* does not preserve empty trailing substrings.
217
217
*/
218
218
bindingset [ result ]
219
- private string inversePad ( string s ) { s = result + ";dummy" }
219
+ deprecated private string inversePad ( string s ) { s = result + ";dummy" }
220
220
221
- private predicate sourceModel ( string row ) { any ( SourceModelCsv s ) .row ( inversePad ( row ) ) }
221
+ deprecated private predicate sourceModel ( string row ) { any ( SourceModelCsv s ) .row ( inversePad ( row ) ) }
222
222
223
- private predicate sinkModel ( string row ) { any ( SinkModelCsv s ) .row ( inversePad ( row ) ) }
223
+ deprecated private predicate sinkModel ( string row ) { any ( SinkModelCsv s ) .row ( inversePad ( row ) ) }
224
224
225
- private predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( inversePad ( row ) ) }
225
+ deprecated private predicate summaryModel ( string row ) {
226
+ any ( SummaryModelCsv s ) .row ( inversePad ( row ) )
227
+ }
228
+
229
+ deprecated private predicate typeModel ( string row ) { any ( TypeModelCsv s ) .row ( inversePad ( row ) ) }
230
+
231
+ deprecated private predicate typeVariableModel ( string row ) {
232
+ any ( TypeVariableModelCsv s ) .row ( inversePad ( row ) )
233
+ }
234
+
235
+ private class DeprecationAdapter extends Unit {
236
+ abstract predicate sourceModel ( string type , string path , string kind ) ;
237
+
238
+ abstract predicate sinkModel ( string type , string path , string kind ) ;
239
+
240
+ abstract predicate summaryModel ( string type , string path , string input , string output , string kind ) ;
241
+
242
+ abstract predicate typeModel ( string type1 , string type2 , string path ) ;
243
+
244
+ abstract predicate typeVariableModel ( string name , string path ) ;
245
+ }
246
+
247
+ private class DeprecationAdapterImpl extends DeprecationAdapter {
248
+ deprecated override predicate sourceModel ( string type , string path , string kind ) {
249
+ exists ( string row |
250
+ sourceModel ( row ) and
251
+ row .splitAt ( ";" , 0 ) = type and
252
+ row .splitAt ( ";" , 1 ) = path and
253
+ row .splitAt ( ";" , 2 ) = kind
254
+ )
255
+ }
256
+
257
+ deprecated override predicate sinkModel ( string type , string path , string kind ) {
258
+ exists ( string row |
259
+ sinkModel ( row ) and
260
+ row .splitAt ( ";" , 0 ) = type and
261
+ row .splitAt ( ";" , 1 ) = path and
262
+ row .splitAt ( ";" , 2 ) = kind
263
+ )
264
+ }
265
+
266
+ deprecated override predicate summaryModel (
267
+ string type , string path , string input , string output , string kind
268
+ ) {
269
+ exists ( string row |
270
+ summaryModel ( row ) and
271
+ row .splitAt ( ";" , 0 ) = type and
272
+ row .splitAt ( ";" , 1 ) = path and
273
+ row .splitAt ( ";" , 2 ) = input and
274
+ row .splitAt ( ";" , 3 ) = output and
275
+ row .splitAt ( ";" , 4 ) = kind
276
+ )
277
+ }
226
278
227
- private predicate typeModel ( string row ) { any ( TypeModelCsv s ) .row ( inversePad ( row ) ) }
279
+ deprecated override predicate typeModel ( string type1 , string type2 , string path ) {
280
+ exists ( string row |
281
+ typeModel ( row ) and
282
+ row .splitAt ( ";" , 0 ) = type1 and
283
+ row .splitAt ( ";" , 1 ) = type2 and
284
+ row .splitAt ( ";" , 2 ) = path
285
+ )
286
+ }
228
287
229
- private predicate typeVariableModel ( string row ) { any ( TypeVariableModelCsv s ) .row ( inversePad ( row ) ) }
288
+ deprecated override predicate typeVariableModel ( string name , string path ) {
289
+ exists ( string row |
290
+ typeVariableModel ( row ) and
291
+ row .splitAt ( ";" , 0 ) = name and
292
+ row .splitAt ( ";" , 1 ) = path
293
+ )
294
+ }
295
+ }
230
296
231
297
/** Holds if a source model exists for the given parameters. */
232
298
predicate sourceModel ( string type , string path , string kind , string model ) {
233
- exists ( string row |
234
- sourceModel ( row ) and
235
- row .splitAt ( ";" , 0 ) = type and
236
- row .splitAt ( ";" , 1 ) = path and
237
- row .splitAt ( ";" , 2 ) = kind and
238
- model = "SourceModelCsv"
239
- )
299
+ any ( DeprecationAdapter a ) .sourceModel ( type , path , kind ) and
300
+ model = "SourceModelCsv"
240
301
or
241
302
exists ( QlBuiltins:: ExtensionId madId |
242
303
Extensions:: sourceModel ( type , path , kind , madId ) and
@@ -246,13 +307,8 @@ predicate sourceModel(string type, string path, string kind, string model) {
246
307
247
308
/** Holds if a sink model exists for the given parameters. */
248
309
private predicate sinkModel ( string type , string path , string kind , string model ) {
249
- exists ( string row |
250
- sinkModel ( row ) and
251
- row .splitAt ( ";" , 0 ) = type and
252
- row .splitAt ( ";" , 1 ) = path and
253
- row .splitAt ( ";" , 2 ) = kind and
254
- model = "SinkModelCsv"
255
- )
310
+ any ( DeprecationAdapter a ) .sinkModel ( type , path , kind ) and
311
+ model = "SinkModelCsv"
256
312
or
257
313
exists ( QlBuiltins:: ExtensionId madId |
258
314
Extensions:: sinkModel ( type , path , kind , madId ) and
@@ -264,15 +320,8 @@ private predicate sinkModel(string type, string path, string kind, string model)
264
320
private predicate summaryModel (
265
321
string type , string path , string input , string output , string kind , string model
266
322
) {
267
- exists ( string row |
268
- summaryModel ( row ) and
269
- row .splitAt ( ";" , 0 ) = type and
270
- row .splitAt ( ";" , 1 ) = path and
271
- row .splitAt ( ";" , 2 ) = input and
272
- row .splitAt ( ";" , 3 ) = output and
273
- row .splitAt ( ";" , 4 ) = kind and
274
- model = "SummaryModelCsv"
275
- )
323
+ any ( DeprecationAdapter a ) .summaryModel ( type , path , input , output , kind ) and
324
+ model = "SummaryModelCsv"
276
325
or
277
326
exists ( QlBuiltins:: ExtensionId madId |
278
327
Extensions:: summaryModel ( type , path , input , output , kind , madId ) and
@@ -282,29 +331,20 @@ private predicate summaryModel(
282
331
283
332
/** Holds if a type model exists for the given parameters. */
284
333
private predicate typeModel ( string type1 , string type2 , string path ) {
285
- exists ( string row |
286
- typeModel ( row ) and
287
- row .splitAt ( ";" , 0 ) = type1 and
288
- row .splitAt ( ";" , 1 ) = type2 and
289
- row .splitAt ( ";" , 2 ) = path
290
- )
334
+ any ( DeprecationAdapter a ) .typeModel ( type1 , type2 , path )
291
335
or
292
336
Extensions:: typeModel ( type1 , type2 , path )
293
337
}
294
338
295
339
/** Holds if a type variable model exists for the given parameters. */
296
340
private predicate typeVariableModel ( string name , string path ) {
297
- exists ( string row |
298
- typeVariableModel ( row ) and
299
- row .splitAt ( ";" , 0 ) = name and
300
- row .splitAt ( ";" , 1 ) = path
301
- )
341
+ any ( DeprecationAdapter a ) .typeVariableModel ( name , path )
302
342
or
303
343
Extensions:: typeVariableModel ( name , path )
304
344
}
305
345
306
346
/**
307
- * Holds if CSV rows involving `type` might be relevant for the analysis of this database.
347
+ * Holds if rows involving `type` might be relevant for the analysis of this database.
308
348
*/
309
349
predicate isRelevantType ( string type ) {
310
350
(
@@ -327,7 +367,7 @@ predicate isRelevantType(string type) {
327
367
}
328
368
329
369
/**
330
- * Holds if `type,path` is used in some CSV row.
370
+ * Holds if `type,path` is used in some row.
331
371
*/
332
372
pragma [ nomagic]
333
373
predicate isRelevantFullPath ( string type , string path ) {
@@ -340,7 +380,7 @@ predicate isRelevantFullPath(string type, string path) {
340
380
)
341
381
}
342
382
343
- /** A string from a CSV row that should be parsed as an access path. */
383
+ /** A string from a row that should be parsed as an access path. */
344
384
private predicate accessPathRange ( string s ) {
345
385
isRelevantFullPath ( _, s )
346
386
or
@@ -632,7 +672,7 @@ module ModelOutput {
632
672
cached
633
673
private module Cached {
634
674
/**
635
- * Holds if a CSV source model contributed `source` with the given `kind`.
675
+ * Holds if a source model contributed `source` with the given `kind`.
636
676
*/
637
677
cached
638
678
API:: Node getASourceNode ( string kind , string model ) {
@@ -643,7 +683,7 @@ module ModelOutput {
643
683
}
644
684
645
685
/**
646
- * Holds if a CSV sink model contributed `sink` with the given `kind`.
686
+ * Holds if a sink model contributed `sink` with the given `kind`.
647
687
*/
648
688
cached
649
689
API:: Node getASinkNode ( string kind , string model ) {
@@ -654,7 +694,7 @@ module ModelOutput {
654
694
}
655
695
656
696
/**
657
- * Holds if a relevant CSV summary exists for these parameters.
697
+ * Holds if a relevant summary exists for these parameters.
658
698
*/
659
699
cached
660
700
predicate relevantSummaryModel (
@@ -684,7 +724,7 @@ module ModelOutput {
684
724
685
725
/**
686
726
* Holds if `node` is seen as an instance of `type` due to a type definition
687
- * contributed by a CSV model.
727
+ * contributed by a model.
688
728
*/
689
729
cached
690
730
API:: Node getATypeNode ( string type ) { result = getNodeFromType ( type ) }
@@ -718,25 +758,6 @@ module ModelOutput {
718
758
* Gets an error message relating to an invalid CSV row in a model.
719
759
*/
720
760
string getAWarning ( ) {
721
- // Check number of columns
722
- exists ( string row , string kind , int expectedArity , int actualArity |
723
- any ( SourceModelCsv csv ) .row ( row ) and kind = "source" and expectedArity = 3
724
- or
725
- any ( SinkModelCsv csv ) .row ( row ) and kind = "sink" and expectedArity = 3
726
- or
727
- any ( SummaryModelCsv csv ) .row ( row ) and kind = "summary" and expectedArity = 5
728
- or
729
- any ( TypeModelCsv csv ) .row ( row ) and kind = "type" and expectedArity = 3
730
- or
731
- any ( TypeVariableModelCsv csv ) .row ( row ) and kind = "type-variable" and expectedArity = 2
732
- |
733
- actualArity = count ( row .indexOf ( ";" ) ) + 1 and
734
- actualArity != expectedArity and
735
- result =
736
- "CSV " + kind + " row should have " + expectedArity + " columns but has " + actualArity +
737
- ": " + row
738
- )
739
- or
740
761
// Check names and arguments of access path tokens
741
762
exists ( AccessPath path , AccessPathToken token |
742
763
( isRelevantFullPath ( _, path ) or typeVariableModel ( _, path ) ) and
0 commit comments