Separate executor sandbox selection from Windows sandbox levels (#45730)

## Why

MXC is a sandbox implementation, not a restricted-token sandbox level. Executor requests need to represent that choice separately from `WindowsSandboxLevel`.

## What changed

- Introduce `WindowsSandboxSelection` for executor sandbox contexts and remove `Mxc` from `WindowsSandboxLevel`.
- Preserve the `windowsSandboxLevel` wire field and its serialized values for compatibility.
- Share sandbox selection between executor process launches and filesystem helpers, and use the new selection in capability discovery and skill reads.
- Disable Windows sandbox selection for executor paths that do not use Windows path conventions.

## Testing

Extend coverage for MXC wire serialization, Windows skill-read sandbox checks, and capability discovery with distinct permissions. Exercise remote filesystem write restrictions with both restricted-token and MXC sandboxes, including rejection when native MXC is unavailable.

GitOrigin-RevId: 266211377bcb138a0dc75861e9ff2225fa37a53d
This commit is contained in:
iceweasel-oai authored and copyberry committed 2026-09-15 16:40:06 +00:00
1 parent a9d2564bcb
commit d4e11a9b97
32 files changed
+256 -150

No files matched your search

+32 -2
View File
@@ -325,6 +325,30 @@ impl TryFrom<ExecPermissionProfile> for PermissionProfile {
}
}
/// Windows sandbox choice encoded in executor RPCs.
///
/// The serialized field retains its legacy `windowsSandboxLevel` name for compatibility, but MXC
/// is a sandbox implementation rather than a RestrictedToken level.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum WindowsSandboxSelection {
#[default]
Disabled,
RestrictedToken,
Elevated,
Mxc,
}
impl From<WindowsSandboxLevel> for WindowsSandboxSelection {
fn from(level: WindowsSandboxLevel) -> Self {
match level {
WindowsSandboxLevel::Disabled => Self::Disabled,
WindowsSandboxLevel::RestrictedToken => Self::RestrictedToken,
WindowsSandboxLevel::Elevated => Self::Elevated,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FileSystemSandboxContext {
@@ -339,7 +363,8 @@ pub struct FileSystemSandboxContext {
/// Executor-local default directories used to resolve `:tmpdir` policy entries.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub temporary_directories: Option<Vec<PathUri>>,
pub windows_sandbox_level: WindowsSandboxLevel,
#[serde(rename = "windowsSandboxLevel")]
pub windows_sandbox_selection: WindowsSandboxSelection,
#[serde(default)]
pub windows_sandbox_private_desktop: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -385,7 +410,7 @@ impl FileSystemSandboxContext {
workspace_roots,
user_home_dir: None,
temporary_directories: None,
windows_sandbox_level: WindowsSandboxLevel::Disabled,
windows_sandbox_selection: WindowsSandboxSelection::Disabled,
windows_sandbox_private_desktop: false,
windows_sandbox_proxy_settings_mode: None,
use_legacy_landlock: false,
@@ -402,6 +427,11 @@ impl FileSystemSandboxContext {
&& !file_system_policy.has_full_disk_write_access()
}
/// Whether this context selects either supported Windows sandbox implementation.
pub fn windows_sandbox_is_requested(&self) -> bool {
self.windows_sandbox_selection != WindowsSandboxSelection::Disabled
}
/// Borrows the executor-owned paths needed to interpret filesystem policy entries.
///
/// Returns `None` after the cwd has been omitted from a transport context.