Expand Windows deny-read globs without invoking ripgrep (#59250)

## What changed

Use the `ignore` crate to snapshot matching files and directories in-process, replacing the external `rg` scan and fallback walker. Remove scanner discovery from MXC sandbox dependency checks.

Keep case-insensitive matching and configured scan depth limits. Skip directory links below the scan root while following explicitly linked roots, and continue past missing or inaccessible entries.

## Testing

Update resolver tests to cover child directory links, linked scan roots, dangling links, and literal brackets in glob patterns.

GitOrigin-RevId: e7f02d4db1fd42958adc212bb54055710fa2e536
This commit is contained in:
iceweasel-oai
2026-11-03 23:00:54 +00:00
committed by copyberry
parent d5830f6fc6
commit 61506432d6
11 changed files with 111 additions and 435 deletions
-1
View File
@@ -85,7 +85,6 @@ tempfile = { workspace = true }
[target.'cfg(windows)'.dependencies]
codex-mxc-sandbox = { workspace = true }
which = { workspace = true }
windows-sys = { workspace = true, features = [
"Win32_Foundation",
"Win32_Security",
@@ -30,11 +30,6 @@ negatives. Backend glob/symlink nuances and writable hard-link aliases are not
fully modeled. The separate glob scan can differ from enforcement's snapshot.
Metrics describe observed checker outcomes, not accuracy or missed violations.
MXC scanner discovery currently uses `which`, while enforcement uses
`Command`. Their search-order and environment differences can select different
executables or cause only one scan to use the internal walker. This is an accepted
telemetry limitation for this phase; changing production scanner selection is deferred.
These are accepted limitations of this phase, not requests to duplicate backend
implementations. Review against this scope. Regressions in explicit policy
handling, executor context, or reporting remain actionable; this is not a blanket
@@ -13,29 +13,10 @@ pub(super) const NAME: &str = "windows_mxc";
pub(super) fn critical_dependencies(
request: &SandboxExecRequest,
policy: &FileSystemSandboxPolicy,
cwd: &AbsolutePathBuf,
_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)
Ok(codex_and_launcher_dependencies(request))
}
pub(super) fn prepare_policy(