mirror of
https://github.com/openai/codex.git
synced 2026-10-23 18:08:45 +00:00
## What changed Add Linux dependency discovery and policy preparation to `exec-server`'s sandbox integrity module. Inventory bundled and system `bwrap` candidates and the deny-glob scanner using the launcher's location and the command's `PATH` and working directory. Resolve `:tmpdir` and tilde-prefixed deny globs using the command's `TMPDIR` and `HOME`, with account home-directory fallback. Reuse Linux sandbox helpers to expand deny globs in the command's explicit environment. ## Testing Add Linux tests covering symlinked launchers, relative and empty `PATH` entries, and empty, relative, and tilde-prefixed `TMPDIR` values alongside home-relative deny globs. GitOrigin-RevId: fe404fa4be77ece677b22d52d77a7234dbf0cffe
110 lines
4.2 KiB
Rust
110 lines
4.2 KiB
Rust
#[cfg(target_os = "linux")]
|
|
mod bwrap;
|
|
mod denial;
|
|
pub mod landlock;
|
|
mod linux_pid_namespace;
|
|
mod manager;
|
|
pub mod policy_transforms;
|
|
mod sandbox_integrity;
|
|
#[cfg(target_os = "macos")]
|
|
pub mod seatbelt;
|
|
mod spawn;
|
|
mod terminal_queries;
|
|
mod violation;
|
|
mod windows;
|
|
#[cfg(windows)]
|
|
mod windows_mxc;
|
|
|
|
#[cfg(target_os = "linux")]
|
|
pub use bwrap::find_executable_in_search_paths;
|
|
#[cfg(target_os = "linux")]
|
|
pub use bwrap::find_pre_sandbox_executable_in_path;
|
|
#[cfg(target_os = "linux")]
|
|
pub use bwrap::find_system_bwrap_in_path;
|
|
#[cfg(target_os = "linux")]
|
|
pub use bwrap::system_bwrap_warning;
|
|
pub use codex_mxc_sandbox::CODEX_WINDOWS_MXC_ARG1;
|
|
pub use codex_mxc_sandbox::is_available as windows_mxc_available;
|
|
pub use codex_mxc_sandbox::run_main as run_windows_mxc_main;
|
|
pub use codex_windows_sandbox::WindowsSandboxProxySettingsMode;
|
|
pub use denial::is_likely_executor_managed_sandbox_denied;
|
|
pub use denial::is_likely_sandbox_denied;
|
|
pub use linux_pid_namespace::LinuxSandboxPidNamespace;
|
|
pub use manager::SandboxCommand;
|
|
pub use manager::SandboxDirectSpawnTransformRequest;
|
|
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::compatibility_sandbox_policy_for_permission_profile;
|
|
pub use manager::get_platform_sandbox;
|
|
pub use manager::with_managed_mitm_ca_readable_root;
|
|
pub use sandbox_integrity::FileContentsChecker;
|
|
pub use sandbox_integrity::IntegrityFinding;
|
|
pub use sandbox_integrity::IntegrityFindingDetails;
|
|
pub use spawn::SpawnRequest;
|
|
pub use spawn::WindowsSandboxSpawnRequest;
|
|
pub use spawn::spawn_process;
|
|
pub use violation::FileSystemSandboxViolation;
|
|
pub use violation::FileSystemSandboxViolationReason;
|
|
pub use violation::NetworkSandboxViolation;
|
|
pub use violation::SandboxViolationBackend;
|
|
pub use violation::SandboxViolationEvent;
|
|
pub use violation::record_filesystem_sandbox_violation;
|
|
pub use violation::record_network_sandbox_violation;
|
|
pub use violation::record_sandbox_violation;
|
|
pub use windows::WindowsSandboxFilesystemOverrides;
|
|
pub use windows::permission_profile_supports_windows_restricted_token_sandbox;
|
|
pub use windows::resolve_windows_elevated_filesystem_overrides;
|
|
pub use windows::resolve_windows_restricted_token_filesystem_overrides;
|
|
pub use windows::unsupported_windows_restricted_token_sandbox_reason;
|
|
pub use windows::windows_sandbox_uses_elevated_backend;
|
|
|
|
use codex_protocol::error::CodexErr;
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
pub fn system_bwrap_warning(
|
|
_permission_profile: &codex_protocol::models::PermissionProfile,
|
|
_sandbox_policy_cwd: &std::path::Path,
|
|
) -> Option<String> {
|
|
None
|
|
}
|
|
|
|
impl From<SandboxTransformError> for CodexErr {
|
|
fn from(err: SandboxTransformError) -> Self {
|
|
match err {
|
|
error @ SandboxTransformError::InvalidCommandCwd { .. }
|
|
| error @ SandboxTransformError::InvalidSandboxPolicyCwd { .. } => {
|
|
CodexErr::InvalidRequest(error.to_string())
|
|
}
|
|
SandboxTransformError::MissingLinuxSandboxExecutable => {
|
|
CodexErr::LandlockSandboxExecutableNotProvided
|
|
}
|
|
SandboxTransformError::EnvironmentNetworkProxy(message) => {
|
|
CodexErr::UnsupportedOperation(message)
|
|
}
|
|
SandboxTransformError::WindowsMxcPreparation(message) => {
|
|
CodexErr::UnsupportedOperation(message)
|
|
}
|
|
#[cfg(target_os = "macos")]
|
|
SandboxTransformError::SeatbeltPreparation(message) => {
|
|
CodexErr::UnsupportedOperation(message)
|
|
}
|
|
#[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(),
|
|
),
|
|
#[cfg(target_os = "windows")]
|
|
SandboxTransformError::WindowsSandboxPreparation(message) => {
|
|
CodexErr::UnsupportedOperation(message)
|
|
}
|
|
}
|
|
}
|
|
}
|