mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Route filesystem reads and writes by their own sandbox permissions (#46122)
## Why Filesystem reads previously required a sandbox whenever writes were restricted, even with full-disk read permission. This made permitted reads depend on sandbox availability. ## What changed - Select sandboxing independently for reads and writes, allowing full-disk reads directly while keeping restricted operations sandboxed. - Use the executor's path convention when evaluating full-disk access, including `:slash_tmp` denials. - Apply read-specific checks to capability discovery and skill resource reads, allowing unrestricted reads on executors without sandboxed discovery support. ## Testing Add regression tests for direct read APIs, restricted writes and reads, executor-specific permission rules, and capability discovery without sandbox support. Update Windows tests to verify sandbox enforcement through writes. GitOrigin-RevId: a03844bd1f0ea583bb54326683cddbfdd050119f
This commit is contained in:
1 parent
70e8fe1be3
commit
a4ee536f01
15 files changed
+635
-151
No files matched your search
@@ -11,7 +11,6 @@ use codex_protocol::permissions::FileSystemAccessMode;
|
||||
use codex_protocol::permissions::FileSystemPath;
|
||||
use codex_protocol::permissions::FileSystemSandboxEntry;
|
||||
use codex_protocol::permissions::FileSystemSandboxEntryMissingPathBehavior;
|
||||
use codex_protocol::permissions::FileSystemSandboxKind;
|
||||
use codex_protocol::permissions::FileSystemSandboxPolicy;
|
||||
use codex_protocol::permissions::FileSystemSandboxPolicyContext;
|
||||
use codex_protocol::permissions::FileSystemSpecialPath;
|
||||
@@ -401,14 +400,20 @@ impl FileSystemSandboxContext {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn should_run_in_sandbox(&self) -> bool {
|
||||
if self.validate_file_system_paths_for_current_host().is_err() {
|
||||
// A sandbox context for another host must not select the unsandboxed filesystem.
|
||||
return true;
|
||||
}
|
||||
let file_system_policy = self.permissions.file_system_sandbox_policy();
|
||||
matches!(file_system_policy.kind, FileSystemSandboxKind::Restricted)
|
||||
&& !file_system_policy.has_full_disk_write_access()
|
||||
/// Whether filesystem reads need a platform sandbox on the selected executor.
|
||||
pub fn should_read_from_sandbox(&self) -> bool {
|
||||
!self
|
||||
.permissions
|
||||
.file_system_sandbox_policy()
|
||||
.has_full_disk_read_access_for_convention(self.cwd.infer_path_convention())
|
||||
}
|
||||
|
||||
/// Whether filesystem writes need a platform sandbox on the selected executor.
|
||||
pub fn should_write_into_sandbox(&self) -> bool {
|
||||
!self
|
||||
.permissions
|
||||
.file_system_sandbox_policy()
|
||||
.has_full_disk_write_access_for_convention(self.cwd.infer_path_convention())
|
||||
}
|
||||
|
||||
/// Whether this context selects either supported Windows sandbox implementation.
|
||||
|
||||
Reference in new issue
Block a user