mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
## What changed Move `SandboxOverride` into the shared protocol and carry the controller's selection through tool attempts, execution requests, and exec-server process and filesystem sandbox preparation. Include it as `sandboxOverride` in filesystem sandbox contexts for observation without granting broader permissions or altering sandbox commands. Default missing values to `NoOverride` and omit that value when serializing to preserve compatibility with existing requests. ## Testing Extend tests to cover override propagation, wire round-trips for all three variants, and deserialization of requests without `sandboxOverride`. GitOrigin-RevId: 2f438cf4aef1134e3149959d14aa731682168ae5
62 lines
1.8 KiB
Rust
62 lines
1.8 KiB
Rust
//! Identifies the sandbox implementation and overrides selected for a command.
|
|
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
use crate::config_types::WindowsSandboxLevel;
|
|
|
|
/// Controller decision that overrides normal sandbox selection for a command.
|
|
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum SandboxOverride {
|
|
/// Use normal sandbox selection.
|
|
#[default]
|
|
NoOverride,
|
|
/// Broaden approved filesystem access while retaining denied-read enforcement.
|
|
EscalatedSandboxWithRestrictions,
|
|
/// Bypass the sandbox on the first attempt.
|
|
BypassSandboxFirstAttempt,
|
|
}
|
|
|
|
impl SandboxOverride {
|
|
pub fn is_no_override(&self) -> bool {
|
|
*self == Self::NoOverride
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum SandboxType {
|
|
None,
|
|
MacosSeatbelt,
|
|
LinuxSeccomp,
|
|
WindowsRestrictedToken,
|
|
WindowsMxc,
|
|
}
|
|
|
|
impl SandboxType {
|
|
pub fn as_metric_tag(self) -> &'static str {
|
|
match self {
|
|
Self::None => "none",
|
|
Self::MacosSeatbelt => "seatbelt",
|
|
Self::LinuxSeccomp => "seccomp",
|
|
Self::WindowsRestrictedToken => "windows_sandbox",
|
|
Self::WindowsMxc => "windows_mxc",
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Preserves explicit MXC selection while honoring legacy runtime level updates.
|
|
pub fn effective_windows_sandbox_type(
|
|
sandbox_type: SandboxType,
|
|
sandbox_level: WindowsSandboxLevel,
|
|
) -> SandboxType {
|
|
match (sandbox_type, sandbox_level) {
|
|
(SandboxType::WindowsMxc, _) => SandboxType::WindowsMxc,
|
|
(_, WindowsSandboxLevel::Disabled) => SandboxType::None,
|
|
(_, WindowsSandboxLevel::RestrictedToken | WindowsSandboxLevel::Elevated) => {
|
|
SandboxType::WindowsRestrictedToken
|
|
}
|
|
}
|
|
}
|