@@ -111,11 +111,14 @@ class SummaryModelCsv extends Unit {
111111 abstract predicate row ( string row ) ;
112112}
113113
114- private predicate sourceModel ( string row ) { any ( SourceModelCsv s ) .row ( row ) }
114+ /** Holds if `row` is a source model. */
115+ predicate sourceModel ( string row ) { any ( SourceModelCsv s ) .row ( row ) }
115116
116- private predicate sinkModel ( string row ) { any ( SinkModelCsv s ) .row ( row ) }
117+ /** Holds if `row` is a sink model. */
118+ predicate sinkModel ( string row ) { any ( SinkModelCsv s ) .row ( row ) }
117119
118- private predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
120+ /** Holds if `row` is a summary model. */
121+ predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
119122
120123/** Holds if a source model exists for the given parameters. */
121124predicate sourceModel (
@@ -232,91 +235,6 @@ predicate modelCoverage(string namespace, int namespaces, string kind, string pa
232235 )
233236}
234237
235- /** Provides a query predicate to check the CSV data for validation errors. */
236- module CsvValidation {
237- /** Holds if some row in a CSV-based flow model appears to contain typos. */
238- query predicate invalidModelRow ( string msg ) {
239- exists ( string pred , string namespace , string type , string name , string signature , string ext |
240- sourceModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "source"
241- or
242- sinkModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "sink"
243- or
244- summaryModel ( namespace , type , _, name , signature , ext , _, _, _, _) and pred = "summary"
245- |
246- not namespace .regexpMatch ( "[a-zA-Z0-9_\\.]+" ) and
247- msg = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
248- or
249- not type .regexpMatch ( "[a-zA-Z0-9_<>,\\+]+" ) and
250- msg = "Dubious type \"" + type + "\" in " + pred + " model."
251- or
252- not name .regexpMatch ( "[a-zA-Z0-9_<>,]*" ) and
253- msg = "Dubious member name \"" + name + "\" in " + pred + " model."
254- or
255- not signature .regexpMatch ( "|\\([a-zA-Z0-9_<>\\.\\+\\*,\\[\\]]*\\)" ) and
256- msg = "Dubious signature \"" + signature + "\" in " + pred + " model."
257- or
258- not ext .regexpMatch ( "|Attribute" ) and
259- msg = "Unrecognized extra API graph element \"" + ext + "\" in " + pred + " model."
260- )
261- or
262- exists ( string pred , AccessPath input , string part |
263- sinkModel ( _, _, _, _, _, _, input , _, _) and pred = "sink"
264- or
265- summaryModel ( _, _, _, _, _, _, input , _, _, _) and pred = "summary"
266- |
267- (
268- invalidSpecComponent ( input , part ) and
269- not part = "" and
270- not ( part = "Argument" and pred = "sink" ) and
271- not parseArg ( part , _)
272- or
273- part = input .getToken ( _) and
274- parseParam ( part , _)
275- ) and
276- msg = "Unrecognized input specification \"" + part + "\" in " + pred + " model."
277- )
278- or
279- exists ( string pred , string output , string part |
280- sourceModel ( _, _, _, _, _, _, output , _, _) and pred = "source"
281- or
282- summaryModel ( _, _, _, _, _, _, _, output , _, _) and pred = "summary"
283- |
284- invalidSpecComponent ( output , part ) and
285- not part = "" and
286- not ( part = [ "Argument" , "Parameter" ] and pred = "source" ) and
287- msg = "Unrecognized output specification \"" + part + "\" in " + pred + " model."
288- )
289- or
290- exists ( string pred , string row , int expect |
291- sourceModel ( row ) and expect = 8 and pred = "source"
292- or
293- sinkModel ( row ) and expect = 8 and pred = "sink"
294- or
295- summaryModel ( row ) and expect = 9 and pred = "summary"
296- |
297- exists ( int cols |
298- cols = 1 + max ( int n | exists ( row .splitAt ( ";" , n ) ) ) and
299- cols != expect and
300- msg =
301- "Wrong number of columns in " + pred + " model row, expected " + expect + ", got " + cols +
302- "."
303- )
304- or
305- exists ( string b |
306- b = row .splitAt ( ";" , 2 ) and
307- not b = [ "true" , "false" ] and
308- msg = "Invalid boolean \"" + b + "\" in " + pred + " model."
309- )
310- )
311- or
312- exists ( string row , string kind | summaryModel ( row ) |
313- kind = row .splitAt ( ";" , 8 ) and
314- not kind = [ "taint" , "value" ] and
315- msg = "Invalid kind \"" + kind + "\" in summary model."
316- )
317- }
318- }
319-
320238private predicate elementSpec (
321239 string namespace , string type , boolean subtypes , string name , string signature , string ext
322240) {
0 commit comments