6666 */
6767
6868import swift
69- private import internal.AccessPathSyntax
7069private import internal.DataFlowDispatch
7170private import internal.DataFlowPrivate
7271private import internal.DataFlowPublic
72+ private import internal.FlowSummaryImpl
7373private import internal.FlowSummaryImpl:: Public
74+ private import internal.FlowSummaryImpl:: Private
7475private import internal.FlowSummaryImpl:: Private:: External
75- private import internal.FlowSummaryImplSpecific
7676private import FlowSummary as FlowSummary
7777private import codeql.mad.ModelValidation as SharedModelVal
7878
@@ -451,7 +451,7 @@ Element interpretElement(
451451 )
452452}
453453
454- private predicate parseField ( AccessPathToken c , Content:: FieldContent f ) {
454+ deprecated private predicate parseField ( AccessPathToken c , Content:: FieldContent f ) {
455455 exists ( string fieldRegex , string name |
456456 c .getName ( ) = "Field" and
457457 fieldRegex = "^([^.]+)$" and
@@ -460,12 +460,12 @@ private predicate parseField(AccessPathToken c, Content::FieldContent f) {
460460 )
461461}
462462
463- private predicate parseTuple ( AccessPathToken c , Content:: TupleContent t ) {
463+ deprecated private predicate parseTuple ( AccessPathToken c , Content:: TupleContent t ) {
464464 c .getName ( ) = "TupleElement" and
465465 t .getIndex ( ) = c .getAnArgument ( ) .toInt ( )
466466}
467467
468- private predicate parseEnum ( AccessPathToken c , Content:: EnumContent e ) {
468+ deprecated private predicate parseEnum ( AccessPathToken c , Content:: EnumContent e ) {
469469 c .getName ( ) = "EnumElement" and
470470 c .getAnArgument ( ) = e .getSignature ( )
471471 or
@@ -474,7 +474,7 @@ private predicate parseEnum(AccessPathToken c, Content::EnumContent e) {
474474}
475475
476476/** Holds if the specification component parses as a `Content`. */
477- predicate parseContent ( AccessPathToken component , Content content ) {
477+ deprecated predicate parseContent ( AccessPathToken component , Content content ) {
478478 parseField ( component , content )
479479 or
480480 parseTuple ( component , content )
@@ -497,7 +497,9 @@ private module Cached {
497497 */
498498 cached
499499 predicate sourceNode ( Node node , string kind ) {
500- exists ( InterpretNode n | isSourceNode ( n , kind ) and n .asNode ( ) = node )
500+ exists ( SourceSinkInterpretationInput:: InterpretNode n |
501+ isSourceNode ( n , kind ) and n .asNode ( ) = node
502+ )
501503 }
502504
503505 /**
@@ -506,8 +508,71 @@ private module Cached {
506508 */
507509 cached
508510 predicate sinkNode ( Node node , string kind ) {
509- exists ( InterpretNode n | isSinkNode ( n , kind ) and n .asNode ( ) = node )
511+ exists ( SourceSinkInterpretationInput:: InterpretNode n |
512+ isSinkNode ( n , kind ) and n .asNode ( ) = node
513+ )
510514 }
511515}
512516
513517import Cached
518+
519+ private predicate interpretSummary (
520+ Function f , string input , string output , string kind , string provenance
521+ ) {
522+ exists (
523+ string namespace , string type , boolean subtypes , string name , string signature , string ext
524+ |
525+ summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , provenance ) and
526+ f = interpretElement ( namespace , type , subtypes , name , signature , ext )
527+ )
528+ }
529+
530+ private class SummarizedCallableAdapter extends SummarizedCallable {
531+ SummarizedCallableAdapter ( ) { interpretSummary ( this , _, _, _, _) }
532+
533+ private predicate relevantSummaryElementManual ( string input , string output , string kind ) {
534+ exists ( Provenance provenance |
535+ interpretSummary ( this , input , output , kind , provenance ) and
536+ provenance .isManual ( )
537+ )
538+ }
539+
540+ private predicate relevantSummaryElementGenerated ( string input , string output , string kind ) {
541+ exists ( Provenance provenance |
542+ interpretSummary ( this , input , output , kind , provenance ) and
543+ provenance .isGenerated ( )
544+ )
545+ }
546+
547+ override predicate propagatesFlow ( string input , string output , boolean preservesValue ) {
548+ exists ( string kind |
549+ this .relevantSummaryElementManual ( input , output , kind )
550+ or
551+ not this .relevantSummaryElementManual ( _, _, _) and
552+ this .relevantSummaryElementGenerated ( input , output , kind )
553+ |
554+ if kind = "value" then preservesValue = true else preservesValue = false
555+ )
556+ }
557+
558+ override predicate hasProvenance ( Provenance provenance ) {
559+ interpretSummary ( this , _, _, _, provenance )
560+ }
561+ }
562+
563+ private class NeutralCallableAdapter extends NeutralCallable {
564+ string kind ;
565+ string provenance_ ;
566+
567+ NeutralCallableAdapter ( ) {
568+ // Neutral models have not been implemented for Swift.
569+ none ( ) and
570+ exists ( this ) and
571+ exists ( kind ) and
572+ exists ( provenance_ )
573+ }
574+
575+ override string getKind ( ) { result = kind }
576+
577+ override predicate hasProvenance ( Provenance provenance ) { provenance = provenance_ }
578+ }
0 commit comments