Skip to content

Validate remote module names used by Save-Help - #28400

Open
Justin Chung (jshigetomi) wants to merge 2 commits into
PowerShell:masterfrom
jshigetomi:241bp
Open

Justin Chung (jshigetomi) wants to merge 2 commits into
PowerShell:masterfrom
jshigetomi:241bp

Conversation

@jshigetomi

@jshigetomi Justin Chung (jshigetomi) commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

PR Summary

PR Context

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Existing files retain their copyright headers
  • This PR is ready to merge
  • Breaking changes
    • None
  • User-facing changes
    • Not Applicable
  • Testing - New and feature
    • Added tests for the changed behavior

Copilot AI balanced review requested due to automatic review settings November 11, 2026 19:12
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@jshigetomi Justin Chung (jshigetomi) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The containment tests can pass without exercising file writes, and their path-prefix check can misclassify escaped files as inside the destination.

2 open issues
What changed in this PR

Hardens Save-Help output-path handling by validating remote module names before using them as path components.

Changes:

  • Rejects empty names, path separators, Windows colons, and . or ...
  • Adds a localized error message for invalid module names.
  • Adds tests for accepted and rejected names, platform-specific colon handling, and output containment.
File Description
test/​powershell/​engine/​Help/​UpdatableHelpSystem.Tests.ps1 Adds remote module-name validation and output-containment checks.
src/​System.Management.Automation/​resources/​HelpDisplayStrings.resx Adds the invalid-module-name error message.
src/​System.Management.Automation/​help/​UpdatableHelpCommandBase.cs Validates module names before further help processing.

Review effort: Balanced

Guid = [guid]::NewGuid()
Version = [Version]'1.0.0.0'
ModuleBase = $root
HelpInfoUri = 'https://example.invalid/help/'
}

$escaped = @(Get-ChildItem -LiteralPath $root -Recurse -File -Force -ErrorAction SilentlyContinue |
Where-Object { -not $_.FullName.StartsWith($destFull, [System.StringComparison]::OrdinalIgnoreCase) })
@jshigetomi Justin Chung (jshigetomi) changed the title Protect Save-Help output paths by validating remote module names Validate remote module names before Save-Help constructs output paths Nov 11, 2026
@jshigetomi Justin Chung (jshigetomi) changed the title Validate remote module names before Save-Help constructs output paths Validate remote module names used by Save-Help Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants