@@ -124,10 +124,17 @@ predicate sinkModel(string row) { any(SinkModelCsv s).row(row) }
124
124
/** Holds if `row` is a summary model. */
125
125
predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
126
126
127
+ bindingset [ input]
128
+ private predicate getKind ( string input , string kind , boolean generated ) {
129
+ input .splitAt ( ":" , 0 ) = "generated" and kind = input .splitAt ( ":" , 1 ) and generated = true
130
+ or
131
+ not input .matches ( "%:%" ) and kind = input and generated = false
132
+ }
133
+
127
134
/** Holds if a source model exists for the given parameters. */
128
135
predicate sourceModel (
129
136
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
130
- string output , string kind
137
+ string output , string kind , boolean generated
131
138
) {
132
139
exists ( string row |
133
140
sourceModel ( row ) and
@@ -139,14 +146,14 @@ predicate sourceModel(
139
146
row .splitAt ( ";" , 4 ) = signature and
140
147
row .splitAt ( ";" , 5 ) = ext and
141
148
row .splitAt ( ";" , 6 ) = output and
142
- row .splitAt ( ";" , 7 ) = kind
149
+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
143
150
)
144
151
}
145
152
146
153
/** Holds if a sink model exists for the given parameters. */
147
154
predicate sinkModel (
148
155
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
149
- string input , string kind
156
+ string input , string kind , boolean generated
150
157
) {
151
158
exists ( string row |
152
159
sinkModel ( row ) and
@@ -158,22 +165,22 @@ predicate sinkModel(
158
165
row .splitAt ( ";" , 4 ) = signature and
159
166
row .splitAt ( ";" , 5 ) = ext and
160
167
row .splitAt ( ";" , 6 ) = input and
161
- row .splitAt ( ";" , 7 ) = kind
168
+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
162
169
)
163
170
}
164
171
165
172
/** Holds if a summary model exists for the given parameters. */
166
173
predicate summaryModel (
167
174
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
168
- string input , string output , string kind
175
+ string input , string output , string kind , boolean generated
169
176
) {
170
- summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , _)
177
+ summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , generated , _)
171
178
}
172
179
173
180
/** Holds if a summary model `row` exists for the given parameters. */
174
181
predicate summaryModel (
175
182
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
176
- string input , string output , string kind , string row
183
+ string input , string output , string kind , boolean generated , string row
177
184
) {
178
185
summaryModel ( row ) and
179
186
row .splitAt ( ";" , 0 ) = namespace and
@@ -185,14 +192,14 @@ predicate summaryModel(
185
192
row .splitAt ( ";" , 5 ) = ext and
186
193
row .splitAt ( ";" , 6 ) = input and
187
194
row .splitAt ( ";" , 7 ) = output and
188
- row .splitAt ( ";" , 8 ) = kind
195
+ exists ( string k | row .splitAt ( ";" , 8 ) = k and getKind ( k , kind , generated ) )
189
196
}
190
197
191
198
/** Holds if `package` have CSV framework coverage. */
192
199
private predicate packageHasCsvCoverage ( string package ) {
193
- sourceModel ( package , _, _, _, _, _, _, _) or
194
- sinkModel ( package , _, _, _, _, _, _, _) or
195
- summaryModel ( package , _, _, _, _, _, _, _, _)
200
+ sourceModel ( package , _, _, _, _, _, _, _, _ ) or
201
+ sinkModel ( package , _, _, _, _, _, _, _, _ ) or
202
+ summaryModel ( package , _, _, _, _, _, _, _, _, _ )
196
203
}
197
204
198
205
/**
@@ -234,25 +241,25 @@ predicate modelCoverage(string package, int pkgs, string kind, string part, int
234
241
part = "source" and
235
242
n =
236
243
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
237
- string ext , string output |
244
+ string ext , string output , boolean generated |
238
245
canonicalPackageHasASubpackage ( package , subpkg ) and
239
- sourceModel ( subpkg , type , subtypes , name , signature , ext , output , kind )
246
+ sourceModel ( subpkg , type , subtypes , name , signature , ext , output , kind , generated )
240
247
)
241
248
or
242
249
part = "sink" and
243
250
n =
244
251
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
245
- string ext , string input |
252
+ string ext , string input , boolean generated |
246
253
canonicalPackageHasASubpackage ( package , subpkg ) and
247
- sinkModel ( subpkg , type , subtypes , name , signature , ext , input , kind )
254
+ sinkModel ( subpkg , type , subtypes , name , signature , ext , input , kind , generated )
248
255
)
249
256
or
250
257
part = "summary" and
251
258
n =
252
259
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
253
- string ext , string input , string output |
260
+ string ext , string input , string output , boolean generated |
254
261
canonicalPackageHasASubpackage ( package , subpkg ) and
255
- summaryModel ( subpkg , type , subtypes , name , signature , ext , input , output , kind )
262
+ summaryModel ( subpkg , type , subtypes , name , signature , ext , input , output , kind , generated )
256
263
)
257
264
)
258
265
}
@@ -261,9 +268,9 @@ predicate modelCoverage(string package, int pkgs, string kind, string part, int
261
268
module CsvValidation {
262
269
private string getInvalidModelInput ( ) {
263
270
exists ( string pred , AccessPath input , string part |
264
- sinkModel ( _, _, _, _, _, _, input , _) and pred = "sink"
271
+ sinkModel ( _, _, _, _, _, _, input , _, _ ) and pred = "sink"
265
272
or
266
- summaryModel ( _, _, _, _, _, _, input , _, _) and pred = "summary"
273
+ summaryModel ( _, _, _, _, _, _, input , _, _, _ ) and pred = "summary"
267
274
|
268
275
(
269
276
invalidSpecComponent ( input , part ) and
@@ -279,9 +286,9 @@ module CsvValidation {
279
286
280
287
private string getInvalidModelOutput ( ) {
281
288
exists ( string pred , string output , string part |
282
- sourceModel ( _, _, _, _, _, _, output , _) and pred = "source"
289
+ sourceModel ( _, _, _, _, _, _, output , _, _ ) and pred = "source"
283
290
or
284
- summaryModel ( _, _, _, _, _, _, _, output , _) and pred = "summary"
291
+ summaryModel ( _, _, _, _, _, _, _, output , _, _ ) and pred = "summary"
285
292
|
286
293
invalidSpecComponent ( output , part ) and
287
294
not part = "" and
@@ -291,8 +298,9 @@ module CsvValidation {
291
298
}
292
299
293
300
private string getInvalidModelKind ( ) {
294
- exists ( string row , string kind | summaryModel ( row ) |
295
- kind = row .splitAt ( ";" , 8 ) and
301
+ exists ( string row , string k , string kind | summaryModel ( row ) |
302
+ k = row .splitAt ( ";" , 8 ) and
303
+ getKind ( k , kind , _) and
296
304
not kind = [ "taint" , "value" ] and
297
305
result = "Invalid kind \"" + kind + "\" in summary model."
298
306
)
@@ -334,11 +342,11 @@ module CsvValidation {
334
342
335
343
private string getInvalidModelSignature ( ) {
336
344
exists ( string pred , string namespace , string type , string name , string signature , string ext |
337
- sourceModel ( namespace , type , _, name , signature , ext , _, _) and pred = "source"
345
+ sourceModel ( namespace , type , _, name , signature , ext , _, _, _ ) and pred = "source"
338
346
or
339
- sinkModel ( namespace , type , _, name , signature , ext , _, _) and pred = "sink"
347
+ sinkModel ( namespace , type , _, name , signature , ext , _, _, _ ) and pred = "sink"
340
348
or
341
- summaryModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "summary"
349
+ summaryModel ( namespace , type , _, name , signature , ext , _, _, _, _ ) and pred = "summary"
342
350
|
343
351
not namespace .regexpMatch ( "[a-zA-Z0-9_\\./]*" ) and
344
352
result = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
@@ -371,9 +379,9 @@ pragma[nomagic]
371
379
private predicate elementSpec (
372
380
string namespace , string type , boolean subtypes , string name , string signature , string ext
373
381
) {
374
- sourceModel ( namespace , type , subtypes , name , signature , ext , _, _) or
375
- sinkModel ( namespace , type , subtypes , name , signature , ext , _, _) or
376
- summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _)
382
+ sourceModel ( namespace , type , subtypes , name , signature , ext , _, _, _ ) or
383
+ sinkModel ( namespace , type , subtypes , name , signature , ext , _, _, _ ) or
384
+ summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _, _ )
377
385
}
378
386
379
387
private string paramsStringPart ( Function f , int i ) {
@@ -421,7 +429,9 @@ SourceOrSinkElement interpretElement(
421
429
predicate hasExternalSpecification ( Function f ) {
422
430
f = any ( SummarizedCallable sc ) .asFunction ( )
423
431
or
424
- exists ( SourceOrSinkElement e | f = e .asEntity ( ) | sourceElement ( e , _, _) or sinkElement ( e , _, _) )
432
+ exists ( SourceOrSinkElement e | f = e .asEntity ( ) |
433
+ sourceElement ( e , _, _, _) or sinkElement ( e , _, _, _)
434
+ )
425
435
}
426
436
427
437
private predicate parseField ( AccessPathToken c , DataFlow:: FieldContent f ) {
0 commit comments