Skip to content

Commit 793f754

Browse files
committed
Python: Adapt to FlowSummaryImpl changes
1 parent eb0d8c6 commit 793f754

2 files changed

Lines changed: 53 additions & 25 deletions

File tree

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,21 +1711,12 @@ class FlowSummaryNode extends Node, TFlowSummaryNode {
17111711
}
17121712

17131713
override DataFlowCallable getEnclosingCallable() {
1714-
result.asLibraryCallable() = this.getSummarizedCallable()
1714+
result = this.getSummaryNode().getEnclosingCallable()
17151715
}
17161716

17171717
override string toString() { result = this.getSummaryNode().toString() }
17181718

1719-
// Hack to return "empty location"
1720-
deprecated override predicate hasLocationInfo(
1721-
string file, int startline, int startcolumn, int endline, int endcolumn
1722-
) {
1723-
file = "" and
1724-
startline = 0 and
1725-
startcolumn = 0 and
1726-
endline = 0 and
1727-
endcolumn = 0
1728-
}
1719+
override Location getLocation() { result = this.getSummaryNode().getLocation() }
17291720
}
17301721

17311722
private class SummaryReturnNode extends FlowSummaryNode, ReturnNode {

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,27 @@ private import DataFlowImplSpecific::Public
1414
module Input implements InputSig<Location, DataFlowImplSpecific::PythonDataFlow> {
1515
private import codeql.util.Void
1616

17-
class SummarizedCallableBase = string;
17+
class SummarizedCallableBase extends string {
18+
bindingset[this]
19+
SummarizedCallableBase() { exists(this) }
1820

19-
class SourceBase = Void;
21+
Location getLocation() { none() }
22+
}
23+
24+
class SourceBase extends Void {
25+
Location getLocation() { none() }
26+
}
2027

21-
class SinkBase = Void;
28+
class SinkBase = SourceBase;
2229

23-
class FlowSummaryCallBase = Void;
30+
class FlowSummaryCallBase = SourceBase;
2431

2532
predicate callableFromSource(SummarizedCallableBase c) { none() }
2633

34+
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
35+
result.asLibraryCallable() = c
36+
}
37+
2738
ArgumentPosition callbackSelfParameterPosition() { result.isLambdaSelf() }
2839

2940
ReturnKind getStandardReturnValueKind() { any() }
@@ -112,11 +123,42 @@ module Input implements InputSig<Location, DataFlowImplSpecific::PythonDataFlow>
112123

113124
private import Make<Location, DataFlowImplSpecific::PythonDataFlow, Input> as Impl
114125

115-
private module StepsInput implements Impl::Private::StepsInputSig {
116-
Impl::Private::SummaryNode getSummaryNode(Node n) {
117-
result = n.(FlowSummaryNode).getSummaryNode()
126+
private module Input2 implements Impl::Private::InputSig2 {
127+
private import codeql.util.Void
128+
129+
class SourceSinkReportingElement extends Void {
130+
Location getLocation() { none() }
131+
132+
DataFlowCallable getEnclosingCallable() { none() }
118133
}
119134

135+
bindingset[source, s]
136+
SourceSinkReportingElement getSourceEntryElement(
137+
Impl::Public::SourceElement source, Impl::Private::SummaryComponentStack s
138+
) {
139+
none()
140+
}
141+
142+
bindingset[e, s]
143+
Node getSourceExitNode(SourceSinkReportingElement e, Impl::Private::SummaryComponentStack s) {
144+
none()
145+
}
146+
147+
SourceSinkReportingElement getSinkExitElement(
148+
Impl::Public::SinkElement sink, Impl::Private::SummaryComponent sc
149+
) {
150+
none()
151+
}
152+
153+
bindingset[e, sc]
154+
Node getSinkEntryNode(SourceSinkReportingElement e, Impl::Private::SummaryComponent sc) { none() }
155+
}
156+
157+
private import Impl::Private::Make2<Input2> as Impl2
158+
159+
private module StepsInput implements Impl2::StepsInputSig {
160+
Impl2::SummaryNode getSummaryNode(Node n) { result = n.(FlowSummaryNode).getSummaryNode() }
161+
120162
overlay[global]
121163
DataFlowCall getACall(Public::SummarizedCallable sc) {
122164
result =
@@ -125,18 +167,13 @@ private module StepsInput implements Impl::Private::StepsInputSig {
125167
sc.(LibraryCallable).getACallSimple().asCfgNode()
126168
])
127169
}
128-
129-
DataFlowCallable getSourceNodeEnclosingCallable(Input::SourceBase source) { none() }
130-
131-
Node getSourceNode(Input::SourceBase source, Impl::Private::SummaryComponentStack s) { none() }
132-
133-
Node getSinkNode(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
134170
}
135171

136172
module Private {
137173
import Impl::Private
174+
import Impl2
138175

139-
module Steps = Impl::Private::Steps<StepsInput>;
176+
module Steps = Impl2::Steps<StepsInput>;
140177

141178
/**
142179
* Provides predicates for constructing summary components.

0 commit comments

Comments
 (0)