Skip to content

Commit 3c19578

Browse files
committed
PS: Hide the new nodes and enure that we still show the old return node.
1 parent 93a4864 commit 3c19578

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

powershell/ql/lib/semmle/code/powershell/dataflow/internal/DataFlowImplSpecific.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ module PowershellDataFlow implements InputSig<Location> {
2121
class ParameterNode = Private::ParameterNodeImpl;
2222

2323
Node exprNode(DataFlowExpr e) { result = Public::exprNode(e) }
24+
25+
predicate neverSkipInPathGraph = Private::neverSkipInPathGraph/1;
2426
}

powershell/ql/lib/semmle/code/powershell/dataflow/internal/DataFlowPrivate.qll

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ abstract class NodeImpl extends Node {
3131

3232
/** Do not call: use `toString()` instead. */
3333
abstract string toStringImpl();
34+
35+
/** Holds if this node should be hidden from path explanations. */
36+
predicate nodeIsHidden() { none() }
3437
}
3538

3639
private class ExprNodeImpl extends ExprNode, NodeImpl {
@@ -284,7 +287,13 @@ private string approxKnownElementIndex(ConstantValue cv) {
284287
import Cached
285288

286289
/** Holds if `n` should be hidden from path explanations. */
287-
predicate nodeIsHidden(Node n) { none() }
290+
predicate nodeIsHidden(Node n) { n.(NodeImpl).nodeIsHidden() }
291+
292+
/**
293+
* Holds if `n` should never be skipped over in the `PathGraph` and in path
294+
* explanations.
295+
*/
296+
predicate neverSkipInPathGraph(Node n) { isReturned(n.(AstNode).getCfgNode()) }
288297

289298
/** An SSA node. */
290299
abstract class SsaNode extends NodeImpl, TSsaNode {
@@ -795,6 +804,8 @@ private class ImplicitWrapNode extends TImplicitWrapNode, NodeImpl {
795804
override Location getLocationImpl() { result = n.getLocation() }
796805

797806
override string toStringImpl() { result = "implicit unwrapping of " + n.toString() }
807+
808+
override predicate nodeIsHidden() { any() }
798809
}
799810

800811
/**
@@ -829,6 +840,8 @@ private class ReturnNodeImpl extends TReturnNodeImpl, NodeImpl {
829840
override Location getLocationImpl() { result = scope.getLocation() }
830841

831842
override string toStringImpl() { result = "return value for " + scope.toString() }
843+
844+
override predicate nodeIsHidden() { any() }
832845
}
833846

834847
/** A node that performs a type cast. */

powershell/ql/test/library-tests/dataflow/returns/test.expected

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,32 @@
11
models
22
edges
3-
| test.ps1:1:25:3:2 | return value for {...} | test.ps1:5:6:5:20 | callSourceOnce | provenance | |
4-
| test.ps1:2:5:2:15 | Source | test.ps1:2:5:2:15 | implicit unwrapping of Source | provenance | |
5-
| test.ps1:2:5:2:15 | implicit unwrapping of Source | test.ps1:1:25:3:2 | return value for {...} | provenance | |
3+
| test.ps1:2:5:2:15 | Source | test.ps1:5:6:5:20 | callSourceOnce | provenance | |
64
| test.ps1:5:6:5:20 | callSourceOnce | test.ps1:6:6:6:8 | x | provenance | |
7-
| test.ps1:8:26:11:2 | return value for {...} | test.ps1:13:6:13:21 | callSourceTwice | provenance | |
8-
| test.ps1:9:5:9:15 | Source | test.ps1:9:5:9:15 | implicit unwrapping of Source | provenance | |
9-
| test.ps1:9:5:9:15 | implicit unwrapping of Source | test.ps1:8:26:11:2 | return value for {...} | provenance | |
10-
| test.ps1:10:5:10:15 | Source | test.ps1:10:5:10:15 | implicit unwrapping of Source | provenance | |
11-
| test.ps1:10:5:10:15 | implicit unwrapping of Source | test.ps1:8:26:11:2 | return value for {...} | provenance | |
5+
| test.ps1:9:5:9:15 | Source | test.ps1:13:6:13:21 | callSourceTwice | provenance | |
6+
| test.ps1:10:5:10:15 | Source | test.ps1:13:6:13:21 | callSourceTwice | provenance | |
127
| test.ps1:13:6:13:21 | callSourceTwice | test.ps1:14:6:14:8 | x | provenance | |
13-
| test.ps1:16:24:18:2 | return value for {...} | test.ps1:20:6:20:19 | returnSource1 | provenance | |
14-
| test.ps1:17:12:17:22 | Source | test.ps1:17:12:17:22 | implicit unwrapping of Source | provenance | |
15-
| test.ps1:17:12:17:22 | implicit unwrapping of Source | test.ps1:16:24:18:2 | return value for {...} | provenance | |
8+
| test.ps1:17:12:17:22 | Source | test.ps1:20:6:20:19 | returnSource1 | provenance | |
169
| test.ps1:20:6:20:19 | returnSource1 | test.ps1:21:6:21:8 | x | provenance | |
17-
| test.ps1:23:24:28:2 | return value for {...} | test.ps1:30:6:30:19 | returnSource2 | provenance | |
18-
| test.ps1:24:10:24:20 | Source | test.ps1:25:5:25:7 | implicit unwrapping of x | provenance | |
19-
| test.ps1:25:5:25:7 | implicit unwrapping of x | test.ps1:23:24:28:2 | return value for {...} | provenance | |
20-
| test.ps1:26:10:26:20 | Source | test.ps1:27:12:27:14 | implicit unwrapping of y | provenance | |
21-
| test.ps1:27:12:27:14 | implicit unwrapping of y | test.ps1:23:24:28:2 | return value for {...} | provenance | |
10+
| test.ps1:24:10:24:20 | Source | test.ps1:25:5:25:7 | x | provenance | |
11+
| test.ps1:25:5:25:7 | x | test.ps1:30:6:30:19 | returnSource2 | provenance | |
12+
| test.ps1:26:10:26:20 | Source | test.ps1:27:12:27:14 | y | provenance | |
13+
| test.ps1:27:12:27:14 | y | test.ps1:30:6:30:19 | returnSource2 | provenance | |
2214
| test.ps1:30:6:30:19 | returnSource2 | test.ps1:31:6:31:8 | x | provenance | |
2315
nodes
24-
| test.ps1:1:25:3:2 | return value for {...} | semmle.label | return value for {...} |
2516
| test.ps1:2:5:2:15 | Source | semmle.label | Source |
26-
| test.ps1:2:5:2:15 | implicit unwrapping of Source | semmle.label | implicit unwrapping of Source |
2717
| test.ps1:5:6:5:20 | callSourceOnce | semmle.label | callSourceOnce |
2818
| test.ps1:6:6:6:8 | x | semmle.label | x |
29-
| test.ps1:8:26:11:2 | return value for {...} | semmle.label | return value for {...} |
3019
| test.ps1:9:5:9:15 | Source | semmle.label | Source |
31-
| test.ps1:9:5:9:15 | implicit unwrapping of Source | semmle.label | implicit unwrapping of Source |
3220
| test.ps1:10:5:10:15 | Source | semmle.label | Source |
33-
| test.ps1:10:5:10:15 | implicit unwrapping of Source | semmle.label | implicit unwrapping of Source |
3421
| test.ps1:13:6:13:21 | callSourceTwice | semmle.label | callSourceTwice |
3522
| test.ps1:14:6:14:8 | x | semmle.label | x |
36-
| test.ps1:16:24:18:2 | return value for {...} | semmle.label | return value for {...} |
3723
| test.ps1:17:12:17:22 | Source | semmle.label | Source |
38-
| test.ps1:17:12:17:22 | implicit unwrapping of Source | semmle.label | implicit unwrapping of Source |
3924
| test.ps1:20:6:20:19 | returnSource1 | semmle.label | returnSource1 |
4025
| test.ps1:21:6:21:8 | x | semmle.label | x |
41-
| test.ps1:23:24:28:2 | return value for {...} | semmle.label | return value for {...} |
4226
| test.ps1:24:10:24:20 | Source | semmle.label | Source |
43-
| test.ps1:25:5:25:7 | implicit unwrapping of x | semmle.label | implicit unwrapping of x |
27+
| test.ps1:25:5:25:7 | x | semmle.label | x |
4428
| test.ps1:26:10:26:20 | Source | semmle.label | Source |
45-
| test.ps1:27:12:27:14 | implicit unwrapping of y | semmle.label | implicit unwrapping of y |
29+
| test.ps1:27:12:27:14 | y | semmle.label | y |
4630
| test.ps1:30:6:30:19 | returnSource2 | semmle.label | returnSource2 |
4731
| test.ps1:31:6:31:8 | x | semmle.label | x |
4832
subpaths

0 commit comments

Comments
 (0)