mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Use executor path context for permission preapproval (#41928)
## Why Permission grants can belong to an executor whose path convention differs from the local host, such as a Windows remote environment. Matching those grants against a host-native working directory can reject valid permissions. ## What changed - Normalize, materialize, and compare additional filesystem permissions using the selected executor's URI-based sandbox context. - Apply the same context-aware preapproval flow to `exec_command`, `apply_patch`, and extension tools. - Fail closed when symbolic temporary-directory or project-root permissions cannot be resolved from executor metadata, while accepting opaque working directory URIs when requested paths use the executor's convention. ## Testing - Added coverage for reusing a Windows permission grant from a non-Windows host, resolving symbolic temporary-directory grants, and normalizing paths with an opaque Windows working directory. GitOrigin-RevId: aee54350a25430a0443f8319e2bb0bbdc4f44282
This commit is contained in:
1 parent
9127f21890
commit
c4350b4ca2
8 files changed
+280
-30
No files matched your search
@@ -18,6 +18,8 @@ use codex_protocol::permissions::FileSystemSandboxPolicyContext;
|
||||
use codex_protocol::permissions::FileSystemSpecialPath;
|
||||
use codex_protocol::permissions::NetworkSandboxPolicy;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_path_uri::LegacyAppPathString;
|
||||
use codex_utils_path_uri::PathConvention;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use dunce::canonicalize;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -162,9 +164,29 @@ fn normalize_additional_permissions_only_checks_convention_with_context() {
|
||||
temporary_directories: None,
|
||||
};
|
||||
assert!(
|
||||
normalize_additional_permissions_with_context(permissions, &context).is_err(),
|
||||
normalize_additional_permissions_with_context(permissions.clone(), &context).is_err(),
|
||||
"context-aware normalization should reject mismatched conventions"
|
||||
);
|
||||
|
||||
let cwd = LegacyAppPathString::from_string(
|
||||
r"\\?\Volume{00000000-0000-0000-0000-000000000000}\workspace",
|
||||
)
|
||||
.to_path_uri(PathConvention::Windows)
|
||||
.expect("opaque Windows cwd");
|
||||
assert!(cwd.is_opaque(), "volume GUID cwd should stay opaque");
|
||||
let workspace_roots = [cwd.clone()];
|
||||
let context = FileSystemSandboxPolicyContext {
|
||||
cwd: &cwd,
|
||||
workspace_roots: &workspace_roots,
|
||||
user_home_dir: None,
|
||||
temporary_directories: None,
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
normalize_additional_permissions_with_context(permissions.clone(), &context)
|
||||
.expect("absolute path with opaque cwd"),
|
||||
permissions
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
Reference in new issue
Block a user