mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Sandbox remote apply_patch operations (#38043)
## Why Cross-platform remote `apply_patch` calls were rejected when filesystem writes were restricted because patch verification and writes could not be safely performed against executor files. ## What changed - Route intercepted and direct remote patches through the executor-managed filesystem sandbox, including the configured workspace roots. - Select the restricted-token sandbox for Windows executor paths when no Windows sandbox level was configured. - Fail closed when an executor cannot enforce the requested sandbox, and treat executor-managed access failures as sandbox denials so approval can retry the patch without sandboxing. ## Testing - Cover sandboxed remote patches, denied writes, approval retries, Windows sandbox selection, and executor filesystem enforcement. GitOrigin-RevId: caddeed0b266c456a689080a14a3a58e2bd7887c
This commit is contained in:
1 parent
1e557a554e
commit
34db7e5563
14 files changed
+408
-123
No files matched your search
@@ -401,6 +401,19 @@ pub(crate) struct SandboxAttempt<'a> {
|
||||
pub(crate) network_proxy: Option<&'a NetworkProxy>,
|
||||
}
|
||||
|
||||
pub(crate) fn executor_windows_sandbox_level(
|
||||
windows_sandbox_level: WindowsSandboxLevel,
|
||||
cwd: &PathUri,
|
||||
) -> WindowsSandboxLevel {
|
||||
if windows_sandbox_level == WindowsSandboxLevel::Disabled
|
||||
&& cwd.infer_path_convention() == Some(PathConvention::Windows)
|
||||
{
|
||||
WindowsSandboxLevel::RestrictedToken
|
||||
} else {
|
||||
windows_sandbox_level
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> SandboxAttempt<'a> {
|
||||
pub(crate) fn network_proxy<'b>(
|
||||
&'b self,
|
||||
@@ -478,24 +491,14 @@ impl<'a> SandboxAttempt<'a> {
|
||||
crate::sandboxing::ExecRequest::from_sandbox_exec_request(request, options, Vec::new());
|
||||
exec_request.exec_server_managed_network = managed_network;
|
||||
if self.sandbox_requested {
|
||||
// This level comes from the orchestrator's config, so `Disabled` means Windows
|
||||
// sandboxing is irrelevant on a non-Windows host. A Windows executor would instead
|
||||
// treat it as unable to enforce the requested sandbox. Select its baseline restricted
|
||||
// token backend while preserving explicitly configured levels and same-OS behavior.
|
||||
let windows_sandbox_level = if self.windows_sandbox_level
|
||||
== WindowsSandboxLevel::Disabled
|
||||
&& self.sandbox_cwd.infer_path_convention() == Some(PathConvention::Windows)
|
||||
&& PathConvention::native() != PathConvention::Windows
|
||||
{
|
||||
WindowsSandboxLevel::RestrictedToken
|
||||
} else {
|
||||
self.windows_sandbox_level
|
||||
};
|
||||
exec_request.exec_server_sandbox = Some(FileSystemSandboxContext {
|
||||
permissions: exec_server_permissions.into(),
|
||||
cwd: Some(exec_request.windows_sandbox_policy_cwd.clone()),
|
||||
workspace_roots: self.workspace_roots.to_vec(),
|
||||
windows_sandbox_level,
|
||||
windows_sandbox_level: executor_windows_sandbox_level(
|
||||
self.windows_sandbox_level,
|
||||
self.sandbox_cwd,
|
||||
),
|
||||
windows_sandbox_private_desktop: self.windows_sandbox_private_desktop,
|
||||
windows_sandbox_proxy_settings_mode: None,
|
||||
use_legacy_landlock: self.use_legacy_landlock,
|
||||
|
||||
Reference in new issue
Block a user