Honor execution environment proxy requirements (#48198)

## Why

An execution environment's enabled proxy configuration was reduced to traffic restrictions, leaving restricted commands offline without a controller proxy or an approved network grant.

## What changed

Carry `NetworkProxyConfig.enabled` into `EnvironmentNetworkPolicy.requires_proxy` and honor it when activating managed networking. This lets environment owners require filtered proxy access while direct network access remains restricted. Policies without an explicit proxy requirement retain the existing activation behavior.

## Testing

Extend remote command coverage to check allowed and denied proxy requests without a controller proxy, and verify that direct network access remains blocked.

GitOrigin-RevId: 7cc0063a0d1118de56b1bd30036338cf14360f6a
This commit is contained in:
Sean Huang
2026-09-25 20:11:25 +00:00
committed by copyberry
parent 888948e522
commit 8f5387d104
6 changed files with 53 additions and 9 deletions
@@ -5,13 +5,17 @@ use crate::NetworkUnixSocketPermissions;
use serde::Deserialize;
use serde::Serialize;
/// Traffic restrictions supplied by the owner of one execution environment.
/// Managed proxy requirements supplied by the owner of one execution environment.
///
/// Proxy enablement, listeners, network mode, MITM, and credentials remain outside
/// attachment-owned traffic policy.
/// The owner can require proxy routing without granting direct network access.
/// Listeners, network mode, MITM, and credentials remain controller-owned.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EnvironmentNetworkPolicy {
/// Requires managed proxy routing even when direct network access is restricted.
/// False or omission leaves activation to the controller and command permissions.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub requires_proxy: bool,
pub domains: Option<NetworkDomainPermissions>,
pub unix_sockets: Option<NetworkUnixSocketPermissions>,
pub allow_upstream_proxy: bool,
@@ -22,9 +26,10 @@ pub struct EnvironmentNetworkPolicy {
}
impl EnvironmentNetworkPolicy {
/// Captures portable traffic restrictions without exposing controller runtime settings.
/// Captures proxy activation and traffic restrictions without controller runtime settings.
pub fn from_config(config: &NetworkProxyConfig, managed_allowed_domains_only: bool) -> Self {
Self {
requires_proxy: config.enabled,
domains: config.domains.clone(),
unix_sockets: config.unix_sockets.clone(),
allow_upstream_proxy: config.allow_upstream_proxy,