Compare commits

...

1 Commits

Author SHA1 Message Date
David Wiesen
ef94e870c9 Skip WindowsApps read-root ACL grants 2026-04-13 09:18:09 -07:00

View File

@@ -340,10 +340,19 @@ fn profile_read_roots(user_profile: &Path) -> Vec<PathBuf> {
.collect()
}
fn should_include_current_exe_parent(dir: &Path) -> bool {
!dir.ancestors().any(|ancestor| {
ancestor
.file_name()
.is_some_and(|name| name.to_string_lossy().eq_ignore_ascii_case("WindowsApps"))
})
}
fn gather_helper_read_roots(codex_home: &Path) -> Vec<PathBuf> {
let mut roots = Vec::new();
if let Ok(exe) = std::env::current_exe()
&& let Some(dir) = exe.parent()
&& should_include_current_exe_parent(dir)
{
roots.push(dir.to_path_buf());
}
@@ -832,6 +841,7 @@ mod tests {
use super::offline_proxy_settings_from_env;
use super::profile_read_roots;
use super::proxy_ports_from_env;
use super::should_include_current_exe_parent;
use crate::helper_materialization::helper_bin_dir;
use crate::policy::SandboxPolicy;
use codex_protocol::protocol::ReadOnlyAccess;
@@ -840,6 +850,7 @@ mod tests {
use std::collections::HashMap;
use std::collections::HashSet;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use tempfile::TempDir;
@@ -1033,6 +1044,16 @@ mod tests {
assert!(roots.contains(&expected));
}
#[test]
fn current_exe_parent_skips_windows_apps_package_dirs() {
assert!(!should_include_current_exe_parent(Path::new(
r"C:\Program Files\WindowsApps\OpenAI.Codex_26.313.5234.0_x64__2p2nqsd0c76g0"
)));
assert!(should_include_current_exe_parent(Path::new(
r"C:\Users\ace\.codex\.sandbox-bin"
)));
}
#[test]
fn restricted_read_roots_skip_platform_defaults_when_disabled() {
let tmp = TempDir::new().expect("tempdir");