Skip to content

[SandboxTest] Improve input validation and WSB file generation#388302

Merged
Madhusudhan-MSFT merged 1 commit into
microsoft:masterfrom
Madhusudhan-MSFT:user/masudars/sandbox-input-validation-improvements
Jun 16, 2026
Merged

[SandboxTest] Improve input validation and WSB file generation#388302
Madhusudhan-MSFT merged 1 commit into
microsoft:masterfrom
Madhusudhan-MSFT:user/masudars/sandbox-input-validation-improvements

Conversation

@Madhusudhan-MSFT

@Madhusudhan-MSFT Madhusudhan-MSFT commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Strengthen SandboxTest.ps1 parameter handling and WSB configuration output to ensure robust behavior with diverse input paths and options.

Changes

  • MapFolder validation: Reject folder paths containing characters that are problematic for XML embedding (', ", <, >, &) with a clear error message identifying the forbidden characters
  • WinGetOptions validation: Add a dynamic allow-list that parses valid flags directly from winget install --help at runtime, ensuring the validation stays current with any installed WinGet version. Includes Write-Debug tracing for observability. Gracefully skips validation with a warning when WinGet is not installed on the host
  • WSB XML generation: Apply [System.Security.SecurityElement]::Escape() to all four interpolated paths (TestDataFolder, PrimaryMappedFolder, SandboxWorkingDirectory, SandboxBootstrapFile) before emitting into the .wsb configuration file, producing well-formed XML regardless of path content

Impact

  • Paths containing XML-meaningful characters no longer produce malformed .wsb files that fail to launch
  • Invalid or unrecognized flags passed via -WinGetOptions are caught early with an actionable error message listing all accepted flags
  • No behavioral change for typical usage — standard paths and valid WinGet flags work exactly as before
Microsoft Reviewers: Open in CodeFlow

## Summary

Strengthen SandboxTest.ps1 parameter handling and WSB configuration
output to ensure robust behavior with diverse input paths and options.

## Changes

- **MapFolder validation**: Reject folder paths containing characters that
  are problematic for XML embedding (', ", <, >, &) with a clear
  error message identifying the forbidden characters
- **WinGetOptions validation**: Add a dynamic allow-list that parses valid
  flags directly from winget install --help at runtime, ensuring the
  validation stays current with any installed WinGet version. Includes
  Write-Debug tracing for observability. Gracefully skips validation
  with a warning when WinGet is not installed on the host
- **WSB XML generation**: Apply [System.Security.SecurityElement]::Escape()
  to all four interpolated paths (TestDataFolder, PrimaryMappedFolder,
  SandboxWorkingDirectory, SandboxBootstrapFile) before emitting into
  the .wsb configuration file, producing well-formed XML regardless
  of path content

## Impact

- Paths containing XML-meaningful characters no longer produce malformed
  .wsb files that fail to launch
- Invalid or unrecognized flags passed via -WinGetOptions are caught
  early with an actionable error message listing all accepted flags
- No behavioral change for typical usage — standard paths and valid
  WinGet flags work exactly as before
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Attention This work item needs to be reviewed by a member of the core team. label Jun 16, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Moderator-Approved One of the Moderators has reviewed and approved this PR label Jun 16, 2026
@Madhusudhan-MSFT Madhusudhan-MSFT merged commit 1410e3e into microsoft:master Jun 16, 2026
3 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Needs-Attention This work item needs to be reviewed by a member of the core team. label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Moderator-Approved One of the Moderators has reviewed and approved this PR Project-File

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants