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

Skip to content

Commit b65e6fb

Browse files
committed
Python: attempt at capturing maximal flows
(this is what used to be "all flows")
1 parent cc8367b commit b65e6fb

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
| test.py:0:0:0:0 | GSSA Variable __name__ | test.py:7:1:7:1 | GSSA Variable b |
2+
| test.py:0:0:0:0 | GSSA Variable __package__ | test.py:7:1:7:1 | GSSA Variable b |
3+
| test.py:0:0:0:0 | GSSA Variable b | test.py:7:1:7:1 | GSSA Variable b |
4+
| test.py:1:5:1:17 | GSSA Variable obfuscated_id | test.py:7:1:7:1 | GSSA Variable b |
5+
| test.py:1:19:1:19 | SSA variable x | test.py:4:10:4:10 | ControlFlowNode for z |
6+
| test.py:1:19:1:19 | SSA variable x | test.py:7:1:7:1 | GSSA Variable b |
7+
| test.py:2:3:2:3 | SSA variable y | test.py:4:10:4:10 | ControlFlowNode for z |
8+
| test.py:2:3:2:3 | SSA variable y | test.py:7:1:7:1 | GSSA Variable b |
9+
| test.py:3:3:3:3 | SSA variable z | test.py:4:10:4:10 | ControlFlowNode for z |
10+
| test.py:3:3:3:3 | SSA variable z | test.py:7:1:7:1 | GSSA Variable b |
11+
| test.py:6:1:6:1 | GSSA Variable a | test.py:4:10:4:10 | ControlFlowNode for z |
12+
| test.py:6:1:6:1 | GSSA Variable a | test.py:7:1:7:1 | GSSA Variable b |
13+
| test.py:6:1:6:1 | GSSA Variable a | test.py:7:5:7:20 | GSSA Variable a |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import maximalFlowsConfig
2+
3+
from
4+
DataFlow::Node source,
5+
DataFlow::Node sink
6+
where
7+
source != sink and
8+
exists(MaximalFlowsConfig cfg | cfg.hasFlow(source, sink))
9+
select
10+
source, sink
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import experimental.dataflow.DataFlow
2+
3+
/**
4+
* A configuration to find all "maximal" flows.
5+
* To be used on small programs.
6+
*/
7+
class MaximalFlowsConfig extends DataFlow::Configuration {
8+
MaximalFlowsConfig() { this = "AllFlowsConfig" }
9+
10+
override predicate isSource(DataFlow::Node node) {
11+
node instanceof DataFlow::ParameterNode
12+
or
13+
node = DataFlow::TEssaNode(_) and
14+
not exists(DataFlow::Node pred |
15+
pred = DataFlow::TEssaNode(_) and
16+
DataFlow::localFlowStep(pred, node)
17+
)
18+
}
19+
20+
override predicate isSink(DataFlow::Node node) {
21+
node instanceof DataFlow::ReturnNode
22+
or
23+
node = DataFlow::TEssaNode(_) and
24+
not exists(node.asEssaNode().getASourceUse())
25+
}
26+
}

0 commit comments

Comments
 (0)