mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Report configured sandbox policy consistently (#41933)
## Why Sandbox diagnostics could report `read-only` when a configured writable root did not yet exist, because policy labeling used filesystem-aware runtime root resolution. ## What changed - Derive diagnostic policy labels from configured writable roots without inspecting the filesystem. Runtime sandbox authorization continues to use filesystem-aware resolution. - Capture sandbox labels once per turn and reuse them for response metadata and tool-result metrics. ## Testing Add coverage for missing project roots, denied roots, and deny rules on project subpaths. GitOrigin-RevId: ccbdb8c32a1f44bfa63ae4d2ae1f9cc408e66b9c
This commit is contained in:
1 parent
4ac20a7f74
commit
a62ff9a5d4
6 files changed
+146
-61
No files matched your search
@@ -1447,6 +1447,21 @@ impl FileSystemSandboxPolicy {
|
||||
})
|
||||
}
|
||||
|
||||
/// Reports configured writable roots for diagnostics without inspecting the filesystem.
|
||||
///
|
||||
/// Unlike runtime root resolution, this includes configured roots even if they
|
||||
/// do not currently exist (including `/tmp`). Do not use this result to authorize
|
||||
/// filesystem access or replace the resolution needed for sandbox enforcement.
|
||||
pub fn has_configured_writable_roots_with_cwd(&self, cwd: &Path) -> bool {
|
||||
!self.has_full_disk_write_access()
|
||||
&& with_local_policy_context(cwd, cwd, |_, context| {
|
||||
self.resolved_entries(context)
|
||||
.into_iter()
|
||||
.any(|(path, access)| access.can_write() && self.can_write_path(&path, context))
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Returns writable roots without following attacker-mutable path components.
|
||||
///
|
||||
/// Trusted top-level aliases such as `/tmp -> /private/tmp` are still
|
||||
@@ -2521,6 +2536,10 @@ mod tests {
|
||||
policy.has_writable_roots_with_cwd(cwd.path()),
|
||||
!policy.get_writable_roots_with_cwd(cwd.path()).is_empty()
|
||||
);
|
||||
assert_eq!(
|
||||
policy.has_configured_writable_roots_with_cwd(cwd.path()),
|
||||
!policy.get_writable_roots_with_cwd(cwd.path()).is_empty()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user