Skip to content

Commit 5fa3beb

Browse files
committed
PS: Normalize parameter keywords and accept test changes.
1 parent 1c380fb commit 5fa3beb

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ private module ParameterNodes {
540540
override predicate isParameterOf(DataFlowCallable c, ParameterPosition pos) {
541541
parameter.getEnclosingScope() = c.asCfgScope() and
542542
(
543-
pos.isKeyword(parameter.getName())
543+
pos.isKeyword(parameter.getName().toLowerCase())
544544
or
545545
// Given a function f with parameters x, y we map
546546
// x to the positions:
@@ -558,7 +558,7 @@ private module ParameterNodes {
558558
parameter.getIndexExcludingPipelines() = i and
559559
f = parameter.getFunction() and
560560
f = ns.getAFunction() and
561-
name = parameter.getName() and
561+
name = parameter.getName().toLowerCase() and
562562
not name = ns.getAName() and
563563
j =
564564
i -

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ edges
142142
| test.ps1:39:14:39:19 | third | test.ps1:8:32:12:1 | z | provenance | |
143143
| test.ps1:39:24:39:30 | second | test.ps1:8:32:12:1 | y | provenance | |
144144
| test.ps1:39:32:39:37 | first | test.ps1:8:32:12:1 | x | provenance | |
145+
| test.ps1:42:1:45:1 | UserInput | test.ps1:44:10:44:19 | UserInput | provenance | |
146+
| test.ps1:47:10:47:19 | Call to Source | test.ps1:48:46:48:51 | input | provenance | |
147+
| test.ps1:48:46:48:51 | input | test.ps1:42:1:45:1 | UserInput | provenance | |
145148
nodes
146149
| global.ps1:1:1:6:32 | Source1 | semmle.label | Source1 |
147150
| global.ps1:1:1:6:32 | Source2 | semmle.label | Source2 |
@@ -230,6 +233,10 @@ nodes
230233
| test.ps1:39:14:39:19 | third | semmle.label | third |
231234
| test.ps1:39:24:39:30 | second | semmle.label | second |
232235
| test.ps1:39:32:39:37 | first | semmle.label | first |
236+
| test.ps1:42:1:45:1 | UserInput | semmle.label | UserInput |
237+
| test.ps1:44:10:44:19 | UserInput | semmle.label | UserInput |
238+
| test.ps1:47:10:47:19 | Call to Source | semmle.label | Call to Source |
239+
| test.ps1:48:46:48:51 | input | semmle.label | input |
233240
subpaths
234241
testFailures
235242
#select
@@ -241,3 +248,4 @@ testFailures
241248
| test.ps1:9:10:9:11 | x | test.ps1:14:10:14:19 | Call to Source | test.ps1:9:10:9:11 | x | $@ | test.ps1:14:10:14:19 | Call to Source | Call to Source |
242249
| test.ps1:10:10:10:11 | y | test.ps1:15:11:15:20 | Call to Source | test.ps1:10:10:10:11 | y | $@ | test.ps1:15:11:15:20 | Call to Source | Call to Source |
243250
| test.ps1:11:10:11:11 | z | test.ps1:16:10:16:19 | Call to Source | test.ps1:11:10:11:11 | z | $@ | test.ps1:16:10:16:19 | Call to Source | Call to Source |
251+
| test.ps1:44:10:44:19 | UserInput | test.ps1:47:10:47:19 | Call to Source | test.ps1:44:10:44:19 | UserInput | $@ | test.ps1:47:10:47:19 | Call to Source | Call to Source |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ThreeArgs -z $third -y $second $first
4141
function Invoke-InvokeExpressionInjection2
4242
{
4343
param($UserInput)
44-
Sink $UserInput # $ MISSING: hasValueFlow=1
44+
Sink $UserInput # $ hasValueFlow=1
4545
}
4646

4747
$input = Source "1"

0 commit comments

Comments
 (0)