Open
Conversation
- powershell.yml: replace includeRule (2 hand-picked rules) with excludeRule PSAvoidUsingWriteHost so all other rules run; Write-Host is used intentionally throughout for user-facing progress output. - Create External Help.yml: add workflow-level permissions block (contents: read) - workflow had no permissions block, relying on permissive repo defaults. - Private/Invoke-Scans.ps1: suppress PSReviewUnusedParameter for EnrollmentAgentEKU and PreferredOwner; both are declared Mandatory as part of the public API but are not yet wired through to inner Find-* calls (reserved for planned ESC13 and remediation-ownership support). Findings deferred / not fixed: - PSUseShouldProcessForStateChangingFunctions: New-Dictionary and Set-RiskRating operate on in-memory objects only (false positives); Update-ESC* functions are remediation code (out of scope). - PSReviewUnusedParameter in Build-Module.ps1: params are used inside a PSPublishModule scriptblock, causing a PSSA false positive. - Find-ESC17 Mode param: referenced only in commented-out WIP code. - PSUseBOMForUnicodeEncodedFile on Invoke-Locksmith.ps1: that file is a generated build artifact; the fix belongs in the build pipeline. - PSAvoidTrailingWhitespace, PSUseSingularNouns: style / out of scope. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Expands CI linting coverage for the PowerShell codebase by running (nearly) the full PSScriptAnalyzer ruleset in GitHub Actions, tightens workflow token permissions, and adds targeted suppressions for known false-positive unused-parameter reports.
Changes:
- Updated PSScriptAnalyzer workflow to run all rules except
PSAvoidUsingWriteHost. - Added explicit
contents: readpermissions to the “Create External Help” workflow. - Suppressed
PSReviewUnusedParameterfor two intentionally reserved parameters inInvoke-Scans.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
Private/Invoke-Scans.ps1 |
Adds PSScriptAnalyzer suppressions for two reserved public-contract parameters. |
.github/workflows/powershell.yml |
Expands analyzer coverage by removing includeRule and adding an excludeRule for Write-Host. |
.github/workflows/Create External Help.yml |
Sets explicit minimal GITHUB_TOKEN permissions (contents: read) at the workflow level. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… monolith Copilot review (#278) correctly identified that the SuppressMessageAttribute entries added to Private/Invoke-Scans.ps1 were not reflected in the generated Invoke-Locksmith.ps1 monolith. PSScriptAnalyzer scans the whole repository recursively, so the monolith would still raise the same warnings that the source suppressions were intended to silence. Applied matching suppressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Expands PSScriptAnalyzer CI coverage from two hand-picked rules to all rules except
PSAvoidUsingWriteHost, adds a missing workflow permissions block, and suppresses two confirmed false-positive unused-parameter warnings in the module's public API.Changes
.github/workflows/powershell.ymlincludeRule(which ran onlyPSAvoidGlobalAliasesandPSAvoidUsingConvertToSecureStringWithPlainText).excludeRule: '"PSAvoidUsingWriteHost"'so all rules run except that one.Write-Hostis used intentionally throughout the module for user-facing progress output; suppressing that rule at the workflow level avoids noise without hiding real issues..github/workflows/Create External Help.ymlpermissions: contents: readat the workflow level. The workflow previously had no permissions block, meaning it inherited whatever the repository default grants (typicallycontents: writeon public repos with Actions enabled). Explicitcontents: readis the minimum this workflow needs (it checks out code but does not push back to the repo).Private/Invoke-Scans.ps1SuppressMessageAttributeentries forPSReviewUnusedParameteronEnrollmentAgentEKUandPreferredOwner.Mandatoryand are part of the function's public contract, but are not yet threaded through to any innerFind-*call:EnrollmentAgentEKU— reserved for ESC13 enrollment-agent scan support (the ESC13 case passes$ClientAuthEkus, not the enrollment-agent EKU).PreferredOwner— reserved for planned remediation-ownership integration.Findings triaged but not fixed
PSUseShouldProcessForStateChangingFunctionsNew-DictionaryPSUseShouldProcessForStateChangingFunctionsSet-RiskRatingPSUseShouldProcessForStateChangingFunctionsUpdate-ESC*RemediationPSUseShouldProcessForStateChangingFunctionsRemove-CommonParameterFromMarkdownPSReviewUnusedParameterBuild-Module.ps1(PublishToPSGallery,PSGalleryAPIPath)Build-Module {}scriptblock at lines 149-150; PSSA cannot see usage inside the closure.PSReviewUnusedParameterBuild-Module.ps1(Mode,Scans,OutputPath)PSReviewUnusedParameterFind-ESC17.ps1(Mode)PSUseBOMForUnicodeEncodedFileInvoke-Locksmith.ps1Invoke-Locksmith.ps1is a generated build artifact compiled fromPublic/andPrivate/sources. Adding a BOM directly to it would be overwritten by the next build. The fix belongs in the build pipeline (ensureBuild-Module.ps1saves the compiled output with UTF-8 BOM).PSUseSingularNounsWrite-HelpOutDocs.ps1,Write-PlatyPSDocs.ps1PSAvoidTrailingWhitespace