Repository navigation
Fix false-positive Write-Log warnings in built-in cmdlet rule - #2303
S.H Jeong (z0rimo) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the PowerShell 6.1 profile-data correction addressing false positives for user-defined Write-Log functions.
No open issues 🎉
What changed in this PR
Fixes #2146 by correcting PowerShell 6.1 command profiles so PSAvoidOverwritingBuiltInCmdlets no longer flags user-defined Write-Log functions. The fix updates profile data without changing rule logic.
Changes:
- Remove stale
Write-Logentries from all four PowerShell 6.1 profiles. - Add regression tests for explicit profiles and default settings, confirming that
Get-ChildItemoverrides still produce warnings.
| File | Description |
|---|---|
| Tests/Rules/AvoidOverwritingBuiltInCmdlets.tests.ps1 | Add regression coverage for Write-Log and genuine built-in overrides. |
| Engine/Settings/core-6.1.0-windows.json | Remove the stale Windows Write-Log entry. |
| Engine/Settings/core-6.1.0-macos.json | Remove the stale macOS Write-Log entry. |
| Engine/Settings/core-6.1.0-linux.json | Remove the stale Linux Write-Log entry. |
| Engine/Settings/core-6.1.0-linux-arm.json | Remove the stale Linux ARM Write-Log entry. |
Review effort: Balanced
|
Hi Christoph Bergmeister (@bergmeister), could you take a look at this PR when you have a chance? This fixes #2146 by removing the stale I also noticed that the Thanks! |
PR Summary
Fixes #2146.
PSAvoidOverwritingBuiltInCmdletsincorrectly reports user-definedWrite-Logfunctions as overwriting a built-in PowerShell command.The four PowerShell 6.1 command profiles contain a stale
Write-Logentry exported byPSDesiredStateConfiguration. This originates from a historical DSC issue where internal helper functions were unintentionally exported (PowerShell/PowerShell#7209).Changes:
Write-Logentry from the Windows, Linux, Linux ARM, and macOScore-6.1.0-*profiles.Get-ChildItemcontinue to produce warnings.The change is limited to the affected JSON entries and regression tests. No C# rule logic or unrelated compatibility data is modified.
Validation:
Expected 1, but got 2) and passed afterward.AvoidOverwritingBuiltInCmdlets: 12 passed.UseCompatibleCommands: 200 passed.UseCompatibleCmdlets: 14 passed.AvoidUsingAlias: 11 passed, 1 skipped.git diff --checkpassed.Testing notes:
The repository pins .NET SDK 8.0.419, which was unavailable locally. The build and tests were run using SDK 10 against a scratchpad copy. SHA256 checks confirmed that the modified source files matched the tested copy and that the JSON files matched the built module's Settings files.
The broader
AllCompatibilityRules.Tests.ps1suite was not completed locally due to its execution time and CPU usage. CI validation is pending.PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.