@@ -404,10 +404,17 @@ private predicate summaryModel(string row) {
404
404
any ( SummaryModelCsv s ) .row ( row )
405
405
}
406
406
407
+ bindingset [ input]
408
+ private predicate getKind ( string input , string kind , boolean generated ) {
409
+ input .splitAt ( ":" , 0 ) = "generated" and kind = input .splitAt ( ":" , 1 ) and generated = true
410
+ or
411
+ not input .matches ( "%:%" ) and kind = input and generated = false
412
+ }
413
+
407
414
/** Holds if a source model exists for the given parameters. */
408
415
predicate sourceModel (
409
416
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
410
- string output , string kind
417
+ string output , string kind , boolean generated
411
418
) {
412
419
exists ( string row |
413
420
sourceModel ( row ) and
@@ -419,14 +426,14 @@ predicate sourceModel(
419
426
row .splitAt ( ";" , 4 ) = signature and
420
427
row .splitAt ( ";" , 5 ) = ext and
421
428
row .splitAt ( ";" , 6 ) = output and
422
- row .splitAt ( ";" , 7 ) = kind
429
+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
423
430
)
424
431
}
425
432
426
433
/** Holds if a sink model exists for the given parameters. */
427
434
predicate sinkModel (
428
435
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
429
- string input , string kind
436
+ string input , string kind , boolean generated
430
437
) {
431
438
exists ( string row |
432
439
sinkModel ( row ) and
@@ -438,22 +445,22 @@ predicate sinkModel(
438
445
row .splitAt ( ";" , 4 ) = signature and
439
446
row .splitAt ( ";" , 5 ) = ext and
440
447
row .splitAt ( ";" , 6 ) = input and
441
- row .splitAt ( ";" , 7 ) = kind
448
+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
442
449
)
443
450
}
444
451
445
452
/** Holds if a summary model exists for the given parameters. */
446
453
predicate summaryModel (
447
454
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
448
- string input , string output , string kind
455
+ string input , string output , string kind , boolean generated
449
456
) {
450
- summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , _)
457
+ summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , generated , _)
451
458
}
452
459
453
460
/** Holds if a summary model `row` exists for the given parameters. */
454
461
predicate summaryModel (
455
462
string namespace , string type , boolean subtypes , string name , string signature , string ext ,
456
- string input , string output , string kind , string row
463
+ string input , string output , string kind , boolean generated , string row
457
464
) {
458
465
summaryModel ( row ) and
459
466
row .splitAt ( ";" , 0 ) = namespace and
@@ -465,13 +472,13 @@ predicate summaryModel(
465
472
row .splitAt ( ";" , 5 ) = ext and
466
473
row .splitAt ( ";" , 6 ) = input and
467
474
row .splitAt ( ";" , 7 ) = output and
468
- row .splitAt ( ";" , 8 ) = kind
475
+ exists ( string k | row .splitAt ( ";" , 8 ) = k and getKind ( k , kind , generated ) )
469
476
}
470
477
471
478
private predicate relevantPackage ( string package ) {
472
- sourceModel ( package , _, _, _, _, _, _, _) or
473
- sinkModel ( package , _, _, _, _, _, _, _) or
474
- summaryModel ( package , _, _, _, _, _, _, _, _)
479
+ sourceModel ( package , _, _, _, _, _, _, _, _ ) or
480
+ sinkModel ( package , _, _, _, _, _, _, _, _ ) or
481
+ summaryModel ( package , _, _, _, _, _, _, _, _, _ , _ )
475
482
}
476
483
477
484
private predicate packageLink ( string shortpkg , string longpkg ) {
@@ -499,25 +506,25 @@ predicate modelCoverage(string package, int pkgs, string kind, string part, int
499
506
part = "source" and
500
507
n =
501
508
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
502
- string ext , string output |
509
+ string ext , string output , boolean generated |
503
510
canonicalPkgLink ( package , subpkg ) and
504
- sourceModel ( subpkg , type , subtypes , name , signature , ext , output , kind )
511
+ sourceModel ( subpkg , type , subtypes , name , signature , ext , output , kind , generated )
505
512
)
506
513
or
507
514
part = "sink" and
508
515
n =
509
516
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
510
- string ext , string input |
517
+ string ext , string input , boolean generated |
511
518
canonicalPkgLink ( package , subpkg ) and
512
- sinkModel ( subpkg , type , subtypes , name , signature , ext , input , kind )
519
+ sinkModel ( subpkg , type , subtypes , name , signature , ext , input , kind , generated )
513
520
)
514
521
or
515
522
part = "summary" and
516
523
n =
517
524
strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
518
- string ext , string input , string output |
525
+ string ext , string input , string output , boolean generated |
519
526
canonicalPkgLink ( package , subpkg ) and
520
- summaryModel ( subpkg , type , subtypes , name , signature , ext , input , output , kind )
527
+ summaryModel ( subpkg , type , subtypes , name , signature , ext , input , output , kind , generated )
521
528
)
522
529
)
523
530
}
@@ -527,11 +534,11 @@ module CsvValidation {
527
534
/** Holds if some row in a CSV-based flow model appears to contain typos. */
528
535
query predicate invalidModelRow ( string msg ) {
529
536
exists ( string pred , string namespace , string type , string name , string signature , string ext |
530
- sourceModel ( namespace , type , _, name , signature , ext , _, _) and pred = "source"
537
+ sourceModel ( namespace , type , _, name , signature , ext , _, _, _ ) and pred = "source"
531
538
or
532
- sinkModel ( namespace , type , _, name , signature , ext , _, _) and pred = "sink"
539
+ sinkModel ( namespace , type , _, name , signature , ext , _, _, _ ) and pred = "sink"
533
540
or
534
- summaryModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "summary"
541
+ summaryModel ( namespace , type , _, name , signature , ext , _, _, _, _ ) and pred = "summary"
535
542
|
536
543
not namespace .regexpMatch ( "[a-zA-Z0-9_\\.]+" ) and
537
544
msg = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
@@ -550,9 +557,9 @@ module CsvValidation {
550
557
)
551
558
or
552
559
exists ( string pred , string input , string part |
553
- sinkModel ( _, _, _, _, _, _, input , _) and pred = "sink"
560
+ sinkModel ( _, _, _, _, _, _, input , _, _ ) and pred = "sink"
554
561
or
555
- summaryModel ( _, _, _, _, _, _, input , _, _) and pred = "summary"
562
+ summaryModel ( _, _, _, _, _, _, input , _, _, _ ) and pred = "summary"
556
563
|
557
564
(
558
565
invalidSpecComponent ( input , part ) and
@@ -567,9 +574,9 @@ module CsvValidation {
567
574
)
568
575
or
569
576
exists ( string pred , string output , string part |
570
- sourceModel ( _, _, _, _, _, _, output , _) and pred = "source"
577
+ sourceModel ( _, _, _, _, _, _, output , _, _ ) and pred = "source"
571
578
or
572
- summaryModel ( _, _, _, _, _, _, _, output , _) and pred = "summary"
579
+ summaryModel ( _, _, _, _, _, _, _, output , _, _ ) and pred = "summary"
573
580
|
574
581
invalidSpecComponent ( output , part ) and
575
582
not part = "" and
@@ -598,16 +605,22 @@ module CsvValidation {
598
605
msg = "Invalid boolean \"" + b + "\" in " + pred + " model."
599
606
)
600
607
)
608
+ or
609
+ exists ( string row , string kind | summaryModel ( row ) |
610
+ kind = row .splitAt ( ";" , 8 ) and
611
+ not kind = [ "taint" , "value" , "generated:taint" , "generated:value" ] and
612
+ msg = "Invalid kind \"" + kind + "\" in summary model."
613
+ )
601
614
}
602
615
}
603
616
604
617
pragma [ nomagic]
605
618
private predicate elementSpec (
606
619
string namespace , string type , boolean subtypes , string name , string signature , string ext
607
620
) {
608
- sourceModel ( namespace , type , subtypes , name , signature , ext , _, _) or
609
- sinkModel ( namespace , type , subtypes , name , signature , ext , _, _) or
610
- summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _)
621
+ sourceModel ( namespace , type , subtypes , name , signature , ext , _, _, _ ) or
622
+ sinkModel ( namespace , type , subtypes , name , signature , ext , _, _, _ ) or
623
+ summaryModel ( namespace , type , subtypes , name , signature , ext , _, _, _, _ )
611
624
}
612
625
613
626
private string paramsStringPart ( Callable c , int i ) {
0 commit comments