Skip to content

Commit 47b59d9

Browse files
committed
Swift: Adapt to FlowSummaryImpl changes
1 parent cb05ad8 commit 47b59d9

3 files changed

Lines changed: 30 additions & 20 deletions

File tree

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ private module Cached {
305305
model = ""
306306
or
307307
// flow through a flow summary (extension of `SummaryModelCsv`)
308-
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom,
309-
nodeTo.(FlowSummaryNode).getSummaryNode(), true, model)
308+
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, true, model)
310309
}
311310

312311
/**
@@ -497,10 +496,10 @@ class FlowSummaryNode extends NodeImpl, TFlowSummaryNode {
497496
}
498497

499498
override DataFlowCallable getEnclosingCallable() {
500-
result.asSummarizedCallable() = this.getSummarizedCallable()
499+
result = this.getSummaryNode().getEnclosingCallable()
501500
}
502501

503-
override Location getLocationImpl() { result = this.getSummarizedCallable().getLocation() }
502+
override Location getLocationImpl() { result = this.getSummaryNode().getLocation() }
504503

505504
override string toStringImpl() { result = this.getSummaryNode().toString() }
506505
}
@@ -1014,8 +1013,7 @@ predicate captureValueStep(Node node1, Node node2) {
10141013

10151014
predicate jumpStep(Node pred, Node succ) {
10161015
// models-as-data summarized flow
1017-
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred.(FlowSummaryNode).getSummaryNode(),
1018-
succ.(FlowSummaryNode).getSummaryNode())
1016+
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
10191017
}
10201018

10211019
predicate storeStep(Node node1, ContentSet c, Node node2) {

swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ module Input implements InputSig<Location, DataFlowImplSpecific::SwiftDataFlow>
1616

1717
class SummarizedCallableBase = Function;
1818

19-
class SourceBase = Void;
19+
class SourceBase extends Void {
20+
Location getLocation() { none() }
21+
}
2022

21-
class SinkBase = Void;
23+
class SinkBase = SourceBase;
2224

23-
class FlowSummaryCallBase = Void;
25+
class FlowSummaryCallBase = SourceBase;
2426

2527
predicate callableFromSource(SummarizedCallableBase c) { c.hasBody() }
2628

29+
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
30+
result.asSummarizedCallable() = c
31+
}
32+
2733
ArgumentPosition callbackSelfParameterPosition() { result instanceof ThisArgumentPosition }
2834

2935
ReturnKind getStandardReturnValueKind() { result instanceof NormalReturnKind }
@@ -114,18 +120,24 @@ module Input implements InputSig<Location, DataFlowImplSpecific::SwiftDataFlow>
114120

115121
private import Make<Location, DataFlowImplSpecific::SwiftDataFlow, Input> as Impl
116122

117-
private module StepsInput implements Impl::Private::StepsInputSig {
118-
Impl::Private::SummaryNode getSummaryNode(Node n) {
119-
result = n.(FlowSummaryNode).getSummaryNode()
120-
}
123+
private module Input2 implements Impl::Private::InputSig2 {
124+
private import codeql.util.Void
121125

122-
DataFlowCall getACall(Public::SummarizedCallable sc) { result.asCall().getStaticTarget() = sc }
126+
class SourceSinkReportingElement extends Void {
127+
Location getLocation() { none() }
123128

124-
DataFlowCallable getSourceNodeEnclosingCallable(Input::SourceBase source) { none() }
129+
DataFlowCallable getEnclosingCallable() { none() }
125130

126-
Node getSourceNode(Input::SourceBase source, Impl::Private::SummaryComponentStack s) { none() }
131+
SourceSinkReportingElement getASuccessor(Impl::Private::SummaryComponent sc) { none() }
132+
}
133+
}
134+
135+
private import Impl::Private::Make2<Input2> as Impl2
127136

128-
Node getSinkNode(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
137+
private module StepsInput implements Impl2::StepsInputSig {
138+
Impl2::SummaryNode getSummaryNode(Node n) { result = n.(FlowSummaryNode).getSummaryNode() }
139+
140+
DataFlowCall getACall(Public::SummarizedCallable sc) { result.asCall().getStaticTarget() = sc }
129141
}
130142

131143
module SourceSinkInterpretationInput implements
@@ -252,8 +264,9 @@ module SourceSinkInterpretationInput implements
252264

253265
module Private {
254266
import Impl::Private
267+
import Impl2
255268

256-
module Steps = Impl::Private::Steps<StepsInput>;
269+
module Steps = Impl2::Steps<StepsInput>;
257270

258271
module External {
259272
import Impl::Private::External

swift/ql/lib/codeql/swift/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ private module Cached {
7676
model = ""
7777
or
7878
// flow through a flow summary (extension of `SummaryModelCsv`)
79-
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom,
80-
nodeTo.(FlowSummaryNode).getSummaryNode(), false, model)
79+
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, false, model)
8180
or
8281
any(AdditionalTaintStep a).step(nodeFrom, nodeTo) and model = "AdditionalTaintStep"
8382
}

0 commit comments

Comments
 (0)