mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Resolve permission profiles with explicit execution-host path context (#44676)
## Why Permission paths need to follow the execution host's path conventions and home directory. Literal directory names containing glob syntax must not change the meaning of deny patterns, and profile availability checks need to account for configured workspace roots. ## What changed - Use `ConfigPathContext` to compile built-in and custom profiles, returning the resolved profile and deduplicated `PathUri` workspace roots. Materialize configured roots while retaining runtime workspace symbols. - Use the same compiler for configuration loading, persisted profile validation, and profile catalogs. Resolve roots against the requested `cwd` when listing profiles. - Resolve home-relative scoped rules using the supplied home directory and reject unsafe directory prefixes when constructing globs. - Share workspace-root materialization across native paths and URIs. Deny the affected root when a workspace glob cannot be safely resolved, and clear grants for legacy home-relative workspace denials whose target is unknown. ## Testing Add coverage for POSIX, Windows, and UNC path resolution, inherited workspace roots, scoped home denials, missing home context, and conservative denial behavior for unsafe globs. Add an app-server test verifying that profile availability reflects the requested `cwd`. GitOrigin-RevId: ca259434742365c16d0b72629cabfbab41513a80
This commit is contained in:
1 parent
935ac7710d
commit
9e22e74e8d
17 files changed
+1453
-428
No files matched your search
@@ -1,6 +1,10 @@
|
||||
use super::*;
|
||||
use codex_config::ConfigPathContext;
|
||||
use codex_core::config::permission_profile_catalog;
|
||||
use codex_hooks::HookListEntryHandler;
|
||||
use codex_utils_absolute_path::AbsolutePathBufGuard;
|
||||
use codex_utils_path_uri::PathConvention;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use futures::StreamExt;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -413,22 +417,26 @@ impl CatalogRequestProcessor {
|
||||
params: PermissionProfileListParams,
|
||||
) -> Result<PermissionProfileListResponse, JSONRPCErrorError> {
|
||||
let PermissionProfileListParams { cursor, limit, cwd } = params;
|
||||
let config_layer_stack = match cwd {
|
||||
Some(cwd) => {
|
||||
let cwd = PathBuf::from(cwd);
|
||||
let (_, config_layer_stack) = self
|
||||
.resolve_cwd_config(&cwd)
|
||||
.await
|
||||
.map_err(|err| internal_error(format!("failed to reload config: {err}")))?;
|
||||
config_layer_stack
|
||||
}
|
||||
None => self
|
||||
.config_manager
|
||||
.load_config_layers(/*cwd*/ None)
|
||||
let (cwd, config_layer_stack) = match cwd {
|
||||
Some(cwd) => self
|
||||
.resolve_cwd_config(&PathBuf::from(cwd))
|
||||
.await
|
||||
.map_err(|err| internal_error(format!("failed to reload config: {err}")))?,
|
||||
None => (
|
||||
self.config.cwd.clone(),
|
||||
self.config_manager
|
||||
.load_config_layers(/*cwd*/ None)
|
||||
.await
|
||||
.map_err(|err| internal_error(format!("failed to reload config: {err}")))?,
|
||||
),
|
||||
};
|
||||
let profiles = permission_profile_catalog(&config_layer_stack)
|
||||
let context = ConfigPathContext::new(
|
||||
PathConvention::native(),
|
||||
Some(PathUri::from_abs_path(&cwd)),
|
||||
AbsolutePathBufGuard::home_directory()
|
||||
.and_then(|home| PathUri::from_host_native_path(home).ok()),
|
||||
);
|
||||
let profiles = permission_profile_catalog(&config_layer_stack, &context)
|
||||
.map_err(|err| internal_error(format!("failed to resolve permission profiles: {err}")))?
|
||||
.into_iter()
|
||||
.map(|profile| PermissionProfileSummary {
|
||||
|
||||
Reference in new issue
Block a user