Skip to content

Commit b3626db

Browse files
committed
updated all powershell tests to use inline expectatoins
1 parent f63c714 commit b3626db

35 files changed

Lines changed: 99 additions & 81 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
experimental/ConvertToSecureStringAsPlainText.ql
1+
query: experimental/ConvertToSecureStringAsPlainText.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
$UserInput = Read-Host 'Please enter your secure code'
2-
$EncryptedInput = ConvertTo-SecureString -String $UserInput -AsPlainText -Force
2+
$EncryptedInput = ConvertTo-SecureString -String $UserInput -AsPlainText -Force # $ Alert
33

44
$SecureUserInput = Read-Host 'Please enter your secure code' -AsSecureString
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
experimental/HardcodedComputerName.ql
1+
query: experimental/HardcodedComputerName.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

powershell/ql/test/query-tests/security/HardcodedComputerName/test.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Function Invoke-MyRemoteCommand ()
22
{
3-
Invoke-Command -Port 343 -ComputerName hardcoderemotehostname
3+
Invoke-Command -Port 343 -ComputerName hardcoderemotehostname # $ Alert
44
}
55

66
Function Invoke-MyCommand ($ComputerName)
@@ -10,7 +10,7 @@ Function Invoke-MyCommand ($ComputerName)
1010

1111
Function Invoke-MyLocalCommand ()
1212
{
13-
Invoke-Command -Port 343 -ComputerName hardcodelocalhostname
13+
Invoke-Command -Port 343 -ComputerName hardcodelocalhostname # $ Alert
1414
}
1515

1616
Function Invoke-MyLocalCommand ()
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
experimental/UseOfReservedCmdletChar.ql
1+
query: experimental/UseOfReservedCmdletChar.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
function MyFunction[1]
1+
function MyFunction[1] # $ Alert Alert
22
{...}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
experimental/UsernameOrPasswordParameter.ql
1+
query: experimental/UsernameOrPasswordParameter.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

powershell/ql/test/query-tests/security/UsernameOrPasswordParameter/test.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ function Test-Script
44
Param
55
(
66
[String]
7-
$Username,
7+
$Username, # $ Alert
88
[SecureString]
9-
$Password
9+
$Password # $ Alert
1010
)
1111
}

powershell/ql/test/query-tests/security/cwe-022/test.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem
33
$zip = [System.IO.Compression.ZipFile]::OpenRead("MyPath\to\archive.zip")
44

55
foreach ($entry in $zip.Entries) {
6-
$targetPath = Join-Path $extractPath $entry.FullName
6+
$targetPath = Join-Path $extractPath $entry.FullName # $ Source
77
$fullTargetPath = [System.IO.Path]::GetFullPath($targetPath)
88

9-
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $fullTargetPath) # BAD
9+
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $fullTargetPath) # $ Alert
1010
}
1111

1212
foreach ($entry in $zip.Entries) {
13-
$targetPath = Join-Path $extractPath $entry.FullName
13+
$targetPath = Join-Path $extractPath $entry.FullName # $ Source
1414
$fullTargetPath = [System.IO.Path]::GetFullPath($targetPath)
1515

16-
$stream = [System.IO.File]::Open($fullTargetPath, 'Create') # BAD
16+
$stream = [System.IO.File]::Open($fullTargetPath, 'Create') # $ Alert
1717
$entry.Open().CopyTo($stream)
1818
$stream.Close()
1919
}
2020

2121
foreach ($entry in $zip.Entries) {
22-
$targetPath = Join-Path $extractPath $entry.FullName
22+
$targetPath = Join-Path $extractPath $entry.FullName # $ Source
2323
$fullTargetPath = [System.IO.Path]::GetFullPath($targetPath)
2424

2525
$extractRoot = [System.IO.Path]::GetFullPath($extractPath)
2626
if ($fullTargetPath.StartsWith($extractRoot)) {
27-
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $fullTargetPath) # GOOD [FALSE POSITIVE]
27+
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $fullTargetPath) # $ Alert
2828
}
2929
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
queries/security/cwe-022/ZipSlip.ql
1+
query: queries/security/cwe-022/ZipSlip.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

0 commit comments

Comments
 (0)