mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Remove the legacy sandbox policy constructor (#59772)
## What changed Remove `FileSystemSandboxContext::from_legacy_sandbox_policy` and migrate its test callers to `from_permission_profile`. Construct read-only, disabled, and externally enforced sandbox contexts directly with `PermissionProfile`. GitOrigin-RevId: e330b89d060061eda106232eab554be5ccd06149
This commit is contained in:
@@ -369,8 +369,8 @@ fn map_fs_error(err: io::Error) -> JSONRPCErrorError {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use codex_protocol::protocol::NetworkAccess;
|
||||
use codex_protocol::protocol::SandboxPolicy;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_protocol::permissions::NetworkSandboxPolicy;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -389,20 +389,16 @@ mod tests {
|
||||
.expect("runtime paths");
|
||||
let handler = FileSystemHandler::new(runtime_paths);
|
||||
let sandbox_cwd = PathUri::from_host_native_path(temp_dir.path()).expect("tempdir URI");
|
||||
let sandbox_context = |sandbox_policy| {
|
||||
FileSystemSandboxContext::from_legacy_sandbox_policy(
|
||||
sandbox_policy,
|
||||
sandbox_cwd.clone(),
|
||||
)
|
||||
.expect("sandbox context")
|
||||
let sandbox_context = |permissions| {
|
||||
FileSystemSandboxContext::from_permission_profile(permissions, sandbox_cwd.clone())
|
||||
};
|
||||
|
||||
for (file_name, sandbox_policy) in [
|
||||
("danger.txt", SandboxPolicy::DangerFullAccess),
|
||||
for (file_name, permission_profile) in [
|
||||
("danger.txt", PermissionProfile::Disabled),
|
||||
(
|
||||
"external.txt",
|
||||
SandboxPolicy::ExternalSandbox {
|
||||
network_access: NetworkAccess::Restricted,
|
||||
PermissionProfile::External {
|
||||
network: NetworkSandboxPolicy::Restricted,
|
||||
},
|
||||
),
|
||||
] {
|
||||
@@ -414,7 +410,7 @@ mod tests {
|
||||
path: path.clone(),
|
||||
follow_symlinks: None,
|
||||
data_base64: STANDARD.encode("ok"),
|
||||
sandbox: Some(sandbox_context(sandbox_policy.clone())),
|
||||
sandbox: Some(sandbox_context(permission_profile.clone())),
|
||||
})
|
||||
.await
|
||||
.expect("write file");
|
||||
@@ -422,7 +418,7 @@ mod tests {
|
||||
let canonicalized = handler
|
||||
.canonicalize(FsCanonicalizeParams {
|
||||
path: path.clone(),
|
||||
sandbox: Some(sandbox_context(sandbox_policy.clone())),
|
||||
sandbox: Some(sandbox_context(permission_profile.clone())),
|
||||
})
|
||||
.await
|
||||
.expect("canonicalize file");
|
||||
@@ -438,7 +434,7 @@ mod tests {
|
||||
.read_file(FsReadFileParams {
|
||||
path,
|
||||
follow_symlinks: None,
|
||||
sandbox: Some(sandbox_context(sandbox_policy)),
|
||||
sandbox: Some(sandbox_context(permission_profile)),
|
||||
})
|
||||
.await
|
||||
.expect("read file");
|
||||
|
||||
@@ -407,9 +407,10 @@ fn exported_sandbox_denial_keeps_launch_identity_and_separate_exit_outcome() {
|
||||
let private_file = directory.path().join(PRIVATE_PAYLOAD);
|
||||
std::fs::write(&private_file, PRIVATE_PAYLOAD).expect("write test file");
|
||||
let cwd = PathUri::from_host_native_path(directory.path()).expect("cwd URI");
|
||||
let sandbox = crate::FileSystemSandboxContext::from_legacy_sandbox_policy(
|
||||
codex_protocol::protocol::SandboxPolicy::new_read_only_policy(), cwd.clone(),
|
||||
).expect("read-only sandbox");
|
||||
let sandbox = crate::FileSystemSandboxContext::from_permission_profile(
|
||||
codex_protocol::models::PermissionProfile::read_only(),
|
||||
cwd.clone(),
|
||||
);
|
||||
for (index, span) in LAUNCH_SPANS.into_iter().enumerate() {
|
||||
let process_id = format!("{PRIVATE_PAYLOAD}-{index}");
|
||||
let launch = format!("00-{TRACE_ID}-{span}-00");
|
||||
|
||||
Reference in New Issue
Block a user