@@ -163,11 +163,11 @@ private predicate sinkModel(string row) { any(SinkModelCsv s).row(row) }
163163
164164private predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
165165
166- bindingset [ input ]
167- private predicate getKind ( string input , string kind , boolean generated ) {
168- input . splitAt ( ":" , 0 ) = "generated" and kind = input . splitAt ( ":" , 1 ) and generated = true
166+ bindingset [ provenance ]
167+ private boolean isGenerated ( string provenance ) {
168+ provenance = "generated" and result = true
169169 or
170- not input . matches ( "%:%" ) and kind = input and generated = false
170+ provenance != "generated" and result = false
171171}
172172
173173/** Holds if a source model exists for the given parameters. */
@@ -185,7 +185,10 @@ predicate sourceModel(
185185 row .splitAt ( ";" , 4 ) = signature and
186186 row .splitAt ( ";" , 5 ) = ext and
187187 row .splitAt ( ";" , 6 ) = output and
188- exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
188+ row .splitAt ( ";" , 7 ) = kind and
189+ exists ( string provenance |
190+ row .splitAt ( ";" , 8 ) = provenance and generated = isGenerated ( provenance )
191+ )
189192 )
190193}
191194
@@ -204,7 +207,10 @@ predicate sinkModel(
204207 row .splitAt ( ";" , 4 ) = signature and
205208 row .splitAt ( ";" , 5 ) = ext and
206209 row .splitAt ( ";" , 6 ) = input and
207- exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
210+ row .splitAt ( ";" , 7 ) = kind and
211+ exists ( string provenance |
212+ row .splitAt ( ";" , 8 ) = provenance and generated = isGenerated ( provenance )
213+ )
208214 )
209215}
210216
@@ -224,7 +230,10 @@ predicate summaryModel(
224230 row .splitAt ( ";" , 5 ) = ext and
225231 row .splitAt ( ";" , 6 ) = input and
226232 row .splitAt ( ";" , 7 ) = output and
227- exists ( string k | row .splitAt ( ";" , 8 ) = k and getKind ( k , kind , generated ) )
233+ row .splitAt ( ";" , 8 ) = kind and
234+ exists ( string provenance |
235+ row .splitAt ( ";" , 9 ) = provenance and generated = isGenerated ( provenance )
236+ )
228237 )
229238}
230239
@@ -359,23 +368,20 @@ module CsvValidation {
359368 )
360369 )
361370 or
362- exists ( string row , string k , string kind | summaryModel ( row ) |
363- k = row .splitAt ( ";" , 8 ) and
364- getKind ( k , kind , _) and
371+ exists ( string row , string kind | summaryModel ( row ) |
372+ kind = row .splitAt ( ";" , 8 ) and
365373 not kind = [ "taint" , "value" ] and
366374 msg = "Invalid kind \"" + kind + "\" in summary model."
367375 )
368376 or
369- exists ( string row , string k , string kind | sinkModel ( row ) |
370- k = row .splitAt ( ";" , 7 ) and
371- getKind ( k , kind , _) and
377+ exists ( string row , string kind | sinkModel ( row ) |
378+ kind = row .splitAt ( ";" , 7 ) and
372379 not kind = [ "code" , "sql" , "xss" , "remote" , "html" ] and
373380 msg = "Invalid kind \"" + kind + "\" in sink model."
374381 )
375382 or
376- exists ( string row , string k , string kind | sourceModel ( row ) |
377- k = row .splitAt ( ";" , 7 ) and
378- getKind ( k , kind , _) and
383+ exists ( string row , string kind | sourceModel ( row ) |
384+ kind = row .splitAt ( ";" , 7 ) and
379385 not kind = "local" and
380386 msg = "Invalid kind \"" + kind + "\" in source model."
381387 )
0 commit comments