@@ -404,10 +404,17 @@ private predicate summaryModel(string row) {
404404 any ( SummaryModelCsv s ) .row ( row )
405405}
406406
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+
407414/** Holds if a source model exists for the given parameters. */
408415predicate sourceModel (
409416 string namespace , string type , boolean subtypes , string name , string signature , string ext ,
410- string output , string kind
417+ string output , string kind , boolean generated
411418) {
412419 exists ( string row |
413420 sourceModel ( row ) and
@@ -419,14 +426,14 @@ predicate sourceModel(
419426 row .splitAt ( ";" , 4 ) = signature and
420427 row .splitAt ( ";" , 5 ) = ext and
421428 row .splitAt ( ";" , 6 ) = output and
422- row .splitAt ( ";" , 7 ) = kind
429+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
423430 )
424431}
425432
426433/** Holds if a sink model exists for the given parameters. */
427434predicate sinkModel (
428435 string namespace , string type , boolean subtypes , string name , string signature , string ext ,
429- string input , string kind
436+ string input , string kind , boolean generated
430437) {
431438 exists ( string row |
432439 sinkModel ( row ) and
@@ -438,22 +445,22 @@ predicate sinkModel(
438445 row .splitAt ( ";" , 4 ) = signature and
439446 row .splitAt ( ";" , 5 ) = ext and
440447 row .splitAt ( ";" , 6 ) = input and
441- row .splitAt ( ";" , 7 ) = kind
448+ exists ( string k | row .splitAt ( ";" , 7 ) = k and getKind ( k , kind , generated ) )
442449 )
443450}
444451
445452/** Holds if a summary model exists for the given parameters. */
446453predicate summaryModel (
447454 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
449456) {
450- summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , _)
457+ summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , generated , _)
451458}
452459
453460/** Holds if a summary model `row` exists for the given parameters. */
454461predicate summaryModel (
455462 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
457464) {
458465 summaryModel ( row ) and
459466 row .splitAt ( ";" , 0 ) = namespace and
@@ -465,13 +472,13 @@ predicate summaryModel(
465472 row .splitAt ( ";" , 5 ) = ext and
466473 row .splitAt ( ";" , 6 ) = input and
467474 row .splitAt ( ";" , 7 ) = output and
468- row .splitAt ( ";" , 8 ) = kind
475+ exists ( string k | row .splitAt ( ";" , 8 ) = k and getKind ( k , kind , generated ) )
469476}
470477
471478private 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 , _, _, _, _, _, _, _, _, _ , _ )
475482}
476483
477484private predicate packageLink ( string shortpkg , string longpkg ) {
@@ -499,25 +506,25 @@ predicate modelCoverage(string package, int pkgs, string kind, string part, int
499506 part = "source" and
500507 n =
501508 strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
502- string ext , string output |
509+ string ext , string output , boolean generated |
503510 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 )
505512 )
506513 or
507514 part = "sink" and
508515 n =
509516 strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
510- string ext , string input |
517+ string ext , string input , boolean generated |
511518 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 )
513520 )
514521 or
515522 part = "summary" and
516523 n =
517524 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 |
519526 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 )
521528 )
522529 )
523530}
@@ -527,11 +534,11 @@ module CsvValidation {
527534 /** Holds if some row in a CSV-based flow model appears to contain typos. */
528535 query predicate invalidModelRow ( string msg ) {
529536 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"
531538 or
532- sinkModel ( namespace , type , _, name , signature , ext , _, _) and pred = "sink"
539+ sinkModel ( namespace , type , _, name , signature , ext , _, _, _ ) and pred = "sink"
533540 or
534- summaryModel ( namespace , type , _, name , signature , ext , _, _, _) and pred = "summary"
541+ summaryModel ( namespace , type , _, name , signature , ext , _, _, _, _ ) and pred = "summary"
535542 |
536543 not namespace .regexpMatch ( "[a-zA-Z0-9_\\.]+" ) and
537544 msg = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
@@ -550,9 +557,9 @@ module CsvValidation {
550557 )
551558 or
552559 exists ( string pred , string input , string part |
553- sinkModel ( _, _, _, _, _, _, input , _) and pred = "sink"
560+ sinkModel ( _, _, _, _, _, _, input , _, _ ) and pred = "sink"
554561 or
555- summaryModel ( _, _, _, _, _, _, input , _, _) and pred = "summary"
562+ summaryModel ( _, _, _, _, _, _, input , _, _, _ ) and pred = "summary"
556563 |
557564 (
558565 invalidSpecComponent ( input , part ) and
@@ -567,9 +574,9 @@ module CsvValidation {
567574 )
568575 or
569576 exists ( string pred , string output , string part |
570- sourceModel ( _, _, _, _, _, _, output , _) and pred = "source"
577+ sourceModel ( _, _, _, _, _, _, output , _, _ ) and pred = "source"
571578 or
572- summaryModel ( _, _, _, _, _, _, _, output , _) and pred = "summary"
579+ summaryModel ( _, _, _, _, _, _, _, output , _, _ ) and pred = "summary"
573580 |
574581 invalidSpecComponent ( output , part ) and
575582 not part = "" and
@@ -598,16 +605,22 @@ module CsvValidation {
598605 msg = "Invalid boolean \"" + b + "\" in " + pred + " model."
599606 )
600607 )
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+ )
601614 }
602615}
603616
604617pragma [ nomagic]
605618private predicate elementSpec (
606619 string namespace , string type , boolean subtypes , string name , string signature , string ext
607620) {
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 , _, _, _, _ )
611624}
612625
613626private string paramsStringPart ( Callable c , int i ) {
0 commit comments