mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
Migrate the Windows MXC sandbox to mxc-sdk (#55378)
## What changed - Replace the separate MXC crates with `mxc-sdk` and adapt request construction to its policy and optional environment fields. - Preserve the native availability probe by caching successful process security environment creation and startup attribute initialization without launching a process. - Use the SDK's native denied-path support check and configure Bazel resource compilation for Windows GNU targets. ## Testing Extend the request construction test to verify that nonempty environments use `Some` and empty environments use `None`. GitOrigin-RevId: 2765c8fd19ee60661b0ce7cb3cba51acadda201a
This commit is contained in:
+18
-17
@@ -508,23 +508,24 @@ crate.annotation(
|
||||
workspace_cargo_toml = "rust/runfiles/Cargo.toml",
|
||||
)
|
||||
|
||||
# MXC keeps its Rust workspace below the repository root.
|
||||
[
|
||||
crate.annotation(
|
||||
crate = name,
|
||||
workspace_cargo_toml = "src/Cargo.toml",
|
||||
)
|
||||
for name in [
|
||||
"appcontainer_common",
|
||||
"learning_mode_core",
|
||||
"learning_mode_windows",
|
||||
"mxc_config_contract",
|
||||
"mxc_telemetry",
|
||||
"process_security_environment_spec",
|
||||
"sandbox_spec",
|
||||
"wxc_common",
|
||||
]
|
||||
]
|
||||
# MXC's resource compiler lookup needs an explicit path for Windows GNU targets.
|
||||
crate.annotation(
|
||||
build_script_deps = [
|
||||
"@crates//:cc-1.2.55",
|
||||
"@crates//:winresource-0.1.34",
|
||||
],
|
||||
build_script_env = {
|
||||
"RC_PATH": "$(execpath @llvm//tools:llvm-rc)",
|
||||
},
|
||||
build_script_tools = [
|
||||
"@llvm//tools:clang",
|
||||
"@llvm//tools:llvm-rc",
|
||||
],
|
||||
crate = "mxc-sdk",
|
||||
patch_args = ["-p1"],
|
||||
patches = ["//patches:mxc-sdk_utf8_resources.patch"],
|
||||
workspace_cargo_toml = "src/Cargo.toml",
|
||||
)
|
||||
|
||||
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
|
||||
Generated
+2
-8
File diff suppressed because one or more lines are too long
Generated
+54
-118
@@ -265,7 +265,7 @@ version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -276,7 +276,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -314,27 +314,6 @@ dependencies = [
|
||||
"wiremock",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "appcontainer_common"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4"
|
||||
dependencies = [
|
||||
"flatbuffers",
|
||||
"getrandom 0.2.17",
|
||||
"learning_mode_core",
|
||||
"learning_mode_windows",
|
||||
"process_security_environment_spec",
|
||||
"sandbox_spec",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.18",
|
||||
"widestring",
|
||||
"windows 0.62.2",
|
||||
"windows-core 0.62.2",
|
||||
"winreg 0.55.0",
|
||||
"wxc_common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.5.1"
|
||||
@@ -4194,13 +4173,13 @@ name = "codex-mxc-sandbox"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"appcontainer_common",
|
||||
"codex-network-proxy",
|
||||
"codex-protocol",
|
||||
"codex-utils-absolute-path",
|
||||
"codex-utils-path-uri",
|
||||
"codex-windows-sandbox",
|
||||
"learning_mode_windows",
|
||||
"flatbuffers",
|
||||
"mxc-sdk",
|
||||
"pretty_assertions",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -4208,7 +4187,6 @@ dependencies = [
|
||||
"thiserror 2.0.18",
|
||||
"tracelogging",
|
||||
"windows-sys 0.61.2",
|
||||
"wxc_common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6623,7 +6601,7 @@ dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users 0.5.2",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6980,7 +6958,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7132,7 +7110,7 @@ checksum = "0ce92ff622d6dadf7349484f42c93271a0d49b7cc4d466a936405bacbe10aa78"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rustix 1.1.4",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7632,7 +7610,7 @@ dependencies = [
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9056,7 +9034,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core 0.62.2",
|
||||
"windows-core 0.58.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9509,7 +9487,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9816,32 +9794,6 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "learning_mode_core"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.10.9",
|
||||
"tempfile",
|
||||
"thiserror 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "learning_mode_windows"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4"
|
||||
dependencies = [
|
||||
"learning_mode_core",
|
||||
"sha2 0.10.9",
|
||||
"thiserror 2.0.18",
|
||||
"windows 0.62.2",
|
||||
"windows-core 0.62.2",
|
||||
"wxc_common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leb128fmt"
|
||||
version = "0.1.0"
|
||||
@@ -10302,22 +10254,37 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mxc_config_contract"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4"
|
||||
name = "mxc-sdk"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=b21120168d70befe12356411423266bfef168446#b21120168d70befe12356411423266bfef168446"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
"cc",
|
||||
"chrono",
|
||||
"cidr",
|
||||
"flatbuffers",
|
||||
"getrandom 0.2.17",
|
||||
"libc",
|
||||
"nix 0.29.0",
|
||||
"same-file",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_path_to_error",
|
||||
"sha2 0.11.0",
|
||||
"tempfile",
|
||||
"thiserror 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mxc_telemetry"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4"
|
||||
dependencies = [
|
||||
"tokio",
|
||||
"tracelogging",
|
||||
"unicode-general-category",
|
||||
"url",
|
||||
"uuid",
|
||||
"widestring",
|
||||
"windows 0.62.2",
|
||||
"windows-core 0.62.2",
|
||||
"winreg 0.55.0",
|
||||
"winresource",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -10489,7 +10456,7 @@ version = "0.50.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -11219,7 +11186,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -11841,14 +11808,6 @@ dependencies = [
|
||||
"windows 0.62.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "process_security_environment_spec"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4"
|
||||
dependencies = [
|
||||
"flatbuffers",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prodash"
|
||||
version = "31.0.1"
|
||||
@@ -12163,7 +12122,7 @@ dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"socket2 0.6.3",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -13463,7 +13422,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.15",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -13476,7 +13435,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.12.1",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -13535,7 +13494,7 @@ dependencies = [
|
||||
"security-framework 3.5.1",
|
||||
"security-framework-sys",
|
||||
"webpki-root-certs",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -13608,14 +13567,6 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sandbox_spec"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4"
|
||||
dependencies = [
|
||||
"flatbuffers",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sansio"
|
||||
version = "1.0.1"
|
||||
@@ -14355,7 +14306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -15185,7 +15136,7 @@ dependencies = [
|
||||
"getrandom 0.4.2",
|
||||
"once_cell",
|
||||
"rustix 1.1.4",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -15241,7 +15192,7 @@ dependencies = [
|
||||
"parking_lot",
|
||||
"rustix 1.1.4",
|
||||
"signal-hook",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -16999,7 +16950,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -17477,6 +17428,15 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winresource"
|
||||
version = "0.1.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2bc6d36480b829272a5bdabf08e6dca8004761c1da7e35efef800540c66221b"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winsafe"
|
||||
version = "0.0.19"
|
||||
@@ -17624,30 +17584,6 @@ version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
|
||||
|
||||
[[package]]
|
||||
name = "wxc_common"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/microsoft/mxc?rev=6cd3d58f05d3447e67109cfb75e042803b843ca4#6cd3d58f05d3447e67109cfb75e042803b843ca4"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"cidr",
|
||||
"getrandom 0.2.17",
|
||||
"libc",
|
||||
"mxc_config_contract",
|
||||
"mxc_telemetry",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_path_to_error",
|
||||
"thiserror 2.0.18",
|
||||
"unicode-general-category",
|
||||
"url",
|
||||
"widestring",
|
||||
"windows 0.62.2",
|
||||
"windows-core 0.62.2",
|
||||
"winreg 0.55.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x11rb"
|
||||
version = "0.13.2"
|
||||
|
||||
+2
-3
@@ -324,12 +324,9 @@ codex-windows-sandbox-test-support = { path = "windows-sandbox-rs/tests/support"
|
||||
core_test_support = { path = "core/tests/common" }
|
||||
|
||||
# External
|
||||
learning_mode_windows = { git = "https://github.com/microsoft/mxc", rev = "6cd3d58f05d3447e67109cfb75e042803b843ca4" }
|
||||
wxc_common = { git = "https://github.com/microsoft/mxc", rev = "6cd3d58f05d3447e67109cfb75e042803b843ca4" }
|
||||
age = "0.12.1"
|
||||
ansi-to-tui = "8.0.1"
|
||||
anyhow = "1"
|
||||
appcontainer_common = { git = "https://github.com/microsoft/mxc", rev = "6cd3d58f05d3447e67109cfb75e042803b843ca4" }
|
||||
arboard = { version = "3", features = ["wayland-data-control"] }
|
||||
arc-swap = "1.9.0"
|
||||
assert_cmd = "2"
|
||||
@@ -380,6 +377,7 @@ ed25519-dalek = { version = "2.2.0", features = ["pkcs8"] }
|
||||
encoding_rs = "0.8.35"
|
||||
eventsource-stream = "0.2.3"
|
||||
file-id = "0.2.3"
|
||||
flatbuffers = "25"
|
||||
flate2 = "1.1.8"
|
||||
futures = { version = "0.3", default-features = false }
|
||||
gethostname = "1.1.0"
|
||||
@@ -418,6 +416,7 @@ maplit = "1.0.2"
|
||||
memchr = "2.7.6"
|
||||
mime_guess = "2.0.5"
|
||||
multimap = "0.10.0"
|
||||
mxc-sdk = { git = "https://github.com/microsoft/mxc", rev = "b21120168d70befe12356411423266bfef168446" }
|
||||
notify = "8.2.0"
|
||||
nucleo = { git = "https://github.com/helix-editor/nucleo.git", rev = "4253de9faabb4e5c6d81d946a5e35a90f87347ee" }
|
||||
once_cell = "1.20.2"
|
||||
|
||||
@@ -21,14 +21,13 @@ codex-protocol = { workspace = true }
|
||||
codex-utils-absolute-path = { workspace = true }
|
||||
codex-utils-path-uri = { workspace = true }
|
||||
codex-windows-sandbox = { workspace = true }
|
||||
mxc-sdk = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
wxc_common = { workspace = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
appcontainer_common = { workspace = true }
|
||||
learning_mode_windows = { workspace = true }
|
||||
flatbuffers = { workspace = true }
|
||||
# 1.2.4 imports OneCore_apiset, which the GNU Windows toolchain does not ship.
|
||||
tracelogging = "=1.2.3"
|
||||
windows-sys = { workspace = true, features = [
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
//! Probe PSEC creation and startup attributes without launching a process.
|
||||
//! Cache the result so automatic MXC selection requires a usable native API.
|
||||
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use flatbuffers::FlatBufferBuilder;
|
||||
use mxc_sdk::mxc_common::models::ContainerPolicy;
|
||||
use mxc_sdk::mxc_common::ui_policy::resolve_ui_restrictions;
|
||||
use mxc_sdk::process_container_common::PROCESS_SECURITY_ENVIRONMENT_FLAG_NONE;
|
||||
use mxc_sdk::process_container_common::ProcessSecurityEnvironmentApi;
|
||||
use mxc_sdk::process_container_common::SecurityEnvironmentStartupInfo;
|
||||
use mxc_sdk::process_container_common::job_object::to_job_object_uilimit_mask;
|
||||
use mxc_sdk::process_security_environment_spec::process_security_environment_layout::EndpointPolicyT;
|
||||
use mxc_sdk::process_security_environment_spec::process_security_environment_layout::FilterAction;
|
||||
use mxc_sdk::process_security_environment_spec::process_security_environment_layout::NetworkPolicyT;
|
||||
use mxc_sdk::process_security_environment_spec::process_security_environment_layout::ProcessSecurityEnvironmentT;
|
||||
use mxc_sdk::process_security_environment_spec::process_security_environment_layout::SchemaVersionT;
|
||||
use mxc_sdk::process_security_environment_spec::process_security_environment_layout::finish_process_security_environment_buffer;
|
||||
|
||||
pub(super) fn is_available() -> bool {
|
||||
static USABLE: OnceLock<bool> = OnceLock::new();
|
||||
*USABLE.get_or_init(|| {
|
||||
// Preserve the previous SDK's probe: no filesystem, network, or UI
|
||||
// grants, and no process launch. API-set presence alone is insufficient.
|
||||
let policy = ContainerPolicy::default();
|
||||
let mut egress = EndpointPolicyT::default();
|
||||
egress.default_action = FilterAction::deny;
|
||||
let mut network = NetworkPolicyT::default();
|
||||
network.egress = Some(Box::new(egress));
|
||||
let mut specification = ProcessSecurityEnvironmentT::default();
|
||||
specification.version = SchemaVersionT { major: 1, minor: 0 };
|
||||
specification.disallow_win32k_system_calls = policy.ui.disable;
|
||||
specification.ui_restrictions = u64::from(to_job_object_uilimit_mask(
|
||||
&resolve_ui_restrictions(&policy.ui, &policy.base_process_ui),
|
||||
));
|
||||
specification.network_policy = Some(Box::new(network));
|
||||
let mut builder = FlatBufferBuilder::with_capacity(/* capacity */ 1024);
|
||||
let specification = specification.pack(&mut builder);
|
||||
finish_process_security_environment_buffer(&mut builder, specification);
|
||||
ProcessSecurityEnvironmentApi::load()
|
||||
.and_then(|api| {
|
||||
api.create(
|
||||
builder.finished_data(),
|
||||
PROCESS_SECURITY_ENVIRONMENT_FLAG_NONE,
|
||||
)
|
||||
})
|
||||
.and_then(|environment| {
|
||||
let startup_info =
|
||||
SecurityEnvironmentStartupInfo::new(Default::default(), environment.raw(), &[]);
|
||||
environment.close();
|
||||
startup_info.map(drop)
|
||||
})
|
||||
.is_ok()
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
//! Native Windows MXC helper. Policy conversion is portable; execution requires
|
||||
//! a usable process security environment and never enters MXC's ACL fallbacks.
|
||||
|
||||
#[cfg(windows)]
|
||||
mod availability;
|
||||
#[cfg(windows)]
|
||||
mod native;
|
||||
#[cfg(any(windows, test))]
|
||||
@@ -97,7 +99,7 @@ pub fn create_command_args(args: CreateMxcCommandArgsParams<'_>) -> Result<Vec<S
|
||||
pub fn is_available() -> bool {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
appcontainer_common::base_container_runner::BaseContainerRunner::is_process_security_environment_usable()
|
||||
availability::is_available()
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use anyhow::ensure;
|
||||
use appcontainer_common::base_container_runner::BaseContainerRunner;
|
||||
use learning_mode_windows::SecurityEnvironmentApi;
|
||||
use wxc_common::logger::Logger;
|
||||
use wxc_common::logger::Mode;
|
||||
use wxc_common::models::ExecutionRequest;
|
||||
use wxc_common::sandbox_process::SandboxBackend;
|
||||
use wxc_common::sandbox_process::StdioMode;
|
||||
use mxc_sdk::mxc_common::logger::Logger;
|
||||
use mxc_sdk::mxc_common::logger::Mode;
|
||||
use mxc_sdk::mxc_common::models::ExecutionRequest;
|
||||
use mxc_sdk::mxc_common::sandbox_process::SandboxBackend;
|
||||
use mxc_sdk::mxc_common::sandbox_process::StdioMode;
|
||||
use mxc_sdk::process_container_common::base_container_runner::BaseContainerRunner;
|
||||
|
||||
// The ETW functions used by tracelogging are documented Advapi32 exports on
|
||||
// both Windows toolchains; 1.2.3 leaves their import library to the application.
|
||||
@@ -25,11 +24,9 @@ pub(super) fn launch(request: &ExecutionRequest) -> Result<i32> {
|
||||
.any(|capability| capability.eq_ignore_ascii_case("permissiveLearningMode")),
|
||||
"MXC native launch does not support permissiveLearningMode"
|
||||
);
|
||||
// With no least-privilege mode, legacy proxy, or capture enabled, this
|
||||
// probe guarantees BaseContainerRunner chooses PSEC rather than SBOX.
|
||||
if !request.policy.denied_paths.is_empty() {
|
||||
ensure!(
|
||||
SecurityEnvironmentApi::load()?.supports_deny_paths()?,
|
||||
BaseContainerRunner::supports_native_denied_paths(),
|
||||
"this Windows build cannot enforce native MXC deny paths"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,27 +13,26 @@ use codex_protocol::protocol::FileSystemSpecialPath;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use codex_windows_sandbox::resolve_windows_deny_read_paths;
|
||||
use mxc_sdk::mxc_common::cmdline::CommandLineContext;
|
||||
use mxc_sdk::mxc_common::cmdline::CommandLineError;
|
||||
use mxc_sdk::mxc_common::cmdline::cmdline_from_argv_for_context;
|
||||
use mxc_sdk::mxc_common::filesystem_object::ExistingObjectComparison;
|
||||
use mxc_sdk::mxc_common::filesystem_object::compare_existing_filesystem_objects;
|
||||
use mxc_sdk::mxc_common::filesystem_object::normalize_object_conflicts;
|
||||
use mxc_sdk::mxc_common::logger::Logger;
|
||||
use mxc_sdk::mxc_common::logger::Mode;
|
||||
use mxc_sdk::mxc_common::models::BaseProcessUiConfig;
|
||||
use mxc_sdk::mxc_common::models::ContainerPolicy;
|
||||
use mxc_sdk::mxc_common::models::ExecutionRequest;
|
||||
use mxc_sdk::mxc_common::models::FallbackPolicy;
|
||||
use mxc_sdk::mxc_common::models::NetworkAction;
|
||||
use mxc_sdk::mxc_common::models::NetworkCidr;
|
||||
use mxc_sdk::mxc_common::models::NetworkEgressPolicy;
|
||||
use mxc_sdk::mxc_common::models::NetworkIngressPolicy;
|
||||
use mxc_sdk::mxc_common::models::NetworkPeer;
|
||||
use mxc_sdk::mxc_common::models::NetworkRule;
|
||||
use mxc_sdk::mxc_common::models::UiPolicy;
|
||||
use thiserror::Error;
|
||||
use wxc_common::cmdline::CommandLineContext;
|
||||
use wxc_common::cmdline::CommandLineError;
|
||||
use wxc_common::cmdline::cmdline_from_argv_for_context;
|
||||
use wxc_common::filesystem_object::ExistingObjectComparison;
|
||||
use wxc_common::filesystem_object::compare_existing_filesystem_objects;
|
||||
use wxc_common::filesystem_object::normalize_object_conflicts;
|
||||
use wxc_common::logger::Logger;
|
||||
use wxc_common::logger::Mode;
|
||||
use wxc_common::models::BaseProcessUiConfig;
|
||||
use wxc_common::models::ContainerPolicy;
|
||||
use wxc_common::models::ExecutionRequest;
|
||||
use wxc_common::models::FallbackPolicy;
|
||||
use wxc_common::models::NetworkAction;
|
||||
use wxc_common::models::NetworkCidr;
|
||||
use wxc_common::models::NetworkEgressPolicy;
|
||||
use wxc_common::models::NetworkIngressPolicy;
|
||||
use wxc_common::models::NetworkPeer;
|
||||
use wxc_common::models::NetworkPolicy;
|
||||
use wxc_common::models::NetworkRule;
|
||||
use wxc_common::models::UiPolicy;
|
||||
|
||||
use crate::MxcCommand;
|
||||
|
||||
@@ -247,7 +246,7 @@ pub(super) fn build_request(
|
||||
..Default::default()
|
||||
};
|
||||
if proxied {
|
||||
// PSEC host loopback is bidirectional. This shape is supported only
|
||||
// PSEC host loopback can be bidirectional. This shape is supported only
|
||||
// when the caller already allows local clients and servers. Keep
|
||||
// private-network ingress denied and allow no direct DNS bypass.
|
||||
egress.allow.push(NetworkRule {
|
||||
@@ -279,7 +278,7 @@ pub(super) fn build_request(
|
||||
.to_str()
|
||||
.ok_or(PolicyError::NonUnicodeCommandCwd)?
|
||||
.to_owned(),
|
||||
env,
|
||||
env: (!env.is_empty()).then_some(env),
|
||||
policy: ContainerPolicy {
|
||||
capabilities: vec!["registryRead".to_owned()],
|
||||
readwrite_paths: unicode_paths(write)?,
|
||||
@@ -288,12 +287,6 @@ pub(super) fn build_request(
|
||||
fallback: FallbackPolicy {
|
||||
allow_dacl_mutation: false,
|
||||
},
|
||||
default_network_policy: if egress_default == NetworkAction::Allow {
|
||||
NetworkPolicy::Allow
|
||||
} else {
|
||||
NetworkPolicy::Block
|
||||
},
|
||||
allow_local_network: ingress_default == NetworkAction::Allow,
|
||||
network_egress: Some(egress),
|
||||
network_ingress: Some(NetworkIngressPolicy {
|
||||
default: ingress_default,
|
||||
|
||||
@@ -16,13 +16,13 @@ use codex_protocol::protocol::FileSystemSpecialPath;
|
||||
use codex_protocol::protocol::NetworkSandboxPolicy;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use mxc_sdk::mxc_common::models::NetworkAction;
|
||||
use mxc_sdk::mxc_common::models::NetworkCidr;
|
||||
use mxc_sdk::mxc_common::models::NetworkEgressPolicy;
|
||||
use mxc_sdk::mxc_common::models::NetworkIngressPolicy;
|
||||
use mxc_sdk::mxc_common::models::NetworkPeer;
|
||||
use mxc_sdk::mxc_common::models::NetworkRule;
|
||||
use pretty_assertions::assert_eq;
|
||||
use wxc_common::models::NetworkAction;
|
||||
use wxc_common::models::NetworkCidr;
|
||||
use wxc_common::models::NetworkEgressPolicy;
|
||||
use wxc_common::models::NetworkIngressPolicy;
|
||||
use wxc_common::models::NetworkPeer;
|
||||
use wxc_common::models::NetworkRule;
|
||||
|
||||
use crate::CreateMxcCommandArgsParams;
|
||||
use crate::MxcCommand;
|
||||
@@ -207,9 +207,13 @@ fn wrapper_preserves_exact_argv_and_separate_command_cwd() -> Result<()> {
|
||||
(
|
||||
r#""C:\Program Files\tool.exe" --permissions "" "quotes\" and slash\\""#.to_owned(),
|
||||
cwd.to_str().unwrap().to_owned(),
|
||||
vec!["CUSTOM=value".to_owned()],
|
||||
Some(vec!["CUSTOM=value".to_owned()]),
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
build_request(&parsed, &cwd, Vec::new(), &[], &[])?.env,
|
||||
None
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ use std::path::PathBuf;
|
||||
use anyhow::Result;
|
||||
use anyhow::ensure;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use mxc_sdk::mxc_common::filesystem_object::ExistingObjectComparison;
|
||||
use mxc_sdk::mxc_common::filesystem_object::compare_existing_filesystem_objects;
|
||||
use windows_sys::Win32::Foundation::RPC_E_CHANGED_MODE;
|
||||
use windows_sys::Win32::Storage::FileSystem::GetDriveTypeW;
|
||||
use windows_sys::Win32::Storage::FileSystem::GetLogicalDrives;
|
||||
@@ -21,8 +23,6 @@ use windows_sys::Win32::UI::Shell::FOLDERID_ProgramData;
|
||||
use windows_sys::Win32::UI::Shell::FOLDERID_ProgramFiles;
|
||||
use windows_sys::Win32::UI::Shell::FOLDERID_ProgramFilesX86;
|
||||
use windows_sys::Win32::UI::Shell::SHGetKnownFolderPath;
|
||||
use wxc_common::filesystem_object::ExistingObjectComparison;
|
||||
use wxc_common::filesystem_object::compare_existing_filesystem_objects;
|
||||
|
||||
struct ComUninitializeGuard;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user