Pin Pester to exact version and use approved PowerShell verbs #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Pin Pester module to specific version (5.7.1) using
-RequiredVersionto prevent automatic upgrades to potentially compromised versions during CI/local test runs. Additionally, refactor helper functions to use approved PowerShell verbs.Motivation
The previous implementation used
-MinimumVersion, allowing automatic upgrades to any newer Pester version from the PowerShell Gallery. If the module or gallery were compromised, malicious code satisfyingPester >= $MinimumVersionwould execute with repository access and CI permissions, creating a supply-chain attack vector.Additionally, helper functions used the non-approved verb
Ensure, which violates PowerShell naming best practices.Type of Change
Changes
MinimumPesterVersion→PesterVersion(matchesPSScriptAnalyzerVersionpattern)Initialize-Pesterfunction (formerlyEnsure-Pester) to enforce exact version matching:Install-Module -MinimumVersion→-RequiredVersionImport-Module -MinimumVersion→-RequiredVersion$pester.Version -lt $MinimumVersion→$_.Version -eq $RequiredVersion-AllowClobberflag for consistency withInitialize-ModulepatternInitialize:Ensure-Directory→Initialize-Directory(in both tool scripts)Ensure-Pester→Initialize-Pester(in Invoke-IdlePesterTests.ps1)Ensure-Module→Initialize-Module(in Invoke-IdleScriptAnalyzer.ps1)Before:
After:
Testing
How to test & review
Run
./tools/Invoke-IdlePesterTests.ps1and./tools/Invoke-IdleScriptAnalyzer.ps1- verify they use Pester 5.7.1 exactly, do not attempt to upgrade, and all function names use approved PowerShell verbs.Checklist
Related Issues
Addresses feedback from #70
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.