Allow network policy to enable transparent TCP capture (#61851)

## What changed

- Add `transparent_tcp` to network configuration and managed requirements, defaulting to off. When enabled, route outbound TCP from managed Linux sandbox commands through the managed SOCKS5 proxy without requiring an executor startup flag.
- Propagate the setting through local and remote execution, require an enabled SOCKS5 proxy, and check the executor's `networkProxyTransparentTcp` capability before remote launches.
- Refresh the live proxy when switching between permission profiles with different network settings.

## Testing

Add coverage for configuration-driven sandbox capture, rejection of unsupported launch contexts, execution parameter propagation, and live permission profile changes.

GitOrigin-RevId: c4db87056de116f433a128806bef673802f35397
This commit is contained in:
viyatb-oai
2026-11-16 18:19:16 +00:00
committed by copyberry
parent fef47a6769
commit effad7568c
29 changed files with 312 additions and 39 deletions
+8 -7
View File
@@ -2182,7 +2182,7 @@ impl Session {
commit,
previous_config,
new_config,
permission_profile_changed,
refresh_network_proxy,
mcp_inputs_changed,
credential_masking_warning,
) = {
@@ -2218,10 +2218,11 @@ impl Session {
});
let previous_config = notify_config_contributors
.then(|| self.build_effective_session_config(&state.session_configuration));
let previous_permission_profile = state.session_configuration.permission_profile();
let updated_permission_profile = updated.permission_profile();
let permission_profile_changed =
previous_permission_profile != updated_permission_profile;
let current = &state.session_configuration;
let refresh_network_proxy = current.permission_profile()
!= updated.permission_profile()
|| current.original_config_do_not_use.permissions.network
!= updated.original_config_do_not_use.permissions.network;
let root_service_tier_changed = updated.parent_thread_id.is_none()
&& state.session_configuration.step_settings.service_tier
!= updated.step_settings.service_tier;
@@ -2281,7 +2282,7 @@ impl Session {
commit,
previous_config,
new_config,
permission_profile_changed,
refresh_network_proxy,
mcp_inputs_changed,
credential_masking_warning,
)
@@ -2294,7 +2295,7 @@ impl Session {
);
}
self.emit_config_changed_contributors(previous_config.as_ref(), new_config.as_ref());
if permission_profile_changed {
if refresh_network_proxy {
self.refresh_managed_network_proxy_for_current_permission_profile()
.await;
}
+40
View File
@@ -1330,6 +1330,46 @@ async fn new_turn_refreshes_managed_network_proxy_for_sandbox_change() -> anyhow
Ok(())
}
#[tokio::test]
async fn switching_profiles_updates_live_transparent_tcp() -> anyhow::Result<()> {
let home = tempfile::tempdir()?;
std::fs::write(
home.path().join(codex_config::CONFIG_TOML_FILE),
r#"
default_permissions = "explicit"
features.network_proxy = true
[permissions.explicit]
extends = ":workspace"
network.enabled = true
[permissions.capture]
extends = "explicit"
network.transparent_tcp = true
"#,
)?;
let config = build_test_config(home.path()).await;
let permissions = config.permissions.permission_profile().clone();
let session = make_session_with_config(|current| *current = config).await?;
let proxy = session
.services
.network_proxy
.load_full()
.expect("live proxy");
for (profile, capture) in [("capture", true), ("explicit", false)] {
session
.update_settings(SessionSettingsUpdate {
permission_profile: Some(permissions.clone()),
active_permission_profile: Some(ActivePermissionProfile::new(profile)),
..Default::default()
})
.await?;
let prepared = proxy
.proxy()
.prepare_for_optional_environment(HashMap::new(), /*environment_id*/ None)?;
assert_eq!(prepared.sandbox_context.transparent_tcp, capture);
}
Ok(())
}
#[tokio::test]
async fn refresh_clears_disabled_managed_network_proxy() -> anyhow::Result<()> {
let permission_profile = PermissionProfile::workspace_write();