mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Derive sandbox contexts from turn environments (#40551)
## What changed - Add Windows sandbox mode, private-desktop behavior, and legacy Landlock selection to each `EnvironmentConfig`. - Centralize sandbox context construction on `TurnEnvironment`, preserving environment-owned permissions, paths, and backend settings while applying additional permission grants. - Use the environment-derived context for project instructions, capability discovery, file uploads, and filesystem-oriented tools. ## Testing - Verify capability discovery uses the selected environment's permission profile and sandbox backends when they differ from the thread defaults. GitOrigin-RevId: 7ae2fed90c8ada950f2e8431e571e9b2c793c291
This commit is contained in:
1 parent
348f49b292
commit
8444cf63b5
47 files changed
+341
-151
No files matched your search
@@ -27,6 +27,9 @@ fn test_turn_environment(environment_id: &str) -> crate::session::turn_context::
|
||||
workspace_roots: Vec::new(),
|
||||
config: EnvironmentConfigState::Ready(EnvironmentConfig {
|
||||
allow_login_shell: true,
|
||||
windows_sandbox_level: WindowsSandboxLevel::Disabled,
|
||||
windows_sandbox_private_desktop: true,
|
||||
use_legacy_landlock: false,
|
||||
permission_profile: PermissionProfileSnapshot::legacy(
|
||||
PermissionProfile::read_only(),
|
||||
),
|
||||
|
||||
@@ -530,6 +530,7 @@ mod tests {
|
||||
use crate::tools::sandboxing::ToolRuntime;
|
||||
use codex_exec_server::Environment;
|
||||
use codex_exec_server::LOCAL_ENVIRONMENT_ID;
|
||||
use codex_protocol::config_types::WindowsSandboxLevel;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_protocol::protocol::EnvironmentConfig;
|
||||
use codex_protocol::protocol::EnvironmentConfigState;
|
||||
@@ -550,6 +551,9 @@ mod tests {
|
||||
workspace_roots: Vec::new(),
|
||||
config: EnvironmentConfigState::Ready(EnvironmentConfig {
|
||||
allow_login_shell: true,
|
||||
windows_sandbox_level: WindowsSandboxLevel::Disabled,
|
||||
windows_sandbox_private_desktop: true,
|
||||
use_legacy_landlock: false,
|
||||
permission_profile: PermissionProfileSnapshot::legacy(
|
||||
PermissionProfile::read_only(),
|
||||
),
|
||||
|
||||
@@ -532,6 +532,8 @@ fn evaluate_intercepted_exec_policy(
|
||||
struct InterceptedExecPolicyContext {
|
||||
approval_policy: AskForApproval,
|
||||
permission_profile: PermissionProfile,
|
||||
// TODO(anp): Reconcile this policy input with TurnEnvironment::sandbox_context
|
||||
// so intercepted commands use the selected environment's Windows backend.
|
||||
windows_sandbox_level: WindowsSandboxLevel,
|
||||
sandbox_permissions: SandboxPermissions,
|
||||
enable_shell_wrapper_parsing: bool,
|
||||
@@ -557,6 +559,8 @@ fn commands_for_intercepted_exec_policy(
|
||||
vec![join_program_and_argv(program, argv)]
|
||||
}
|
||||
|
||||
// TODO(anp): Capture these Windows and Landlock settings from
|
||||
// TurnEnvironment::sandbox_context when preparing this executor, preserving its snapshot.
|
||||
struct CoreShellCommandExecutor {
|
||||
command: Vec<String>,
|
||||
cwd: AbsolutePathBuf,
|
||||
|
||||
Reference in new issue
Block a user