mirror of
https://github.com/openai/codex.git
synced 2026-12-05 01:00:54 +00:00
## What changed Add Windows MXC backend helpers to inventory the Codex executable, sandbox launcher, and available `rg` scanner when deny globs are configured. Prepare filesystem policies for inspection by reusing MXC temporary-directory and volume resolution and replacing deny globs with concrete path snapshots. Allow Windows deny-glob resolution to run its scanner with an explicit command environment and working directory, including an empty environment. The integrity helpers are not yet invoked by an execution runner. ## Testing Add a backend test verifying that deny-glob snapshots replace the original patterns, including empty snapshots, and affect `FileContentsChecker` results. GitOrigin-RevId: 409c527663d230d76d65be3bf0a37959f694d77e
50 lines
1.6 KiB
Rust
50 lines
1.6 KiB
Rust
//! Discover MXC dependencies separately from resolving configured policy rules.
|
|
|
|
use super::dependencies::Dependency;
|
|
use super::dependencies::codex_and_launcher_dependencies;
|
|
use codex_protocol::permissions::FileSystemSandboxPolicy;
|
|
use codex_sandboxing::SandboxExecRequest;
|
|
use codex_sandboxing::SandboxType;
|
|
use codex_utils_absolute_path::AbsolutePathBuf;
|
|
use std::io;
|
|
|
|
pub(super) const SANDBOX_TYPE: SandboxType = SandboxType::WindowsMxc;
|
|
pub(super) const NAME: &str = "windows_mxc";
|
|
|
|
pub(super) fn critical_dependencies(
|
|
request: &SandboxExecRequest,
|
|
policy: &FileSystemSandboxPolicy,
|
|
cwd: &AbsolutePathBuf,
|
|
) -> io::Result<Vec<Dependency>> {
|
|
let command_cwd = request.cwd.to_abs_path()?;
|
|
let mut dependencies = codex_and_launcher_dependencies(request);
|
|
if !policy
|
|
.get_unreadable_globs_with_cwd(cwd.as_path())
|
|
.is_empty()
|
|
{
|
|
let path = request
|
|
.env
|
|
.iter()
|
|
.find(|(key, _)| key.eq_ignore_ascii_case("PATH"))
|
|
.map(|(_, value)| value);
|
|
if let Ok(scanner) = which::which_in(
|
|
codex_mxc_sandbox::GLOB_SCAN_PROGRAM,
|
|
path,
|
|
command_cwd.as_path(),
|
|
) {
|
|
dependencies.push(("glob_scanner", Ok(scanner)));
|
|
}
|
|
}
|
|
Ok(dependencies)
|
|
}
|
|
|
|
pub(super) fn prepare_policy(
|
|
request: &SandboxExecRequest,
|
|
policy: FileSystemSandboxPolicy,
|
|
cwd: &AbsolutePathBuf,
|
|
) -> io::Result<FileSystemSandboxPolicy> {
|
|
let command_cwd = request.cwd.to_abs_path()?;
|
|
codex_mxc_sandbox::prepare_file_system_policy(policy, &request.env, cwd, command_cwd.as_path())
|
|
.map_err(io::Error::other)
|
|
}
|