From 65be622e9fac9eb3cb4fda8333ec1be47caac0a0 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Wed, 15 Oct 2025 15:18:26 +0100 Subject: [PATCH] Fix tests 2 --- codex-rs/core/src/executor/sandbox.rs | 5 ++--- codex-rs/core/src/safety.rs | 30 +++++++++++++-------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/codex-rs/core/src/executor/sandbox.rs b/codex-rs/core/src/executor/sandbox.rs index 313222dd24..eee65a5b4f 100644 --- a/codex-rs/core/src/executor/sandbox.rs +++ b/codex-rs/core/src/executor/sandbox.rs @@ -415,9 +415,8 @@ mod tests { ) .await .expect("ok"); - // On platforms with a sandbox, DangerFullAccess still prefers it - let expected = crate::safety::get_platform_sandbox().unwrap_or(SandboxType::None); - assert_eq!(decision.initial_sandbox, expected); + // DangerFullAccess bypasses sandboxing entirely. + assert_eq!(decision.initial_sandbox, SandboxType::None); assert_eq!(decision.escalate_on_failure, false); } diff --git a/codex-rs/core/src/safety.rs b/codex-rs/core/src/safety.rs index 0ed0f929ff..bf5c2c1319 100644 --- a/codex-rs/core/src/safety.rs +++ b/codex-rs/core/src/safety.rs @@ -55,23 +55,23 @@ pub fn assess_patch_safety( if is_write_patch_constrained_to_writable_paths(action, sandbox_policy, cwd) || policy == AskForApproval::OnFailure { - // Only auto‑approve when we can actually enforce a sandbox. Otherwise - // fall back to asking the user because the patch may touch arbitrary - // paths outside the project. - match get_platform_sandbox() { - Some(sandbox_type) => SafetyCheck::AutoApprove { - sandbox_type, + if matches!(sandbox_policy, SandboxPolicy::DangerFullAccess) { + // DangerFullAccess is intended to bypass sandboxing entirely. + SafetyCheck::AutoApprove { + sandbox_type: SandboxType::None, user_explicitly_approved: false, - }, - None if sandbox_policy == &SandboxPolicy::DangerFullAccess => { - // If the user has explicitly requested DangerFullAccess, then - // we can auto-approve even without a sandbox. - SafetyCheck::AutoApprove { - sandbox_type: SandboxType::None, - user_explicitly_approved: false, - } } - None => SafetyCheck::AskUser, + } else { + // Only auto‑approve when we can actually enforce a sandbox. Otherwise + // fall back to asking the user because the patch may touch arbitrary + // paths outside the project. + match get_platform_sandbox() { + Some(sandbox_type) => SafetyCheck::AutoApprove { + sandbox_type, + user_explicitly_approved: false, + }, + None => SafetyCheck::AskUser, + } } } else if policy == AskForApproval::Never { SafetyCheck::Reject {