You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "HuYellow (via GitHub)" <gi...@apache.org> on 2026/08/26 17:09:56 UTC
[PR] fix(windows): skip nested junctions for read ACL grants [maka]
HuYellow opened a new pull request, #3952:
URL: https://github.com/apache/maka/pull/3952
## Summary
- treat nested Windows reparse points as traversal boundaries for recursive read grants, so ordinary files remain available to Glob
- retain fail-closed admission for a reparse-point root and for nested reparse points under recursive write grants
- cover the ACL target boundary and the end-to-end Glob behavior with real NTFS junction tests
Fixes #3938
## Verification
- `npm run build:test`
- `npm run lint`
- `npm run format:check`
- `npm run typecheck`
- `npm run windows:inventory`
- `cargo fmt --manifest-path experiments/windows-sandbox/launcher/Cargo.toml -- --check`
- `cargo test --locked --manifest-path experiments/windows-sandbox/launcher/Cargo.toml` (54 passed)
- `experiments/windows-sandbox/appcontainer-smoke.ps1` (AppContainer token, atomic Job, ACL cleanup, file and network boundaries passed)
- `node --test packages/runtime/dist/__tests__/filesystem-worker-windows-smoke.test.js` (5 passed, including issue #3938)
`npm test` was also attempted. Its full build completed, but the all-workspace run does not pass in this local Codex Windows sandbox because unrelated existing tests require ordinary file-symlink privileges, POSIX process semantics, or Git ref operations that fail under the sandbox; failed suites also left `provider-admission-integration.test.js` running without progress. The affected Windows broker and filesystem worker suites above pass independently.
## Security review focus
Recursive reads still use `icacls /L /T`, which updates a nested junction object without following it. The ACL regression test verifies that neither the junction target nor its descendant receives the synthetic AppContainer SID. Recursive writes keep the previous whole-tree reparse-point rejection, and a reparse-point root is still rejected before any grant.
## AI use
Select exactly one:
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: OpenAI Codex implemented the fix, added regression coverage, and ran local verification. The commit includes the required `Generated-by: OpenAI Codex` trailer.
## Checklist
- [x] Tests cover the change and fail without it
- [x] Lint, format, typecheck and the affected suites pass locally
Does this PR entail a change in behavior?
- [x] Yes - described under Summary above
- [ ] No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "HuYellow (via GitHub)" <gi...@apache.org>.
HuYellow commented on PR #3952:
URL: https://github.com/apache/maka/pull/3952#issuecomment-5434134171
Follow-up: all current checks are green at 82c8766b7. The CI test job passed in 16m45s, and the Windows release package job passed in 17m28s, including Package the Windows installer and ZIP, Verify the Windows release, packaged adversarial evidence, upgrade/autoupdate, and rollback checks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): skip nested junctions for read ACL grants [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #3952:
URL: https://github.com/apache/maka/pull/3952#issuecomment-5429250240
I reviewed this PR at exact head `949df79d846042ba0ea037cdc115baf9f47384cf` (base `2d10b52`, merge-base `38f0a275`, 4 files +176−16).
**Spec: GO — no P0–P3**
- Root reparse points are still unconditionally rejected; recursive write still rejects the whole tree; recursive read now terminates at a nested reparse boundary (`acl_ledger.rs:443-477`).
- The Windows ACL path correctly uses `icacls /L /T` so it does not follow the target; the real junction ACL test proves the target and its descendants do not receive the synthetic SID and verifies cleanup.
- The filesystem-worker Windows smoke covers both ordinary `main.go` enumeration and the junction-descendant pattern returning empty.
- No implemented-but-wrong / missing / scope-creep finding within #3938; the existing hard-link scan→grant race is not introduced by this diff.
**Standards: NO-GO — 1 hard P1 + 1 judgment-only P3**
- **P1 — governing security contract and release evidence are not in sync with the new strategy.** `acl_ledger.rs:443-477` now accepts a nested reparse boundary for recursive read, but `docs/architecture/windows-sandbox-rfc-v1.md` still requires “recursive reparse-point rejection before ACL mutation” in several places and defines the packaged recursive-junction admission refusal as W1/release evidence. `adversarial-matrix-smoke.ps1:208-216` also still requires the same nested-junction read request to fail closed as before. As a result the exact-head `package` run `32993195237` fails directly: launcher exits 0, matrix reports `Junction alias admission did not fail closed`. Fix by either formally revising the RFC and the machine-readable matrix to a read traversal-boundary contract (keep root/write rejection, prove target denial with a real child) or restoring the recursive rejection.
- **Judgment-only P3:** `skip_nested_reparse_points: bool` with bare `false/true` encodes a security policy as a boolean; a named enum would reduce inversion risk.
Other checks: `git diff --check` passes. `windows_recovery` and `windows_sandbox_w0_protocol` are green; `package` is red for the reason above (directly related), `test` is red due to an unrelated Desktop prompt-rail E2E (66 pass / 1 fail / 1 skip). OPEN / MERGEABLE / REVIEW_REQUIRED, no reviews/comments, head did not drift.
**What I did not check:** full local test suite beyond the focused checks noted.
**Gate:** exact head has no P0–P2, but the P1 standards finding and the failing required `package`/`test` checks must be closed (update RFC + `adversarial-matrix-smoke.ps1` to match the new read-boundary contract, or restore rejection) before merge.
---
> **Automated review notice:** This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "HuYellow (via GitHub)" <gi...@apache.org>.
HuYellow commented on code in PR #3952:
URL: https://github.com/apache/maka/pull/3952#discussion_r3903286243
##########
packages/runtime/src/filesystem-worker/operations.ts:
##########
@@ -649,6 +675,254 @@ function assertContainedGlobPattern(pattern: string): void {
}
}
+type WindowsGlobPatternPart = string | RegExp | typeof GLOBSTAR;
+
+interface WindowsGlobBranchState {
+ readonly id: number;
+ readonly pattern: readonly WindowsGlobPatternPart[];
+ readonly indexes: readonly number[];
+}
+
+interface WindowsGlobPathState {
+ readonly absolutePath: string;
+ readonly relativePath: string;
+ readonly isDirectory: boolean;
+ readonly branches: readonly WindowsGlobBranchState[];
+}
+
+async function windowsNonFollowingGlob(
+ root: string,
+ pattern: string,
+ limit: number,
+ readDirectory?: (path: string) => Promise<Dirent[]>,
+): Promise<string[]> {
+ const matcher = new Minimatch(pattern, WINDOWS_GLOB_MATCH_OPTIONS);
+ const initialBranches = matcher.set.map((compiled, id) => ({
+ id,
+ pattern: compiled as WindowsGlobPatternPart[],
+ indexes: [0],
+ }));
+ const files: string[] = [];
+ const emitted = new Set<string>();
+ const emit = (relativePath: string): boolean => {
+ if (emitted.has(relativePath)) return false;
+ emitted.add(relativePath);
+ files.push(relativePath);
+ return files.length >= limit;
+ };
+
+ const pending: WindowsGlobPathState[] = [
+ { absolutePath: root, relativePath: '.', isDirectory: true, branches: initialBranches },
+ ];
+ while (pending.length > 0) {
+ const currentPath = pending.pop();
+ if (!currentPath) break;
+ let entries: Dirent[] | undefined;
+ const readEntries = async (): Promise<Dirent[]> => {
+ if (entries) return entries;
+ entries =
+ (await readWindowsNonFollowingDirectory(root, currentPath.absolutePath, readDirectory)) ??
+ [];
+ return entries;
+ };
+ const childPaths = new Map<string, WindowsGlobPathState>();
+
+ // Keep Node Glob's branch and LIFO traversal order so a bounded result is
+ // the same prefix users receive outside the Windows sandbox.
+ for (const branch of currentPath.branches) {
+ const last = branch.pattern.length - 1;
+ const isLast = windowsGlobPatternIsLast(branch, currentPath.isDirectory);
+ const isFirst = branch.indexes.includes(0);
+
+ if (isFirst && branch.pattern[0] === '.') {
+ addWindowsGlobSubpattern(childPaths, currentPath, {
+ ...branch,
+ indexes: [1],
+ });
+ continue;
+ }
+
+ const finalPart = branch.pattern[last];
+ if (isLast && typeof finalPart === 'string') {
+ if (finalPart === '' || finalPart === '.') {
+ if (currentPath.isDirectory && emit(currentPath.relativePath)) return files;
+ } else if (currentPath.isDirectory) {
+ const entry = (await readEntries()).find(
+ (candidate) =>
+ !candidate.isSymbolicLink() &&
+ candidate.name.toLowerCase() === finalPart.toLowerCase(),
+ );
+ if (entry) {
+ const relativePath = join(currentPath.relativePath, entry.name);
+ if (emit(relativePath)) return files;
+ }
+ }
+ if (branch.indexes.length === 1 && branch.indexes[0] === last) continue;
+ } else if (
+ isLast &&
+ finalPart === GLOBSTAR &&
+ (currentPath.relativePath !== '.' ||
+ branch.pattern[0] === '.' ||
+ (last === 0 && currentPath.isDirectory)) &&
+ emit(currentPath.relativePath)
+ ) {
+ return files;
+ }
+
+ if (!currentPath.isDirectory) continue;
+
+ for (const entry of await readEntries()) {
+ // libuv reports every Windows FILE_ATTRIBUTE_REPARSE_POINT as a link
+ // Dirent, including junctions and reparse types that lstat may otherwise
+ // present as ordinary directories. Never return or enter one.
+ if (entry.isSymbolicLink()) continue;
+
+ const relativePath = join(currentPath.relativePath, entry.name);
+ const absolutePath = join(currentPath.absolutePath, entry.name);
+ const subIndexes = new Set<number>();
+ for (const index of branch.indexes) {
+ const part = branch.pattern[index];
+ const nextIndex = index + 1;
+ const nextMatches = windowsGlobPartMatches(branch.pattern, nextIndex, entry.name);
+
+ if (part === GLOBSTAR) {
+ let nextNonGlobIndex = nextIndex;
+ while (branch.pattern[nextNonGlobIndex] === GLOBSTAR) nextNonGlobIndex += 1;
+ const matchesDot =
+ entry.name.startsWith('.') &&
+ windowsGlobPartMatches(branch.pattern, nextNonGlobIndex, entry.name);
+ if (entry.name.startsWith('.') && !matchesDot) continue;
+
+ if (entry.isDirectory()) {
+ subIndexes.add(index);
+ } else if (index === last && emit(relativePath)) {
+ return files;
+ }
+
+ if (nextMatches && nextIndex === last && !isLast) {
+ if (emit(relativePath)) return files;
+ } else if (nextMatches && entry.isDirectory()) {
+ subIndexes.add(index + 2);
+ }
+ if ((nextMatches || branch.pattern[0] === '.') && entry.isDirectory()) {
+ subIndexes.add(nextIndex);
+ }
+ }
+
+ if (typeof part === 'string') {
+ if (windowsGlobPartMatches(branch.pattern, index, entry.name) && index !== last) {
+ subIndexes.add(nextIndex);
+ } else if (
+ part === '.' &&
+ windowsGlobPartMatches(branch.pattern, nextIndex, entry.name)
+ ) {
+ if (nextIndex === last) {
+ if (emit(relativePath)) return files;
+ } else {
+ subIndexes.add(nextIndex + 1);
+ }
+ }
+ }
+
+ if (part instanceof RegExp && windowsGlobPartMatches(branch.pattern, index, entry.name)) {
+ if (index === last) {
+ if (emit(relativePath)) return files;
+ } else if (entry.isDirectory()) {
+ subIndexes.add(nextIndex);
+ }
+ }
+ }
+
+ if (subIndexes.size > 0) {
+ addWindowsGlobSubpattern(
+ childPaths,
+ {
+ absolutePath,
+ relativePath,
+ isDirectory: entry.isDirectory(),
Review Comment:
Addressed at head `da2612040`. Each queued directory is now `lstat`-checked, opened, and compared by `dev`/`ino` before `readdir`, immediately before the read, and after it; changed child directories are pruned and a changed root fails with `path_changed`. The deterministic regression caches the parent `Dirent`, replaces the child with a junction, and proves the child read callback is never invoked. W0 and the full heavy CI lane are green.
##########
packages/runtime/src/filesystem-worker/client.ts:
##########
@@ -376,6 +376,13 @@ export class FilesystemWorkerClient {
const launch = await this.input.getLaunchSpec();
if (!launch.ok) throw clientError(launch.reason, 'launch', requestId, launch.message);
const workerProfile = deriveWorkerProfile(effectiveProfile, operationBoundary);
+ const windowsNonFollowingReadRoot =
+ platform === 'win32' &&
+ operation.kind === 'glob' &&
+ target.scope === 'subtree' &&
+ target.targetType === 'directory'
+ ? target.enforcementPath
Review Comment:
Addressed at head `da2612040`. The client now carries both the pre-realpath `sourcePath` and canonical `enforcementPath` in the digest-bound policy. Before ACL mutation, the broker opens both with `FILE_FLAG_OPEN_REPARSE_POINT`, rejects a reparse source, and requires matching volume/file identity. Added client path-preservation coverage plus a real client -> broker root-junction smoke. W0 (64/64 Rust tests + worker smoke) and Windows `package` are green.
##########
experiments/windows-sandbox/launcher/src/acl_ledger.rs:
##########
@@ -53,6 +53,9 @@ use crate::windows_launcher::{appcontainer_profile_name, current_user_sid_string
pub(crate) const LEDGER_VERSION: u8 = 2;
const ACL_MUTEX_TIMEOUT_MS: u32 = 30_000;
+const MAX_NON_FOLLOWING_READ_GRANTS: usize = 4_096;
+const MAX_NON_FOLLOWING_READ_ENTRIES: usize = 100_000;
Review Comment:
Addressed at head `da2612040`. A shared Minimatch compilation now derives a digest-bound finite traversal depth. `main.go`/limit 1 carries `maxDepth=0`, so the broker emits one exact root grant and does not enumerate children. Finite patterns grant only ordinary directories through the required depth; the 100k budget now counts directory/reparse planning entries rather than ordinary files. Added Rust zero-scan/directory-budget tests and a 100,001-entry root-only result regression beside a junction. W0, heavy CI, and Windows `package` are green.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3952:
URL: https://github.com/apache/maka/pull/3952#discussion_r3889596766
##########
packages/runtime/src/filesystem-worker/client.ts:
##########
@@ -376,6 +376,13 @@ export class FilesystemWorkerClient {
const launch = await this.input.getLaunchSpec();
if (!launch.ok) throw clientError(launch.reason, 'launch', requestId, launch.message);
const workerProfile = deriveWorkerProfile(effectiveProfile, operationBoundary);
+ const windowsNonFollowingReadRoot =
+ platform === 'win32' &&
+ operation.kind === 'glob' &&
+ target.scope === 'subtree' &&
+ target.targetType === 'directory'
+ ? target.enforcementPath
Review Comment:
[P2 · category ①] windowsNonFollowingReadRoot is derived after normalizeSandboxBoundaryPath has already called realpathAllowMissing. If the requested Glob root is itself a junction, target.enforcementPath is its resolved target, so the broker sees an ordinary physical directory and its explicit “root reparse is rejected” check can never fire. This violates #3938 for a normal root-junction input. Calibration: current profile containment usually still rejects a target outside the approved profile, so this review does not claim a sandbox escape. Preserve and validate a non-followed root identity/path before canonicalization (while retaining canonical containment authority), and add an end-to-end client root-junction regression rather than only direct Rust partition tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "HuYellow (via GitHub)" <gi...@apache.org>.
HuYellow commented on PR #3952:
URL: https://github.com/apache/maka/pull/3952#issuecomment-5492763206
Follow-up complete at `da2612040`.
- Addressed and resolved all three Aug 30 review threads: root-junction identity, cached-Dirent replacement, and >100k/root-only admission.
- Synchronized the English/Chinese RFC, experiment README, broker protocol/digest, Runtime tests, W0 smoke, and packaged verifier.
- All current checks are green, including Rust 64/64 + real broker worker smoke, `heavy`, `test`, Windows `package`, recovery, audit, and cross-platform CLI validation.
The branch remains mergeable. `main` advanced by five unrelated Desktop/Runtime Host/CLI/Storage commits while CI ran; none touches the Windows worker/broker paths changed here. Ready for maintainer review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3952:
URL: https://github.com/apache/maka/pull/3952#issuecomment-5945268526
<!-- maka-lifecycle:stale-warning -->
This pull request has had no new commits for 30 days and has been marked stale. It will be closed in 7 days unless a new commit is pushed.
Comments do not reset this timer: only a new commit does. If the pull request is intentionally long-lived, a maintainer can apply the `pinned` label.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3952:
URL: https://github.com/apache/maka/pull/3952#issuecomment-6073938026
<!-- maka-lifecycle:stale-close -->
This pull request has been closed because it received no new commits during the 7-day grace period. This is not a judgement on the merit of the change; it only keeps the review queue aligned with work that is actively in flight.
The branch and review history are preserved. Push a new commit and reopen the pull request whenever the work is ready to continue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "HuYellow (via GitHub)" <gi...@apache.org>.
HuYellow commented on PR #3952:
URL: https://github.com/apache/maka/pull/3952#issuecomment-5434017818
Addressed at head `82c8766b7`.
- P1: replaced the global recursive-read relaxation with a digest-bound `nonFollowingReadRoot` available only to read-only recursive Glob. Raw recursive reads and writes still reject nested reparse points, so the original packaged adversarial admission check remains valid.
- Synchronized the English/Chinese RFCs, Windows sandbox README, Runtime smoke coverage, and packaged verifier. The verifier now proves broad `**/*` omits the junction entry and descendants while ordinary files remain visible.
- P3: removed the `skip_nested_reparse_points: bool` entirely. The policy is represented by an optional canonical root and validated at the client, profile, manifest protocol, digest, and broker admission boundaries.
- Added fail-closed planner limits for grants, inspected entries, and depth, plus hard-link/root/policy-tamper coverage.
Local results include Rust `62/62`, Windows worker smoke `5/5`, AppContainer smoke, raw packaged adversarial matrix, and full `verify:windows-x64` including the packaged Electron worker, 64-launch soak, node-pty/ConPTY, renderer, installer, and ZIP checks.
The specialized implementation incorporates the three functional commits from #3955 by @sunrioa and @ling with authorship preserved. The branch is also merged with current `main`; the final lockfile keeps `brace-expansion 5.0.9`, and both generated notices are synchronized.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3952:
URL: https://github.com/apache/maka/pull/3952#discussion_r3889596768
##########
packages/runtime/src/filesystem-worker/operations.ts:
##########
@@ -649,6 +675,254 @@ function assertContainedGlobPattern(pattern: string): void {
}
}
+type WindowsGlobPatternPart = string | RegExp | typeof GLOBSTAR;
+
+interface WindowsGlobBranchState {
+ readonly id: number;
+ readonly pattern: readonly WindowsGlobPatternPart[];
+ readonly indexes: readonly number[];
+}
+
+interface WindowsGlobPathState {
+ readonly absolutePath: string;
+ readonly relativePath: string;
+ readonly isDirectory: boolean;
+ readonly branches: readonly WindowsGlobBranchState[];
+}
+
+async function windowsNonFollowingGlob(
+ root: string,
+ pattern: string,
+ limit: number,
+ readDirectory?: (path: string) => Promise<Dirent[]>,
+): Promise<string[]> {
+ const matcher = new Minimatch(pattern, WINDOWS_GLOB_MATCH_OPTIONS);
+ const initialBranches = matcher.set.map((compiled, id) => ({
+ id,
+ pattern: compiled as WindowsGlobPatternPart[],
+ indexes: [0],
+ }));
+ const files: string[] = [];
+ const emitted = new Set<string>();
+ const emit = (relativePath: string): boolean => {
+ if (emitted.has(relativePath)) return false;
+ emitted.add(relativePath);
+ files.push(relativePath);
+ return files.length >= limit;
+ };
+
+ const pending: WindowsGlobPathState[] = [
+ { absolutePath: root, relativePath: '.', isDirectory: true, branches: initialBranches },
+ ];
+ while (pending.length > 0) {
+ const currentPath = pending.pop();
+ if (!currentPath) break;
+ let entries: Dirent[] | undefined;
+ const readEntries = async (): Promise<Dirent[]> => {
+ if (entries) return entries;
+ entries =
+ (await readWindowsNonFollowingDirectory(root, currentPath.absolutePath, readDirectory)) ??
+ [];
+ return entries;
+ };
+ const childPaths = new Map<string, WindowsGlobPathState>();
+
+ // Keep Node Glob's branch and LIFO traversal order so a bounded result is
+ // the same prefix users receive outside the Windows sandbox.
+ for (const branch of currentPath.branches) {
+ const last = branch.pattern.length - 1;
+ const isLast = windowsGlobPatternIsLast(branch, currentPath.isDirectory);
+ const isFirst = branch.indexes.includes(0);
+
+ if (isFirst && branch.pattern[0] === '.') {
+ addWindowsGlobSubpattern(childPaths, currentPath, {
+ ...branch,
+ indexes: [1],
+ });
+ continue;
+ }
+
+ const finalPart = branch.pattern[last];
+ if (isLast && typeof finalPart === 'string') {
+ if (finalPart === '' || finalPart === '.') {
+ if (currentPath.isDirectory && emit(currentPath.relativePath)) return files;
+ } else if (currentPath.isDirectory) {
+ const entry = (await readEntries()).find(
+ (candidate) =>
+ !candidate.isSymbolicLink() &&
+ candidate.name.toLowerCase() === finalPart.toLowerCase(),
+ );
+ if (entry) {
+ const relativePath = join(currentPath.relativePath, entry.name);
+ if (emit(relativePath)) return files;
+ }
+ }
+ if (branch.indexes.length === 1 && branch.indexes[0] === last) continue;
+ } else if (
+ isLast &&
+ finalPart === GLOBSTAR &&
+ (currentPath.relativePath !== '.' ||
+ branch.pattern[0] === '.' ||
+ (last === 0 && currentPath.isDirectory)) &&
+ emit(currentPath.relativePath)
+ ) {
+ return files;
+ }
+
+ if (!currentPath.isDirectory) continue;
+
+ for (const entry of await readEntries()) {
+ // libuv reports every Windows FILE_ATTRIBUTE_REPARSE_POINT as a link
+ // Dirent, including junctions and reparse types that lstat may otherwise
+ // present as ordinary directories. Never return or enter one.
+ if (entry.isSymbolicLink()) continue;
+
+ const relativePath = join(currentPath.relativePath, entry.name);
+ const absolutePath = join(currentPath.absolutePath, entry.name);
+ const subIndexes = new Set<number>();
+ for (const index of branch.indexes) {
+ const part = branch.pattern[index];
+ const nextIndex = index + 1;
+ const nextMatches = windowsGlobPartMatches(branch.pattern, nextIndex, entry.name);
+
+ if (part === GLOBSTAR) {
+ let nextNonGlobIndex = nextIndex;
+ while (branch.pattern[nextNonGlobIndex] === GLOBSTAR) nextNonGlobIndex += 1;
+ const matchesDot =
+ entry.name.startsWith('.') &&
+ windowsGlobPartMatches(branch.pattern, nextNonGlobIndex, entry.name);
+ if (entry.name.startsWith('.') && !matchesDot) continue;
+
+ if (entry.isDirectory()) {
+ subIndexes.add(index);
+ } else if (index === last && emit(relativePath)) {
+ return files;
+ }
+
+ if (nextMatches && nextIndex === last && !isLast) {
+ if (emit(relativePath)) return files;
+ } else if (nextMatches && entry.isDirectory()) {
+ subIndexes.add(index + 2);
+ }
+ if ((nextMatches || branch.pattern[0] === '.') && entry.isDirectory()) {
+ subIndexes.add(nextIndex);
+ }
+ }
+
+ if (typeof part === 'string') {
+ if (windowsGlobPartMatches(branch.pattern, index, entry.name) && index !== last) {
+ subIndexes.add(nextIndex);
+ } else if (
+ part === '.' &&
+ windowsGlobPartMatches(branch.pattern, nextIndex, entry.name)
+ ) {
+ if (nextIndex === last) {
+ if (emit(relativePath)) return files;
+ } else {
+ subIndexes.add(nextIndex + 1);
+ }
+ }
+ }
+
+ if (part instanceof RegExp && windowsGlobPartMatches(branch.pattern, index, entry.name)) {
+ if (index === last) {
+ if (emit(relativePath)) return files;
+ } else if (entry.isDirectory()) {
+ subIndexes.add(nextIndex);
+ }
+ }
+ }
+
+ if (subIndexes.size > 0) {
+ addWindowsGlobSubpattern(
+ childPaths,
+ {
+ absolutePath,
+ relativePath,
+ isDirectory: entry.isDirectory(),
Review Comment:
[P1 · category ②/③] The walker decides a child is safe from the cached Dirent and queues it as a directory, but later readWindowsNonFollowingDirectory calls fs.readdir(path) without rechecking lstat/reparse identity. Replacing that child with a junction during the queue window makes readdir follow the target, so a nested reparse is entered despite the promised non-following boundary; a self-junction can also keep expanding work. Revalidate the directory as non-reparse at open/read time (or use a Windows handle with no-follow identity) and add the deterministic Dirent→replacement race regression.
##########
packages/runtime/src/filesystem-worker/client.ts:
##########
@@ -376,6 +376,13 @@ export class FilesystemWorkerClient {
const launch = await this.input.getLaunchSpec();
if (!launch.ok) throw clientError(launch.reason, 'launch', requestId, launch.message);
const workerProfile = deriveWorkerProfile(effectiveProfile, operationBoundary);
+ const windowsNonFollowingReadRoot =
+ platform === 'win32' &&
+ operation.kind === 'glob' &&
+ target.scope === 'subtree' &&
+ target.targetType === 'directory'
+ ? target.enforcementPath
Review Comment:
[P1 · category ③] windowsNonFollowingReadRoot is derived after normalizeSandboxBoundaryPath has already called realpathAllowMissing. If the requested Glob root is itself a junction, target.enforcementPath is its resolved target, so the broker sees an ordinary physical directory and its explicit “root reparse is rejected” check can never fire. The operation therefore follows exactly the root alias #3938 says must remain rejected. Preserve and validate a non-followed root identity/path before canonicalization (while still using canonical containment authority), and add an end-to-end client root-junction regression rather than only direct Rust partition tests.
##########
experiments/windows-sandbox/launcher/src/acl_ledger.rs:
##########
@@ -53,6 +53,9 @@ use crate::windows_launcher::{appcontainer_profile_name, current_user_sid_string
pub(crate) const LEDGER_VERSION: u8 = 2;
const ACL_MUTEX_TIMEOUT_MS: u32 = 30_000;
+const MAX_NON_FOLLOWING_READ_GRANTS: usize = 4_096;
+const MAX_NON_FOLLOWING_READ_ENTRIES: usize = 100_000;
Review Comment:
[P2 · category ①] Every sandboxed Windows Glob now performs a full recursive ACL-planning scan and fails after 100,000 entries before the Glob pattern or its result limit can bound work. Large but ordinary monorepos/node_modules can exceed this even for pattern main.go and limit 1, making the core Glob path unavailable. Please make admission proportional to the directories the non-following operation actually needs, or provide a bounded continuation/partition strategy; add a >100k ordinary-tree regression that still returns a small requested result without following junctions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(windows): let Glob skip nested junctions [maka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #3952: fix(windows): let Glob skip nested junctions
URL: https://github.com/apache/maka/pull/3952
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org