Improve PowerShell Remoting Argument Validation - #27870
Merged
Travis Plunk (TravisEz13) merged 2 commits intoAug 20, 2026
Merged
Conversation
Anam Navied (anamnavi)
requested review from
a team,
Travis Plunk (TravisEz13) and
Dongbo Wang (daxian-dbw)
as code owners
August 20, 2026 17:20
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
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
ArgumentListentries (e.g.,-i,-l,-p,-o,-s) rather than interpolated strings. - Remove the custom
ParseArgvlogic 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, andKeyFilePath, plus a Windows skip for thepwshconfigendpoint 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.
Travis Plunk (TravisEz13)
enabled auto-merge (squash)
August 20, 2026 21:00
Travis Plunk (TravisEz13)
approved these changes
Aug 20, 2026
Travis Plunk (TravisEz13)
merged commit Aug 20, 2026
294fbbc
into
PowerShell:master
36 of 44 checks passed
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.
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
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header