mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
fix: ignore dangerous project-level config keys (#20098)
## Description
Ignore these top-level config keys when loading project-scoped
config.toml files:
```
"openai_base_url",
"chatgpt_base_url",
"model_provider",
"model_providers",
"profile",
"profiles",
"experimental_realtime_ws_base_url",
```
## What changed
- Add a project-local config denylist for credential-routing fields such
as `openai_base_url`, `chatgpt_base_url`, `model_provider`,
`model_providers`, `profile`, `profiles`, and
`experimental_realtime_ws_base_url`.
- Strip those fields from project config layers before they participate
in effective config merging, while leaving safe project-local settings
intact.
- Track ignored project-local keys on config layers and surface a
startup warning telling users to move those settings to user-level
`config.toml` if they intentionally need them.
- Update profile behavior coverage so project-local `profile` /
`profiles` entries are ignored instead of overriding user-level profile
selection.
## Verification
- `cargo test -p codex-config`
- `cargo test -p codex-core
project_layer_ignores_unsupported_config_keys`
- `cargo test -p codex-core project_profiles_are_ignored`
- `cargo test -p codex-core config::config_loader_tests`
This commit is contained in:
1 parent
6014b6679f
commit
9ddb267e9c
5 files changed
+239
-10
No files matched your search
@@ -170,6 +170,12 @@ pub struct ConfigLayerStack {
|
||||
|
||||
/// Whether execpolicy should skip `.rules` files from user and project config-layer folders.
|
||||
ignore_user_and_project_exec_policy_rules: bool,
|
||||
|
||||
/// Startup warnings discovered while building this stack.
|
||||
///
|
||||
/// `None` means the loader did not check for stack-level warnings, while
|
||||
/// `Some(vec![])` means it checked and found nothing to report.
|
||||
startup_warnings: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl ConfigLayerStack {
|
||||
@@ -185,6 +191,7 @@ impl ConfigLayerStack {
|
||||
requirements,
|
||||
requirements_toml,
|
||||
ignore_user_and_project_exec_policy_rules: false,
|
||||
startup_warnings: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -200,6 +207,15 @@ impl ConfigLayerStack {
|
||||
self.ignore_user_and_project_exec_policy_rules
|
||||
}
|
||||
|
||||
pub(crate) fn with_startup_warnings(mut self, startup_warnings: Vec<String>) -> Self {
|
||||
self.startup_warnings = Some(startup_warnings);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn startup_warnings(&self) -> Option<&[String]> {
|
||||
self.startup_warnings.as_deref()
|
||||
}
|
||||
|
||||
/// Returns the raw user config layer, if any.
|
||||
///
|
||||
/// This does not merge other config layers or apply any requirements.
|
||||
@@ -239,6 +255,7 @@ impl ConfigLayerStack {
|
||||
requirements_toml: self.requirements_toml.clone(),
|
||||
ignore_user_and_project_exec_policy_rules: self
|
||||
.ignore_user_and_project_exec_policy_rules,
|
||||
startup_warnings: self.startup_warnings.clone(),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
@@ -262,6 +279,7 @@ impl ConfigLayerStack {
|
||||
requirements_toml: self.requirements_toml.clone(),
|
||||
ignore_user_and_project_exec_policy_rules: self
|
||||
.ignore_user_and_project_exec_policy_rules,
|
||||
startup_warnings: self.startup_warnings.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user