Refactor PS login to use a static param()-bound script - #600
Draft
MaddyMicrosoft wants to merge 2 commits into
Draft
Refactor PS login to use a static param()-bound script#600MaddyMicrosoft wants to merge 2 commits into
MaddyMicrosoft wants to merge 2 commits into
Conversation
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.
What
Move the Azure PowerShell login step from an interpolated PS script string to a static
AzPSLogin.ps1file invoked viapwsh -File, with user values passed as bound parameters and secret-shaped values passed via env vars.Why
The current
AzPSScriptBuilderconcatenates action inputs into a PowerShell script string. Every interpolation is a potential injection surface if escaping is missed for even one field. This refactor gives the PS path the same structural safety the CLI path (AzureCliLogin.ts) has always had: data and code travel through different channels.tenant-id,subscription-id,client-id,resourceManagerEndpointUrl) ride as argv → PowerShell parameter binding treats them as inert strings.clientSecret,federatedToken) ride as env vars → they never appear in argv,ps aux, or thecore.debuglog.Changes
src/PowerShell/AzPSLogin.ps1param()binding and splattedConnect-AzAccount.src/PowerShell/AzPSScriptBuilder.ts{ methodName, args, env }instead of a script string.src/PowerShell/AzPSLogin.tssrc/PowerShell/AzPSUtils.tsrunPwshhelper; newrunPSFile(args, env).scripts/copy-ps-assets.jsAzPSLogin.ps1intolib/main/at build time.package.jsonbuild:mainruns the copy script.README.md[!WARNING]blocks: don't pipe${{ github.event.* }}into these inputs; keepenable-AzPSSessionoff unless needed.Verification
$, and switch-shaped values intenant,subscription,client-id, andresourceManagerEndpointUrl.pwsh: adversarial payloads arrive atConnect-AzAccount/Add-AzEnvironmentas literal string data, not code.npm run buildproduceslib/main/index.js+lib/main/AzPSLogin.ps1.Scope notes
On
LoginConfigformat-validation suggestion: deliberately not included. Azure's ARM API spec (Microsoft.Subscription/subscriptions/rename,SubscriptionNameschema) allows any Unicode string for subscription display names, and Az.Accounts'-Subscriptionaccepts both GUIDs and display names via[Alias("SubscriptionName", "SubscriptionId")]. Any character-class check we impose has legitimate false positives against real subscription names likeProd (US East). The refactor closes the exploitation surface structurally; format validation is defense-in-depth we couldn't cleanly bound.Happy to add per-field checks for
tenant-idandclient-id(which really are always GUID/domain) if reviewers prefer.Behaviour change worth noting
core.debuglog format: previously printed the fully interpolated PS script (including aConvertTo-SecureString 'value'line subject tocore.setSecretmasking). Now prints the argv sent topwshand contains no secret-shaped values at all. Only visible whenACTIONS_STEP_DEBUGis enabled.