Skip to content

Reject an unmappable WSLc one-shot process.cwd - #1300

Merged
Gudge (MGudgin) merged 2 commits into
mainfrom
user/gudge/wslc_oneshot_cwd_fail_loud
Sep 29, 2026
Merged

Gudge (MGudgin) merged 2 commits into
mainfrom
user/gudge/wslc_oneshot_cwd_fail_loud

Conversation

@MGudgin

@MGudgin Gudge (MGudgin) commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

📖 Description

WSLc one-shot maps process.cwd from a local Windows drive path to /mnt/<drive>. Any other value (an in-container path such as /workspace, a relative or drive-relative path, or a UNC path) was silently dropped, and the workload ran in the container's default working directory.

This change keeps the existing one-shot path form and makes an unmappable value fail the launch:

  • policy_mapping::container_working_directory owns the rule: a blank value is treated as omitted, a drive path is mapped, and any other value returns an error that names it.
  • validate_runner calls the helper, so run-to-completion and streaming launches (JSON configs, mxc-sdk, FFI) reject the value as policy_validation before any container work.
  • start_container uses the same helper through a match whose Err arm keeps that entry point fail-closed.
  • docs/schema.md and the WSL guide document the one-shot and state-aware cwd forms.
process.cwd Behavior
omitted, "", whitespace-only container default (unchanged)
C:\work, C:/work, C: mapped to /mnt/c/... (unchanged)
/workspace, work, C:work, \\server\share rejected, error names the value

🔗 References

Fixes #902. The cross-backend relative-cwd defect is tracked in #1299.

🔍 Validation

  • cargo test -p wslc_common: 242 passed, including new helper (with interior-NUL rejection), validate_runner, and streaming spawn regression tests. The spawn test asserts that the rejection happens before start_container runs.
  • cargo clippy -p wslc_common --all-targets -- -D warnings
  • cargo fmt --all -- --check

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

Copilot AI balanced review requested due to automatic review settings September 27, 2026 03:20
@MGudgin
Gudge (MGudgin) requested a review from a team as a code owner September 27, 2026 03: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.

Copilot review overview

🟡 Changes recommended

Interior NULs can still truncate the working directory passed to the WSLc SDK.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

This PR makes WSLc one-shot launches reject unsupported process.cwd values instead of silently ignoring them.

Changes:

  • Centralizes one-shot working-directory mapping and validation.
  • Applies validation to buffered and streaming launches with regression tests.
  • Documents distinct one-shot and state-aware path formats.
File Description
wsl_container_runner.rs Validates and applies mapped cwd values.
sandbox.rs Tests early streaming rejection.
policy_mapping.rs Adds cwd mapping and validation helper.
wsl-container-getting-started.md Documents WSLc cwd behavior.
schema.md Clarifies backend-specific cwd formats.

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

Copilot AI review requested due to automatic review settings September 27, 2026 03:33

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.

Copilot review overview

🟢 Approval recommended

The implementation consistently rejects unmappable values before normal launch paths and includes focused regression coverage and documentation.

Review effort: Balanced
Findings: None

Resolved since last review (1)

Gudge and others added 2 commits September 26, 2026 21:19
The WSLc one-shot runner mapped process.cwd from a local Windows drive path
to /mnt/<drive> inside an if-let with no else branch, so any other value
(an in-container path such as /workspace, a relative or drive-relative path,
or a UNC path) was dropped and the workload ran in the container's default
working directory.

Add policy_mapping::container_working_directory as the single owner of the
rule: a blank value is treated as omitted, a drive path is mapped, and any
other value is an error that names it. validate_runner calls it, so both
run-to-completion and streaming launches reject the value as
policy_validation before any container work. start_container uses the same
helper through a match whose Err arm keeps that entry point fail-closed.

Document the one-shot cwd form in docs/schema.md and the WSL guide.

Fixes #902

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The mapped cwd is handed to the WSLc SDK as a C string, so a value such as
C:\work\0ignored was truncated to /mnt/c/work and the workload ran in a
directory other than the one the request named. container_working_directory
now rejects an interior NUL, matching the state-aware cstr_bytes guard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4d5bc4fd-28cd-4313-be79-c61367eac45e
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/wslc_oneshot_cwd_fail_loud branch from c5a81b8 to 715d585 Compare September 27, 2026 04:20
Copilot AI review requested due to automatic review settings September 27, 2026 04:20

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.

Copilot review overview

🟢 Approval recommended

The implementation consistently rejects invalid values before launch and includes focused regression coverage and documentation.

Review effort: Balanced
Findings: None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:shipit:

@MGudgin
Gudge (MGudgin) merged commit b637893 into main Sep 29, 2026
31 checks passed
@MGudgin
Gudge (MGudgin) deleted the user/gudge/wslc_oneshot_cwd_fail_loud branch September 29, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cross-backend] process.cwd is silently discarded or resolved against host state

3 participants