mirror of
https://github.com/openai/codex.git
synced 2026-10-27 16:02:59 +00:00
Remove generated-default filesystem path variants (#33632)
## What changed - Represent built-in filesystem policy entries with the same `Path` and `Special` variants used by other entries. - Remove generated-default filtering from Windows sandbox policy resolution and simplify elevated deny-write handling to rely on direct-runtime enforcement and the legacy policy projection. - Update protocol conversions, policy transforms, and profile expectations for the reduced filesystem path model. GitOrigin-RevId: a65793e6855a03d52a575e82cb3d4b9b2e32db5c
This commit is contained in:
@@ -4167,7 +4167,7 @@ exclude_slash_tmp = true
|
||||
file_system_policy
|
||||
.entries
|
||||
.contains(&FileSystemSandboxEntry {
|
||||
path: FileSystemPath::GeneratedDefaultPath {
|
||||
path: FileSystemPath::Path {
|
||||
path: AbsolutePathBuf::resolve_path_against_base(
|
||||
subpath,
|
||||
cwd.path()
|
||||
|
||||
@@ -249,8 +249,6 @@ fn insert_filesystem_permission_toml(
|
||||
FileSystemPath::Special { value } => {
|
||||
insert_special_filesystem_permission_toml(entries, value, entry.access);
|
||||
}
|
||||
FileSystemPath::GeneratedDefaultPath { .. }
|
||||
| FileSystemPath::GeneratedDefaultSpecial { .. } => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,13 +153,13 @@ fn render_file_system_entry(rendered: &mut String, entry: &FileSystemSandboxEntr
|
||||
}
|
||||
rendered.push_str("\">");
|
||||
match &entry.path {
|
||||
FileSystemPath::Path { path } | FileSystemPath::GeneratedDefaultPath { path } => {
|
||||
FileSystemPath::Path { path } => {
|
||||
push_text_element(rendered, "path", path.to_string_lossy().as_ref());
|
||||
}
|
||||
FileSystemPath::GlobPattern { pattern } => {
|
||||
push_text_element(rendered, "glob", pattern);
|
||||
}
|
||||
FileSystemPath::Special { value } | FileSystemPath::GeneratedDefaultSpecial { value } => {
|
||||
FileSystemPath::Special { value } => {
|
||||
let value = render_special_path(value);
|
||||
push_text_element(rendered, "special", &value);
|
||||
}
|
||||
|
||||
@@ -803,51 +803,6 @@ fn windows_elevated_supports_split_write_read_carveouts() {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[test]
|
||||
fn windows_workspace_defaults_do_not_hide_explicit_metadata_carveouts() {
|
||||
let temp_dir = tempfile::TempDir::new().expect("tempdir");
|
||||
let cwd = temp_dir.path().canonicalize().expect("canonical cwd").abs();
|
||||
|
||||
let default_profile = PermissionProfile::workspace_write();
|
||||
let default_overrides = resolve_windows_elevated_filesystem_overrides(
|
||||
SandboxType::WindowsRestrictedToken,
|
||||
&default_profile,
|
||||
&cwd,
|
||||
/*use_windows_elevated_backend*/ true,
|
||||
)
|
||||
.expect("resolve workspace defaults");
|
||||
assert!(
|
||||
default_overrides.is_none_or(|overrides| overrides.additional_deny_write_paths.is_empty())
|
||||
);
|
||||
|
||||
for name in codex_protocol::permissions::PROTECTED_METADATA_PATH_NAMES {
|
||||
let (mut explicit_policy, network_policy) = default_profile.to_runtime_permissions();
|
||||
explicit_policy
|
||||
.entries
|
||||
.push(codex_protocol::permissions::FileSystemSandboxEntry {
|
||||
path: codex_protocol::permissions::FileSystemPath::Special {
|
||||
value: codex_protocol::permissions::FileSystemSpecialPath::project_roots(Some(
|
||||
(*name).into(),
|
||||
)),
|
||||
},
|
||||
access: codex_protocol::permissions::FileSystemAccessMode::Read,
|
||||
});
|
||||
let explicit_profile =
|
||||
PermissionProfile::from_runtime_permissions(&explicit_policy, network_policy);
|
||||
|
||||
let overrides = resolve_windows_elevated_filesystem_overrides(
|
||||
SandboxType::WindowsRestrictedToken,
|
||||
&explicit_profile,
|
||||
&cwd,
|
||||
/*use_windows_elevated_backend*/ true,
|
||||
)
|
||||
.expect("resolve explicit metadata carveout")
|
||||
.expect("explicit metadata carveout needs an override");
|
||||
assert_eq!(overrides.additional_deny_write_paths, vec![cwd.join(name)]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_elevated_supports_unreadable_split_carveouts() {
|
||||
let temp_dir = tempfile::TempDir::new().expect("tempdir");
|
||||
|
||||
@@ -197,59 +197,6 @@ async fn windows_restricted_token_rejects_exact_and_glob_deny_read_policy() -> a
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial(codex_home)]
|
||||
async fn windows_elevated_does_not_create_missing_workspace_metadata() -> anyhow::Result<()> {
|
||||
let codex_home =
|
||||
codex_home_for_windows_sandbox_test("windows-elevated-missing-metadata-codex-home")?;
|
||||
let _codex_home_guard = EnvVarGuard::set("CODEX_HOME", codex_home.path().as_os_str());
|
||||
stage_windows_sandbox_helpers()?;
|
||||
let workspace = TempDir::new()?;
|
||||
let cwd = dunce::canonicalize(workspace.path())?.abs();
|
||||
let permission_profile = PermissionProfile::workspace_write()
|
||||
.materialize_project_roots_with_workspace_roots(std::slice::from_ref(&cwd));
|
||||
|
||||
let output = process_exec_tool_call(
|
||||
ExecParams {
|
||||
command: vec![
|
||||
"cmd.exe".to_string(),
|
||||
"/D".to_string(),
|
||||
"/C".to_string(),
|
||||
"echo sandbox-ok".to_string(),
|
||||
],
|
||||
cwd: cwd.clone(),
|
||||
expiration: 10_000.into(),
|
||||
capture_policy: ExecCapturePolicy::ShellTool,
|
||||
env: HashMap::new(),
|
||||
network: None,
|
||||
network_environment_id: None,
|
||||
sandbox_permissions: SandboxPermissions::UseDefault,
|
||||
windows_sandbox_level: WindowsSandboxLevel::Elevated,
|
||||
windows_sandbox_private_desktop: false,
|
||||
justification: None,
|
||||
arg0: None,
|
||||
},
|
||||
&permission_profile,
|
||||
&cwd,
|
||||
std::slice::from_ref(&cwd),
|
||||
&None,
|
||||
/*use_legacy_landlock*/ false,
|
||||
/*stdout_stream*/ None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert_eq!(output.exit_code, 0, "sandboxed command should complete");
|
||||
for name in codex_protocol::permissions::PROTECTED_METADATA_PATH_NAMES {
|
||||
let path = cwd.join(name);
|
||||
assert!(
|
||||
!path.exists(),
|
||||
"elevated setup should not create missing workspace metadata: {}",
|
||||
path.display()
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial(codex_home)]
|
||||
async fn windows_elevated_enforces_deny_read_and_protects_setup_marker() -> anyhow::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user