diff --git a/codex-rs/core/tests/suite/workspace_roots.rs b/codex-rs/core/tests/suite/workspace_roots.rs index aabe8b052e..6c81551f48 100644 --- a/codex-rs/core/tests/suite/workspace_roots.rs +++ b/codex-rs/core/tests/suite/workspace_roots.rs @@ -34,24 +34,39 @@ const COMMAND_CALL_ID: &str = "workspace-root-command"; const PNG_BASE64: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="; -fn workspace_roots_read_profile() -> PermissionProfile { - PermissionProfile::from_runtime_permissions( - &FileSystemSandboxPolicy::restricted(vec![ - FileSystemSandboxEntry { - path: FileSystemPath::Special { - value: FileSystemSpecialPath::Minimal, - }, - access: FileSystemAccessMode::Read, +fn workspace_roots_read_profile() -> Result { + let mut entries = vec![ + FileSystemSandboxEntry { + path: FileSystemPath::Special { + value: FileSystemSpecialPath::Minimal, }, - FileSystemSandboxEntry { - path: FileSystemPath::Special { - value: FileSystemSpecialPath::project_roots(/*subpath*/ None), - }, - access: FileSystemAccessMode::Read, + access: FileSystemAccessMode::Read, + }, + FileSystemSandboxEntry { + path: FileSystemPath::Special { + value: FileSystemSpecialPath::project_roots(/*subpath*/ None), }, - ]), + access: FileSystemAccessMode::Read, + }, + ]; + #[cfg(target_os = "linux")] + if !core_test_support::is_remote_test_environment() { + // Bubblewrap re-execs the test binary after applying the filesystem policy. + // Bazel places that binary outside the platform paths covered by `:minimal`. + entries.push(FileSystemSandboxEntry { + path: FileSystemPath::Path { + path: codex_utils_absolute_path::AbsolutePathBuf::from_absolute_path( + std::env::current_exe()?, + )?, + }, + access: FileSystemAccessMode::Read, + }); + } + + Ok(PermissionProfile::from_runtime_permissions( + &FileSystemSandboxPolicy::restricted(entries), NetworkSandboxPolicy::Restricted, - ) + )) } async fn workspace_roots_test(server: &MockServer) -> Result { @@ -122,7 +137,7 @@ async fn mount_file_and_command_calls( } async fn submit_workspace_turn(test: &TestCodex, prompt: &str) -> Result<()> { - test.submit_turn_with_permission_profile(prompt, workspace_roots_read_profile()) + test.submit_turn_with_permission_profile(prompt, workspace_roots_read_profile()?) .await }