diff --git a/swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll b/swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll index 7fac65ecde5..6c5f580f876 100644 --- a/swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll +++ b/swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll @@ -499,40 +499,22 @@ private predicate interpretSummary( // adapter class for converting Mad summaries to `SummarizedCallable`s private class SummarizedCallableAdapter extends SummarizedCallable { - SummarizedCallableAdapter() { interpretSummary(this, _, _, _, _, _) } + string input_; + string output_; + string kind; + Provenance p_; + string model_; - private predicate relevantSummaryElementManual( - string input, string output, string kind, string model - ) { - exists(Provenance provenance | - interpretSummary(this, input, output, kind, provenance, model) and - provenance.isManual() - ) - } - - private predicate relevantSummaryElementGenerated( - string input, string output, string kind, string model - ) { - exists(Provenance provenance | - interpretSummary(this, input, output, kind, provenance, model) and - provenance.isGenerated() - ) - } + SummarizedCallableAdapter() { interpretSummary(this, input_, output_, kind, p_, model_) } override predicate propagatesFlow( - string input, string output, boolean preservesValue, string model + string input, string output, boolean preservesValue, Provenance p, boolean isExact, string model ) { - exists(string kind | - this.relevantSummaryElementManual(input, output, kind, model) - or - not this.relevantSummaryElementManual(_, _, _, _) and - this.relevantSummaryElementGenerated(input, output, kind, model) - | - if kind = "value" then preservesValue = true else preservesValue = false - ) - } - - override predicate hasProvenance(Provenance provenance) { - interpretSummary(this, _, _, _, provenance, _) + input = input_ and + output = output_ and + (if kind = "value" then preservesValue = true else preservesValue = false) and + p = p_ and + isExact = true and + model = model_ } } diff --git a/swift/ql/lib/codeql/swift/dataflow/FlowSummary.qll b/swift/ql/lib/codeql/swift/dataflow/FlowSummary.qll index 0cec06a7c9c..83b99bd842a 100644 --- a/swift/ql/lib/codeql/swift/dataflow/FlowSummary.qll +++ b/swift/ql/lib/codeql/swift/dataflow/FlowSummary.qll @@ -13,4 +13,9 @@ private module Summaries { private import codeql.swift.frameworks.Frameworks } -class SummarizedCallable = Impl::Public::SummarizedCallable; +/** Provides the `Range` class used to define the extent of `SummarizedCallable`. */ +module SummarizedCallable { + class Range = Impl::Public::SummarizedCallable; +} + +class SummarizedCallable = Impl::Public::RelevantSummarizedCallable; diff --git a/swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll b/swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll index 692e3626080..c1ddb7f781f 100644 --- a/swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll +++ b/swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll @@ -20,6 +20,8 @@ module Input implements InputSig class SinkBase = Void; + predicate callableFromSource(SummarizedCallableBase c) { c.hasBody() } + ArgumentPosition callbackSelfParameterPosition() { result instanceof ThisArgumentPosition } ReturnKind getStandardReturnValueKind() { result instanceof NormalReturnKind }