mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
0d0abe839a
## Summary - adds macOS Seatbelt deny rules for unreadable glob patterns - expands unreadable glob matches on Linux and masks them in bwrap, including canonical symlink targets - keeps Linux glob expansion robust when `rg` is unavailable in minimal or Bazel test environments - adds sandbox integration coverage that runs `shell` and `exec_command` with a `**/*.env = none` policy and verifies the secret contents do not reach the model ## Linux glob expansion ```text Prefer: rg --files --hidden --no-ignore --glob <pattern> -- <search-root> Fallback: internal globset walker when rg is not installed Failure: any other rg failure aborts sandbox construction ``` ``` [permissions.workspace.filesystem] glob_scan_max_depth = 2 [permissions.workspace.filesystem.":project_roots"] "**/*.env" = "none" ``` This keeps the common path fast without making sandbox construction depend on an ambient `rg` binary. If `rg` is present but fails for another reason, the sandbox setup fails closed instead of silently omitting deny-read masks. ## Platform support - macOS: subprocess sandbox enforcement is handled by Seatbelt regex deny rules - Linux: subprocess sandbox enforcement is handled by expanding existing glob matches and masking them in bwrap - Windows: policy/config/direct-tool glob support is already on `main` from #15979; Windows subprocess sandbox paths continue to fail closed when unreadable split filesystem carveouts require runtime enforcement, rather than silently running unsandboxed ## Stack 1. #15979 - merged: cross-platform glob deny-read policy/config/direct-tool support for macOS, Linux, and Windows 2. This PR - macOS/Linux subprocess sandbox enforcement plus Windows fail-closed clarification 3. #17740 - managed deny-read requirements ## Verification - Added integration coverage for `shell` and `exec_command` glob deny-read enforcement - `cargo check -p codex-sandboxing -p codex-linux-sandbox --tests` - `cargo check -p codex-core --test all` - `cargo clippy -p codex-linux-sandbox -p codex-sandboxing --tests` - `just bazel-lock-check` --------- Co-authored-by: Codex <noreply@openai.com>
48 lines
1.5 KiB
Rust
48 lines
1.5 KiB
Rust
#[cfg(target_os = "linux")]
|
|
mod bwrap;
|
|
pub mod landlock;
|
|
mod manager;
|
|
pub mod policy_transforms;
|
|
#[cfg(target_os = "macos")]
|
|
pub mod seatbelt;
|
|
|
|
#[cfg(target_os = "linux")]
|
|
pub use bwrap::find_system_bwrap_in_path;
|
|
#[cfg(target_os = "linux")]
|
|
pub use bwrap::system_bwrap_warning;
|
|
pub use manager::SandboxCommand;
|
|
pub use manager::SandboxExecRequest;
|
|
pub use manager::SandboxManager;
|
|
pub use manager::SandboxTransformError;
|
|
pub use manager::SandboxTransformRequest;
|
|
pub use manager::SandboxType;
|
|
pub use manager::SandboxablePreference;
|
|
pub use manager::get_platform_sandbox;
|
|
|
|
use codex_protocol::error::CodexErr;
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
pub fn system_bwrap_warning(
|
|
_sandbox_policy: &codex_protocol::protocol::SandboxPolicy,
|
|
) -> Option<String> {
|
|
None
|
|
}
|
|
|
|
impl From<SandboxTransformError> for CodexErr {
|
|
fn from(err: SandboxTransformError) -> Self {
|
|
match err {
|
|
SandboxTransformError::MissingLinuxSandboxExecutable => {
|
|
CodexErr::LandlockSandboxExecutableNotProvided
|
|
}
|
|
#[cfg(target_os = "linux")]
|
|
SandboxTransformError::Wsl1UnsupportedForBubblewrap => {
|
|
CodexErr::UnsupportedOperation(crate::bwrap::WSL1_BWRAP_WARNING.to_string())
|
|
}
|
|
#[cfg(not(target_os = "macos"))]
|
|
SandboxTransformError::SeatbeltUnavailable => CodexErr::UnsupportedOperation(
|
|
"seatbelt sandbox is only available on macOS".to_string(),
|
|
),
|
|
}
|
|
}
|
|
}
|