mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Use turn environment permissions for tool execution (#37038)
## What changed - Derive sandboxing, approval, and permission-profile environment variables from the selected turn environment for shell, unified exec, `apply_patch`, image viewing, and network approval flows. - Materialize project-root permissions against every workspace root in that environment, allowing `apply_patch` to write to secondary workspace roots while preserving protected paths. - Carry the selected environment's permission profile into spawned or resumed agents and Guardian permission context. ## Testing - Add an integration test covering `apply_patch` writes in a secondary workspace root. - Extend tool, Guardian, and multi-agent tests to distinguish environment permissions from thread-level permissions. GitOrigin-RevId: e22da8974bcd3de1e724978b1a7790307a51e4bc
This commit is contained in:
1 parent
1fe6be9719
commit
bac3ef1d8e
28 files changed
+398
-147
No files matched your search
@@ -81,6 +81,25 @@ impl TurnEnvironment {
|
||||
&self.workspace_roots
|
||||
}
|
||||
|
||||
pub(crate) fn permission_profile(&self) -> &PermissionProfile {
|
||||
self.config.permission_profile.permission_profile()
|
||||
}
|
||||
|
||||
pub(crate) fn active_permission_profile(&self) -> Option<ActivePermissionProfile> {
|
||||
self.config.permission_profile.active_permission_profile()
|
||||
}
|
||||
|
||||
pub(crate) fn permission_profile_with_workspace_roots(&self) -> PermissionProfile {
|
||||
let workspace_roots = self
|
||||
.workspace_roots()
|
||||
.iter()
|
||||
.filter_map(|workspace_root| workspace_root.to_abs_path().ok())
|
||||
.collect::<Vec<_>>();
|
||||
self.permission_profile()
|
||||
.clone()
|
||||
.materialize_project_roots_with_workspace_roots(&workspace_roots)
|
||||
}
|
||||
|
||||
pub(crate) fn selection(&self) -> TurnEnvironmentSelection {
|
||||
TurnEnvironmentSelection {
|
||||
environment_id: self.environment_id.clone(),
|
||||
@@ -333,7 +352,7 @@ impl TurnContext {
|
||||
environment: &TurnEnvironment,
|
||||
) -> FileSystemSandboxContext {
|
||||
let permissions = effective_permission_profile(
|
||||
self.config.permissions.permission_profile(),
|
||||
environment.permission_profile(),
|
||||
additional_permissions.as_ref(),
|
||||
);
|
||||
FileSystemSandboxContext {
|
||||
|
||||
Reference in new issue
Block a user