Python: Implement OutNode

Also, fix test for local flow
This commit is contained in:
Rasmus Lerchedahl Petersen
2020-06-17 16:24:44 +02:00
parent 52898f16f5
commit 71f364eef3
5 changed files with 106 additions and 43 deletions

View File

@@ -0,0 +1,36 @@
import python
import experimental.dataflow.DataFlow
class SimpleConfig extends DataFlow::Configuration {
SimpleConfig() { this = "SimpleConfig" }
// TODO: make a test out of this
override predicate isSource(DataFlow::Node node) {
node.asEssaNode() instanceof EssaNodeDefinition
}
// TODO: make a test out of this
override predicate isSink(DataFlow::Node node) {
not exists(EssaDefinition succ |
node.asEssaNode().getDefinition() = pred(succ)
)
}
EssaDefinition pred(EssaDefinition n) {
// result = value(n.(EssaNodeDefinition))
// or
result = n.(EssaNodeRefinement).getInput()
or
result = n.(EssaEdgeRefinement).getInput()
or
result = n.(PhiFunction).getShortCircuitInput()
}
}
from
DataFlow::Node source,
DataFlow::Node sink
where
exists(SimpleConfig cfg | cfg.hasFlow(source, sink))
select
source, sink

View File

@@ -1,4 +1,6 @@
ERROR: Could not resolve module DataFlow (local.ql:5,3-11)
ERROR: Could not resolve module DataFlow (local.ql:6,3-11)
ERROR: Could not resolve module DataFlow (local.ql:8,3-11)
ERROR: Could not resolve module semmle.code.python.dataflow.DataFlow (local.ql:2,8-44)
| test.py:1:1:1:1 | GSSA Variable a | test.py:8:5:8:8 | GSSA Variable a |
| test.py:1:5:1:5 | ControlFlowNode for IntegerLiteral | test.py:1:1:1:1 | GSSA Variable a |
| 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:5:7:5:11 | ControlFlowNode for BinaryExpr | test.py:5:3:5:3 | SSA variable y |
| test.py:8:5:8:8 | ControlFlowNode for f() | test.py:8:1:8:1 | GSSA Variable c |