Resolve filesystem denials with explicit path context (#44669)

## Why

Filesystem denial paths need to use the owning environment's path syntax, base directory, and home directory. Host-native resolution cannot supply those facts for another platform, and invalid denials must not be silently skipped when building the sandbox policy.

## What changed

- Add `ConfigPathContext` to requirements layers so `permissions.filesystem.deny_read` can resolve using explicit POSIX or Windows path facts, with native defaults when no context is supplied.
- Share URI-based resolution and validation for literal paths and glob prefixes. Reject ambiguous or lossy paths, including NUL bytes, Windows stream syntax, and unsupported UNC spellings.
- Move denial conversion into `FilesystemConstraints::apply_to_policy`, preserving glob patterns and deduplicating entries. Validate all denials before modifying the policy and propagate failures through configuration loading.

## Testing

Add tests for per-layer base and home resolution, Windows drives and globs, nested context restoration, missing home directories, and policy conversion without partial mutation. Add a configuration-loading regression test for a required denial glob containing a NUL byte.

GitOrigin-RevId: fa0da0d149407958e39897a39fe7b87edd6f1644
This commit is contained in:
Sean Huang authored and copyberry committed 2026-09-10 23:08:23 +00:00
1 parent 78600239a1
commit cc05ecfe17
13 files changed
+738 -62

No files matched your search

+3
View File
@@ -12,6 +12,7 @@ mod config_requirements;
pub mod config_toml;
mod constraint;
mod diagnostics;
mod filesystem_constraints;
mod fingerprint;
mod hook_config;
mod host_name;
@@ -25,6 +26,7 @@ mod mcp_types;
mod merge;
mod model_provider_requirements;
mod overrides;
mod path_context;
pub mod permissions_toml;
mod plugin_edit;
pub mod profile_toml;
@@ -169,6 +171,7 @@ pub use merge::is_structured_feature_path;
pub use merge::merge_toml_values;
pub use merge::shell_environment_filter_entry;
pub use overrides::build_cli_overrides_layer;
pub use path_context::ConfigPathContext;
pub use plugin_edit::PluginConfigEdit;
pub use plugin_edit::apply_user_plugin_config_edits;
pub use plugin_edit::clear_user_plugin;