mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Python: implemented ParameterNode, updated test
This commit is contained in:
@@ -52,7 +52,7 @@ class Node extends TNode {
|
||||
* Gets an upper bound on the type of this node.
|
||||
*/
|
||||
DataFlowType getTypeBound() {
|
||||
none()
|
||||
any()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,11 +91,17 @@ ExprNode exprNode(DataFlowExpr e) { none() }
|
||||
* flow graph.
|
||||
*/
|
||||
class ParameterNode extends Node {
|
||||
ParameterNode() {
|
||||
this.asEssaNode() instanceof ParameterDefinition
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this node is the parameter of callable `c` at the specified
|
||||
* (zero-based) position.
|
||||
*/
|
||||
predicate isParameterOf(DataFlowCallable c, int i) { none() }
|
||||
predicate isParameterOf(DataFlowCallable c, int i) {
|
||||
this.asEssaNode().(ParameterDefinition).getDefiningNode() = c.getParameter(i)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,8 @@ class AllFlowsConfig extends DataFlow::Configuration {
|
||||
AllFlowsConfig() { this = "AllFlowsConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node node) {
|
||||
node.asCfgNode().isEntryNode()
|
||||
// node.asCfgNode().isEntryNode()
|
||||
node instanceof DataFlow::ParameterNode
|
||||
or
|
||||
node = DataFlow::TEssaNode(_) and
|
||||
not exists(DataFlow::Node pred |
|
||||
@@ -18,11 +19,9 @@ class AllFlowsConfig extends DataFlow::Configuration {
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node node) {
|
||||
node.asCfgNode().isNormalExit()
|
||||
node instanceof DataFlow::ReturnNode
|
||||
or
|
||||
node = DataFlow::TEssaNode(_) and
|
||||
not exists(DataFlow::Node succ |
|
||||
DataFlow::localFlowStep(node, succ)
|
||||
)
|
||||
not exists(node.asEssaNode().getASourceUse())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
| test.py:8:5:8:8 | ControlFlowNode for f() |
|
||||
| test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
|
||||
|
||||
@@ -1 +1 @@
|
||||
| test.py:6:10:6:14 | ControlFlowNode for BinaryExpr |
|
||||
| test.py:4:10:4:10 | ControlFlowNode for z |
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
| test.py:0:0:0:0 | GSSA Variable __name__ | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:0:0:0:0 | GSSA Variable __name__ | test.py:8:5:8:8 | ControlFlowNode for f() |
|
||||
| test.py:0:0:0:0 | GSSA Variable __name__ | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
|
||||
| test.py:0:0:0:0 | GSSA Variable __package__ | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:0:0:0:0 | GSSA Variable __package__ | test.py:8:5:8:8 | ControlFlowNode for f() |
|
||||
| test.py:0:0:0:0 | GSSA Variable c | test.py:8:5:8:8 | ControlFlowNode for f() |
|
||||
| test.py:0:0:0:0 | GSSA Variable __package__ | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
|
||||
| test.py:0:0:0:0 | GSSA Variable b | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
|
||||
| test.py:0:0:0:0 | SSA variable $ | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:1:1:1:1 | GSSA Variable a | test.py:2:5:2:5 | ControlFlowNode for a |
|
||||
| test.py:1:1:1:1 | GSSA Variable a | test.py:8:5:8:8 | ControlFlowNode for f() |
|
||||
| test.py:1:1:1:1 | GSSA Variable a | test.py:8:5:8:8 | GSSA Variable a |
|
||||
| test.py:1:1:1:1 | GSSA Variable a | test.py:8:7:8:7 | ControlFlowNode for a |
|
||||
| test.py:1:5:1:5 | ControlFlowNode for IntegerLiteral | test.py:1:1:1:1 | GSSA Variable a |
|
||||
| test.py:2:1:2:1 | GSSA Variable b | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:2:1:2:1 | GSSA Variable b | test.py:8:5:8:8 | ControlFlowNode for f() |
|
||||
| test.py:2:5:2:5 | ControlFlowNode for a | test.py:2:1:2:1 | GSSA Variable b |
|
||||
| test.py:4:1:4:9 | ControlFlowNode for FunctionExpr | test.py:4:5:4:5 | GSSA Variable f |
|
||||
| test.py:4:5:4:5 | GSSA Variable f | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:4:5:4:5 | GSSA Variable f | test.py:8:5:8:5 | ControlFlowNode for f |
|
||||
| test.py:4:5:4:5 | GSSA Variable f | test.py:8:5:8:8 | ControlFlowNode for f() |
|
||||
| test.py:4:7:4:7 | ControlFlowNode for x | test.py:4:7:4:7 | SSA variable x |
|
||||
| test.py:4:7:4:7 | SSA variable x | test.py:4:1:4:9 | Exit node for Function f |
|
||||
| test.py:4:7:4:7 | SSA variable x | test.py:5:7:5:7 | ControlFlowNode for x |
|
||||
| test.py:5:3:5:3 | SSA variable y | test.py:4:1:4:9 | Exit node for Function f |
|
||||
| test.py:5:3:5:3 | SSA variable y | test.py:6:10:6:10 | ControlFlowNode for y |
|
||||
| test.py:5:7:5:11 | ControlFlowNode for BinaryExpr | test.py:5:3:5:3 | SSA variable y |
|
||||
| test.py:8:1:8:1 | GSSA Variable c | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:8:5:8:8 | ControlFlowNode for f() | test.py:8:1:8:1 | GSSA Variable c |
|
||||
| test.py:8:5:8:8 | GSSA Variable a | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:1:1:1:21 | ControlFlowNode for FunctionExpr | test.py:1:5:1:17 | GSSA Variable obfuscated_id |
|
||||
| test.py:1:5:1:17 | GSSA Variable obfuscated_id | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:1:5:1:17 | GSSA Variable obfuscated_id | test.py:7:5:7:17 | ControlFlowNode for obfuscated_id |
|
||||
| test.py:1:5:1:17 | GSSA Variable obfuscated_id | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
|
||||
| test.py:1:19:1:19 | ControlFlowNode for x | test.py:1:19:1:19 | SSA variable x |
|
||||
| test.py:1:19:1:19 | SSA variable x | test.py:1:1:1:21 | Exit node for Function obfuscated_id |
|
||||
| test.py:1:19:1:19 | SSA variable x | test.py:2:7:2:7 | ControlFlowNode for x |
|
||||
| test.py:2:3:2:3 | SSA variable y | test.py:1:1:1:21 | Exit node for Function obfuscated_id |
|
||||
| test.py:2:3:2:3 | SSA variable y | test.py:3:7:3:7 | ControlFlowNode for y |
|
||||
| test.py:2:7:2:7 | ControlFlowNode for x | test.py:2:3:2:3 | SSA variable y |
|
||||
| test.py:3:3:3:3 | SSA variable z | test.py:1:1:1:21 | Exit node for Function obfuscated_id |
|
||||
| test.py:3:3:3:3 | SSA variable z | test.py:4:10:4:10 | ControlFlowNode for z |
|
||||
| test.py:3:7:3:7 | ControlFlowNode for y | test.py:3:3:3:3 | SSA variable z |
|
||||
| test.py:6:1:6:1 | GSSA Variable a | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
|
||||
| test.py:6:1:6:1 | GSSA Variable a | test.py:7:5:7:20 | GSSA Variable a |
|
||||
| test.py:6:1:6:1 | GSSA Variable a | test.py:7:19:7:19 | ControlFlowNode for a |
|
||||
| test.py:6:5:6:6 | ControlFlowNode for IntegerLiteral | test.py:6:1:6:1 | GSSA Variable a |
|
||||
| test.py:7:1:7:1 | GSSA Variable b | test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() | test.py:7:1:7:1 | GSSA Variable b |
|
||||
| test.py:7:5:7:20 | GSSA Variable a | test.py:0:0:0:0 | Exit node for Module test |
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
| test.py:0:0:0:0 | Exit node for Module test |
|
||||
| test.py:4:1:4:9 | Exit node for Function f |
|
||||
| test.py:0:0:0:0 | GSSA Variable __name__ |
|
||||
| test.py:0:0:0:0 | GSSA Variable __package__ |
|
||||
| test.py:0:0:0:0 | GSSA Variable b |
|
||||
| test.py:0:0:0:0 | SSA variable $ |
|
||||
| test.py:4:10:4:10 | ControlFlowNode for z |
|
||||
| test.py:7:1:7:1 | GSSA Variable b |
|
||||
| test.py:7:5:7:20 | GSSA Variable a |
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
| test.py:0:0:0:0 | Entry node for Module test |
|
||||
| test.py:0:0:0:0 | GSSA Variable __name__ |
|
||||
| test.py:0:0:0:0 | GSSA Variable __package__ |
|
||||
| test.py:0:0:0:0 | GSSA Variable c |
|
||||
| test.py:0:0:0:0 | GSSA Variable b |
|
||||
| test.py:0:0:0:0 | SSA variable $ |
|
||||
| test.py:1:1:1:1 | GSSA Variable a |
|
||||
| test.py:2:1:2:1 | GSSA Variable b |
|
||||
| test.py:4:1:4:9 | Entry node for Function f |
|
||||
| test.py:4:5:4:5 | GSSA Variable f |
|
||||
| test.py:4:7:4:7 | SSA variable x |
|
||||
| test.py:5:3:5:3 | SSA variable y |
|
||||
| test.py:8:1:8:1 | GSSA Variable c |
|
||||
| test.py:1:5:1:17 | GSSA Variable obfuscated_id |
|
||||
| test.py:1:19:1:19 | SSA variable x |
|
||||
| test.py:2:3:2:3 | SSA variable y |
|
||||
| test.py:3:3:3:3 | SSA variable z |
|
||||
| test.py:6:1:6:1 | GSSA Variable a |
|
||||
| test.py:7:1:7:1 | GSSA Variable b |
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
a = 3
|
||||
b = a
|
||||
def obfuscated_id(x):
|
||||
y = x
|
||||
z = y
|
||||
return z
|
||||
|
||||
def f(x):
|
||||
y = x + 2 # would expect flow to here from x
|
||||
return y - 2 # would expect flow to here from y
|
||||
|
||||
c = f(a)
|
||||
a = 42
|
||||
b = obfuscated_id(a)
|
||||
|
||||
Reference in New Issue
Block a user