Skip to content

Commit a5a632f

Browse files
committed
added cmdletbinding case to tests
1 parent 97170ee commit a5a632f

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

powershell/ql/test/query-tests/security/cwe-078/CommandInjection/CommandInjectionCritical.expected

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
queries/security/cwe-078/CommandInjectionCritical.ql

powershell/ql/test/query-tests/security/cwe-078/CommandInjection/test.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ function Invoke-ExpandStringInjection2
147147
$executionContext.SessionState.InvokeCommand.ExpandString($UserInput) # BAD
148148
}
149149

150+
function Invoke-InvokeExpressionInjectionCmdletBinding
151+
{
152+
[CmdletBinding()]
153+
param($UserInput)
154+
Invoke-Expression "Get-Process -Name $UserInput" # BAD
155+
}
150156

151157

152158
$input = Read-Host "enter input"
@@ -171,6 +177,7 @@ Invoke-MethodInjection3 -UserInput $input
171177
Invoke-PropertyInjection -UserInput $input
172178
Invoke-ExpandStringInjection1 -UserInput $input
173179
Invoke-ExpandStringInjection2 -UserInput $input
180+
Invoke-InvokeExpressionInjectionCmdletBinding -userInput $input
174181

175182
#typed input
176183
function Invoke-InvokeExpressionInjectionSafe1

0 commit comments

Comments
 (0)