@@ -162,10 +162,17 @@ private predicate sinkModel(string row) { any(SinkModelCsv s).row(row) }
162
162
163
163
private predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
164
164
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
+
165
172
/** Holds if a source model exists for the given parameters. */
166
173
predicate sourceModel (
167
174
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
168
- string output , string kind
175
+ string output , string kind , boolean generated
169
176
) {
170
177
exists ( string row |
171
178
sourceModel ( row ) and
@@ -177,14 +184,14 @@ predicate sourceModel(
177
184
row .splitAt ( ";" , 4 ) = signature and
178
185
row .splitAt ( ";" , 5 ) = ext and
179
186
row .splitAt ( ";" , 6 ) = output and
180
- row .splitAt ( ";" , 7 ) = kind
187
+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
181
188
)
182
189
}
183
190
184
191
/** Holds if a sink model exists for the given parameters. */
185
192
predicate sinkModel (
186
193
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
187
- string input , string kind
194
+ string input , string kind , boolean generated
188
195
) {
189
196
exists ( string row |
190
197
sinkModel ( row ) and
@@ -196,14 +203,14 @@ predicate sinkModel(
196
203
row .splitAt ( ";" , 4 ) = signature and
197
204
row .splitAt ( ";" , 5 ) = ext and
198
205
row .splitAt ( ";" , 6 ) = input and
199
- row .splitAt ( ";" , 7 ) = kind
206
+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
200
207
)
201
208
}
202
209
203
210
/** Holds if a summary model exists for the given parameters. */
204
211
predicate summaryModel (
205
212
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
207
214
) {
208
215
exists ( string row |
209
216
summaryModel ( row ) and
@@ -216,14 +223,14 @@ predicate summaryModel(
216
223
row .splitAt ( ";" , 5 ) = ext and
217
224
row .splitAt ( ";" , 6 ) = input and
218
225
row .splitAt ( ";" , 7 ) = output and
219
- row .splitAt ( ";" , 8 ) = kind
226
+ exists ( string k | row .splitAt ( ";" , 8 ) = k and getKind ( k , kind , generated ) )
220
227
)
221
228
}
222
229
223
230
private 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 , _, _, _, _, _, _, _, _, _ )
227
234
}
228
235
229
236
private predicate namespaceLink ( string shortns , string longns ) {
@@ -251,25 +258,25 @@ predicate modelCoverage(string namespace, int namespaces, string kind, string pa
251
258
part = "source" and
252
259
n =
253
260
strictcount ( string subns , string type , boolean subtypes , string name , string signature ,
254
- string ext , string output |
261
+ string ext , string output , boolean generated |
255
262
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 )
257
264
)
258
265
or
259
266
part = "sink" and
260
267
n =
261
268
strictcount ( string subns , string type , boolean subtypes , string name , string signature ,
262
- string ext , string input |
269
+ string ext , string input , boolean generated |
263
270
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 )
265
272
)
266
273
or
267
274
part = "summary" and
268
275
n =
269
276
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 |
271
278
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 )
273
280
)
274
281
)
275
282
}
@@ -279,11 +286,11 @@ module CsvValidation {
279
286
/** Holds if some row in a CSV-based flow model appears to contain typos. */
280
287
query predicate invalidModelRow ( string msg ) {
281
288
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"
283
290
or
284
- sinkModel ( namespace , type , _, name , signature , ext , _, _) and pred = "sink"
291
+ sinkModel ( namespace , type , _, name , signature , ext , _, _, _ ) and pred = "sink"
285
292
or
286
- summaryModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "summary"
293
+ summaryModel ( namespace , type , _, name , signature , ext , _, _, _, _ ) and pred = "summary"
287
294
|
288
295
not namespace .regexpMatch ( "[a-zA-Z0-9_\\.]+" ) and
289
296
msg = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
@@ -302,9 +309,9 @@ module CsvValidation {
302
309
)
303
310
or
304
311
exists ( string pred , AccessPath input , string part |
305
- sinkModel ( _, _, _, _, _, _, input , _) and pred = "sink"
312
+ sinkModel ( _, _, _, _, _, _, input , _, _ ) and pred = "sink"
306
313
or
307
- summaryModel ( _, _, _, _, _, _, input , _, _) and pred = "summary"
314
+ summaryModel ( _, _, _, _, _, _, input , _, _, _ ) and pred = "summary"
308
315
|
309
316
(
310
317
invalidSpecComponent ( input , part ) and
@@ -319,9 +326,9 @@ module CsvValidation {
319
326
)
320
327
or
321
328
exists ( string pred , string output , string part |
322
- sourceModel ( _, _, _, _, _, _, output , _) and pred = "source"
329
+ sourceModel ( _, _, _, _, _, _, output , _, _ ) and pred = "source"
323
330
or
324
- summaryModel ( _, _, _, _, _, _, _, output , _) and pred = "summary"
331
+ summaryModel ( _, _, _, _, _, _, _, output , _, _ ) and pred = "summary"
325
332
|
326
333
invalidSpecComponent ( output , part ) and
327
334
not part = "" and
@@ -351,20 +358,23 @@ module CsvValidation {
351
358
)
352
359
)
353
360
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
356
364
not kind = [ "taint" , "value" ] and
357
365
msg = "Invalid kind \"" + kind + "\" in summary model."
358
366
)
359
367
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
362
371
not kind = [ "code" , "sql" , "xss" , "remote" , "html" ] and
363
372
msg = "Invalid kind \"" + kind + "\" in sink model."
364
373
)
365
374
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
368
378
not kind = "local" and
369
379
msg = "Invalid kind \"" + kind + "\" in source model."
370
380
)
@@ -374,9 +384,9 @@ module CsvValidation {
374
384
private predicate elementSpec (
375
385
string namespace , string type , boolean subtypes , string name , string signature , string ext
376
386
) {
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 , _, _, _, _ )
380
390
}
381
391
382
392
private predicate elementSpec (
@@ -502,6 +512,13 @@ Element interpretElement(
502
512
)
503
513
}
504
514
515
+ /**
516
+ * Holds if `c` has a `generated` summary.
517
+ */
518
+ predicate hasSummary ( DataFlowCallable c , boolean generated ) {
519
+ summaryElement ( c , _, _, _, generated )
520
+ }
521
+
505
522
cached
506
523
private module Cached {
507
524
/**
0 commit comments