Skip to content

Improve PowerShell Remoting Argument Validation - #27870

Merged
Travis Plunk (TravisEz13) merged 2 commits into
PowerShell:masterfrom
anamnavi:remoting-validation
Aug 20, 2026
Merged

Travis Plunk (TravisEz13) merged 2 commits into
PowerShell:masterfrom
anamnavi:remoting-validation

Conversation

@anamnavi

@anamnavi Anam Navied (anamnavi) commented Aug 20, 2026

Copy link
Copy Markdown
Member

PR Summary

This pull request refactors SSH process argument handling in PowerShell remoting to use ProcessStartInfo.ArgumentList throughout the SSH invocation flow and expands test coverage for invalid and edge-case parameter values.

By treating SSH arguments as discrete entries instead of constructing command-line strings, the implementation becomes simpler, more consistent, and easier to maintain. The update also includes additional validation tests, platform-specific test improvements, and helper logic for Windows process creation.

PR Context

PR Checklist

Copilot AI lite review requested due to automatic review settings August 20, 2026 17:20
@azure-pipelines

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

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.

Pull request overview

This pull request refactors how SSH remoting process arguments are constructed in RunspaceConnectionInfo.cs to use ProcessStartInfo.ArgumentList end-to-end (reducing parsing/quoting ambiguity) and expands SSH remoting Pester coverage to validate rejection/failure behavior for malformed SSH-related parameters.

Changes:

  • Build SSH arguments as discrete ArgumentList entries (e.g., -i, -l, -p, -o, -s) rather than interpolated strings.
  • Remove the custom ParseArgv logic on UNIX by directly prepending the executable name to the existing argument list.
  • Add Windows-specific argument flattening/quoting helpers and expand SSH remoting tests for malformed UserName, Port, Subsystem, and KeyFilePath, plus a Windows skip for the pwshconfig endpoint test.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs Refactors SSH process argument construction to use ArgumentList, replaces argv parsing on UNIX, and adds Windows command-line join/quote helpers.
test/SSHRemoting/SSHRemoting.Basic.Tests.ps1 Adds shared SSH test variables, refactors session retry helper logic, and expands negative test coverage for malformed SSH parameters.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@anamnavi Anam Navied (anamnavi) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Aug 20, 2026
@TravisEz13
Travis Plunk (TravisEz13) enabled auto-merge (squash) August 20, 2026 21:00
@TravisEz13
Travis Plunk (TravisEz13) merged commit 294fbbc into PowerShell:master Aug 20, 2026
36 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants