mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Run sandbox integrity checks before commands and filesystem operations (#51843)
## What changed Wire existing sandbox integrity checks into local command preparation, exec-server process preparation, and sandboxed filesystem helper and file-open operations. Make execution request preparation asynchronous so callers can await the checks. The checks remain observational: failures and timeouts do not prevent command execution. ## Testing Add regression tests that launch a real command after checker preparation fails or exceeds its timeout, verifying successful output and exit status. GitOrigin-RevId: a82399f8aeb8b08f9965e6121b4c7f460552af3f
This commit is contained in:
@@ -88,6 +88,7 @@ impl FileSystemSandboxRunner {
|
||||
request: FsHelperRequest,
|
||||
) -> Result<FsHelperPayload, JSONRPCErrorError> {
|
||||
let command = self.sandbox_command(sandbox)?;
|
||||
crate::run_integrity_checks(&command).await;
|
||||
let request_json = serde_json::to_vec(&request).map_err(json_error)?;
|
||||
run_command(command, request_json).await
|
||||
}
|
||||
|
||||
@@ -298,6 +298,7 @@ pub(crate) async fn prepare_exec_request_with_telemetry(
|
||||
}
|
||||
.map_err(|err| invalid_params(format!("failed to prepare process sandbox: {err}")))?;
|
||||
request.sandbox_override = sandbox_context.sandbox_override;
|
||||
crate::run_integrity_checks(&request).await;
|
||||
let windows_sandbox = if sandbox == SandboxType::WindowsRestrictedToken {
|
||||
let windows_sandbox_level = windows_sandbox_level.ok_or_else(|| {
|
||||
invalid_params("restricted token sandbox requires a sandbox level".to_string())
|
||||
|
||||
@@ -93,6 +93,7 @@ impl SandboxedFileSystem {
|
||||
.sandbox_runner
|
||||
.sandbox_command(sandbox)
|
||||
.map_err(map_sandbox_error)?;
|
||||
crate::run_integrity_checks(&command).await;
|
||||
crate::sandboxed_file_open::open(command, path.clone(), mode)
|
||||
.await
|
||||
.map_err(map_sandbox_error)
|
||||
|
||||
Reference in New Issue
Block a user