Preserve target-native paths in command approvals (#42577)

## What changed

- Pass the selected executor's `PathUri` through user command approval requests instead of converting the working directory to a host-native path.
- Make native-path permission helpers explicitly local and require executor-aware permission transforms to receive a `FileSystemSandboxPolicyContext`.
- Cover approved remote commands to verify that the approval request reports the selected remote working directory and execution resumes after approval.

GitOrigin-RevId: 0aa3042f2d7594af6c7d0abf31d7f99cf67d5556
This commit is contained in:
iceweasel-oai
2026-09-03 16:21:10 +00:00
committed by copyberry
parent 0650d6d1ca
commit 7a7c188682
30 changed files with 304 additions and 368 deletions
+16 -10
View File
@@ -233,7 +233,7 @@ fn add_helper_runtime_permissions(
}
for helper_read_root in helper_read_roots {
if file_system_policy.can_read_path_with_cwd(helper_read_root.as_path(), cwd) {
if file_system_policy.can_read_local_path_with_cwd(helper_read_root.as_path(), cwd) {
continue;
}
@@ -571,8 +571,8 @@ mod tests {
cwd.as_path(),
);
assert!(policy.can_read_path_with_cwd(readable.as_path(), cwd.as_path()));
assert!(policy.can_write_path_with_cwd(writable.as_path(), cwd.as_path()));
assert!(policy.can_read_local_path_with_cwd(readable.as_path(), cwd.as_path()));
assert!(policy.can_write_local_path_with_cwd(writable.as_path(), cwd.as_path()));
}
#[test]
@@ -800,10 +800,13 @@ mod tests {
);
assert!(
policy.can_read_path_with_cwd(runtime_paths.codex_self_exe.as_path(), cwd.as_path())
policy.can_read_local_path_with_cwd(
runtime_paths.codex_self_exe.as_path(),
cwd.as_path(),
)
);
assert!(!policy.can_read_path_with_cwd(parent.as_path(), cwd.as_path()));
assert!(!policy.can_read_path_with_cwd(sibling.as_path(), cwd.as_path()));
assert!(!policy.can_read_local_path_with_cwd(parent.as_path(), cwd.as_path()));
assert!(!policy.can_read_local_path_with_cwd(sibling.as_path(), cwd.as_path()));
}
#[test]
@@ -831,11 +834,14 @@ mod tests {
);
assert!(
policy.can_read_path_with_cwd(runtime_paths.codex_self_exe.as_path(), cwd.as_path())
policy.can_read_local_path_with_cwd(
runtime_paths.codex_self_exe.as_path(),
cwd.as_path(),
)
);
assert!(policy.can_read_path_with_cwd(alias.as_path(), cwd.as_path()));
assert!(!policy.can_read_path_with_cwd(codex_parent.as_path(), cwd.as_path()));
assert!(!policy.can_read_path_with_cwd(alias_parent.as_path(), cwd.as_path()));
assert!(policy.can_read_local_path_with_cwd(alias.as_path(), cwd.as_path()));
assert!(!policy.can_read_local_path_with_cwd(codex_parent.as_path(), cwd.as_path()));
assert!(!policy.can_read_local_path_with_cwd(alias_parent.as_path(), cwd.as_path()));
}
fn restricted_policy(entries: Vec<FileSystemSandboxEntry>) -> FileSystemSandboxPolicy {