mirror of
https://github.com/openai/codex.git
synced 2026-11-20 23:08:21 +00:00
Add keyed shell environment policy filters (#34590)
## What changed - Add `shell_environment_policy.filters`, mapping environment-variable patterns to `include` or `exclude`, while continuing to accept the legacy `exclude` and `include_only` arrays. - Merge filter keys case-insensitively across config layers so higher-precedence entries can override individual patterns. Switching representations replaces the other representation instead of combining them. - Reject mixed, duplicate, or malformed filter definitions in enabled layers, config writes, and reloads, while retaining the previous session configuration when a reload is invalid. - Make config-manager reads and writes representation-aware and preserve existing formatting when updating individual policy values. ## Testing Add coverage for parsing, schema constraints, layered merging, validation and diagnostics, config writes, override metadata, and invalid session reloads. GitOrigin-RevId: e15464bca53e6e7ef31fcc97537fda60ed5d670a
This commit is contained in:
1 parent
65f8bf6853
commit
7442f5f932
29 files changed
+1662
-115
No files matched your search
@@ -23,10 +23,12 @@ use crate::merge::merge_toml_values;
|
||||
use crate::overrides::build_cli_overrides_layer;
|
||||
use crate::project_root_markers::default_project_root_markers;
|
||||
use crate::project_root_markers::project_root_markers_from_config;
|
||||
use crate::shell_environment_policy::ShellEnvironmentPolicyFilterConfigToml;
|
||||
use crate::state::ConfigLayerEntry;
|
||||
use crate::state::ConfigLayerStack;
|
||||
use crate::state::ConfigLoadOptions;
|
||||
use crate::state::LoaderOverrides;
|
||||
use crate::state::validate_enabled_config_layers;
|
||||
use crate::strict_config::config_error_from_ignored_toml_value_fields;
|
||||
use crate::strict_config::ignored_toml_value_field;
|
||||
use crate::strict_config::unknown_feature_toml_value_field;
|
||||
@@ -408,6 +410,21 @@ pub async fn load_config_layers_state(
|
||||
));
|
||||
}
|
||||
|
||||
if let Err(err) = validate_enabled_config_layers(&layers) {
|
||||
if let Some(config_error) = typed_first_layer_config_error_from_entries::<
|
||||
ShellEnvironmentPolicyFilterConfigToml,
|
||||
>(&layers, CONFIG_TOML_FILE)
|
||||
.await
|
||||
{
|
||||
return Err(io_error_from_config_error(
|
||||
io::ErrorKind::InvalidData,
|
||||
config_error,
|
||||
/*source*/ None,
|
||||
));
|
||||
}
|
||||
return Err(err);
|
||||
}
|
||||
|
||||
let config_layer_stack = ConfigLayerStack::new(
|
||||
layers,
|
||||
config_requirements_toml.clone().try_into()?,
|
||||
|
||||
Reference in new issue
Block a user