Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e078da

Browse files
committed
Python: Better definition of all flows
does not become too big, when we filter out 0-step flows
1 parent 5ca6391 commit 9e078da

4 files changed

Lines changed: 23 additions & 23 deletions

File tree

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
import experimental.dataflow.DataFlow
22

33
/**
4-
* A configuration to find "all" flows.
5-
* To be used on small programs.
4+
* A configuration to find all flows.
5+
* To be used on tiny programs.
66
*/
77
class AllFlowsConfig extends DataFlow::Configuration {
88
AllFlowsConfig() { this = "AllFlowsConfig" }
99

10-
override predicate isSource(DataFlow::Node node) {
11-
// node.asCfgNode().isEntryNode()
12-
node instanceof DataFlow::ParameterNode
13-
or
14-
node = DataFlow::TEssaNode(_) and
15-
not exists(DataFlow::Node pred |
16-
pred = DataFlow::TEssaNode(_) and
17-
DataFlow::localFlowStep(pred, node)
18-
)
19-
}
10+
override predicate isSource(DataFlow::Node node) { any() }
2011

21-
override predicate isSink(DataFlow::Node node) {
22-
node instanceof DataFlow::ReturnNode
23-
or
24-
node = DataFlow::TEssaNode(_) and
25-
not exists(node.asEssaNode().getASourceUse())
26-
}
12+
override predicate isSink(DataFlow::Node node) { any() }
2713
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
| test.py:0:0:0:0 | GSSA Variable __name__ | test.py:0:0:0:0 | GSSA Variable __name__ |
2-
| test.py:0:0:0:0 | GSSA Variable __package__ | test.py:0:0:0:0 | GSSA Variable __package__ |
3-
| test.py:0:0:0:0 | GSSA Variable b | test.py:0:0:0:0 | GSSA Variable b |
4-
| test.py:0:0:0:0 | SSA variable $ | test.py:0:0:0:0 | SSA variable $ |
5-
| test.py:7:1:7:1 | GSSA Variable b | test.py:7:1:7:1 | GSSA Variable b |
1+
| test.py:1:19:1:19 | SSA variable x | test.py:1:1:1:21 | Exit node for Function obfuscated_id |
2+
| test.py:1:19:1:19 | SSA variable x | test.py:2:7:2:7 | ControlFlowNode for x |
3+
| test.py:4:10:4:10 | ControlFlowNode for z | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
4+
| test.py:7:19:7:19 | ControlFlowNode for a | test.py:1:1:1:21 | Exit node for Function obfuscated_id |
5+
| test.py:7:19:7:19 | ControlFlowNode for a | test.py:1:19:1:19 | SSA variable x |
6+
| test.py:7:19:7:19 | ControlFlowNode for a | test.py:2:7:2:7 | ControlFlowNode for x |

python/ql/test/experimental/dataflow/global.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from
44
DataFlow::Node source,
55
DataFlow::Node sink
66
where
7+
source != sink and
78
exists(AllFlowsConfig cfg | cfg.hasFlow(source, sink))
89
select
910
source, sink
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
| test.py:1:19:1:19 | SSA variable x : DataFlowType | test.py:1:1:1:21 | Exit node for Function obfuscated_id |
2+
| test.py:1:19:1:19 | SSA variable x : DataFlowType | test.py:1:1:1:21 | Exit node for Function obfuscated_id |
3+
| test.py:1:19:1:19 | SSA variable x : DataFlowType | test.py:1:1:1:21 | Exit node for Function obfuscated_id : DataFlowType |
4+
| test.py:1:19:1:19 | SSA variable x : DataFlowType | test.py:1:1:1:21 | Exit node for Function obfuscated_id : DataFlowType |
5+
| test.py:1:19:1:19 | SSA variable x : DataFlowType | test.py:2:7:2:7 | ControlFlowNode for x |
6+
| test.py:1:19:1:19 | SSA variable x : DataFlowType | test.py:2:7:2:7 | ControlFlowNode for x |
7+
| test.py:1:19:1:19 | SSA variable x : DataFlowType | test.py:2:7:2:7 | ControlFlowNode for x : DataFlowType |
8+
| test.py:1:19:1:19 | SSA variable x : DataFlowType | test.py:2:7:2:7 | ControlFlowNode for x : DataFlowType |
9+
| test.py:4:10:4:10 | ControlFlowNode for z : DataFlowType | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
10+
| test.py:4:10:4:10 | ControlFlowNode for z : DataFlowType | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() : DataFlowType |
11+
| test.py:7:19:7:19 | ControlFlowNode for a : DataFlowType | test.py:1:19:1:19 | SSA variable x |
12+
| test.py:7:19:7:19 | ControlFlowNode for a : DataFlowType | test.py:1:19:1:19 | SSA variable x : DataFlowType |

0 commit comments

Comments
 (0)