@@ -428,13 +428,17 @@ private class SummaryModelCsvBase extends SummaryModelCsv {
428428 }
429429}
430430
431- private predicate sourceModel ( string row ) { any ( SourceModelCsv s ) .row ( row ) }
431+ /** Holds if `row` is a source model. */
432+ predicate sourceModel ( string row ) { any ( SourceModelCsv s ) .row ( row ) }
432433
433- private predicate sinkModel ( string row ) { any ( SinkModelCsv s ) .row ( row ) }
434+ /** Holds if `row` is a sink model. */
435+ predicate sinkModel ( string row ) { any ( SinkModelCsv s ) .row ( row ) }
434436
435- private predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
437+ /** Holds if `row` is a summary model. */
438+ predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
436439
437- private predicate negativeSummaryModel ( string row ) { any ( NegativeSummaryModelCsv s ) .row ( row ) }
440+ /** Holds if `row` is negative summary model. */
441+ predicate negativeSummaryModel ( string row ) { any ( NegativeSummaryModelCsv s ) .row ( row ) }
438442
439443/** Holds if a source model exists for the given parameters. */
440444predicate sourceModel (
@@ -571,123 +575,6 @@ predicate modelCoverage(string package, int pkgs, string kind, string part, int
571575 )
572576}
573577
574- /** Provides a query predicate to check the CSV data for validation errors. */
575- module CsvValidation {
576- /** Holds if some row in a CSV-based flow model appears to contain typos. */
577- query predicate invalidModelRow ( string msg ) {
578- exists (
579- string pred , string namespace , string type , string name , string signature , string ext ,
580- string provenance
581- |
582- sourceModel ( namespace , type , _, name , signature , ext , _, _, provenance ) and pred = "source"
583- or
584- sinkModel ( namespace , type , _, name , signature , ext , _, _, provenance ) and pred = "sink"
585- or
586- summaryModel ( namespace , type , _, name , signature , ext , _, _, _, provenance ) and
587- pred = "summary"
588- or
589- negativeSummaryModel ( namespace , type , name , signature , provenance ) and
590- ext = "" and
591- pred = "nonesummary"
592- |
593- not namespace .regexpMatch ( "[a-zA-Z0-9_\\.]+" ) and
594- msg = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
595- or
596- not type .regexpMatch ( "[a-zA-Z0-9_\\$<>]+" ) and
597- msg = "Dubious type \"" + type + "\" in " + pred + " model."
598- or
599- not name .regexpMatch ( "[a-zA-Z0-9_]*" ) and
600- msg = "Dubious name \"" + name + "\" in " + pred + " model."
601- or
602- not signature .regexpMatch ( "|\\([a-zA-Z0-9_\\.\\$<>,\\[\\]]*\\)" ) and
603- msg = "Dubious signature \"" + signature + "\" in " + pred + " model."
604- or
605- not ext .regexpMatch ( "|Annotated" ) and
606- msg = "Unrecognized extra API graph element \"" + ext + "\" in " + pred + " model."
607- or
608- not provenance = [ "manual" , "generated" ] and
609- msg = "Unrecognized provenance description \"" + provenance + "\" in " + pred + " model."
610- )
611- or
612- exists ( string pred , string input , string part |
613- sinkModel ( _, _, _, _, _, _, input , _, _) and pred = "sink"
614- or
615- summaryModel ( _, _, _, _, _, _, input , _, _, _) and pred = "summary"
616- |
617- (
618- invalidSpecComponent ( input , part ) and
619- not part = "" and
620- not ( part = "Argument" and pred = "sink" ) and
621- not parseArg ( part , _)
622- or
623- part = input .( AccessPath ) .getToken ( 0 ) and
624- parseParam ( part , _)
625- ) and
626- msg = "Unrecognized input specification \"" + part + "\" in " + pred + " model."
627- )
628- or
629- exists ( string pred , string output , string part |
630- sourceModel ( _, _, _, _, _, _, output , _, _) and pred = "source"
631- or
632- summaryModel ( _, _, _, _, _, _, _, output , _, _) and pred = "summary"
633- |
634- invalidSpecComponent ( output , part ) and
635- not part = "" and
636- not ( part = [ "Argument" , "Parameter" ] and pred = "source" ) and
637- msg = "Unrecognized output specification \"" + part + "\" in " + pred + " model."
638- )
639- or
640- exists ( string pred , string row , int expect |
641- sourceModel ( row ) and expect = 9 and pred = "source"
642- or
643- sinkModel ( row ) and expect = 9 and pred = "sink"
644- or
645- summaryModel ( row ) and expect = 10 and pred = "summary"
646- |
647- exists ( int cols |
648- cols = 1 + max ( int n | exists ( row .splitAt ( ";" , n ) ) ) and
649- cols != expect and
650- msg =
651- "Wrong number of columns in " + pred + " model row, expected " + expect + ", got " + cols +
652- " in " + row + "."
653- )
654- or
655- exists ( string b |
656- b = row .splitAt ( ";" , 2 ) and
657- not b = [ "true" , "false" ] and
658- msg = "Invalid boolean \"" + b + "\" in " + pred + " model."
659- )
660- )
661- or
662- exists ( string row , string kind | summaryModel ( row ) |
663- kind = row .splitAt ( ";" , 8 ) and
664- not kind = [ "taint" , "value" ] and
665- msg = "Invalid kind \"" + kind + "\" in summary model."
666- )
667- or
668- exists ( string row , string kind | sinkModel ( row ) |
669- kind = row .splitAt ( ";" , 7 ) and
670- not kind =
671- [
672- "open-url" , "jndi-injection" , "ldap" , "sql" , "jdbc-url" , "logging" , "mvel" , "xpath" ,
673- "groovy" , "xss" , "ognl-injection" , "intent-start" , "pending-intent-sent" ,
674- "url-open-stream" , "url-redirect" , "create-file" , "write-file" , "set-hostname-verifier" ,
675- "header-splitting" , "information-leak" , "xslt" , "jexl" , "bean-validation"
676- ] and
677- not kind .matches ( "regex-use%" ) and
678- not kind .matches ( "qltest%" ) and
679- msg = "Invalid kind \"" + kind + "\" in sink model."
680- )
681- or
682- exists ( string row , string kind | sourceModel ( row ) |
683- kind = row .splitAt ( ";" , 7 ) and
684- not kind = [ "remote" , "contentprovider" , "android-widget" , "android-external-storage-dir" ] and
685- not kind .matches ( "qltest%" ) and
686- msg = "Invalid kind \"" + kind + "\" in source model."
687- )
688- }
689- }
690-
691578pragma [ nomagic]
692579private predicate elementSpec (
693580 string namespace , string type , boolean subtypes , string name , string signature , string ext
0 commit comments