Skip to content

Commit 1b454ed

Browse files
committed
PS: add tests and accept test changes.
1 parent 0aa6670 commit 1b454ed

File tree

8 files changed

+284
-283
lines changed

8 files changed

+284
-283
lines changed

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

Lines changed: 76 additions & 250 deletions
Large diffs are not rendered by default.

powershell/ql/test/library-tests/dataflow/fields/test.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,17 @@ $myClass = [MyClass]::new()
5858

5959
$myClass.field = Source "12"
6060

61-
$myClass.callSink()
61+
$myClass.callSink()
62+
63+
function produce {
64+
$x = Source "13"
65+
$y = Source "14"
66+
$z = Source "15"
67+
$x
68+
$y, $z
69+
}
70+
71+
$x = produce
72+
Sink $x[0] # $ hasValueFlow=13 hasValueFlow=14 hasValueFlow=15
73+
Sink $x[1] # $ hasValueFlow=13 hasValueFlow=14 hasValueFlow=15
74+
Sink $x[2] # $ hasValueFlow=13 hasValueFlow=14 hasValueFlow=15
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
| test.ps1:1:1:1:4 | a1 | test.ps1:2:6:2:9 | a1 |
22
| test.ps1:1:7:1:13 | Source | test.ps1:1:1:1:4 | a1 |
33
| test.ps1:1:7:1:13 | Source | test.ps1:1:1:1:13 | ...=... |
4-
| test.ps1:2:1:2:9 | Sink | test.ps1:2:1:2:9 | implicit unwrapping of Sink |
5-
| test.ps1:2:1:2:9 | Sink | test.ps1:2:1:2:9 | implicit unwrapping of Sink |
4+
| test.ps1:2:1:2:9 | Sink | test.ps1:2:1:2:9 | pre-return value for Sink |
5+
| test.ps1:2:1:2:9 | Sink | test.ps1:2:1:2:9 | pre-return value for Sink |
66
| test.ps1:2:1:2:9 | implicit unwrapping of Sink | test.ps1:1:1:8:9 | return value for test.ps1 |
7+
| test.ps1:2:1:2:9 | pre-return value for Sink | test.ps1:2:1:2:9 | implicit unwrapping of Sink |
78
| test.ps1:4:1:4:3 | b | test.ps1:5:4:5:6 | b |
89
| test.ps1:4:6:4:13 | GetBool | test.ps1:4:1:4:3 | b |
910
| test.ps1:4:6:4:13 | GetBool | test.ps1:4:1:4:13 | ...=... |
10-
| test.ps1:5:4:5:6 | b | test.ps1:5:4:5:6 | b |
1111
| test.ps1:6:5:6:8 | a2 | test.ps1:8:6:8:9 | a2 |
1212
| test.ps1:6:11:6:17 | Source | test.ps1:6:5:6:8 | a2 |
1313
| test.ps1:6:11:6:17 | Source | test.ps1:6:5:6:17 | ...=... |
14-
| test.ps1:8:1:8:9 | Sink | test.ps1:8:1:8:9 | implicit unwrapping of Sink |
15-
| test.ps1:8:1:8:9 | Sink | test.ps1:8:1:8:9 | implicit unwrapping of Sink |
14+
| test.ps1:8:1:8:9 | Sink | test.ps1:8:1:8:9 | pre-return value for Sink |
15+
| test.ps1:8:1:8:9 | Sink | test.ps1:8:1:8:9 | pre-return value for Sink |
1616
| test.ps1:8:1:8:9 | implicit unwrapping of Sink | test.ps1:1:1:8:9 | return value for test.ps1 |
17+
| test.ps1:8:1:8:9 | pre-return value for Sink | test.ps1:8:1:8:9 | implicit unwrapping of Sink |
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
models
2+
edges
3+
| test.ps1:2:10:2:21 | Source | test.ps1:5:5:5:7 | x | provenance | |
4+
| test.ps1:3:10:3:21 | Source | test.ps1:6:5:6:7 | y | provenance | |
5+
| test.ps1:4:10:4:21 | Source | test.ps1:6:9:6:11 | z | provenance | |
6+
| test.ps1:5:5:5:7 | x | test.ps1:17:1:17:8 | produce [element] | provenance | |
7+
| test.ps1:6:5:6:7 | y | test.ps1:6:5:6:11 | ...,... [element 0] | provenance | |
8+
| test.ps1:6:5:6:11 | ...,... [element 0] | test.ps1:17:1:17:8 | produce [element] | provenance | |
9+
| test.ps1:6:5:6:11 | ...,... [element 1] | test.ps1:17:1:17:8 | produce [element] | provenance | |
10+
| test.ps1:6:9:6:11 | z | test.ps1:6:5:6:11 | ...,... [element 1] | provenance | |
11+
| test.ps1:10:11:10:44 | x [element 0] | test.ps1:13:14:13:16 | x | provenance | |
12+
| test.ps1:10:11:10:44 | x [element 1] | test.ps1:13:14:13:16 | x | provenance | |
13+
| test.ps1:10:11:10:44 | x [element] | test.ps1:13:14:13:16 | x | provenance | |
14+
| test.ps1:17:1:17:8 | produce [element] | test.ps1:10:11:10:44 | x [element] | provenance | |
15+
| test.ps1:19:6:19:17 | Source | test.ps1:21:1:21:3 | x | provenance | |
16+
| test.ps1:20:6:20:17 | Source | test.ps1:21:5:21:7 | y | provenance | |
17+
| test.ps1:21:1:21:3 | x | test.ps1:21:1:21:7 | ...,... [element 0] | provenance | |
18+
| test.ps1:21:1:21:7 | ...,... [element 0] | test.ps1:10:11:10:44 | x [element 0] | provenance | |
19+
| test.ps1:21:1:21:7 | ...,... [element 0] | test.ps1:21:1:21:7 | ...,... [element 0] | provenance | |
20+
| test.ps1:21:1:21:7 | ...,... [element 1] | test.ps1:10:11:10:44 | x [element 1] | provenance | |
21+
| test.ps1:21:1:21:7 | ...,... [element 1] | test.ps1:21:1:21:7 | ...,... [element 1] | provenance | |
22+
| test.ps1:21:5:21:7 | y | test.ps1:21:1:21:7 | ...,... [element 1] | provenance | |
23+
| test.ps1:25:14:25:16 | _ [element 0] | test.ps1:25:14:25:16 | _ | provenance | |
24+
| test.ps1:25:14:25:16 | _ [element 1] | test.ps1:25:14:25:16 | _ | provenance | |
25+
| test.ps1:29:6:29:17 | Source | test.ps1:31:1:31:3 | x | provenance | |
26+
| test.ps1:30:6:30:17 | Source | test.ps1:31:5:31:7 | y | provenance | |
27+
| test.ps1:31:1:31:3 | x | test.ps1:31:1:31:7 | ...,... [element 0] | provenance | |
28+
| test.ps1:31:1:31:7 | ...,... [element 0] | test.ps1:25:14:25:16 | _ [element 0] | provenance | |
29+
| test.ps1:31:1:31:7 | ...,... [element 0] | test.ps1:31:1:31:7 | ...,... [element 0] | provenance | |
30+
| test.ps1:31:1:31:7 | ...,... [element 1] | test.ps1:25:14:25:16 | _ [element 1] | provenance | |
31+
| test.ps1:31:1:31:7 | ...,... [element 1] | test.ps1:31:1:31:7 | ...,... [element 1] | provenance | |
32+
| test.ps1:31:5:31:7 | y | test.ps1:31:1:31:7 | ...,... [element 1] | provenance | |
33+
nodes
34+
| test.ps1:2:10:2:21 | Source | semmle.label | Source |
35+
| test.ps1:3:10:3:21 | Source | semmle.label | Source |
36+
| test.ps1:4:10:4:21 | Source | semmle.label | Source |
37+
| test.ps1:5:5:5:7 | x | semmle.label | x |
38+
| test.ps1:6:5:6:7 | y | semmle.label | y |
39+
| test.ps1:6:5:6:11 | ...,... [element 0] | semmle.label | ...,... [element 0] |
40+
| test.ps1:6:5:6:11 | ...,... [element 1] | semmle.label | ...,... [element 1] |
41+
| test.ps1:6:9:6:11 | z | semmle.label | z |
42+
| test.ps1:10:11:10:44 | x [element 0] | semmle.label | x [element 0] |
43+
| test.ps1:10:11:10:44 | x [element 1] | semmle.label | x [element 1] |
44+
| test.ps1:10:11:10:44 | x [element] | semmle.label | x [element] |
45+
| test.ps1:13:14:13:16 | x | semmle.label | x |
46+
| test.ps1:17:1:17:8 | produce [element] | semmle.label | produce [element] |
47+
| test.ps1:19:6:19:17 | Source | semmle.label | Source |
48+
| test.ps1:20:6:20:17 | Source | semmle.label | Source |
49+
| test.ps1:21:1:21:3 | x | semmle.label | x |
50+
| test.ps1:21:1:21:7 | ...,... [element 0] | semmle.label | ...,... [element 0] |
51+
| test.ps1:21:1:21:7 | ...,... [element 0] | semmle.label | ...,... [element 0] |
52+
| test.ps1:21:1:21:7 | ...,... [element 1] | semmle.label | ...,... [element 1] |
53+
| test.ps1:21:1:21:7 | ...,... [element 1] | semmle.label | ...,... [element 1] |
54+
| test.ps1:21:5:21:7 | y | semmle.label | y |
55+
| test.ps1:25:14:25:16 | _ | semmle.label | _ |
56+
| test.ps1:25:14:25:16 | _ [element 0] | semmle.label | _ [element 0] |
57+
| test.ps1:25:14:25:16 | _ [element 1] | semmle.label | _ [element 1] |
58+
| test.ps1:29:6:29:17 | Source | semmle.label | Source |
59+
| test.ps1:30:6:30:17 | Source | semmle.label | Source |
60+
| test.ps1:31:1:31:3 | x | semmle.label | x |
61+
| test.ps1:31:1:31:7 | ...,... [element 0] | semmle.label | ...,... [element 0] |
62+
| test.ps1:31:1:31:7 | ...,... [element 0] | semmle.label | ...,... [element 0] |
63+
| test.ps1:31:1:31:7 | ...,... [element 1] | semmle.label | ...,... [element 1] |
64+
| test.ps1:31:1:31:7 | ...,... [element 1] | semmle.label | ...,... [element 1] |
65+
| test.ps1:31:5:31:7 | y | semmle.label | y |
66+
subpaths
67+
testFailures
68+
#select
69+
| test.ps1:13:14:13:16 | x | test.ps1:2:10:2:21 | Source | test.ps1:13:14:13:16 | x | $@ | test.ps1:2:10:2:21 | Source | Source |
70+
| test.ps1:13:14:13:16 | x | test.ps1:3:10:3:21 | Source | test.ps1:13:14:13:16 | x | $@ | test.ps1:3:10:3:21 | Source | Source |
71+
| test.ps1:13:14:13:16 | x | test.ps1:4:10:4:21 | Source | test.ps1:13:14:13:16 | x | $@ | test.ps1:4:10:4:21 | Source | Source |
72+
| test.ps1:13:14:13:16 | x | test.ps1:19:6:19:17 | Source | test.ps1:13:14:13:16 | x | $@ | test.ps1:19:6:19:17 | Source | Source |
73+
| test.ps1:13:14:13:16 | x | test.ps1:20:6:20:17 | Source | test.ps1:13:14:13:16 | x | $@ | test.ps1:20:6:20:17 | Source | Source |
74+
| test.ps1:25:14:25:16 | _ | test.ps1:29:6:29:17 | Source | test.ps1:25:14:25:16 | _ | $@ | test.ps1:29:6:29:17 | Source | Source |
75+
| test.ps1:25:14:25:16 | _ | test.ps1:30:6:30:17 | Source | test.ps1:25:14:25:16 | _ | $@ | test.ps1:30:6:30:17 | Source | Source |
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function produce {
2+
$x = Source "16"
3+
$y = Source "17"
4+
$z = Source "18"
5+
$x
6+
$y, $z
7+
}
8+
9+
function consume {
10+
Param([Parameter(ValueFromPipeline)] $x)
11+
12+
process {
13+
Sink $x # $ hasValueFlow=16 hasValueFlow=17 hasValueFlow=18 hasValueFlow=19 hasValueFlow=20
14+
}
15+
}
16+
17+
produce | consume
18+
19+
$x = Source "19"
20+
$y = Source "20"
21+
$x, $y | consume
22+
23+
function consume2 {
24+
process {
25+
Sink $_ # $ hasValueFlow=21 hasValueFlow=22
26+
}
27+
}
28+
29+
$x = Source "21"
30+
$y = Source "22"
31+
$x, $y | consume2
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @kind path-problem
3+
*/
4+
5+
import powershell
6+
import semmle.code.powershell.dataflow.DataFlow
7+
private import TestUtilities.InlineFlowTest
8+
import DefaultFlowTest
9+
import ValueFlow::PathGraph
10+
11+
from ValueFlow::PathNode source, ValueFlow::PathNode sink
12+
where ValueFlow::flowPath(source, sink)
13+
select sink, source, sink, "$@", source, source.toString()

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

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,68 @@ models
22
edges
33
| test.ps1:2:5:2:15 | Source | test.ps1:5:6:5:20 | callSourceOnce | provenance | |
44
| test.ps1:5:6:5:20 | callSourceOnce | test.ps1:6:6:6:8 | x | 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 | |
7-
| test.ps1:13:6:13:21 | callSourceTwice | test.ps1:14:6:14:8 | x | provenance | |
8-
| test.ps1:17:12:17:22 | Source | test.ps1:20:6:20:19 | returnSource1 | provenance | |
9-
| test.ps1:20:6:20:19 | returnSource1 | test.ps1:21:6:21:8 | x | 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 | |
14-
| test.ps1:30:6:30:19 | returnSource2 | test.ps1:31:6:31:8 | x | provenance | |
5+
| test.ps1:9:5:9:15 | Source | test.ps1:13:6:13:21 | callSourceTwice [element] | provenance | |
6+
| test.ps1:10:5:10:15 | Source | test.ps1:13:6:13:21 | callSourceTwice [element] | provenance | |
7+
| test.ps1:13:6:13:21 | callSourceTwice [element] | test.ps1:15:6:15:8 | x [element] | provenance | |
8+
| test.ps1:13:6:13:21 | callSourceTwice [element] | test.ps1:16:6:16:8 | x [element] | provenance | |
9+
| test.ps1:15:6:15:8 | x [element] | test.ps1:15:6:15:11 | ...[...] | provenance | |
10+
| test.ps1:16:6:16:8 | x [element] | test.ps1:16:6:16:11 | ...[...] | provenance | |
11+
| test.ps1:19:12:19:22 | Source | test.ps1:22:6:22:19 | returnSource1 | provenance | |
12+
| test.ps1:22:6:22:19 | returnSource1 | test.ps1:23:6:23:8 | x | provenance | |
13+
| test.ps1:26:10:26:20 | Source | test.ps1:27:5:27:7 | x | provenance | |
14+
| test.ps1:27:5:27:7 | x | test.ps1:32:6:32:19 | returnSource2 [element] | provenance | |
15+
| test.ps1:28:10:28:20 | Source | test.ps1:29:12:29:14 | y | provenance | |
16+
| test.ps1:29:12:29:14 | y | test.ps1:32:6:32:19 | returnSource2 [element] | provenance | |
17+
| test.ps1:32:6:32:19 | returnSource2 [element] | test.ps1:33:6:33:8 | x [element] | provenance | |
18+
| test.ps1:32:6:32:19 | returnSource2 [element] | test.ps1:34:6:34:8 | x [element] | provenance | |
19+
| test.ps1:33:6:33:8 | x [element] | test.ps1:33:6:33:11 | ...[...] | provenance | |
20+
| test.ps1:34:6:34:8 | x [element] | test.ps1:34:6:34:11 | ...[...] | provenance | |
21+
| test.ps1:38:9:38:19 | Source | test.ps1:42:6:42:22 | callSourceInLoop [element] | provenance | |
22+
| test.ps1:42:6:42:22 | callSourceInLoop [element] | test.ps1:43:6:43:8 | x [element] | provenance | |
23+
| test.ps1:42:6:42:22 | callSourceInLoop [element] | test.ps1:44:6:44:8 | x [element] | provenance | |
24+
| test.ps1:43:6:43:8 | x [element] | test.ps1:43:6:43:11 | ...[...] | provenance | |
25+
| test.ps1:44:6:44:8 | x [element] | test.ps1:44:6:44:11 | ...[...] | provenance | |
1526
nodes
1627
| test.ps1:2:5:2:15 | Source | semmle.label | Source |
1728
| test.ps1:5:6:5:20 | callSourceOnce | semmle.label | callSourceOnce |
1829
| test.ps1:6:6:6:8 | x | semmle.label | x |
1930
| test.ps1:9:5:9:15 | Source | semmle.label | Source |
2031
| test.ps1:10:5:10:15 | Source | semmle.label | Source |
21-
| test.ps1:13:6:13:21 | callSourceTwice | semmle.label | callSourceTwice |
22-
| test.ps1:14:6:14:8 | x | semmle.label | x |
23-
| test.ps1:17:12:17:22 | Source | semmle.label | Source |
24-
| test.ps1:20:6:20:19 | returnSource1 | semmle.label | returnSource1 |
25-
| test.ps1:21:6:21:8 | x | semmle.label | x |
26-
| test.ps1:24:10:24:20 | Source | semmle.label | Source |
27-
| test.ps1:25:5:25:7 | x | semmle.label | x |
32+
| test.ps1:13:6:13:21 | callSourceTwice [element] | semmle.label | callSourceTwice [element] |
33+
| test.ps1:15:6:15:8 | x [element] | semmle.label | x [element] |
34+
| test.ps1:15:6:15:11 | ...[...] | semmle.label | ...[...] |
35+
| test.ps1:16:6:16:8 | x [element] | semmle.label | x [element] |
36+
| test.ps1:16:6:16:11 | ...[...] | semmle.label | ...[...] |
37+
| test.ps1:19:12:19:22 | Source | semmle.label | Source |
38+
| test.ps1:22:6:22:19 | returnSource1 | semmle.label | returnSource1 |
39+
| test.ps1:23:6:23:8 | x | semmle.label | x |
2840
| test.ps1:26:10:26:20 | Source | semmle.label | Source |
29-
| test.ps1:27:12:27:14 | y | semmle.label | y |
30-
| test.ps1:30:6:30:19 | returnSource2 | semmle.label | returnSource2 |
31-
| test.ps1:31:6:31:8 | x | semmle.label | x |
41+
| test.ps1:27:5:27:7 | x | semmle.label | x |
42+
| test.ps1:28:10:28:20 | Source | semmle.label | Source |
43+
| test.ps1:29:12:29:14 | y | semmle.label | y |
44+
| test.ps1:32:6:32:19 | returnSource2 [element] | semmle.label | returnSource2 [element] |
45+
| test.ps1:33:6:33:8 | x [element] | semmle.label | x [element] |
46+
| test.ps1:33:6:33:11 | ...[...] | semmle.label | ...[...] |
47+
| test.ps1:34:6:34:8 | x [element] | semmle.label | x [element] |
48+
| test.ps1:34:6:34:11 | ...[...] | semmle.label | ...[...] |
49+
| test.ps1:38:9:38:19 | Source | semmle.label | Source |
50+
| test.ps1:42:6:42:22 | callSourceInLoop [element] | semmle.label | callSourceInLoop [element] |
51+
| test.ps1:43:6:43:8 | x [element] | semmle.label | x [element] |
52+
| test.ps1:43:6:43:11 | ...[...] | semmle.label | ...[...] |
53+
| test.ps1:44:6:44:8 | x [element] | semmle.label | x [element] |
54+
| test.ps1:44:6:44:11 | ...[...] | semmle.label | ...[...] |
3255
subpaths
3356
testFailures
3457
#select
3558
| test.ps1:6:6:6:8 | x | test.ps1:2:5:2:15 | Source | test.ps1:6:6:6:8 | x | $@ | test.ps1:2:5:2:15 | Source | Source |
36-
| test.ps1:14:6:14:8 | x | test.ps1:9:5:9:15 | Source | test.ps1:14:6:14:8 | x | $@ | test.ps1:9:5:9:15 | Source | Source |
37-
| test.ps1:14:6:14:8 | x | test.ps1:10:5:10:15 | Source | test.ps1:14:6:14:8 | x | $@ | test.ps1:10:5:10:15 | Source | Source |
38-
| test.ps1:21:6:21:8 | x | test.ps1:17:12:17:22 | Source | test.ps1:21:6:21:8 | x | $@ | test.ps1:17:12:17:22 | Source | Source |
39-
| test.ps1:31:6:31:8 | x | test.ps1:24:10:24:20 | Source | test.ps1:31:6:31:8 | x | $@ | test.ps1:24:10:24:20 | Source | Source |
40-
| test.ps1:31:6:31:8 | x | test.ps1:26:10:26:20 | Source | test.ps1:31:6:31:8 | x | $@ | test.ps1:26:10:26:20 | Source | Source |
59+
| test.ps1:15:6:15:11 | ...[...] | test.ps1:9:5:9:15 | Source | test.ps1:15:6:15:11 | ...[...] | $@ | test.ps1:9:5:9:15 | Source | Source |
60+
| test.ps1:15:6:15:11 | ...[...] | test.ps1:10:5:10:15 | Source | test.ps1:15:6:15:11 | ...[...] | $@ | test.ps1:10:5:10:15 | Source | Source |
61+
| test.ps1:16:6:16:11 | ...[...] | test.ps1:9:5:9:15 | Source | test.ps1:16:6:16:11 | ...[...] | $@ | test.ps1:9:5:9:15 | Source | Source |
62+
| test.ps1:16:6:16:11 | ...[...] | test.ps1:10:5:10:15 | Source | test.ps1:16:6:16:11 | ...[...] | $@ | test.ps1:10:5:10:15 | Source | Source |
63+
| test.ps1:23:6:23:8 | x | test.ps1:19:12:19:22 | Source | test.ps1:23:6:23:8 | x | $@ | test.ps1:19:12:19:22 | Source | Source |
64+
| test.ps1:33:6:33:11 | ...[...] | test.ps1:26:10:26:20 | Source | test.ps1:33:6:33:11 | ...[...] | $@ | test.ps1:26:10:26:20 | Source | Source |
65+
| test.ps1:33:6:33:11 | ...[...] | test.ps1:28:10:28:20 | Source | test.ps1:33:6:33:11 | ...[...] | $@ | test.ps1:28:10:28:20 | Source | Source |
66+
| test.ps1:34:6:34:11 | ...[...] | test.ps1:26:10:26:20 | Source | test.ps1:34:6:34:11 | ...[...] | $@ | test.ps1:26:10:26:20 | Source | Source |
67+
| test.ps1:34:6:34:11 | ...[...] | test.ps1:28:10:28:20 | Source | test.ps1:34:6:34:11 | ...[...] | $@ | test.ps1:28:10:28:20 | Source | Source |
68+
| test.ps1:43:6:43:11 | ...[...] | test.ps1:38:9:38:19 | Source | test.ps1:43:6:43:11 | ...[...] | $@ | test.ps1:38:9:38:19 | Source | Source |
69+
| test.ps1:44:6:44:11 | ...[...] | test.ps1:38:9:38:19 | Source | test.ps1:44:6:44:11 | ...[...] | $@ | test.ps1:38:9:38:19 | Source | Source |

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ function callSourceTwice {
1111
}
1212

1313
$x = callSourceTwice
14-
Sink $x # $ hasValueFlow=2 hasValueFlow=3
14+
Sink $x # $ hasTaintFlow=2 hasTaintFlow=3
15+
Sink $x[0] # $ hasValueFlow=2 SPURIOUS: hasValueFlow=3
16+
Sink $x[1] # $ hasValueFlow=3 SPURIOUS: hasValueFlow=2
1517

1618
function returnSource1 {
1719
return Source "4"
@@ -28,4 +30,15 @@ function returnSource2 {
2830
}
2931

3032
$x = returnSource2
31-
Sink $x # $ hasValueFlow=5 hasValueFlow=6
33+
Sink $x[0] # $ hasValueFlow=5 SPURIOUS: hasValueFlow=6
34+
Sink $x[1] # $ hasValueFlow=6 SPURIOUS: hasValueFlow=5
35+
36+
function callSourceInLoop {
37+
for ($i = 0; $i -lt 2; $i++) {
38+
Source "7"
39+
}
40+
}
41+
42+
$x = callSourceInLoop
43+
Sink $x[0] # $ hasValueFlow=7
44+
Sink $x[1] # $ hasValueFlow=7

0 commit comments

Comments
 (0)