mirror of
https://github.com/openai/codex.git
synced 2026-11-18 15:01:48 +00:00
Enable network policy callbacks for remote exec (#35652)
## What changed - Forward remote managed-network policy requests to the controller-side decider when Guardian review is enabled. - Bound callbacks using the configured permission-hook and Guardian review timeouts, restore trusted execution attribution, and recheck live baseline policy before requesting a decision. - Cancel pending decisions when the process or execution scope ends, and propagate EOF across the sandbox proxy bridge with half-closes. ## Testing - Cover callback enablement, strict allowlist behavior, live policy updates, trusted attribution, and execution-scope cancellation. GitOrigin-RevId: 83b47657c8c4546dfe98eec8b272833e96a46b7e
This commit is contained in:
1 parent
976129f097
commit
462ed19a05
13 files changed
+398
-52
No files matched your search
@@ -114,6 +114,7 @@ async fn exec_command_with_tty(
|
||||
process_id,
|
||||
&request,
|
||||
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile,
|
||||
/*network_policy_decider*/ None,
|
||||
tty,
|
||||
Box::new(NoopSpawnLifecycle),
|
||||
turn.environments
|
||||
@@ -755,6 +756,7 @@ async fn completed_pipe_commands_preserve_exit_code() -> anyhow::Result<()> {
|
||||
/*process_id*/ 1234,
|
||||
&request,
|
||||
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile,
|
||||
/*network_policy_decider*/ None,
|
||||
/*tty*/ false,
|
||||
Box::new(NoopSpawnLifecycle),
|
||||
&environment,
|
||||
@@ -796,6 +798,7 @@ async fn unified_exec_uses_remote_exec_server_when_configured() -> anyhow::Resul
|
||||
/*process_id*/ 1234,
|
||||
&request,
|
||||
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile,
|
||||
/*network_policy_decider*/ None,
|
||||
/*tty*/ true,
|
||||
Box::new(NoopSpawnLifecycle),
|
||||
remote_test_env.environment(),
|
||||
@@ -855,6 +858,7 @@ async fn remote_exec_server_rejects_inherited_fd_launches() -> anyhow::Result<()
|
||||
/*process_id*/ 1234,
|
||||
&request,
|
||||
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile,
|
||||
/*network_policy_decider*/ None,
|
||||
/*tty*/ true,
|
||||
Box::new(TestSpawnLifecycle {
|
||||
inherited_fds: vec![42],
|
||||
|
||||
@@ -59,6 +59,7 @@ use crate::unified_exec::process::OutputHandles;
|
||||
use crate::unified_exec::process::SpawnLifecycleHandle;
|
||||
use crate::unified_exec::process::UnifiedExecProcess;
|
||||
use codex_core_plugins::PluginCommandAttribution;
|
||||
use codex_network_proxy::NetworkPolicyDecider;
|
||||
use codex_network_proxy::NetworkProxy;
|
||||
use codex_protocol::config_types::ShellEnvironmentPolicy;
|
||||
use codex_protocol::error::CodexErr;
|
||||
@@ -1019,12 +1020,17 @@ impl UnifiedExecProcessManager {
|
||||
attempt.env_for(command, options, network, environment_id)
|
||||
}
|
||||
.map_err(ToolError::Codex)?;
|
||||
let network_policy_decider = network_proxy_launch
|
||||
.as_ref()
|
||||
.filter(|launch| launch.policy_decision_timeout_ms.is_some())
|
||||
.and_then(|_| network.and_then(NetworkProxy::remote_policy_decider));
|
||||
request.exec_server_network_proxy = network_proxy_launch;
|
||||
request.exec_server_env_config = exec_server_env_config;
|
||||
self.open_session_with_prepared_exec_env(
|
||||
process_id,
|
||||
&request,
|
||||
windows_sandbox_proxy_settings_mode,
|
||||
network_policy_decider,
|
||||
tty,
|
||||
spawn_lifecycle,
|
||||
environment,
|
||||
@@ -1041,11 +1047,13 @@ impl UnifiedExecProcessManager {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) async fn open_session_with_prepared_exec_env(
|
||||
&self,
|
||||
process_id: i32,
|
||||
request: &ExecRequest,
|
||||
windows_sandbox_proxy_settings_mode: codex_sandboxing::WindowsSandboxProxySettingsMode,
|
||||
network_policy_decider: Option<Arc<dyn NetworkPolicyDecider>>,
|
||||
tty: bool,
|
||||
mut spawn_lifecycle: SpawnLifecycleHandle,
|
||||
environment: &codex_exec_server::Environment,
|
||||
@@ -1059,16 +1067,22 @@ impl UnifiedExecProcessManager {
|
||||
));
|
||||
}
|
||||
|
||||
let started = environment
|
||||
.get_exec_backend()
|
||||
.start(exec_server_params_for_request(
|
||||
process_id,
|
||||
request,
|
||||
windows_sandbox_proxy_settings_mode,
|
||||
tty,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| UnifiedExecError::create_process(err.to_string()))?;
|
||||
let backend = environment.get_exec_backend();
|
||||
let params = exec_server_params_for_request(
|
||||
process_id,
|
||||
request,
|
||||
windows_sandbox_proxy_settings_mode,
|
||||
tty,
|
||||
);
|
||||
let started = match network_policy_decider {
|
||||
Some(decider) => {
|
||||
backend
|
||||
.start_with_network_policy_decider(params, decider)
|
||||
.await
|
||||
}
|
||||
None => backend.start(params).await,
|
||||
}
|
||||
.map_err(|err| UnifiedExecError::create_process(err.to_string()))?;
|
||||
spawn_lifecycle.after_spawn();
|
||||
return UnifiedExecProcess::from_exec_server_started(started).await;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user