mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Fix macOS system-alias matching in patch permission checks (#47879)
## Why Local `apply_patch` permission checks can treat a macOS system alias and its canonical spelling as different locations, sending writes covered by temporary-directory grants for unnecessary approval. ## What changed - Normalize trusted top-level aliases in local policy roots and patch targets, reusing a prepared matcher for permission requests and patch safety checks. - Share alias normalization with Seatbelt and the macOS executor sandbox while preserving mutable symlinks and missing descendants. - Preserve read-only and deny precedence, protected metadata restrictions, and remote URI matching. Propagate normalization failures from fallible permission checks. ## Testing Add macOS regressions for multi-file patches with missing parent directories through both direct `apply_patch` calls and shell interception, asserting automatic approval and file contents. Add unit coverage for alias restriction precedence, mutable symlink preservation, missing descendants, and remote permission isolation. GitOrigin-RevId: 0822ff951eaab728cb1ad91281745fa1b8809f15
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use crate::safety::PatchSandboxRoute;
|
||||
use crate::session::tests::make_session_and_context;
|
||||
use crate::session::tests::update_selected_settings_for_test;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
@@ -64,9 +65,9 @@ async fn prepare_apply_patch_uses_action_policy_before_turn_policy() {
|
||||
let prepared = prepare_apply_patch(
|
||||
&step,
|
||||
&environment,
|
||||
&file_system_policy,
|
||||
&context,
|
||||
PatchSandboxRoute::Platform(codex_protocol::config_types::WindowsSandboxLevel::Disabled),
|
||||
&PatchSandboxRoute::Platform(codex_protocol::config_types::WindowsSandboxLevel::Disabled)
|
||||
.prepare_matching(&file_system_policy, &context)
|
||||
.expect("prepare patch matching"),
|
||||
action,
|
||||
)
|
||||
.expect("issuing action policy should request approval");
|
||||
|
||||
Reference in New Issue
Block a user