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

Skip to content

Commit a45b5a7

Browse files
committed
Python: Implemented return node
but I think they receive no flow
1 parent 25d624d commit a45b5a7

4 files changed

Lines changed: 8 additions & 21 deletions

File tree

python/ql/src/experimental/dataflow/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class ArgumentNode extends Node {
8888
}
8989

9090
/** Holds if this argument occurs at the given position in the given call. */
91-
cached
9291
predicate argumentOf(DataFlowCall call, int pos) {
9392
this.asCfgNode() = call.getArg(pos)
9493
}
@@ -120,15 +119,15 @@ class ReturnKind extends TReturnKind {
120119

121120
/** A data flow node that represents a value returned by a callable. */
122121
class ReturnNode extends Node {
123-
// ReturnNode() { this.asCfgNode() instanceof TODO }
122+
ReturnNode() { this.asCfgNode().isNormalExit() }
124123

125124
/** Gets the kind of this return node. */
126125
ReturnKind getKind() { result = TNormalReturnKind() }
127126
}
128127

129128
/** A data flow node that represents the output of a call. */
130129
class OutNode extends Node {
131-
OutNode() { this.asCfgNode() instanceof CallNode}
130+
OutNode() { this.asCfgNode() instanceof CallNode }
132131

133132
/** Gets the underlying call, where this node is a corresponding output of kind `kind`. */
134133
cached

python/ql/test/experimental/dataflow/allFlowsConfig.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ class AllFlowsConfig extends DataFlow::Configuration {
88
AllFlowsConfig() { this = "AllFlowsConfig" }
99

1010
override predicate isSource(DataFlow::Node node) {
11-
node.asCfgNode() instanceof CallNode
11+
node.asCfgNode().isEntryNode()
1212
}
1313

1414
override predicate isSink(DataFlow::Node node) {
15+
node.asCfgNode().isNormalExit()
16+
or
17+
node = DataFlow::TEssaNode(_) and
1518
not exists(DataFlow::Node succ |
1619
DataFlow::localFlowStep(node, succ)
1720
)
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
| test.py:0:0:0:0 | Entry node for Module test |
21
| test.py:0:0:0:0 | Exit node for Module test |
32
| test.py:0:0:0:0 | GSSA Variable __name__ |
43
| test.py:0:0:0:0 | GSSA Variable __package__ |
54
| test.py:0:0:0:0 | GSSA Variable c |
65
| test.py:0:0:0:0 | SSA variable $ |
7-
| test.py:1:1:1:1 | ControlFlowNode for a |
8-
| test.py:2:1:2:1 | ControlFlowNode for b |
96
| test.py:2:1:2:1 | GSSA Variable b |
10-
| test.py:4:1:4:9 | Entry node for Function f |
117
| test.py:4:1:4:9 | Exit node for Function f |
12-
| test.py:4:5:4:5 | ControlFlowNode for f |
138
| test.py:4:5:4:5 | GSSA Variable f |
14-
| test.py:4:7:4:7 | ControlFlowNode for x |
159
| test.py:4:7:4:7 | SSA variable x |
16-
| test.py:5:3:5:3 | ControlFlowNode for y |
1710
| test.py:5:3:5:3 | SSA variable y |
18-
| test.py:5:7:5:7 | ControlFlowNode for x |
19-
| test.py:5:11:5:11 | ControlFlowNode for IntegerLiteral |
20-
| test.py:6:3:6:14 | ControlFlowNode for Return |
21-
| test.py:6:10:6:10 | ControlFlowNode for y |
22-
| test.py:6:10:6:14 | ControlFlowNode for BinaryExpr |
23-
| test.py:6:14:6:14 | ControlFlowNode for IntegerLiteral |
24-
| test.py:8:1:8:1 | ControlFlowNode for c |
2511
| test.py:8:1:8:1 | GSSA Variable c |
26-
| test.py:8:5:8:5 | ControlFlowNode for f |
2712
| test.py:8:5:8:8 | GSSA Variable a |
28-
| test.py:8:7:8:7 | ControlFlowNode for a |
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
| test.py:8:5:8:8 | ControlFlowNode for f() |
1+
| test.py:0:0:0:0 | Entry node for Module test |
2+
| test.py:4:1:4:9 | Entry node for Function f |

0 commit comments

Comments
 (0)