Repository navigation
fix(gate): leave the contents of a Win32 Package folder out of a folder search #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,15 @@ BeforeAll { | |
| # A Pester suite next to the scripts, as the suite template places it: not an Intune script | ||
| [System.IO.File]::WriteAllText((Join-Path $script:Scripts 'IntuneScripts.Tests.ps1'), | ||
| "BeforeAll { Import-Module IntuneScriptLab }`r`nDescribe 'x' { It 'y' { 1 | Should-Be 1 } }`r`n", $utf8Bom) | ||
| # A Win32 app's package content, as the suite template lays it out: the installer runs through | ||
| # the install command as SYSTEM, so it is not an Intune script either. Read as one, its | ||
| # machine-wide write is a user-context warning. 'Packages' is a folder of Win32 apps and stays in. | ||
| $null = New-Item -ItemType Directory -Path (Join-Path $script:Scripts 'Win32\Widget\Package') -Force | ||
| $null = New-Item -ItemType Directory -Path (Join-Path $script:Scripts 'Packages\Gadget') -Force | ||
| [System.IO.File]::WriteAllText((Join-Path $script:Scripts 'Win32\Widget\Package\install.ps1'), | ||
| "New-Item -Path HKLM:\SOFTWARE\Widget -Force | Out-Null`r`nexit 0`r`n", $utf8Bom) | ||
| [System.IO.File]::WriteAllText((Join-Path $script:Scripts 'Packages\Gadget\Detect.ps1'), | ||
| "Write-Output 'installed'`r`nexit 0`r`n", $utf8Bom) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kept clean on purpose. Its first version returned before exit 1 and carried an error-level finding, and 'Packages/Gadget' sorts before 'Remediations/Widget', so it became the first error annotation and the earlier test's assertion on that line failed. A clean Win32 detection still appears in the output through its IslAssumedContext line, which is all the new test needs. |
||
|
|
||
| # -File carries the script's exit code out as the process exit code on both hosts; a switch | ||
| # cannot be negated that way, so the quiet run uses -Command (and expects exit 0 anyway) | ||
|
|
@@ -110,6 +119,17 @@ Describe 'Invoke-IntuneScriptGate' -Tag 'Integration', 'Gate' { | |
| ($direct.Output -join "`n") | Should-BeLikeString '*IslModuleDependency*' | ||
| } | ||
|
|
||
| It 'leaves a Win32 Package folder out, keeps a Packages folder in, and analyzes a named installer' { | ||
| $run = Invoke-GateFile -Arguments @('-Path', $script:Scripts, '-Annotate', '-Root', $script:Scripts, | ||
| '-FailOn', 'None') | ||
| $run.ExitCode | Should-Be 0 | ||
| ($run.Output -join "`n") | Should-NotBeLikeString '*Package\install.ps1*' | ||
| ($run.Output -join "`n") | Should-BeLikeString '*Packages\Gadget\Detect.ps1*' | ||
| $installer = Join-Path $script:Scripts 'Win32\Widget\Package\install.ps1' | ||
| $direct = Invoke-GateFile -Arguments @('-Path', $installer, '-FailOn', 'None') | ||
| ($direct.Output -join "`n") | Should-BeLikeString '*IslContextIssue*' | ||
| } | ||
|
|
||
| It 'percent-encodes the colon of an absolute path outside -Root in the file property' { | ||
| # With -Root below the scripts, every path stays absolute and carries a drive letter | ||
| $run = Invoke-GateFile -Arguments @('-Path', $script:Scripts, '-Annotate', '-FailOn', 'None', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The separator is appended so a Package folder that is the file's own parent matches too: DirectoryName ends in '\Package' with nothing after it, and the pattern needs a separator on both sides to reject 'Packages' and 'MyPackage'. The class accepts both slashes so the same line holds on a Linux runner.