Repository navigation
fix(scan): refuse filesystem-sized scan and build roots - #365
Merged
Merged
Conversation
Walking a filesystem root, an OS image, or an enormous directory could hang or exhaust memory before any file cap applied. vg scan and vg build now exit 1 with a stable message that tells the user to pass a project subdirectory, --exclude ignore patterns, or --allow-unsafe-root. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
Keep this branch's public walk policy: VG_MAX_WALK_ENTRIES defaults to 1000000, and --allow-unsafe-root / VG_ALLOW_UNSAFE_ROOT skip the filesystem-root, OS-image, and walk-budget checks. Call sites that arrived with main delegate to that policy. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
Keep both unreleased changelog notes. The walk policy is unchanged: VG_MAX_WALK_ENTRIES defaults to 1000000, and --allow-unsafe-root still skips the filesystem-root, OS-image, and walk-budget checks. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
vibgrate-team
marked this pull request as ready for review
October 6, 2026 12:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vg scanandvg buildwalked whatever directory they were given. Pointing either command at/, an unpacked operating-system image, or a huge unpack directory could hang or run out of memory before the existing file cap applied, and the failure was not something a user could act on.Both commands now fail closed before that walk runs away:
/, a drive root, or a symlink to one) is refused without listing it.etc+usr+var, plusbin,sbin,lib, orboot; orWindowsplusProgram Files,Users, orProgramData) is refused after one directory listing.VG_MAX_WALK_ENTRIES(default1000000;0disables the budget) stops with the same class of error.The process exits 1. The message is stable for a given path and names what to do next: pass a project subdirectory, narrow the walk with
--excludeignore patterns, raiseVG_MAX_WALK_ENTRIES, or pass--allow-unsafe-root(VG_ALLOW_UNSAFE_ROOT=1does the same).vg build ./appchecks./app, not the current directory.Related issues
Fixes #258
Checklist
pnpm testpassespnpm lintis cleanpnpm typecheckis cleangraph.json/ report output. The new error text depends only on the path and a fixed marker list, not on readdir order, time, or randomness.git commit -s, DCO)Notes for reviewers
The walk budget counts directory entries the walk actually looks at. Skipped dependency directories such as
node_modulescount as one entry and are not descended into.--allow-unsafe-rootskips the filesystem-root check, the OS-image check, and the walk budget.VG_MAX_WALK_ENTRIESraises or disables only the budget, so an OS image is still refused.vg build <subdir>and a scoped discover judge the directories that will be walked, so a narrowed path is accepted even when the current directory would not be.How to verify
pnpm test test/root-safety.test.ts pnpm lint pnpm typechecktest/root-safety.test.tscovers the filesystem root (including a symlink to it), Unix and Windows image layouts, the walk budget, the override, and thevg scan/vg builderror path. Those cases use temp directories and a fixed entry ceiling, so they do not depend on the clock and they do not walk/.Full
pnpm test(5022 tests),pnpm lint, andpnpm typecheckpassed.