linux-sandbox: use standalone bundled bwrap

This commit is contained in:
Michael Bolin
2026-05-05 16:26:30 -07:00
parent 332b8b2c74
commit f1dbc71e45
25 changed files with 661 additions and 270 deletions
+3
View File
@@ -7,5 +7,8 @@ codex_rust_crate(
# they install process-global test-binary dispatch state, and the remote
# exec-server cases already rely on serialization around the full CLI path.
integration_test_args = ["--test-threads=1"],
extra_binaries = [
"//codex-rs/bwrap:bwrap",
],
test_tags = ["no-sandbox"],
)
+22 -1
View File
@@ -29,6 +29,15 @@ use crate::rpc::internal_error;
use crate::rpc::invalid_request;
const FS_HELPER_ENV_ALLOWLIST: &[&str] = &["PATH", "TMPDIR", "TMP", "TEMP"];
#[cfg(debug_assertions)]
const FS_HELPER_BAZEL_BWRAP_ENV_ALLOWLIST: &[&str] = &[
"CARGO_BIN_EXE_bwrap",
"RUNFILES_DIR",
"RUNFILES_MANIFEST_FILE",
"RUNFILES_MANIFEST_ONLY",
"TEST_SRCDIR",
"TEST_WORKSPACE",
];
#[derive(Clone, Debug)]
pub(crate) struct FileSystemSandboxRunner {
@@ -220,7 +229,19 @@ fn helper_env_from_vars(
}
fn helper_env_key_is_allowed(key: &str) -> bool {
FS_HELPER_ENV_ALLOWLIST.contains(&key) || (cfg!(windows) && key.eq_ignore_ascii_case("PATH"))
FS_HELPER_ENV_ALLOWLIST.contains(&key)
|| bazel_bwrap_env_key_is_allowed(key)
|| (cfg!(windows) && key.eq_ignore_ascii_case("PATH"))
}
#[cfg(debug_assertions)]
fn bazel_bwrap_env_key_is_allowed(key: &str) -> bool {
option_env!("BAZEL_PACKAGE").is_some() && FS_HELPER_BAZEL_BWRAP_ENV_ALLOWLIST.contains(&key)
}
#[cfg(not(debug_assertions))]
fn bazel_bwrap_env_key_is_allowed(_key: &str) -> bool {
false
}
async fn run_command(