mirror of
https://github.com/openai/codex.git
synced 2026-09-10 20:26:47 +00:00
fix: skip WindowsApps helper roots in sandbox refresh
This commit is contained in:
@@ -334,6 +334,7 @@ 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()
|
||||
&& !is_windowsapps_install_path(dir)
|
||||
{
|
||||
roots.push(dir.to_path_buf());
|
||||
}
|
||||
@@ -343,6 +344,15 @@ fn gather_helper_read_roots(codex_home: &Path) -> Vec<PathBuf> {
|
||||
roots
|
||||
}
|
||||
|
||||
fn is_windowsapps_install_path(path: &Path) -> bool {
|
||||
path.components().any(|component| {
|
||||
component
|
||||
.as_os_str()
|
||||
.to_string_lossy()
|
||||
.eq_ignore_ascii_case("WindowsApps")
|
||||
})
|
||||
}
|
||||
|
||||
fn gather_legacy_full_read_roots(
|
||||
command_cwd: &Path,
|
||||
policy: &SandboxPolicy,
|
||||
@@ -1009,6 +1019,16 @@ mod tests {
|
||||
assert!(roots.contains(&expected));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windowsapps_install_paths_are_skipped_for_helper_roots() {
|
||||
assert!(is_windowsapps_install_path(Path::new(
|
||||
r"C:\Program Files\WindowsApps\OpenAI.Codex_1.0.0_x64__token\app\resources"
|
||||
)));
|
||||
assert!(!is_windowsapps_install_path(Path::new(
|
||||
r"C:\Program Files\OpenAI\Codex\app\resources"
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restricted_read_roots_skip_platform_defaults_when_disabled() {
|
||||
let tmp = TempDir::new().expect("tempdir");
|
||||
|
||||
Reference in New Issue
Block a user