Skip to content

Commit 4c0f54f

Browse files
authored
Merge pull request github#5007 from yoff/python-disregard-comp-args
2 parents 0be0929 + e44f181 commit 4c0f54f

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

python/ql/src/semmle/python/dataflow/new/internal/DataFlowPublic.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ ExprNode exprNode(DataFlowExpr e) { result.getNode().getNode() = e }
179179
class ParameterNode extends CfgNode {
180180
ParameterDefinition def;
181181

182-
ParameterNode() { node = def.getDefiningNode() }
182+
ParameterNode() {
183+
node = def.getDefiningNode() and
184+
// Disregard parameters that we cannot resolve
185+
// TODO: Make this unnecessary
186+
exists(DataFlowCallable c | node = c.getParameter(_))
187+
}
183188

184189
/**
185190
* Holds if this node is the parameter of callable `c` at the

python/ql/test/experimental/dataflow/consistency/dataflow-consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
uniqueEnclosingCallable
2-
| test.py:239:27:239:27 | ControlFlowNode for p | Node should have one enclosing callable but has 0. |
32
uniqueType
43
uniqueNodeLocation
54
missingLocation
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.py:239:27:239:27 | Parameter | There is no `ParameterNode` associated with this parameter. |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import python
2+
import semmle.python.dataflow.new.DataFlow
3+
4+
query predicate parameterWithoutNode(Parameter p, string msg) {
5+
not exists(DataFlow::ParameterNode node | p = node.getParameter()) and
6+
msg = "There is no `ParameterNode` associated with this parameter."
7+
}

python/ql/test/experimental/dataflow/coverage/localFlow.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| test.py:187:1:187:53 | GSSA Variable SINK | test.py:189:5:189:8 | ControlFlowNode for SINK |
99
| test.py:187:1:187:53 | GSSA Variable SOURCE | test.py:188:25:188:30 | ControlFlowNode for SOURCE |
1010
| test.py:188:5:188:5 | SSA variable x | test.py:189:10:189:10 | ControlFlowNode for x |
11+
| test.py:188:9:188:68 | ControlFlowNode for .0 | test.py:188:9:188:68 | SSA variable .0 |
1112
| test.py:188:9:188:68 | ControlFlowNode for ListComp | test.py:188:5:188:5 | SSA variable x |
1213
| test.py:188:9:188:68 | SSA variable .0 | test.py:188:9:188:68 | ControlFlowNode for .0 |
1314
| test.py:188:16:188:16 | SSA variable v | test.py:188:45:188:45 | ControlFlowNode for v |

0 commit comments

Comments
 (0)