mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: Implement OutNode
Also, fix test for local flow
This commit is contained in:
36
python/ql/test/experimental/dataflow/global.ql
Normal file
36
python/ql/test/experimental/dataflow/global.ql
Normal 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
|
||||
@@ -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 |
|
||||
|
||||
Reference in New Issue
Block a user