Skip to content

Commit 9f13c7c

Browse files
committed
C#: Adapt to FlowSummaryImpl changes
1 parent f263799 commit 9f13c7c

3 files changed

Lines changed: 59 additions & 29 deletions

File tree

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,7 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo, string model) {
714714
) and
715715
model = ""
716716
or
717-
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom,
718-
nodeTo.(FlowSummaryNode).getSummaryNode(), true, model)
717+
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, true, model)
719718
}
720719

721720
/**
@@ -1778,7 +1777,7 @@ class FlowSummaryNode extends NodeImpl, TFlowSummaryNode {
17781777
}
17791778

17801779
override DataFlowCallable getEnclosingCallableImpl() {
1781-
result.asSummarizedCallable() = this.getSummarizedCallable()
1780+
result = this.getSummaryNode().getEnclosingCallable()
17821781
}
17831782

17841783
override DataFlowType getDataFlowType() {
@@ -1789,7 +1788,7 @@ class FlowSummaryNode extends NodeImpl, TFlowSummaryNode {
17891788

17901789
override ControlFlowNode getControlFlowNodeImpl() { none() }
17911790

1792-
override Location getLocationImpl() { result = this.getSummarizedCallable().getLocation() }
1791+
override Location getLocationImpl() { result = this.getSummaryNode().getLocation() }
17931792

17941793
override string toStringImpl() { result = this.getSummaryNode().toString() }
17951794
}
@@ -2085,8 +2084,7 @@ predicate jumpStep(Node pred, Node succ) {
20852084
)
20862085
)
20872086
or
2088-
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred.(FlowSummaryNode).getSummaryNode(),
2089-
succ.(FlowSummaryNode).getSummaryNode())
2087+
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
20902088
or
20912089
succ = pred.(LocalFunctionCreationNode).getAnAccess(false)
20922090
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ module Input implements InputSig<Location, DataFlowImplSpecific::CsharpDataFlow>
3030
)
3131
}
3232

33-
class SourceBase = Void;
33+
class SourceBase extends Void {
34+
Location getLocation() { none() }
35+
}
36+
37+
class SinkBase = SourceBase;
3438

35-
class SinkBase = Void;
39+
class FlowSummaryCallBase = SourceBase;
3640

37-
class FlowSummaryCallBase = Void;
41+
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
42+
result.asSummarizedCallable() = c
43+
}
3844

3945
predicate neutralElement(SummarizedCallableBase c, string kind, string provenance, boolean isExact) {
4046
interpretNeutral(c, kind, provenance, isExact)
@@ -122,7 +128,45 @@ module Input implements InputSig<Location, DataFlowImplSpecific::CsharpDataFlow>
122128

123129
private import Make<Location, DataFlowImplSpecific::CsharpDataFlow, Input> as Impl
124130

125-
private module TypesInput implements Impl::Private::TypesInputSig {
131+
private module Input2 implements Impl::Private::InputSig2 {
132+
private import codeql.util.Void
133+
134+
class SourceSinkReportingElement extends Void {
135+
Location getLocation() { none() }
136+
137+
DataFlowCallable getEnclosingCallable() { none() }
138+
}
139+
140+
SourceSinkReportingElement getSourceEntryElement(
141+
Impl::Public::SourceElement source, Impl::Private::SummaryComponent sc
142+
) {
143+
none()
144+
}
145+
146+
SourceSinkReportingElement getNextElement(
147+
SourceSinkReportingElement prev, Impl::Private::SummaryComponent sc
148+
) {
149+
none()
150+
}
151+
152+
bindingset[e, sc]
153+
Node getSourceExitNode(SourceSinkReportingElement e, Impl::Private::SummaryComponent sc) {
154+
none()
155+
}
156+
157+
SourceSinkReportingElement getSinkExitElement(
158+
Impl::Public::SinkElement sink, Impl::Private::SummaryComponent sc
159+
) {
160+
none()
161+
}
162+
163+
bindingset[e, sc]
164+
Node getSinkEntryNode(SourceSinkReportingElement e, Impl::Private::SummaryComponent sc) { none() }
165+
}
166+
167+
private import Impl::Private::Make2<Input2> as Impl2
168+
169+
private module TypesInput implements Impl2::TypesInputSig {
126170
DataFlowType getSyntheticGlobalType(Impl::Private::SyntheticGlobal sg) {
127171
exists(sg) and
128172
result.asGvnType() = Gvn::getGlobalValueNumber(any(ObjectType t))
@@ -195,27 +239,15 @@ private module TypesInput implements Impl::Private::TypesInputSig {
195239
)
196240
}
197241

198-
DataFlowType getSourceType(Input::SourceBase source, Impl::Private::SummaryComponentStack s) {
199-
none()
200-
}
201-
202-
DataFlowType getSinkType(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
242+
DataFlowType getSourceSinkType(Input2::SourceSinkReportingElement e) { none() }
203243
}
204244

205-
private module StepsInput implements Impl::Private::StepsInputSig {
206-
Impl::Private::SummaryNode getSummaryNode(Node n) {
207-
result = n.(FlowSummaryNode).getSummaryNode()
208-
}
245+
private module StepsInput implements Impl2::StepsInputSig {
246+
Impl2::SummaryNode getSummaryNode(Node n) { result = n.(FlowSummaryNode).getSummaryNode() }
209247

210248
DataFlowCall getACall(Public::SummarizedCallable sc) {
211249
sc = viableCallable(result).asSummarizedCallable()
212250
}
213-
214-
DataFlowCallable getSourceNodeEnclosingCallable(Input::SourceBase source) { none() }
215-
216-
Node getSourceNode(Input::SourceBase source, Impl::Private::SummaryComponentStack s) { none() }
217-
218-
Node getSinkNode(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
219251
}
220252

221253
module SourceSinkInterpretationInput implements
@@ -339,9 +371,10 @@ module SourceSinkInterpretationInput implements
339371

340372
module Private {
341373
import Impl::Private
342-
import Impl::Private::Types<TypesInput>
374+
import Impl2
375+
import Types<TypesInput>
343376

344-
module Steps = Impl::Private::Steps<StepsInput>;
377+
module Steps = Impl2::Steps<StepsInput>;
345378

346379
module External {
347380
import Impl::Private::External

csharp/ql/lib/semmle/code/csharp/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ private module Cached {
171171
) and
172172
model = ""
173173
or
174-
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom,
175-
nodeTo.(FlowSummaryNode).getSummaryNode(), false, model)
174+
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, false, model)
176175
}
177176
}
178177

0 commit comments

Comments
 (0)