mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
## Why Managed network requirements support both legacy tables and `permissions.network`. Equivalent declarations in one source should be accepted, while older runtime clients still need the top-level network field. ## What changed - Normalize `network_proxy` and `experimental_network` into `permissions.network` before merging requirements, preserving source attribution and explicit empty allowlist replacements. - Accept legacy and nested declarations in one source when they describe the same policy, comparing domain and review selectors by their canonical identities. Continue rejecting mixed surfaces across sources. - Populate the legacy output field for compatibility and preserve legacy selector text when both forms are supplied. - Include contributing requirement sources in cloud bundle errors without exposing submitted TOML. ## Testing Add coverage for equivalent and conflicting declarations, empty allowlist overrides, loader compatibility, and debug output. Add a proxy regression test verifying that a saved grant cannot bypass managed loopback restrictions. GitOrigin-RevId: e0d2a600f5c7c6c07a665ccc0e18a72ff172fd6d
43 lines
1.5 KiB
Rust
43 lines
1.5 KiB
Rust
use codex_config::AbsolutePathBuf;
|
|
use codex_config::CloudConfigBundle;
|
|
use codex_config::CloudConfigBundleLayers;
|
|
use codex_config::CloudConfigBundleLoadError;
|
|
use codex_config::CloudConfigBundleLoadErrorCode;
|
|
use codex_config::compose_requirements;
|
|
use codex_config::config_toml::validate_model_providers;
|
|
|
|
pub(crate) fn validate_bundle(
|
|
bundle: &CloudConfigBundle,
|
|
base_dir: &AbsolutePathBuf,
|
|
) -> Result<(), CloudConfigBundleLoadError> {
|
|
let bundle_layers =
|
|
CloudConfigBundleLayers::from_bundle(bundle.clone(), base_dir).map_err(|_| {
|
|
CloudConfigBundleLoadError::new(
|
|
CloudConfigBundleLoadErrorCode::InvalidBundle,
|
|
/*status_code*/ None,
|
|
"invalid cloud config bundle: invalid TOML",
|
|
)
|
|
})?;
|
|
let CloudConfigBundleLayers {
|
|
enterprise_managed_config: _,
|
|
enterprise_managed_requirements,
|
|
} = bundle_layers;
|
|
|
|
let requirements = compose_requirements(enterprise_managed_requirements)?;
|
|
if let Some(providers) = requirements.and_then(|requirements| requirements.model_providers) {
|
|
validate_model_providers(&providers).map_err(|_| {
|
|
CloudConfigBundleLoadError::new(
|
|
CloudConfigBundleLoadErrorCode::InvalidBundle,
|
|
/*status_code*/ None,
|
|
"invalid cloud config bundle: invalid model provider configuration",
|
|
)
|
|
})?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "validation_tests.rs"]
|
|
mod tests;
|