Resolve permission requests in the executor context (#42146)

## Why

`request_permissions` paths and grants need to be evaluated against the selected executor environment, including its path convention, home directory, workspace roots, and temporary directories.

## What changed

- Resolve relative and home-relative permission paths using the executor context, reject mismatched path conventions and lossy paths, and support legacy `read` and `write` path lists.
- Move grant intersection into core so requested and granted permissions use the originating environment's sandbox context. Preserve deny entries conservatively when a special path cannot be resolved.
- Keep the full originating environment with pending permission requests so delayed responses are normalized against the same context.

## Testing

- Cover POSIX, Windows, UNC, relative, and home-relative path resolution and invalid path contexts.
- Verify end-to-end app-server grants are limited to the requested workspace scope and unresolved temporary-directory denies are preserved.

GitOrigin-RevId: 730a2aacd391262e92a6314f3a5b6c262e3dca10
This commit is contained in:
iceweasel-oai authored and copyberry committed 2026-09-01 22:08:08 +00:00
1 parent 86b7d12742
commit cd8bd62c6e
10 files changed
+492 -307

No files matched your search

@@ -562,6 +562,47 @@ fn intersect_permission_profiles_preserves_deny_across_case_variant_grant() {
);
}
#[test]
fn intersect_permission_profiles_preserves_denies_for_unresolved_tmpdir() {
let cwd = PathUri::parse("file:///workspace").expect("cwd URI");
let context = FileSystemSandboxPolicyContext {
cwd: &cwd,
workspace_roots: std::slice::from_ref(&cwd),
user_home_dir: None,
temporary_directories: None,
};
let write = FileSystemSandboxEntry::new(
FileSystemPath::Special {
value: FileSystemSpecialPath::Tmpdir,
},
FileSystemAccessMode::Write,
);
let deny = FileSystemSandboxEntry::new(
PathUri::parse("file:///tmp/private").expect("deny").into(),
FileSystemAccessMode::Deny,
);
let profile = |entries| PermissionProfile {
file_system: Some(FileSystemPermissions {
entries,
glob_scan_max_depth: None,
}),
..Default::default()
};
let grant = profile(vec![write.clone()]);
let grant_with_deny = profile(vec![write, deny]);
for (requested, granted) in [
(grant_with_deny.clone(), grant.clone()),
(grant, grant_with_deny.clone()),
(grant_with_deny.clone(), grant_with_deny.clone()),
] {
assert_eq!(
intersect_permission_profiles_with_context(requested, granted, &context),
grant_with_deny
);
}
}
#[test]
fn intersect_permission_profiles_preserves_rooted_first_segment_glob_deny() {
use FileSystemAccessMode::Deny;