Skip to content

fix(passport): pin the export output directory (R4-F1) - #147

Merged
DVOpenLabs merged 5 commits into
feat/portfolio-integrationfrom
fix/passport-export-publication
Nov 14, 2026
Merged

DVOpenLabs merged 5 commits into
feat/portfolio-integrationfrom
fix/passport-export-publication

Conversation

@DVOpenLabs

Copy link
Copy Markdown
Owner

Closes Sol BLOCK R4-F1 on #140: passport export -o validated 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.

  • POSIX: held directory fd; dir_fd-relative exclusive create + no-replace link; real path read from /proc/self/fd (fails closed) or F_GETPATH.
  • Windows: directory handle without 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.
  • Missing / unverifiable output directory is refused (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.py and pass here; Windows only locally (passport tests 62 passed). The POSIX branch has never been run; Linux CI is its first execution. Not tested: macOS F_GETPATH, FAT/exFAT/ReFS ancestor-rename semantics, case-sensitive-directory volumes (reasoned only).

Behaviour changes: Windows passports are written with LF line endings; -o needs 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

DVOpenLabs and others added 4 commits November 13, 2026 16:51
…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>
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Team
  • Run ID: c0fc6a18-4b01-42b8-8fe6-76812199dbc6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…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
DVOpenLabs marked this pull request as ready for review November 14, 2026 13:17
@DVOpenLabs
DVOpenLabs merged commit b23dbc2 into feat/portfolio-integration Nov 14, 2026
7 checks passed
@DVOpenLabs
DVOpenLabs deleted the fix/passport-export-publication branch November 14, 2026 13:17
DVOpenLabs added a commit that referenced this pull request Nov 14, 2026
feat: Phase 2 portfolio tracks P2, P4-P8 with shared local-path guard (R4-F1 fixed via #147; Opus+Sol approved f40a18d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant