mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
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:
@@ -158,6 +158,9 @@ pub struct EnvironmentCapabilities {
|
||||
/// Whether executor proxies enforce managed review domains before ordinary allows.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub network_proxy_review_domains: bool,
|
||||
/// Whether the executor can capture TCP for a managed Linux sandbox launch.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub network_proxy_transparent_tcp: bool,
|
||||
/// Whether the selected shell can mask executor environment credentials.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
credential_masking: bool,
|
||||
@@ -323,6 +326,7 @@ impl EnvironmentInfo {
|
||||
capabilities: EnvironmentCapabilities {
|
||||
network_proxy_launch: true,
|
||||
network_proxy_review_domains: true,
|
||||
network_proxy_transparent_tcp: cfg!(target_os = "linux"),
|
||||
credential_masking,
|
||||
credential_masking_custom_providers: credential_masking,
|
||||
capability_discovery_sandbox: true,
|
||||
@@ -413,6 +417,18 @@ pub struct ExecParams {
|
||||
pub network_proxy: Option<RemoteNetworkProxyLaunchConfig>,
|
||||
}
|
||||
|
||||
impl ExecParams {
|
||||
pub fn requests_transparent_tcp(&self) -> bool {
|
||||
self.network_proxy
|
||||
.as_ref()
|
||||
.is_some_and(|launch| launch.proxy.transparent_tcp)
|
||||
|| self
|
||||
.managed_network
|
||||
.as_ref()
|
||||
.is_some_and(|ctx| ctx.transparent_tcp)
|
||||
}
|
||||
}
|
||||
|
||||
/// Executor ingress for process requests from clients that may omit the sandbox policy cwd.
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -1408,6 +1424,7 @@ mod tests {
|
||||
sandbox: None,
|
||||
enforce_managed_network: true,
|
||||
managed_network: Some(ManagedNetworkSandboxContext {
|
||||
transparent_tcp: false,
|
||||
loopback_ports: vec![43123, 48081],
|
||||
allow_local_binding: false,
|
||||
allow_unix_sockets: vec!["/tmp/allowed.sock".to_string()],
|
||||
@@ -1540,6 +1557,7 @@ mod tests {
|
||||
sandbox: None,
|
||||
enforce_managed_network: true,
|
||||
managed_network: Some(ManagedNetworkSandboxContext {
|
||||
transparent_tcp: false,
|
||||
loopback_ports: vec![43123],
|
||||
allow_local_binding: true,
|
||||
allow_unix_sockets: Vec::new(),
|
||||
@@ -1590,6 +1608,7 @@ mod tests {
|
||||
EnvironmentCapabilities {
|
||||
network_proxy_launch: true,
|
||||
network_proxy_review_domains: false,
|
||||
network_proxy_transparent_tcp: false,
|
||||
credential_masking: false,
|
||||
credential_masking_custom_providers: false,
|
||||
capability_discovery_sandbox: true,
|
||||
|
||||
Reference in New Issue
Block a user