Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ops/platform-acceptance/windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ function Get-Distros {
return @($raw -split "`r?`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ })
}
function Invoke-Distro([string] $Command) {
& $Wsl -d $Distro -u root --exec /bin/bash -lc $Command | Out-Host
# PowerShell 5 re-quotes native command arguments before invoking wsl.exe.
# That mangles bash substitutions and nested quotes even when the
# PowerShell string itself is literal. Send the script over stdin instead;
# this preserves the exact bytes and was proven under the real runner user.
$Command | & $Wsl -d $Distro -u root --exec /bin/bash -s | Out-Host
if ($LASTEXITCODE -ne 0) { Refuse "in-distribution command failed: $Command" }
}
function Assert-DistroVersion([string] $ExpectedVersion) {
Expand Down
2 changes: 2 additions & 0 deletions test/phase4-platform-acceptance.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ test("Windows code publishes no artifact/signing claim and requires honest reboo
assert.match(windows, /apply-linux-release\.sh/);
assert.match(windows, /function Assert-DistroVersion/);
assert.equal((windows.match(/Assert-DistroVersion \$(?:Version|PreviousVersion)/g) || []).length, 4);
assert.match(windows, /\$Command \| & \$Wsl -d \$Distro -u root --exec \/bin\/bash -s/);
assert.doesNotMatch(windows, /\/bin\/bash -lc \$Command/);
Comment on lines +215 to +216

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject all argument-based -lc forms.

The negative assertion matches only /bin/bash -lc $Command. A future edit could add quotes or different whitespace and still pass while using argument transport. Match the --exec /bin/bash -lc shape independently of $Command.

Proposed test adjustment
-  assert.doesNotMatch(windows, /\/bin\/bash -lc \$Command/);
+  assert.doesNotMatch(windows, /--exec\s+\/bin\/bash\s+-lc\b/);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
assert.match(windows, /\$Command \| & \$Wsl -d \$Distro -u root --exec \/bin\/bash -s/);
assert.doesNotMatch(windows, /\/bin\/bash -lc \$Command/);
assert.match(windows, /\$Command \| & \$Wsl -d \$Distro -u root --exec \/bin\/bash -s/);
assert.doesNotMatch(windows, /--exec\s+\/bin\/bash\s+-lc\b/);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/phase4-platform-acceptance.mjs` around lines 215 - 216, Strengthen the
negative assertion in the Windows command test so it rejects any argument-based
`-lc` invocation following `--exec /bin/bash`, regardless of quoting,
whitespace, or the specific command argument. Keep the existing positive
assertion unchanged and update only the doesNotMatch pattern around the windows
command output.

assert.doesNotMatch(windows, /Invoke-Distro "test .*systemctl/);
assert.match(windows, /LocalRootfs/);
assert.match(read("site/public/install.ps1"), /LocalRootfsSha256/);
Expand Down
Loading