Skip to content

Commit aae96d0

Browse files
committed
C#: Adapt to FlowSummaryImpl changes
1 parent 793f754 commit aae96d0

2 files changed

Lines changed: 50 additions & 18 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ class FlowSummaryNode extends NodeImpl, TFlowSummaryNode {
17781778
}
17791779

17801780
override DataFlowCallable getEnclosingCallableImpl() {
1781-
result.asSummarizedCallable() = this.getSummarizedCallable()
1781+
result = this.getSummaryNode().getEnclosingCallable()
17821782
}
17831783

17841784
override DataFlowType getDataFlowType() {
@@ -1789,7 +1789,7 @@ class FlowSummaryNode extends NodeImpl, TFlowSummaryNode {
17891789

17901790
override ControlFlowNode getControlFlowNodeImpl() { none() }
17911791

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

17941794
override string toStringImpl() { result = this.getSummaryNode().toString() }
17951795
}

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

Lines changed: 48 additions & 16 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,40 @@ 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+
bindingset[source, s]
141+
SourceSinkReportingElement getSourceEntryElement(
142+
Impl::Public::SourceElement source, Impl::Private::SummaryComponentStack s
143+
) {
144+
none()
145+
}
146+
147+
bindingset[e, s]
148+
Node getSourceExitNode(SourceSinkReportingElement e, Impl::Private::SummaryComponentStack s) {
149+
none()
150+
}
151+
152+
SourceSinkReportingElement getSinkExitElement(
153+
Impl::Public::SinkElement sink, Impl::Private::SummaryComponent sc
154+
) {
155+
none()
156+
}
157+
158+
bindingset[e, sc]
159+
Node getSinkEntryNode(SourceSinkReportingElement e, Impl::Private::SummaryComponent sc) { none() }
160+
}
161+
162+
private import Impl::Private::Make2<Input2> as Impl2
163+
164+
private module TypesInput implements Impl2::TypesInputSig {
126165
DataFlowType getSyntheticGlobalType(Impl::Private::SyntheticGlobal sg) {
127166
exists(sg) and
128167
result.asGvnType() = Gvn::getGlobalValueNumber(any(ObjectType t))
@@ -202,20 +241,12 @@ private module TypesInput implements Impl::Private::TypesInputSig {
202241
DataFlowType getSinkType(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
203242
}
204243

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

210247
DataFlowCall getACall(Public::SummarizedCallable sc) {
211248
sc = viableCallable(result).asSummarizedCallable()
212249
}
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() }
219250
}
220251

221252
module SourceSinkInterpretationInput implements
@@ -339,9 +370,10 @@ module SourceSinkInterpretationInput implements
339370

340371
module Private {
341372
import Impl::Private
342-
import Impl::Private::Types<TypesInput>
373+
import Impl2
374+
import Types<TypesInput>
343375

344-
module Steps = Impl::Private::Steps<StepsInput>;
376+
module Steps = Impl2::Steps<StepsInput>;
345377

346378
module External {
347379
import Impl::Private::External

0 commit comments

Comments
 (0)