Repository navigation
fix(passport): pin the export output directory (R4-F1) - #147
Merged
DVOpenLabs merged 5 commits intoNov 14, 2026
Merged
Conversation
…ect the write (R4-F1) export -o validated the path, then created the temp file and published it by path, leaving a window in which the directory or an ancestor could be swapped (for example for a link to a network share). snapstudio_core/safe_publish.py now opens the directory once and publishes through that pin: dir_fd-relative create + no-replace link on POSIX (real path checked from the descriptor); on Windows a directory handle without FILE_SHARE_DELETE, final path read from the handle and checked, then create + no-replace rename. Tests: tests/passport/test_export_publication.py swaps the directory at the moment of first file creation and fails on the previous write path (passport lands in the swapped-in directory); the legacy appears-before-publication test now targets the new primitive on each platform. Full backend suite: 5241 passed expected (one test updated), run before the test edit 5240 passed + that test. Only the Windows pin was exercised locally; POSIX is covered by Linux CI. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…n export publication (R4-F1 review) Sol BLOCK on 082af75: (HIGH) an actor with write access to an empty pinned directory could install a junction in place; (MEDIUM) unresolved /proc/self/fd paths passed the network check; (MEDIUM) temp names grew with the destination name and backslashes were rejected on POSIX. Windows now creates the final name exclusively with sharing off, re-checks the pinned directory for a reparse point, verifies the file handle's own final path equals the verified directory plus name, and discards the empty file on a mismatch. Linux reads the descriptor path with readlink and fails closed. Temp names are bounded and independent of the destination; separator rejection is platform-aware. Tests: in-place junction and ancestor-swap regressions (fail on the old write path); obsolete no-hard-link rename test removed (path gone), covered by the retargeted destination-appears test. Verified: tests/passport + review-fix tests 82 passed on Windows; full backend 5242 passed before removing the obsolete test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t failed cleanup (R4-F1 review round 2) Sol BLOCK on c824bf0: case-folded final-path comparison could accept a junction to a differently-cased sibling on a case-sensitive volume (HIGH); POSIX name test still required a backslash to be rejected (MEDIUM); discard ignored a failed disposition (LOW). Compare exact canonical paths; make the separator test platform-aware (POSIX accepts a backslash); raise when the empty file cannot be removed. Verified: passport + review-fix tests 82 passed on Windows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…path (R4-F1 review notes) Opus/Sol approved 3e89141 with notes: no test reached the file-handle final-path check, because the junction test fires before the directory re-check, and the docs wrongly called the window untestable. Add a no-op _before_create seam and two Windows tests (junction set exactly before the create is refused and leaves the decoy empty; a failed disposition is reported). Correct the docs. Verified: tests/passport 62 passed on Windows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
…its of export publication Opus and Sol approved f84829a with this note. Doc-only; no code or test change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
DVOpenLabs
marked this pull request as ready for review
November 14, 2026 13:17
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.
Closes Sol BLOCK R4-F1 on #140:
passport export -ovalidated the output path and then created/published by path, so a swap of the directory or an ancestor in between could redirect the write.Design (
backend/snapstudio_core/safe_publish.py): pin the output directory once and publish through the pin.dir_fd-relative exclusive create + no-replacelink; real path read from/proc/self/fd(fails closed) orF_GETPATH.FILE_SHARE_DELETE(blocks rename/delete of the directory and ancestors); reparse re-check; final name created exclusively with sharing off; the file handle's own final path must equal the verified directory plus name, otherwise the empty file is discarded before any content is written.bad_output).Reviews: Sol BLOCK on 082af75 and c824bf0 (junction on an empty pinned dir; /proc fail-open; case-folded path compare; POSIX name test) all repaired; Opus + Sol APPROVE-WITH-NOTES on 3e89141. Notes addressed in f84829a (post-recheck seam + tests, docs).
Evidence (fixture-tested): swap-at-first-create, ancestor-swap and in-place-junction regression tests fail against the previous
passport_cli.pyand pass here; Windows only locally (passport tests 62 passed). The POSIX branch has never been run; Linux CI is its first execution. Not tested: macOSF_GETPATH, FAT/exFAT/ReFS ancestor-rename semantics, case-sensitive-directory volumes (reasoned only).Behaviour changes: Windows passports are written with LF line endings;
-oneeds read access to the output directory; POSIX needs hard-link support; mapped network drives are refused.Residual: an empty file may be briefly created in a redirected location before being removed; a killed process mid-write can leave a truncated file at the final name.
Not merged by design: #140 and its descendants stay unmerged until this lands and further authorization.
🤖 Generated with Claude Code