Skip to content

Commit f2e440a

Browse files
committed
PS: Fix dataflow after the changes in github#22145.
1 parent 1ca05ad commit f2e440a

3 files changed

Lines changed: 39 additions & 23 deletions

File tree

‎powershell/ql/lib/semmle/code/powershell/dataflow/internal/DataFlowPrivate.qll‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ module LocalFlow {
179179
FlowSummaryNode nodeFrom, FlowSummaryNode nodeTo, FlowSummaryImpl::Public::SummarizedCallable c,
180180
string model
181181
) {
182-
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo.getSummaryNode(), true, model) and
182+
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, true, model) and
183183
c = nodeFrom.getSummarizedCallable()
184184
}
185185

@@ -188,8 +188,7 @@ module LocalFlow {
188188
or
189189
nodeFrom =
190190
unique(FlowSummaryNode n1 |
191-
FlowSummaryImpl::Private::Steps::summaryLocalStep(n1,
192-
nodeTo.(FlowSummaryNode).getSummaryNode(), true, _)
191+
FlowSummaryImpl::Private::Steps::summaryLocalStep(n1, nodeTo, true, _)
193192
)
194193
}
195194
}
@@ -737,10 +736,10 @@ class FlowSummaryNode extends NodeImpl, TFlowSummaryNode {
737736
override CfgScope getCfgScope() { none() }
738737

739738
override DataFlowCallable getEnclosingCallable() {
740-
result.asLibraryCallable() = this.getSummarizedCallable()
739+
result = this.getSummaryNode().getEnclosingCallable()
741740
}
742741

743-
override EmptyLocation getLocationImpl() { any() }
742+
override Location getLocationImpl() { result = this.getSummaryNode().getLocation() }
744743

745744
override predicate nodeIsHidden() { this.getSummaryNode().isHidden() }
746745

@@ -934,8 +933,7 @@ predicate jumpStep(Node pred, Node succ) {
934933
def.definesAt(pred.(EnvVarNode).getVariable(), any(EntryBasicBlock entry), -1)
935934
)
936935
or
937-
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred.(FlowSummaryNode).getSummaryNode(),
938-
succ.(FlowSummaryNode).getSummaryNode())
936+
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
939937
}
940938

941939
private predicate arrayExprStore(Node node1, ContentSet cs, Node node2, CfgNodes::ExprCfgNode e) {

‎powershell/ql/lib/semmle/code/powershell/dataflow/internal/FlowSummaryImpl.qll‎

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,28 @@ private import DataFlowImplSpecific::Public
1212
module Input implements InputSig<Location, DataFlowImplSpecific::PowershellDataFlow> {
1313
private import codeql.util.Void
1414

15-
class SummarizedCallableBase = string;
15+
class SummarizedCallableBase extends string {
16+
bindingset[this]
17+
SummarizedCallableBase() { exists(this) }
1618

17-
class SourceBase = Void;
19+
bindingset[this]
20+
Location getLocation() { result instanceof EmptyLocation }
21+
}
22+
23+
class SourceBase extends Void {
24+
Location getLocation() { none() }
25+
}
1826

19-
class SinkBase = Void;
27+
class SinkBase = SourceBase;
2028

21-
class FlowSummaryCallBase = Void;
29+
class FlowSummaryCallBase = SourceBase;
2230

2331
predicate callableFromSource(SummarizedCallableBase c) { none() }
2432

33+
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
34+
result.asLibraryCallable() = c
35+
}
36+
2537
ArgumentPosition callbackSelfParameterPosition() { none() }
2638

2739
ReturnKind getStandardReturnValueKind() { result instanceof NormalReturnKind }
@@ -125,28 +137,35 @@ module Input implements InputSig<Location, DataFlowImplSpecific::PowershellDataF
125137

126138
private import Make<Location, DataFlowImplSpecific::PowershellDataFlow, Input> as Impl
127139

128-
private module StepsInput implements Impl::Private::StepsInputSig {
129-
Impl::Private::SummaryNode getSummaryNode(Node n) {
130-
result = n.(FlowSummaryNode).getSummaryNode()
140+
private module Input2 implements Impl::Private::InputSig2 {
141+
private import codeql.util.Void
142+
143+
class SourceSinkReportingElement extends Void {
144+
Location getLocation() { none() }
145+
146+
DataFlowCallable getEnclosingCallable() { none() }
147+
148+
SourceSinkReportingElement getASuccessor(Impl::Private::SummaryComponent sc) { none() }
131149
}
150+
}
151+
152+
private import Impl::Private::Make2<Input2> as Impl2
153+
154+
private module StepsInput implements Impl2::StepsInputSig {
155+
Impl2::SummaryNode getSummaryNode(Node n) { result = n.(FlowSummaryNode).getSummaryNode() }
132156

133157
DataFlowCall getACall(Public::SummarizedCallable sc) {
134158
result.asCall().getAstNode() = sc.(LibraryCallable).getACall()
135159
or
136160
result.asCall().getAstNode() = sc.(LibraryCallable).getACallSimple()
137161
}
138-
139-
Node getSourceNode(Input::SourceBase source, Impl::Private::SummaryComponentStack sc) { none() }
140-
141-
DataFlowCallable getSourceNodeEnclosingCallable(Input::SourceBase source) { none() }
142-
143-
Node getSinkNode(Input::SinkBase source, Impl::Private::SummaryComponent sc) { none() }
144162
}
145163

146164
module Private {
147165
import Impl::Private
166+
import Impl2
148167

149-
module Steps = Impl::Private::Steps<StepsInput>;
168+
module Steps = Impl2::Steps<StepsInput>;
150169

151170
/**
152171
* Provides predicates for constructing summary components.

‎powershell/ql/lib/semmle/code/powershell/dataflow/internal/TaintTrackingPrivate.qll‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ private module Cached {
9595
) and
9696
model = ""
9797
or
98-
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom,
99-
nodeTo.(FlowSummaryNode).getSummaryNode(), false, model)
98+
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, false, model)
10099
}
101100

102101
cached

0 commit comments

Comments
 (0)