mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
Make sandbox settings environment-owned
This commit is contained in:
@@ -111,6 +111,7 @@ pub fn local(cwd: AbsolutePathBuf) -> TurnEnvironmentSelection {
|
||||
environment_id: codex_exec_server::LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&cwd)],
|
||||
sandbox: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +144,7 @@ impl TestEnv {
|
||||
environment_id: codex_exec_server::REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&cwd)],
|
||||
sandbox: None,
|
||||
},
|
||||
None => local(cwd.clone()),
|
||||
};
|
||||
@@ -211,6 +213,7 @@ pub async fn test_env() -> Result<TestEnv> {
|
||||
environment_id: codex_exec_server::REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: cwd_uri.clone(),
|
||||
workspace_roots: vec![cwd_uri.clone()],
|
||||
sandbox: None,
|
||||
};
|
||||
let cwd = if remote_env == TestEnvironment::WineExec {
|
||||
// TODO(anp): Convert `Config::cwd` to `LegacyAppPathString` and remove this
|
||||
|
||||
@@ -706,11 +706,13 @@ async fn multi_environment_thread_loads_every_project_and_keeps_creation_snapsho
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&test.config.cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&test.config.cwd)],
|
||||
sandbox: None,
|
||||
},
|
||||
TurnEnvironmentSelection {
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_host_native_path(local_root.path())?,
|
||||
workspace_roots: vec![PathUri::from_host_native_path(local_root.path())?],
|
||||
sandbox: None,
|
||||
},
|
||||
],
|
||||
thread_extension_init: Default::default(),
|
||||
|
||||
@@ -1654,6 +1654,7 @@ async fn apply_patch_turn_diff_tracks_local_and_remote_environment_paths() -> Re
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&shared_cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&shared_cwd)],
|
||||
sandbox: None,
|
||||
},
|
||||
];
|
||||
test.codex
|
||||
|
||||
@@ -115,6 +115,7 @@ async fn model_visible_environment_context_preserves_foreign_workspace_roots() -
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&test.config.cwd),
|
||||
workspace_roots: vec![foreign_root],
|
||||
sandbox: None,
|
||||
}],
|
||||
)),
|
||||
..Default::default()
|
||||
|
||||
@@ -11,6 +11,7 @@ use codex_protocol::protocol::AskForApproval;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::Op;
|
||||
use codex_protocol::protocol::ThreadSettingsOverrides;
|
||||
use codex_protocol::protocol::TurnEnvironmentSandbox;
|
||||
use codex_protocol::protocol::TurnEnvironmentSelection;
|
||||
use codex_protocol::protocol::TurnEnvironmentSelections;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
@@ -185,24 +186,35 @@ async fn two_exec_servers_isolate_workspace_write_roots() -> Result<()> {
|
||||
|
||||
let first_workspace_uri = PathUri::from_host_native_path(first_workspace.path())?;
|
||||
let second_workspace_uri = PathUri::from_host_native_path(second_workspace.path())?;
|
||||
let environment_sandbox = TurnEnvironmentSandbox {
|
||||
permission_profile: PermissionProfile::workspace_write_with(
|
||||
&[],
|
||||
NetworkSandboxPolicy::Restricted,
|
||||
/*exclude_tmpdir_env_var*/ true,
|
||||
/*exclude_slash_tmp*/ true,
|
||||
),
|
||||
active_permission_profile: None,
|
||||
windows_sandbox_level: Default::default(),
|
||||
windows_sandbox_private_desktop: false,
|
||||
use_legacy_landlock: false,
|
||||
};
|
||||
let environments = vec![
|
||||
TurnEnvironmentSelection {
|
||||
environment_id: FIRST_ENVIRONMENT_ID.to_string(),
|
||||
cwd: first_workspace_uri.clone(),
|
||||
workspace_roots: vec![first_workspace_uri],
|
||||
sandbox: Some(environment_sandbox.clone()),
|
||||
},
|
||||
TurnEnvironmentSelection {
|
||||
environment_id: SECOND_ENVIRONMENT_ID.to_string(),
|
||||
cwd: second_workspace_uri.clone(),
|
||||
workspace_roots: vec![second_workspace_uri],
|
||||
sandbox: Some(environment_sandbox),
|
||||
},
|
||||
];
|
||||
let permission_profile = PermissionProfile::workspace_write_with(
|
||||
&[],
|
||||
NetworkSandboxPolicy::Restricted,
|
||||
/*exclude_tmpdir_env_var*/ true,
|
||||
/*exclude_slash_tmp*/ true,
|
||||
);
|
||||
// Keep the thread default unrestricted. This makes the cross-write
|
||||
// assertions prove that execution used each environment's sandbox.
|
||||
let permission_profile = PermissionProfile::Disabled;
|
||||
let (sandbox_policy, permission_profile) =
|
||||
turn_permission_fields(permission_profile, test.config.cwd.as_path());
|
||||
test.codex
|
||||
|
||||
@@ -1068,6 +1068,7 @@ async fn approved_network_host_for_one_environment_still_prompts_in_another() ->
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&remote_cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&remote_cwd)],
|
||||
sandbox: None,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -319,6 +319,7 @@ async fn explicit_remote_shell_runs_in_remote_cwd() -> Result<()> {
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&test.config.cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&test.config.cwd)],
|
||||
sandbox: None,
|
||||
}]),
|
||||
)
|
||||
.await?;
|
||||
@@ -708,6 +709,7 @@ async fn deferred_executor_starts_noise_connection_after_registration() -> Resul
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&test.config.cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&test.config.cwd)],
|
||||
sandbox: None,
|
||||
}],
|
||||
)),
|
||||
..Default::default()
|
||||
@@ -902,6 +904,7 @@ async fn deferred_executor_wait_reports_startup_failure() -> Result<()> {
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&test.config.cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&test.config.cwd)],
|
||||
sandbox: None,
|
||||
}],
|
||||
)),
|
||||
..Default::default()
|
||||
@@ -1251,6 +1254,7 @@ async fn exec_command_routes_to_selected_remote_environment() -> Result<()> {
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&remote_cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&remote_cwd)],
|
||||
sandbox: None,
|
||||
};
|
||||
let multi_env_output = exec_command_routing_output(
|
||||
&test,
|
||||
@@ -1390,11 +1394,13 @@ async fn remote_exec_materializes_target_roots_before_sandbox_selection() -> Res
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&local_cwd.path().abs()),
|
||||
workspace_roots: Vec::new(),
|
||||
sandbox: None,
|
||||
},
|
||||
TurnEnvironmentSelection {
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: remote_cwd_uri.clone(),
|
||||
workspace_roots: vec![remote_cwd_uri.clone()],
|
||||
sandbox: None,
|
||||
},
|
||||
],
|
||||
)),
|
||||
@@ -1563,6 +1569,7 @@ async fn remote_request_permissions_grant_unblocks_later_remote_exec() -> Result
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&remote_cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&remote_cwd)],
|
||||
sandbox: None,
|
||||
},
|
||||
],
|
||||
AskForApproval::OnRequest,
|
||||
@@ -1705,6 +1712,7 @@ async fn apply_patch_freeform_routes_to_selected_remote_environment() -> Result<
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&remote_cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&remote_cwd)],
|
||||
sandbox: None,
|
||||
},
|
||||
]),
|
||||
)
|
||||
@@ -1789,6 +1797,7 @@ async fn apply_patch_approvals_are_remembered_per_environment() -> Result<()> {
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&remote_cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&remote_cwd)],
|
||||
sandbox: None,
|
||||
},
|
||||
];
|
||||
let local_patch = format!(
|
||||
@@ -1991,6 +2000,7 @@ async fn apply_patch_intercepted_exec_command_routes_to_selected_remote_environm
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: PathUri::from_abs_path(&remote_cwd),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&remote_cwd)],
|
||||
sandbox: None,
|
||||
},
|
||||
]),
|
||||
)
|
||||
|
||||
@@ -39,6 +39,7 @@ fn resume_history(
|
||||
permission_profile: None,
|
||||
network: None,
|
||||
file_system_sandbox_policy: None,
|
||||
environment_sandboxes: None,
|
||||
model: previous_model.to_string(),
|
||||
comp_hash: None,
|
||||
personality: None,
|
||||
|
||||
@@ -587,6 +587,7 @@ async fn view_image_routes_to_selected_remote_environment() -> anyhow::Result<()
|
||||
environment_id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
cwd: remote_cwd_uri.clone(),
|
||||
workspace_roots: vec![remote_cwd_uri],
|
||||
sandbox: None,
|
||||
};
|
||||
let relative_call_id = "call-view-image-relative-multi-env";
|
||||
let absolute_call_id = "call-view-image-absolute-multi-env";
|
||||
|
||||
Reference in New Issue
Block a user