Skip to content

fix: enforce Copilot CLI shim policy on macOS and Linux - #341916

Closed
Don Jayamanne (DonJayamanne) wants to merge 1 commit into
mainfrom
don/agents/issue-10108-policy-resolution-plan
Closed

Don Jayamanne (DonJayamanne) wants to merge 1 commit into
mainfrom
don/agents/issue-10108-policy-resolution-plan

Conversation

@DonJayamanne

Copy link
Copy Markdown
Contributor

Fixes microsoft/vscode-internalbacklog#10108

Summary

Make the native Rust copilot shim read CopilotCliCommand on macOS and Linux. A terminal opened before policy is disabled can retain the shim on PATH; previously the non-Windows reader always returned false, allowing a missing CLI to be offered for installation.

  • Linux reads /etc/vscode/policy.json and recognizes only a JSON boolean false.
  • macOS reads effective CFBoolean values using CFPreferencesCopyAppValue for Stable, Insiders, Exploration, and OSS. A false value in any domain disables installation.
  • Preserve installed-CLI discovery before policy evaluation: an installed CLI still launches; a missing CLI under disabled policy produces the existing message, skips the prompt, and exits 10. The existing setup probe and install commands consume the same policy result.
  • Keep the existing Windows registry reader unchanged. Missing, invalid, or unreadable Linux/macOS policy values fail open.
  • Add platform-reader and application regressions, explicit Core Foundation ownership contracts, and update the directly related requirements and policy-support comment.
  • Add target-specific serde_json / core-foundation-sys dependencies and bump the shim to 0.1.1 as required for binary replacement. Retired script shims are unchanged.

Prior patterns

Validation

All commands below passed locally with Rust 1.88 on macOS unless otherwise noted.

Command Result
cargo +1.88 test --manifest-path copilot_shim/Cargo.toml --locked Passed before the final safety-annotation/documentation repair: 70 library tests, 4 app integration tests, 3 PTY tests
cargo +1.88 test --manifest-path copilot_shim/Cargo.toml --locked --lib policy Passed after the final repair: 10 selected policy tests
cargo +1.88 clippy --manifest-path copilot_shim/Cargo.toml --all-targets --locked -- -D warnings Passed after the final repair
cargo +1.88 fmt --manifest-path copilot_shim/Cargo.toml --check Passed after the final repair
cargo +1.88 build --manifest-path copilot_shim/Cargo.toml --release --locked --bin copilot Passed before the final safety-annotation/documentation repair
cargo +1.88 check --manifest-path copilot_shim/Cargo.toml --target x86_64-unknown-linux-gnu --all-targets --locked Passed; cross-target compilation, not Linux test execution
cargo +1.88 check --manifest-path copilot_shim/Cargo.toml --target x86_64-pc-windows-msvc --all-targets --locked Passed; cross-target compilation, not Windows test execution
cargo +1.88 metadata --manifest-path copilot_shim/Cargo.toml --locked --no-deps --format-version 1 Passed; package version verified as 0.1.1
npm run eslint -- src/vs/platform/agentHost/common/agentHostPolicySupport.ts Passed, including after fast-forwarding to main
git diff --check Passed

A temporary metadata-only probe including the actual policy source confirmed that the helper's formerly safe call now fails with E0133, while an explicit unsafe call compiles. The probe was not executed and was removed afterward. The final repair received an independent read-only review with no findings.

The branch was fast-forwarded to main before publication. The Rust package and all eight reviewed file contents remained unchanged, so their successful validation was retained.

Coverage limits

  • Native Linux/Windows CI execution is still needed; local cross-target checks are not runtime validation.
  • No root-capable Linux binary smoke against the real /etc/vscode/policy.json was run.
  • No real MDM deployment, product-domain policy mutation, managed-over-user precedence test, or cfprefsd propagation test was run on this developer machine.
  • No policy declaration or catalog metadata changed; policy export was not required or run.

Read native CopilotCliCommand policy in existing terminals before offering installation, while preserving installed CLI launches and Windows behavior.

Fixes microsoft/vscode-internalbacklog#10108

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 01:07
@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 93ed9b41 Current: 48940c68

Changed (2)

sessions/sessionToolbar/sessionToolbar/SubmenuOpen/Light
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/PluginMarketplaceMigrationDisabled/Light
Before After
before after

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.

🔵 Needs a closer look

Native Linux/Windows execution and macOS managed-policy integration remain unverified for this enterprise-policy enforcement change.

0 open findings

What changed in this PR

Closes the stale-terminal policy gap by making the native Copilot CLI shim enforce installation policy on macOS and Linux while preserving installed-CLI launches.

Changes:

  • Adds platform policy readers while retaining Windows behavior.
  • Adds policy regressions and updates requirements.
  • Adds platform dependencies and bumps the shim to 0.1.1.

No actionable defects were identified.

File Description
src/​vs/​platform/​agentHost/​common/​agentHostPolicySupport.ts Clarifies cross-platform enforcement in a comment.
copilot_shim/​src/​runtime.rs Delegates policy checks to the shared reader.
copilot_shim/​src/​policy.rs Adds Linux/macOS readers and tests.
copilot_shim/​src/​lib.rs Registers the policy module.
copilot_shim/​src/​app.rs Tests policy blocking and installed-CLI bypass.
copilot_shim/​REQUIREMENTS.md Documents policy behavior and validation limits.
copilot_shim/​Cargo.toml Adds dependencies and bumps the version.
copilot_shim/​Cargo.lock Locks dependencies and the new version.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Karthik Nadig (karthiknadig) added a commit that referenced this pull request Oct 19, 2026
… macOS shim (#342101)

* linux: expose the Copilot shim in DEB/RPM packages

Honor Linux installation policy and preserve the official installer PATH. Manage Stable and Insiders command ownership through guarded package lifecycle hooks.

Add native runtime regressions and a focused package lifecycle harness while leaving deferred packaging formats and non-Linux behavior unchanged.

Co-authored-by: Copilot <[email protected]>

* test: fix Copilot package launcher and rendering checks

Use a scenario-local profile for root launcher validation and ignore disabled shell comments when checking unresolved package placeholders. Preserve strict helper validation and add focused regressions.

Co-authored-by: Copilot <[email protected]>

* copilot: apply the CopilotCliCommand policy to Linux packages and the macOS shim

The Linux DEB/RPM scripts now ask the shim for the CopilotCliCommand policy
before managing /usr/bin/copilot, matching Windows setup: a disabled policy
removes a link to either edition's shim instead of creating one, and an
unreadable policy leaves the entry unchanged. DEB packages add a preseedable
<package>/add-copilot-command debconf question (medium priority, default true)
that lets an edition opt out; hand-over on removal respects the other
edition's answer and the policy.

The shim gains `--vscode-shim policy`, which exits 0 when the policy allows
the command and 10 when it turns it off, and reads the policy on macOS from
the configuration-profile domains of every quality (ported from #341916).

Co-authored-by: Don Jayamanne <[email protected]>
Co-authored-by: Copilot <[email protected]>

* test: drop rendering tests that only exercised the harness validator

Keep the checks of the real link helper source and the DEB/RPM templates;
the removed cases tested the package-lifecycle harness's own validator
rather than product code.

Co-authored-by: Copilot <[email protected]>

* copilot: bump the shim to 0.1.2

main's #342224 and this branch both changed the shim and bumped it from 0.1.0
to 0.1.1. Windows setup keeps a published shim whose file version matches, so
the merged shim needs its own version to replace main's 0.1.1.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Don Jayamanne <[email protected]>
Co-authored-by: Copilot <[email protected]>
Don Jayamanne (DonJayamanne) added a commit that referenced this pull request Oct 19, 2026
#342660)

copilot: apply the CopilotCliCommand policy to Linux packages and the macOS shim (#342101)

* linux: expose the Copilot shim in DEB/RPM packages

Honor Linux installation policy and preserve the official installer PATH. Manage Stable and Insiders command ownership through guarded package lifecycle hooks.

Add native runtime regressions and a focused package lifecycle harness while leaving deferred packaging formats and non-Linux behavior unchanged.



* test: fix Copilot package launcher and rendering checks

Use a scenario-local profile for root launcher validation and ignore disabled shell comments when checking unresolved package placeholders. Preserve strict helper validation and add focused regressions.



* copilot: apply the CopilotCliCommand policy to Linux packages and the macOS shim

The Linux DEB/RPM scripts now ask the shim for the CopilotCliCommand policy
before managing /usr/bin/copilot, matching Windows setup: a disabled policy
removes a link to either edition's shim instead of creating one, and an
unreadable policy leaves the entry unchanged. DEB packages add a preseedable
<package>/add-copilot-command debconf question (medium priority, default true)
that lets an edition opt out; hand-over on removal respects the other
edition's answer and the policy.

The shim gains `--vscode-shim policy`, which exits 0 when the policy allows
the command and 10 when it turns it off, and reads the policy on macOS from
the configuration-profile domains of every quality (ported from #341916).




* test: drop rendering tests that only exercised the harness validator

Keep the checks of the real link helper source and the DEB/RPM templates;
the removed cases tested the package-lifecycle harness's own validator
rather than product code.



* copilot: bump the shim to 0.1.2

main's #342224 and this branch both changed the shim and bumped it from 0.1.0
to 0.1.1. Windows setup keeps a published shim whose file version matches, so
the merged shim needs its own version to replace main's 0.1.1.



---------

Co-authored-by: Karthik Nadig <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.

2 participants