Skip to content

Commit 494ef7a

Browse files
committed
PS: Fix missing flow.
1 parent 4d8809a commit 494ef7a

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
528528
or
529529
not exists(e.getValue().asInt())
530530
)
531+
or
532+
exists(Content::KnownElementContent ec, int index |
533+
node2.asExpr().(CfgNodes::ExprNodes::ArrayLiteralCfgNode).getElement(index) = node1.asExpr() and
534+
c.isKnownOrUnknownElement(ec) and
535+
index = ec.getIndex().asInt()
536+
)
531537
}
532538

533539
/**

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ edges
157157
| test.ps1:31:6:31:22 | ...[...] [element 2] | test.ps1:31:6:31:33 | ...[...] | provenance | |
158158
| test.ps1:31:6:31:22 | ...[...] [element 3] | test.ps1:31:6:31:33 | ...[...] | provenance | |
159159
| test.ps1:31:6:31:22 | ...[...] [element 4] | test.ps1:31:6:31:33 | ...[...] | provenance | |
160+
| test.ps1:33:6:33:17 | Source | test.ps1:35:15:35:17 | x | provenance | |
161+
| test.ps1:35:9:35:17 | ...,... [element 2] | test.ps1:38:6:38:11 | arr8 [element 2] | provenance | |
162+
| test.ps1:35:9:35:17 | ...,... [element 2] | test.ps1:39:6:39:11 | arr8 [element 2] | provenance | |
163+
| test.ps1:35:15:35:17 | x | test.ps1:35:9:35:17 | ...,... [element 2] | provenance | |
164+
| test.ps1:38:6:38:11 | arr8 [element 2] | test.ps1:38:6:38:14 | ...[...] | provenance | |
165+
| test.ps1:39:6:39:11 | arr8 [element 2] | test.ps1:39:6:39:21 | ...[...] | provenance | |
160166
nodes
161167
| test.ps1:1:1:1:3 | [post] a [f] | semmle.label | [post] a [f] |
162168
| test.ps1:1:8:1:18 | Source | semmle.label | Source |
@@ -287,6 +293,13 @@ nodes
287293
| test.ps1:31:6:31:22 | ...[...] [element 3] | semmle.label | ...[...] [element 3] |
288294
| test.ps1:31:6:31:22 | ...[...] [element 4] | semmle.label | ...[...] [element 4] |
289295
| test.ps1:31:6:31:33 | ...[...] | semmle.label | ...[...] |
296+
| test.ps1:33:6:33:17 | Source | semmle.label | Source |
297+
| test.ps1:35:9:35:17 | ...,... [element 2] | semmle.label | ...,... [element 2] |
298+
| test.ps1:35:15:35:17 | x | semmle.label | x |
299+
| test.ps1:38:6:38:11 | arr8 [element 2] | semmle.label | arr8 [element 2] |
300+
| test.ps1:38:6:38:14 | ...[...] | semmle.label | ...[...] |
301+
| test.ps1:39:6:39:11 | arr8 [element 2] | semmle.label | arr8 [element 2] |
302+
| test.ps1:39:6:39:21 | ...[...] | semmle.label | ...[...] |
290303
subpaths
291304
testFailures
292305
#select
@@ -299,3 +312,5 @@ testFailures
299312
| test.ps1:26:6:26:25 | ...[...] | test.ps1:25:23:25:33 | Source | test.ps1:26:6:26:25 | ...[...] | $@ | test.ps1:25:23:25:33 | Source | Source |
300313
| test.ps1:30:6:30:17 | ...[...] | test.ps1:29:31:29:41 | Source | test.ps1:30:6:30:17 | ...[...] | $@ | test.ps1:29:31:29:41 | Source | Source |
301314
| test.ps1:31:6:31:33 | ...[...] | test.ps1:29:31:29:41 | Source | test.ps1:31:6:31:33 | ...[...] | $@ | test.ps1:29:31:29:41 | Source | Source |
315+
| test.ps1:38:6:38:14 | ...[...] | test.ps1:33:6:33:17 | Source | test.ps1:38:6:38:14 | ...[...] | $@ | test.ps1:33:6:33:17 | Source | Source |
316+
| test.ps1:39:6:39:21 | ...[...] | test.ps1:33:6:33:17 | Source | test.ps1:39:6:39:21 | ...[...] | $@ | test.ps1:33:6:33:17 | Source | Source |

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ $x = Source "10"
3535
$arr8 = 0, 1, $x
3636
Sink $arr8[0] # clean
3737
Sink $arr8[1] # clean
38-
Sink $arr8[2] # $ MISSING: hasValueFlow=10
39-
Sink $arr8[$unknown] # MISSING: hasValueFlow=10
38+
Sink $arr8[2] # $ hasValueFlow=10
39+
Sink $arr8[$unknown] # $ hasValueFlow=10
4040

4141
$y = Source "11"
4242

0 commit comments

Comments
 (0)