@@ -162,10 +162,17 @@ private predicate sinkModel(string row) { any(SinkModelCsv s).row(row) }
162162
163163private predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
164164
165+ bindingset [ input]
166+ private predicate getKind ( string input , string kind , boolean generated ) {
167+ input .splitAt ( ":" , 0 ) = "generated" and kind = input .splitAt ( ":" , 1 ) and generated = true
168+ or
169+ not input .matches ( "%:%" ) and kind = input and generated = false
170+ }
171+
165172/** Holds if a source model exists for the given parameters. */
166173predicate sourceModel (
167174 string namespace , string type , boolean subtypes , string name , string signature , string ext ,
168- string output , string kind
175+ string output , string kind , boolean generated
169176) {
170177 exists ( string row |
171178 sourceModel ( row ) and
@@ -177,14 +184,14 @@ predicate sourceModel(
177184 row .splitAt ( ";" , 4 ) = signature and
178185 row .splitAt ( ";" , 5 ) = ext and
179186 row .splitAt ( ";" , 6 ) = output and
180- row .splitAt ( ";" , 7 ) = kind
187+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
181188 )
182189}
183190
184191/** Holds if a sink model exists for the given parameters. */
185192predicate sinkModel (
186193 string namespace , string type , boolean subtypes , string name , string signature , string ext ,
187- string input , string kind
194+ string input , string kind , boolean generated
188195) {
189196 exists ( string row |
190197 sinkModel ( row ) and
@@ -196,14 +203,14 @@ predicate sinkModel(
196203 row .splitAt ( ";" , 4 ) = signature and
197204 row .splitAt ( ";" , 5 ) = ext and
198205 row .splitAt ( ";" , 6 ) = input and
199- row .splitAt ( ";" , 7 ) = kind
206+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
200207 )
201208}
202209
203210/** Holds if a summary model exists for the given parameters. */
204211predicate summaryModel (
205212 string namespace , string type , boolean subtypes , string name , string signature , string ext ,
206- string input , string output , string kind
213+ string input , string output , string kind , boolean generated
207214) {
208215 exists ( string row |
209216 summaryModel ( row ) and
@@ -216,14 +223,14 @@ predicate summaryModel(
216223 row .splitAt ( ";" , 5 ) = ext and
217224 row .splitAt ( ";" , 6 ) = input and
218225 row .splitAt ( ";" , 7 ) = output and
219- row .splitAt ( ";" , 8 ) = kind
226+ exists ( string k | row .splitAt ( ";" , 8 ) = k and getKind ( k , kind , generated ) )
220227 )
221228}
222229
223230private predicate relevantNamespace ( string namespace ) {
224- sourceModel ( namespace , _, _, _, _, _, _, _) or
225- sinkModel ( namespace , _, _, _, _, _, _, _) or
226- summaryModel ( namespace , _, _, _, _, _, _, _, _)
231+ sourceModel ( namespace , _, _, _, _, _, _, _, _ ) or
232+ sinkModel ( namespace , _, _, _, _, _, _, _, _ ) or
233+ summaryModel ( namespace , _, _, _, _, _, _, _, _, _ )
227234}
228235
229236private predicate namespaceLink ( string shortns , string longns ) {
@@ -251,25 +258,25 @@ predicate modelCoverage(string namespace, int namespaces, string kind, string pa
251258 part = "source" and
252259 n =
253260 strictcount ( string subns , string type , boolean subtypes , string name , string signature ,
254- string ext , string output |
261+ string ext , string output , boolean generated |
255262 canonicalNamespaceLink ( namespace , subns ) and
256- sourceModel ( subns , type , subtypes , name , signature , ext , output , kind )
263+ sourceModel ( subns , type , subtypes , name , signature , ext , output , kind , generated )
257264 )
258265 or
259266 part = "sink" and
260267 n =
261268 strictcount ( string subns , string type , boolean subtypes , string name , string signature ,
262- string ext , string input |
269+ string ext , string input , boolean generated |
263270 canonicalNamespaceLink ( namespace , subns ) and
264- sinkModel ( subns , type , subtypes , name , signature , ext , input , kind )
271+ sinkModel ( subns , type , subtypes , name , signature , ext , input , kind , generated )
265272 )
266273 or
267274 part = "summary" and
268275 n =
269276 strictcount ( string subns , string type , boolean subtypes , string name , string signature ,
270- string ext , string input , string output |
277+ string ext , string input , string output , boolean generated |
271278 canonicalNamespaceLink ( namespace , subns ) and
272- summaryModel ( subns , type , subtypes , name , signature , ext , input , output , kind )
279+ summaryModel ( subns , type , subtypes , name , signature , ext , input , output , kind , generated )
273280 )
274281 )
275282}
@@ -279,11 +286,11 @@ module CsvValidation {
279286 /** Holds if some row in a CSV-based flow model appears to contain typos. */
280287 query predicate invalidModelRow ( string msg ) {
281288 exists ( string pred , string namespace , string type , string name , string signature , string ext |
282- sourceModel ( namespace , type , _, name , signature , ext , _, _) and pred = "source"
289+ sourceModel ( namespace , type , _, name , signature , ext , _, _, _ ) and pred = "source"
283290 or
284- sinkModel ( namespace , type , _, name , signature , ext , _, _) and pred = "sink"
291+ sinkModel ( namespace , type , _, name , signature , ext , _, _, _ ) and pred = "sink"
285292 or
286- summaryModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "summary"
293+ summaryModel ( namespace , type , _, name , signature , ext , _, _, _, _ ) and pred = "summary"
287294 |
288295 not namespace .regexpMatch ( "[a-zA-Z0-9_\\.]+" ) and
289296 msg = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
@@ -302,9 +309,9 @@ module CsvValidation {
302309 )
303310 or
304311 exists ( string pred , AccessPath input , string part |
305- sinkModel ( _, _, _, _, _, _, input , _) and pred = "sink"
312+ sinkModel ( _, _, _, _, _, _, input , _, _ ) and pred = "sink"
306313 or
307- summaryModel ( _, _, _, _, _, _, input , _, _) and pred = "summary"
314+ summaryModel ( _, _, _, _, _, _, input , _, _, _ ) and pred = "summary"
308315 |
309316 (
310317 invalidSpecComponent ( input , part ) and
@@ -319,9 +326,9 @@ module CsvValidation {
319326 )
320327 or
321328 exists ( string pred , string output , string part |
322- sourceModel ( _, _, _, _, _, _, output , _) and pred = "source"
329+ sourceModel ( _, _, _, _, _, _, output , _, _ ) and pred = "source"
323330 or
324- summaryModel ( _, _, _, _, _, _, _, output , _) and pred = "summary"
331+ summaryModel ( _, _, _, _, _, _, _, output , _, _ ) and pred = "summary"
325332 |
326333 invalidSpecComponent ( output , part ) and
327334 not part = "" and
@@ -351,20 +358,23 @@ module CsvValidation {
351358 )
352359 )
353360 or
354- exists ( string row , string kind | summaryModel ( row ) |
355- kind = row .splitAt ( ";" , 8 ) and
361+ exists ( string row , string k , string kind | summaryModel ( row ) |
362+ k = row .splitAt ( ";" , 8 ) and
363+ getKind ( k , kind , _) and
356364 not kind = [ "taint" , "value" ] and
357365 msg = "Invalid kind \"" + kind + "\" in summary model."
358366 )
359367 or
360- exists ( string row , string kind | sinkModel ( row ) |
361- kind = row .splitAt ( ";" , 7 ) and
368+ exists ( string row , string k , string kind | sinkModel ( row ) |
369+ k = row .splitAt ( ";" , 7 ) and
370+ getKind ( k , kind , _) and
362371 not kind = [ "code" , "sql" , "xss" , "remote" , "html" ] and
363372 msg = "Invalid kind \"" + kind + "\" in sink model."
364373 )
365374 or
366- exists ( string row , string kind | sourceModel ( row ) |
367- kind = row .splitAt ( ";" , 7 ) and
375+ exists ( string row , string k , string kind | sourceModel ( row ) |
376+ k = row .splitAt ( ";" , 7 ) and
377+ getKind ( k , kind , _) and
368378 not kind = "local" and
369379 msg = "Invalid kind \"" + kind + "\" in source model."
370380 )
@@ -374,9 +384,9 @@ module CsvValidation {
374384private predicate elementSpec (
375385 string namespace , string type , boolean subtypes , string name , string signature , string ext
376386) {
377- sourceModel ( namespace , type , subtypes , name , signature , ext , _, _) or
378- sinkModel ( namespace , type , subtypes , name , signature , ext , _, _) or
379- summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _)
387+ sourceModel ( namespace , type , subtypes , name , signature , ext , _, _, _ ) or
388+ sinkModel ( namespace , type , subtypes , name , signature , ext , _, _, _ ) or
389+ summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _, _ )
380390}
381391
382392private predicate elementSpec (
@@ -502,6 +512,13 @@ Element interpretElement(
502512 )
503513}
504514
515+ /**
516+ * Holds if `c` has a `generated` summary.
517+ */
518+ predicate hasSummary ( DataFlowCallable c , boolean generated ) {
519+ summaryElement ( c , _, _, _, generated )
520+ }
521+
505522cached
506523private module Cached {
507524 /**
0 commit comments