mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
Extract shared network policy types from the proxy crate (#63986)
## Why The protocol and feature configuration crates depend on the network proxy crate for data types. Give them a smaller dependency that contains the shared definitions. ## What changed Move environment network policies, domain and Unix socket permissions, policy decisions and their sources, and credential provider definitions into `codex-network-policy-types`. Use the new crate directly from `codex-protocol` and `codex-features`. Re-export the moved types from `codex-network-proxy` and keep environment policy conversion and application, along with credential provider validation, in the proxy crate. GitOrigin-RevId: 8af684da746830bce45ac00135aed8052dba3824
This commit is contained in:
@@ -23,6 +23,7 @@ aws-sigv4 = { workspace = true }
|
||||
base64 = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
chrono = { workspace = true }
|
||||
codex-network-policy-types = { workspace = true }
|
||||
codex-utils-absolute-path = { workspace = true }
|
||||
codex-utils-home-dir = { workspace = true }
|
||||
codex-utils-path-uri = { workspace = true }
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
mod standalone;
|
||||
|
||||
pub use codex_network_policy_types::NetworkDomainPermission;
|
||||
pub use codex_network_policy_types::NetworkDomainPermissionEntry;
|
||||
pub use codex_network_policy_types::NetworkDomainPermissions;
|
||||
pub use codex_network_policy_types::NetworkUnixSocketPermission;
|
||||
pub use codex_network_policy_types::NetworkUnixSocketPermissions;
|
||||
pub use standalone::StaticNetworkProxyConfig;
|
||||
|
||||
use anyhow::Context;
|
||||
@@ -7,9 +12,7 @@ use anyhow::Result;
|
||||
use anyhow::bail;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use serde::Deserialize;
|
||||
use serde::Deserializer;
|
||||
use serde::Serialize;
|
||||
use serde::Serializer;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::net::IpAddr;
|
||||
@@ -22,104 +25,6 @@ use crate::Platform;
|
||||
use crate::mitm_hook::MitmHookConfig;
|
||||
use crate::policy::normalize_host;
|
||||
|
||||
/// Variant order encodes effective precedence for duplicate patterns:
|
||||
/// `None < Allow < Deny`, so deny wins over allow when entries conflict.
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum NetworkDomainPermission {
|
||||
None,
|
||||
Allow,
|
||||
Deny,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct NetworkDomainPermissionEntry {
|
||||
pub pattern: String,
|
||||
pub permission: NetworkDomainPermission,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct NetworkDomainPermissions {
|
||||
pub entries: Vec<NetworkDomainPermissionEntry>,
|
||||
}
|
||||
|
||||
impl Serialize for NetworkDomainPermissions {
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
self.effective_entries()
|
||||
.into_iter()
|
||||
.map(|entry| (entry.pattern, entry.permission))
|
||||
.collect::<BTreeMap<_, _>>()
|
||||
.serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for NetworkDomainPermissions {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let entries = BTreeMap::<String, NetworkDomainPermission>::deserialize(deserializer)?
|
||||
.into_iter()
|
||||
.map(|(pattern, permission)| NetworkDomainPermissionEntry {
|
||||
pattern,
|
||||
permission,
|
||||
})
|
||||
.collect();
|
||||
Ok(Self { entries })
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkDomainPermissions {
|
||||
fn effective_entries(&self) -> Vec<NetworkDomainPermissionEntry> {
|
||||
let mut order = Vec::new();
|
||||
let mut effective_permissions = BTreeMap::new();
|
||||
|
||||
for entry in &self.entries {
|
||||
if !effective_permissions.contains_key(&entry.pattern) {
|
||||
order.push(entry.pattern.clone());
|
||||
}
|
||||
|
||||
let permission = effective_permissions
|
||||
.entry(entry.pattern.clone())
|
||||
.or_insert(entry.permission);
|
||||
if entry.permission > *permission {
|
||||
*permission = entry.permission;
|
||||
}
|
||||
}
|
||||
|
||||
order
|
||||
.into_iter()
|
||||
.filter_map(|pattern| {
|
||||
effective_permissions.remove(&pattern).map(|permission| {
|
||||
NetworkDomainPermissionEntry {
|
||||
pattern,
|
||||
permission,
|
||||
}
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum NetworkUnixSocketPermission {
|
||||
Allow,
|
||||
Deny,
|
||||
}
|
||||
|
||||
/// Socket policy keys are preserved across controller and executor hosts.
|
||||
/// Allow entries must be NUL-free and absolute according to the executor OS;
|
||||
/// Deny entries are retained without path validation or expansion.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
|
||||
pub struct NetworkUnixSocketPermissions {
|
||||
#[serde(flatten)]
|
||||
pub entries: BTreeMap<String, NetworkUnixSocketPermission>,
|
||||
}
|
||||
|
||||
/// A caller-provided MITM CA for trusted proxy configuration, not sandbox `config.toml`.
|
||||
/// The private key file is readable only by the proxy process.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
|
||||
@@ -2,7 +2,6 @@ mod configured;
|
||||
mod destination;
|
||||
mod environment;
|
||||
mod matching;
|
||||
mod provider_config;
|
||||
mod providers;
|
||||
mod registry;
|
||||
mod replacement;
|
||||
@@ -26,6 +25,8 @@ use std::sync::Arc;
|
||||
use std::sync::RwLock;
|
||||
use url::Url;
|
||||
|
||||
pub use codex_network_policy_types::CredentialAuthMethod;
|
||||
pub use codex_network_policy_types::CredentialProviderConfig;
|
||||
pub use environment::CredentialBrokerContext;
|
||||
pub use environment::CredentialBrokerEnvironment;
|
||||
pub use environment::brokered_credential_binding_env_keys;
|
||||
@@ -37,8 +38,15 @@ pub use environment::credential_broker_provider_context_env_keys;
|
||||
pub use environment::credential_broker_provider_sources_allowed;
|
||||
pub use environment::is_credential_broker_provider_env_key;
|
||||
pub(crate) use environment::marked_credential_dummy_env_keys;
|
||||
pub use provider_config::CredentialAuthMethod;
|
||||
pub use provider_config::CredentialProviderConfig;
|
||||
|
||||
/// Validate a complete provider definition using the broker's compilation rules.
|
||||
pub fn validate_credential_provider(
|
||||
id: &str,
|
||||
config: &CredentialProviderConfig,
|
||||
) -> anyhow::Result<()> {
|
||||
configured::ConfiguredCredentialProvider::compile(id, config)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub const CREDENTIAL_BROKER_ACTIVE_ENV_KEY: &str = "CODEX_NETWORK_PROXY_CREDENTIAL_BROKER_ACTIVE";
|
||||
pub(crate) const BROKERED_CREDENTIALS_ENV_KEY: &str = "CODEX_NETWORK_PROXY_BROKERED_CREDENTIALS";
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
/// Declarative description of an environment-backed credential family.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub struct CredentialProviderConfig {
|
||||
pub env: Vec<String>,
|
||||
pub patterns: Vec<String>,
|
||||
/// URL prefixes authorized for injection. Bare loopback hosts imply HTTP; other bare hosts
|
||||
/// imply HTTPS.
|
||||
pub url_prefixes: Vec<String>,
|
||||
/// Environment variable containing an additional URL prefix or hostname.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub url_prefix_from_env: Option<String>,
|
||||
pub auth: Vec<CredentialAuthMethod>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub header: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub prefix: Option<String>,
|
||||
}
|
||||
|
||||
impl CredentialProviderConfig {
|
||||
/// Validate a complete provider definition using the broker's compilation rules.
|
||||
pub fn validate(&self, id: &str) -> anyhow::Result<()> {
|
||||
super::configured::ConfiguredCredentialProvider::compile(id, self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Authentication formats supported by declarative credential providers.
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CredentialAuthMethod {
|
||||
Bearer,
|
||||
Token,
|
||||
Basic,
|
||||
Header,
|
||||
}
|
||||
@@ -1,121 +1,97 @@
|
||||
use crate::NetworkDomainPermissions;
|
||||
//! Project proxy settings into environment policies and compose them with controller restrictions.
|
||||
|
||||
use crate::EnvironmentNetworkPolicy;
|
||||
use crate::NetworkProxyConfig;
|
||||
use crate::NetworkUnixSocketPermission;
|
||||
use crate::NetworkUnixSocketPermissions;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
/// Managed proxy requirements supplied by the owner of one execution environment.
|
||||
///
|
||||
/// 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,
|
||||
/// Route outbound TCP from managed Linux sandbox commands through the managed SOCKS5 proxy.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub transparent_tcp: bool,
|
||||
pub domains: Option<NetworkDomainPermissions>,
|
||||
/// Managed host selectors inherited by every execution in this environment.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub review_domains: Vec<String>,
|
||||
pub unix_sockets: Option<NetworkUnixSocketPermissions>,
|
||||
pub allow_upstream_proxy: bool,
|
||||
pub dangerously_allow_all_unix_sockets: bool,
|
||||
/// Omission inherits local-binding policy; an explicit false remains a restriction.
|
||||
pub allow_local_binding: Option<bool>,
|
||||
pub managed_allowed_domains_only: bool,
|
||||
}
|
||||
|
||||
impl EnvironmentNetworkPolicy {
|
||||
/// 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,
|
||||
transparent_tcp: config.transparent_tcp,
|
||||
domains: config.domains.clone(),
|
||||
review_domains: config.review_domains.clone(),
|
||||
unix_sockets: config.unix_sockets.clone(),
|
||||
allow_upstream_proxy: config.allow_upstream_proxy,
|
||||
dangerously_allow_all_unix_sockets: config
|
||||
.dangerously_allow_all_unix_sockets
|
||||
.unwrap_or(false),
|
||||
allow_local_binding: config.allow_local_binding,
|
||||
managed_allowed_domains_only,
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies attachment-owned traffic settings while preserving inherited denials and proxy setup.
|
||||
pub fn apply_to(&self, config: &mut NetworkProxyConfig) {
|
||||
config.transparent_tcp |= self.transparent_tcp;
|
||||
// Neither owner nor controller may remove the other's review selectors.
|
||||
for pattern in &self.review_domains {
|
||||
if !config
|
||||
.review_domains
|
||||
.iter()
|
||||
.any(|existing| existing.eq_ignore_ascii_case(pattern))
|
||||
{
|
||||
config.review_domains.push(pattern.clone());
|
||||
}
|
||||
}
|
||||
// Use the owner's domain rules without dropping controller denials.
|
||||
let inherited_denials = config.denied_domains().unwrap_or_default();
|
||||
config.domains.clone_from(&self.domains);
|
||||
for domain in inherited_denials {
|
||||
config.upsert_domain_permission(
|
||||
domain,
|
||||
crate::NetworkDomainPermission::Deny,
|
||||
crate::normalize_host,
|
||||
);
|
||||
}
|
||||
// An omitted controller policy leaves socket permissions to the attachment;
|
||||
// an explicitly empty socket map still supplies a restrictive ceiling.
|
||||
let inherited_allow_all = config
|
||||
/// Captures proxy activation and traffic restrictions without controller runtime settings.
|
||||
pub fn environment_policy_from_config(
|
||||
config: &NetworkProxyConfig,
|
||||
managed_allowed_domains_only: bool,
|
||||
) -> EnvironmentNetworkPolicy {
|
||||
EnvironmentNetworkPolicy {
|
||||
requires_proxy: config.enabled,
|
||||
transparent_tcp: config.transparent_tcp,
|
||||
domains: config.domains.clone(),
|
||||
review_domains: config.review_domains.clone(),
|
||||
unix_sockets: config.unix_sockets.clone(),
|
||||
allow_upstream_proxy: config.allow_upstream_proxy,
|
||||
dangerously_allow_all_unix_sockets: config
|
||||
.dangerously_allow_all_unix_sockets
|
||||
.unwrap_or(config.unix_sockets.is_none());
|
||||
let inherited_sockets = config.unix_sockets.take().unwrap_or_default();
|
||||
let mut effective_sockets = self.unix_sockets.clone().unwrap_or_default();
|
||||
|
||||
// "Allow all" cannot override a socket denied by either policy.
|
||||
let inherited_permits_all = inherited_allow_all
|
||||
&& !inherited_sockets
|
||||
.entries
|
||||
.values()
|
||||
.any(|permission| matches!(permission, NetworkUnixSocketPermission::Deny));
|
||||
let owner_permits_all = self.dangerously_allow_all_unix_sockets
|
||||
&& !effective_sockets
|
||||
.entries
|
||||
.values()
|
||||
.any(|permission| matches!(permission, NetworkUnixSocketPermission::Deny));
|
||||
|
||||
// Keep shared socket grants; controller denials always take priority.
|
||||
effective_sockets.entries.retain(|path, permission| {
|
||||
matches!(permission, NetworkUnixSocketPermission::Deny)
|
||||
|| inherited_permits_all
|
||||
|| matches!(
|
||||
inherited_sockets.entries.get(path),
|
||||
Some(NetworkUnixSocketPermission::Allow)
|
||||
)
|
||||
});
|
||||
for (path, permission) in inherited_sockets.entries {
|
||||
if owner_permits_all || matches!(permission, NetworkUnixSocketPermission::Deny) {
|
||||
effective_sockets.entries.insert(path, permission);
|
||||
}
|
||||
}
|
||||
|
||||
// Socket and upstream-proxy permissions require both controller and owner grants.
|
||||
config.unix_sockets = (!effective_sockets.entries.is_empty()).then_some(effective_sockets);
|
||||
config.dangerously_allow_all_unix_sockets =
|
||||
Some(inherited_permits_all && owner_permits_all);
|
||||
config.allow_upstream_proxy &= self.allow_upstream_proxy;
|
||||
// Either explicit denial wins; defer unresolved defaults to the executor.
|
||||
config.allow_local_binding = match (config.allow_local_binding, self.allow_local_binding) {
|
||||
(Some(controller), Some(owner)) => Some(controller && owner),
|
||||
(controller, owner) => controller.or(owner),
|
||||
};
|
||||
.unwrap_or(false),
|
||||
allow_local_binding: config.allow_local_binding,
|
||||
managed_allowed_domains_only,
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies attachment-owned traffic settings while preserving inherited denials and proxy setup.
|
||||
pub fn apply_environment_policy(
|
||||
policy: &EnvironmentNetworkPolicy,
|
||||
config: &mut NetworkProxyConfig,
|
||||
) {
|
||||
config.transparent_tcp |= policy.transparent_tcp;
|
||||
// Neither owner nor controller may remove the other's review selectors.
|
||||
for pattern in &policy.review_domains {
|
||||
if !config
|
||||
.review_domains
|
||||
.iter()
|
||||
.any(|existing| existing.eq_ignore_ascii_case(pattern))
|
||||
{
|
||||
config.review_domains.push(pattern.clone());
|
||||
}
|
||||
}
|
||||
// Use the owner's domain rules without dropping controller denials.
|
||||
let inherited_denials = config.denied_domains().unwrap_or_default();
|
||||
config.domains.clone_from(&policy.domains);
|
||||
for domain in inherited_denials {
|
||||
config.upsert_domain_permission(
|
||||
domain,
|
||||
crate::NetworkDomainPermission::Deny,
|
||||
crate::normalize_host,
|
||||
);
|
||||
}
|
||||
// An omitted controller policy leaves socket permissions to the attachment;
|
||||
// an explicitly empty socket map still supplies a restrictive ceiling.
|
||||
let inherited_allow_all = config
|
||||
.dangerously_allow_all_unix_sockets
|
||||
.unwrap_or(config.unix_sockets.is_none());
|
||||
let inherited_sockets = config.unix_sockets.take().unwrap_or_default();
|
||||
let mut effective_sockets = policy.unix_sockets.clone().unwrap_or_default();
|
||||
|
||||
// "Allow all" cannot override a socket denied by either policy.
|
||||
let inherited_permits_all = inherited_allow_all
|
||||
&& !inherited_sockets
|
||||
.entries
|
||||
.values()
|
||||
.any(|permission| matches!(permission, NetworkUnixSocketPermission::Deny));
|
||||
let owner_permits_all = policy.dangerously_allow_all_unix_sockets
|
||||
&& !effective_sockets
|
||||
.entries
|
||||
.values()
|
||||
.any(|permission| matches!(permission, NetworkUnixSocketPermission::Deny));
|
||||
|
||||
// Keep shared socket grants; controller denials always take priority.
|
||||
effective_sockets.entries.retain(|path, permission| {
|
||||
matches!(permission, NetworkUnixSocketPermission::Deny)
|
||||
|| inherited_permits_all
|
||||
|| matches!(
|
||||
inherited_sockets.entries.get(path),
|
||||
Some(NetworkUnixSocketPermission::Allow)
|
||||
)
|
||||
});
|
||||
for (path, permission) in inherited_sockets.entries {
|
||||
if owner_permits_all || matches!(permission, NetworkUnixSocketPermission::Deny) {
|
||||
effective_sockets.entries.insert(path, permission);
|
||||
}
|
||||
}
|
||||
|
||||
// Socket and upstream-proxy permissions require both controller and owner grants.
|
||||
config.unix_sockets = (!effective_sockets.entries.is_empty()).then_some(effective_sockets);
|
||||
config.dangerously_allow_all_unix_sockets = Some(inherited_permits_all && owner_permits_all);
|
||||
config.allow_upstream_proxy &= policy.allow_upstream_proxy;
|
||||
// Either explicit denial wins; defer unresolved defaults to the executor.
|
||||
config.allow_local_binding = match (config.allow_local_binding, policy.allow_local_binding) {
|
||||
(Some(controller), Some(owner)) => Some(controller && owner),
|
||||
(controller, owner) => controller.or(owner),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ pub use aws_sigv4::ProxySecretSource;
|
||||
pub use certs::CHILD_ONLY_CA_ENV_KEYS;
|
||||
pub use certs::CUSTOM_CA_ENV_KEYS;
|
||||
pub use certs::is_managed_mitm_ca_trust_bundle_path;
|
||||
pub use codex_network_policy_types::EnvironmentNetworkPolicy;
|
||||
pub use codex_utils_path_uri::Platform;
|
||||
pub use config::NetworkDomainPermission;
|
||||
pub use config::NetworkDomainPermissionEntry;
|
||||
@@ -73,10 +74,12 @@ pub use credential_broker::brokered_credential_value_env_keys;
|
||||
pub use credential_broker::credential_broker_provider_context_env_keys;
|
||||
pub use credential_broker::credential_broker_provider_sources_allowed;
|
||||
pub use credential_broker::is_credential_broker_provider_env_key;
|
||||
pub use credential_broker::validate_credential_provider;
|
||||
pub use domain_matcher::canonical_allow_pattern;
|
||||
pub use domain_matcher::canonical_deny_pattern;
|
||||
pub use domain_matcher::canonical_review_pattern;
|
||||
pub use environment_policy::EnvironmentNetworkPolicy;
|
||||
pub use environment_policy::apply_environment_policy;
|
||||
pub use environment_policy::environment_policy_from_config;
|
||||
pub use mitm_hook::InjectedHeaderConfig;
|
||||
pub use mitm_hook::MitmHookActionsConfig;
|
||||
pub use mitm_hook::MitmHookBodyConfig;
|
||||
|
||||
@@ -8,6 +8,8 @@ use crate::state::NetworkProxyState;
|
||||
use anyhow::Result;
|
||||
use chrono::SecondsFormat;
|
||||
use chrono::Utc;
|
||||
pub use codex_network_policy_types::NetworkDecisionSource;
|
||||
pub use codex_network_policy_types::NetworkPolicyDecision;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
@@ -62,42 +64,6 @@ impl NetworkProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, serde::Deserialize, serde::Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum NetworkPolicyDecision {
|
||||
Deny,
|
||||
Ask,
|
||||
}
|
||||
|
||||
impl NetworkPolicyDecision {
|
||||
pub const fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::Deny => "deny",
|
||||
Self::Ask => "ask",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, serde::Deserialize, serde::Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum NetworkDecisionSource {
|
||||
BaselinePolicy,
|
||||
ModeGuard,
|
||||
ProxyState,
|
||||
Decider,
|
||||
}
|
||||
|
||||
impl NetworkDecisionSource {
|
||||
pub const fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::BaselinePolicy => "baseline_policy",
|
||||
Self::ModeGuard => "mode_guard",
|
||||
Self::ProxyState => "proxy_state",
|
||||
Self::Decider => "decider",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct NetworkPolicyRequest {
|
||||
pub protocol: NetworkProtocol,
|
||||
|
||||
@@ -1103,7 +1103,7 @@ impl NetworkProxy {
|
||||
}
|
||||
}
|
||||
if let Some(policy) = environment_policy {
|
||||
policy.apply_to(&mut config);
|
||||
crate::apply_environment_policy(policy, &mut config);
|
||||
}
|
||||
config.allow_local_binding = Some(local_binding_policy.resolve(&config));
|
||||
anyhow::ensure!(
|
||||
@@ -2138,7 +2138,7 @@ mod tests {
|
||||
"remote",
|
||||
"execution-1",
|
||||
"token-1".to_string(),
|
||||
Some(crate::EnvironmentNetworkPolicy::from_config(
|
||||
Some(crate::environment_policy_from_config(
|
||||
&owner_config,
|
||||
/*managed_allowed_domains_only*/ false,
|
||||
)),
|
||||
@@ -2195,7 +2195,7 @@ mod tests {
|
||||
"owner-environment",
|
||||
"execution-3",
|
||||
"token-3".to_string(),
|
||||
Some(crate::EnvironmentNetworkPolicy::from_config(
|
||||
Some(crate::environment_policy_from_config(
|
||||
&owner_config,
|
||||
/*managed_allowed_domains_only*/ true,
|
||||
)),
|
||||
@@ -2716,7 +2716,7 @@ mod tests {
|
||||
"remote-env",
|
||||
"execution-2",
|
||||
"token-2".to_string(),
|
||||
Some(crate::EnvironmentNetworkPolicy::from_config(
|
||||
Some(crate::environment_policy_from_config(
|
||||
&owner_config,
|
||||
/*managed_allowed_domains_only*/ false,
|
||||
)),
|
||||
|
||||
Reference in New Issue
Block a user