Repository navigation
fix(cso): treat untracked nested repos and submodules as snapshot boundaries - #3256
Closed
surlymochan wants to merge 1 commit into
Closed
surlymochan wants to merge 1 commit into
surlymochan wants to merge 1 commit into
Conversation
An untracked nested repository makes gstack-cso start fail with UNSAFE_PATH. Git lists it as one entry with a trailing slash, so relativePath() rejected the empty segment and aborted the run. A registered submodule gitlink already failed one step later for the same reason: it is a directory, and the capture loop only reads regular files. Accept the boundary under its own name and record it like a host dependency tree: one manifest entry, originalHash not-read, an excluded: transformation that discloses the omission in the report's snapshot-inputs coverage, no payload copied, and an identity check during capture so a swapped or symlinked boundary fails closed. Nested repository contents are never audited with the outer repository because Git never descends into them.
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Contributor
|
Thank you @surlymochan. This was the right fix, and the write-up made it fast to verify. I cherry-picked your commit into #3303 with your authorship kept (c03461a), so it lands under your name. Your two tests fail on main and pass with the change, as you said. #3303 adds a few things around it:
One tweak to your test: the exact entry-list assertion ignores unrelated root files, because a git wrapper on our CI machines writes a log into the fixture repo. I'm closing this in favor of #3303. Thanks again. |
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.
Refs #3255 (bug 1).
Problem
gstack-cso startaborts withUNSAFE_PATH: Expected a contained relative pathwhen the audited repo contains an untracked nested Git repository.git ls-files --otherslists it as one entry with a trailing slash (inner/), andpaths()passes that straight torelativePath(), which rejects the empty segment.Stripping the slash alone only moves the failure: the capture loop then hands the directory to
readStable(), which rejects it asSpecial or hard-linked source file. A registered submodule already fails at that second step today, sincels-files --cachedlists its gitlink as a directory path (sub).Fix
paths()normalizes the trailing slash, the same way the ignored-directory collector inrejectSpecialFiles()already does.capture(), a directory in Git's inventory is recorded as a repository boundary: one manifest entry withoriginalHash: 'not-read'and anexcluded:transformation (NESTED_REPOSITORY), nothing copied tosnapshot/orreadable/.snapshotCoverage()already reportsexcluded:entries as explicit exclusions, so the omission shows up in the report instead of being silent.assertEntriesStablere-checks each boundary bylstat(dev/ino/mode, not a symlink, still a directory), so a swapped or replaced boundary fails withSNAPSHOT_RACE.Nested repositories and submodules now behave the same way, and their contents are not audited as part of the outer repo (Git never descends into them either).
Bug 2 (not in this PR)
Passing a larger
maxBytesto the historygit log -pcall is not enough: with ~1.8 MiB of patches,history-status.jsonstill comes backnot_assessedwithPayload withheld because redaction could not safely locate every secret, becauseredact()inlib/cso/process.tsscans withmaxBytes: MAX_OUTPUTand the redaction engine fails closed above that. Fixing it means raising the redaction ceiling for retained history, which is a policy call I'd rather leave to you.Verification
test/cso-snapshot-state.test.ts: untracked nested repo, and registered submodule gitlink. Both fail onmain(Expected a contained relative path/Special or hard-linked source file: sub) and pass with this change.bun test test/cso-snapshot-state.test.ts: 88 pass, 0 fail.bun run typecheck: clean.bun run typecheck:test: no new diagnostics.bun run format:cso:check: clean.VERSION/CHANGELOG are left for
/ship.