66
66
*/
67
67
68
68
import swift
69
- private import internal.AccessPathSyntax
70
69
private import internal.DataFlowDispatch
71
70
private import internal.DataFlowPrivate
72
71
private import internal.DataFlowPublic
72
+ private import internal.FlowSummaryImpl
73
73
private import internal.FlowSummaryImpl:: Public
74
+ private import internal.FlowSummaryImpl:: Private
74
75
private import internal.FlowSummaryImpl:: Private:: External
75
- private import internal.FlowSummaryImplSpecific
76
76
private import FlowSummary as FlowSummary
77
77
private import codeql.mad.ModelValidation as SharedModelVal
78
78
@@ -451,7 +451,7 @@ Element interpretElement(
451
451
)
452
452
}
453
453
454
- private predicate parseField ( AccessPathToken c , Content:: FieldContent f ) {
454
+ deprecated private predicate parseField ( AccessPathToken c , Content:: FieldContent f ) {
455
455
exists ( string fieldRegex , string name |
456
456
c .getName ( ) = "Field" and
457
457
fieldRegex = "^([^.]+)$" and
@@ -460,12 +460,12 @@ private predicate parseField(AccessPathToken c, Content::FieldContent f) {
460
460
)
461
461
}
462
462
463
- private predicate parseTuple ( AccessPathToken c , Content:: TupleContent t ) {
463
+ deprecated private predicate parseTuple ( AccessPathToken c , Content:: TupleContent t ) {
464
464
c .getName ( ) = "TupleElement" and
465
465
t .getIndex ( ) = c .getAnArgument ( ) .toInt ( )
466
466
}
467
467
468
- private predicate parseEnum ( AccessPathToken c , Content:: EnumContent e ) {
468
+ deprecated private predicate parseEnum ( AccessPathToken c , Content:: EnumContent e ) {
469
469
c .getName ( ) = "EnumElement" and
470
470
c .getAnArgument ( ) = e .getSignature ( )
471
471
or
@@ -474,7 +474,7 @@ private predicate parseEnum(AccessPathToken c, Content::EnumContent e) {
474
474
}
475
475
476
476
/** Holds if the specification component parses as a `Content`. */
477
- predicate parseContent ( AccessPathToken component , Content content ) {
477
+ deprecated predicate parseContent ( AccessPathToken component , Content content ) {
478
478
parseField ( component , content )
479
479
or
480
480
parseTuple ( component , content )
@@ -497,7 +497,9 @@ private module Cached {
497
497
*/
498
498
cached
499
499
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
+ )
501
503
}
502
504
503
505
/**
@@ -506,8 +508,71 @@ private module Cached {
506
508
*/
507
509
cached
508
510
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
+ )
510
514
}
511
515
}
512
516
513
517
import 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