Skip to content

Commit 897bbbc

Browse files
committed
Python: Fix test issues
1 parent e0437b6 commit 897bbbc

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

python/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ private module Input implements InputSig<Location, PythonDataFlow> {
2626
or
2727
// TODO: Implement post-updates for **kwargs, see tests added in https://github.com/github/codeql/pull/14936
2828
exists(ArgumentPosition apos | n.argumentOf(_, apos) and apos.isDictSplat())
29+
or
30+
missingArgumentCallExclude(n)
2931
}
3032

3133
predicate reverseReadExclude(Node n) {
@@ -134,6 +136,14 @@ private module Input implements InputSig<Location, PythonDataFlow> {
134136
other.getNode().getScope() = f
135137
)
136138
}
139+
140+
predicate missingArgumentCallExclude(ArgumentNode arg) {
141+
// We overapproximate the argument nodes in order to not rely on the global `getCallArg`
142+
// predicate.
143+
// Because of this, we must exclude the cases where we have an approximation but no actual
144+
// argument node.
145+
arg = getCallArgApproximation() and not getCallArg(_, _, _, arg, _)
146+
}
137147
}
138148

139149
import MakeConsistency<Location, PythonDataFlow, PythonTaintTracking, Input>

python/ql/lib/utils/test/dataflow/MaximalFlowTest.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module MaximalFlowsConfig implements DataFlow::ConfigSig {
3535
predicate isSink(DataFlow::Node node) {
3636
exists(node.getLocation().getFile().getRelativePath()) and
3737
not any(CallNode c).getArg(_) = node.asCfgNode() and
38-
not node instanceof DataFlow::ArgumentNode and
38+
not isArgumentNode(node, _, _) and
3939
not node.asCfgNode().(NameNode).getId().matches("SINK%") and
4040
not DataFlow::localFlowStep(node, _)
4141
}

python/ql/lib/utils/test/dataflow/callGraphConfig.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module CallGraphConfig implements DataFlow::ConfigSig {
99
predicate isSource(DataFlow::Node node) {
1010
node instanceof DataFlowPrivate::ReturnNode
1111
or
12-
node instanceof DataFlow::ArgumentNode
12+
DataFlowPrivate::isArgumentNode(node, _, _)
1313
}
1414

1515
predicate isSink(DataFlow::Node node) {

python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import python
1616
import semmle.python.dataflow.new.DataFlow
1717
import semmle.python.dataflow.new.internal.DataFlowDispatch
18+
import semmle.python.dataflow.new.internal.DataFlowPrivate
1819

1920
predicate initSelfCallOverridden(
2021
Function init, DataFlow::Node self, DataFlow::MethodCallNode call, Function target,
@@ -39,7 +40,7 @@ predicate readsFromSelf(Function method) {
3940
self.getParameter() = method.getArg(0) and
4041
DataFlow::localFlow(self, sink)
4142
|
42-
sink instanceof DataFlow::ArgumentNode
43+
isArgumentNode(sink, _, _)
4344
or
4445
sink = any(DataFlow::AttrRead a).getObject()
4546
)

0 commit comments

Comments
 (0)