Repository navigation
refactor(engine): DeleteFs trait sandbox refactor + emitter wiring (SEC-1.q) - #4728
Merged
Merged
Conversation
…EC-1.q) Extend DeleteFs with unix-only `*_at` siblings (unlink_file_at, rmdir_at, unlink_symlink_at, unlink_device_at, unlink_special_at, remove_dir_all_at) that take a parent dirfd + single-component leaf and route through fast_io::unlinkat / fast_io::recursive_unlinkat (SEC-1.s). Path-based methods stay as the no-sandbox / Windows fallback so existing callers keep working unchanged. Closes the six GAP sites in crates/engine/src/delete/emitter/fs.rs from PR #4710 audit section 4 (#22-#27) by giving RealDeleteFs a dirfd- anchored dispatch shape. Adds DeleteEmitter::with_sandbox carrier slot that opens a per-plan dirfd via DirSandbox::root_dirfd just before dispatch so a mid-syscall symlink swap on the parent walk cannot redirect the call. Plan-directory open failure transparently falls back to the path-based methods so the drain stays compatible. RecordingDeleteFs and ScriptedDeleteFs implement `*_at` by discarding parent_fd and recording the leaf name so every emitter unit test keeps working without sandbox plumbing. New sandbox.rs test module exercises each `*_at` variant against a live tempdir, the recursive peel's symlink-swap resistance, and the sandbox-off / missing-plan-directory fallback paths. Promotes recursive_unlinkat(parent_dirfd, leaf) from a SEC-1.s internal helper to a pub entry point so engine can use it directly without synthesising absolute-path arguments. Receiver-deletion integration in crates/transfer/ deferred to a follow-up per design doc; the receiver loop does not yet route through DeleteEmitter.
4 tasks
oferchen
added a commit
that referenced
this pull request
May 22, 2026
#4729) Captures the receiver-side `--delete` wiring follow-up SEC-1.q (PR #4728) intentionally deferred. The merged engine-side work added a sandbox-aware DeleteFs trait surface plus the DeleteEmitter::with_sandbox carrier, but the receiver loop in crates/transfer/src/receiver/directory/deletion.rs still calls std::fs::remove_file / remove_dir_all / read_dir directly. Lays out three options (migrate receiver to DeleteEmitter, swap to fast_io *_via_sandbox_or_fallback helpers, defer behind Landlock) with LoC scope, risk, test cost, and cross-platform plan. Recommends Option B (direct helper swap) on effort-vs-risk grounds and because the SEC-1.r temp_guard / temp_cleanup PR (#4723) is the established precedent for exactly this carrier-threading shape. Closes audit rows #5-#7 in docs/audits/sec-1-path-syscall-audit-2026-05-22.md once the implementation PR lands. Docs-only.
3 of 4 tasks
oferchen
added a commit
that referenced
this pull request
May 22, 2026
SkipWhile<Components, _> has no as_path() method on stable Rust 1.88; the previous skip_while-then-as_path call introduced in SEC-1.q (#4728) slipped through that PR's CI but breaks fmt+clippy on every subsequent master CI run. Switch to a manual Components::next() walk that consumes the leading Prefix/RootDir/CurDir components, then calls as_path() on the unwrapped Components iterator.
oferchen
added a commit
that referenced
this pull request
May 22, 2026
SkipWhile<Components, _> has no as_path() method on stable Rust 1.88; the previous skip_while-then-as_path call introduced in SEC-1.q (#4728) slipped through that PR's CI but breaks fmt+clippy on every subsequent master CI run. Switch to a manual Components::next() walk that consumes the leading Prefix/RootDir/CurDir components, then calls as_path() on the unwrapped Components iterator.
oferchen
added a commit
that referenced
this pull request
May 22, 2026
…olding (PIP-8) (#4731) * refactor(transfer,engine): tear out dead parallel-receive-delta scaffolding (PIP-8) PIP-7 (#4730) proved that the receiver-side parallel-receive-delta dispatch was a side-effect-only no-op. ReceiverContext::delta_pipeline had 1 writer (enable_parallel_receive_delta) and 0 readers - the production receive loop never drained the swapped pipeline. The only observable behaviour the feature flag enabled was the side effect of constructing ParallelDeltaPipeline::new, which spawns a DeltaConsumer background thread - the suspected source of the file_1.txt corruption PIP-4 surfaced. Remove the dead scaffolding: - ReceiverContext::enable_parallel_receive_delta - ReceiverContext::set_delta_pipeline - ReceiverContext::dispatch_receiver_strategy - ReceiverContext::select_receiver_strategy - ReceiverContext::total_source_bytes - ReceiverContext::dispatch_forced_parallel - The delta_pipeline: Option<Box<dyn ReceiverDeltaPipeline>> field - The ReceiverStrategy enum and TransferStats::receiver_strategy_chosen - PARALLEL_RECEIVE_FILE_COUNT_THRESHOLD, PARALLEL_RECEIVE_BYTES_THRESHOLD, FORCE_PARALLEL_RECEIVE_ENV constants - strategy_tests module in receiver/mod.rs - crates/transfer/src/receiver/tests/file_list/receiver_strategy.rs - dispatch_receiver_strategy() call sites in receiver/transfer/ {sync,pipelined,pipelined_incremental}.rs Keep compiled (no functional change): - ParallelDeltaApplier - benches drive it directly (parallel_receive_delta_perf, br_3j_f_dashmap_cores_vs_throughput, parallel_verify_chunk) - ParallelDeltaPipeline - wire_format_parallel_scheduling_fuzz exercises it; PIP-9 will need it as a substrate - DeltaConsumer - engine consumer tests + multi_producer_audit - The parallel-receive-delta feature flag - now a no-op pending PIP-9 Add docs/design/pip-9-parallel-receive-delta-wire-up-2026-05-22.md to track the future RJN-3 fan-out integration of ParallelDeltaApplier through a production reader. Update README, CHANGELOG, and the deferral notes in parallel-receive-delta-default-on.md, pip-4-closure-2026-05-21.md, br-6-sign-off-check-in-2026-05-21.md, and the PIP-7 doc itself (status: OPEN -> MITIGATED-PENDING-PIP-9). * fix(engine): use Components::next() walk for plan_directory_to_relative SkipWhile<Components, _> has no as_path() method on stable Rust 1.88; the previous skip_while-then-as_path call introduced in SEC-1.q (#4728) slipped through that PR's CI but breaks fmt+clippy on every subsequent master CI run. Switch to a manual Components::next() walk that consumes the leading Prefix/RootDir/CurDir components, then calls as_path() on the unwrapped Components iterator.
oferchen
added a commit
that referenced
this pull request
May 22, 2026
…-1.q2) (#4732) * feat(transfer): thread DirSandbox through receiver --delete path (SEC-1.q2) Replace the three unanchored syscalls in delete_extraneous_files with their sandbox-anchored siblings so a TOCTOU symlink swap on a top-level extraneous entry cannot redirect the listing or the unlink to an attacker-chosen inode outside the destination tree. Adds fast_io::read_dir_via_sandbox_or_fallback (mirrors the existing *_via_sandbox_or_fallback shape: openat(O_DIRECTORY | O_NOFOLLOW) + fdopendir for single-component scans, std::fs::read_dir fallback otherwise). Closes audit rows #5, #6, #7 from the SEC-1 path-syscall audit. Mirrors the SEC-1.r temp_guard/temp_cleanup carrier-threading pattern (PR #4723): the Option<Arc<DirSandbox>> is cloned once into the map_blocking worker closure and forwarded to every helper call. Sandbox-off and multi-component paths take the documented identical- behaviour fallback. No transfer-crate unsafe is introduced; all unsafe stays behind the existing fast_io safe wrappers. Windows continues through std::fs::remove_file / remove_dir_all / read_dir (NTFS handle semantics already close the symlink-swap window per the SEC-1.l audit). * fix(engine): use Components::next() walk for plan_directory_to_relative SkipWhile<Components, _> has no as_path() method on stable Rust 1.88; the previous skip_while-then-as_path call introduced in SEC-1.q (#4728) slipped through that PR's CI but breaks fmt+clippy on every subsequent master CI run. Switch to a manual Components::next() walk that consumes the leading Prefix/RootDir/CurDir components, then calls as_path() on the unwrapped Components iterator. * fix(transfer): cfg-gate rel_for_unlink to unix to silence Windows unused-var
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…EC-1.q) (#4728) Extend DeleteFs with unix-only `*_at` siblings (unlink_file_at, rmdir_at, unlink_symlink_at, unlink_device_at, unlink_special_at, remove_dir_all_at) that take a parent dirfd + single-component leaf and route through fast_io::unlinkat / fast_io::recursive_unlinkat (SEC-1.s). Path-based methods stay as the no-sandbox / Windows fallback so existing callers keep working unchanged. Closes the six GAP sites in crates/engine/src/delete/emitter/fs.rs from PR #4710 audit section 4 (#22-#27) by giving RealDeleteFs a dirfd- anchored dispatch shape. Adds DeleteEmitter::with_sandbox carrier slot that opens a per-plan dirfd via DirSandbox::root_dirfd just before dispatch so a mid-syscall symlink swap on the parent walk cannot redirect the call. Plan-directory open failure transparently falls back to the path-based methods so the drain stays compatible. RecordingDeleteFs and ScriptedDeleteFs implement `*_at` by discarding parent_fd and recording the leaf name so every emitter unit test keeps working without sandbox plumbing. New sandbox.rs test module exercises each `*_at` variant against a live tempdir, the recursive peel's symlink-swap resistance, and the sandbox-off / missing-plan-directory fallback paths. Promotes recursive_unlinkat(parent_dirfd, leaf) from a SEC-1.s internal helper to a pub entry point so engine can use it directly without synthesising absolute-path arguments. Receiver-deletion integration in crates/transfer/ deferred to a follow-up per design doc; the receiver loop does not yet route through DeleteEmitter.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
#4729) Captures the receiver-side `--delete` wiring follow-up SEC-1.q (PR #4728) intentionally deferred. The merged engine-side work added a sandbox-aware DeleteFs trait surface plus the DeleteEmitter::with_sandbox carrier, but the receiver loop in crates/transfer/src/receiver/directory/deletion.rs still calls std::fs::remove_file / remove_dir_all / read_dir directly. Lays out three options (migrate receiver to DeleteEmitter, swap to fast_io *_via_sandbox_or_fallback helpers, defer behind Landlock) with LoC scope, risk, test cost, and cross-platform plan. Recommends Option B (direct helper swap) on effort-vs-risk grounds and because the SEC-1.r temp_guard / temp_cleanup PR (#4723) is the established precedent for exactly this carrier-threading shape. Closes audit rows #5-#7 in docs/audits/sec-1-path-syscall-audit-2026-05-22.md once the implementation PR lands. Docs-only.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…olding (PIP-8) (#4731) * refactor(transfer,engine): tear out dead parallel-receive-delta scaffolding (PIP-8) PIP-7 (#4730) proved that the receiver-side parallel-receive-delta dispatch was a side-effect-only no-op. ReceiverContext::delta_pipeline had 1 writer (enable_parallel_receive_delta) and 0 readers - the production receive loop never drained the swapped pipeline. The only observable behaviour the feature flag enabled was the side effect of constructing ParallelDeltaPipeline::new, which spawns a DeltaConsumer background thread - the suspected source of the file_1.txt corruption PIP-4 surfaced. Remove the dead scaffolding: - ReceiverContext::enable_parallel_receive_delta - ReceiverContext::set_delta_pipeline - ReceiverContext::dispatch_receiver_strategy - ReceiverContext::select_receiver_strategy - ReceiverContext::total_source_bytes - ReceiverContext::dispatch_forced_parallel - The delta_pipeline: Option<Box<dyn ReceiverDeltaPipeline>> field - The ReceiverStrategy enum and TransferStats::receiver_strategy_chosen - PARALLEL_RECEIVE_FILE_COUNT_THRESHOLD, PARALLEL_RECEIVE_BYTES_THRESHOLD, FORCE_PARALLEL_RECEIVE_ENV constants - strategy_tests module in receiver/mod.rs - crates/transfer/src/receiver/tests/file_list/receiver_strategy.rs - dispatch_receiver_strategy() call sites in receiver/transfer/ {sync,pipelined,pipelined_incremental}.rs Keep compiled (no functional change): - ParallelDeltaApplier - benches drive it directly (parallel_receive_delta_perf, br_3j_f_dashmap_cores_vs_throughput, parallel_verify_chunk) - ParallelDeltaPipeline - wire_format_parallel_scheduling_fuzz exercises it; PIP-9 will need it as a substrate - DeltaConsumer - engine consumer tests + multi_producer_audit - The parallel-receive-delta feature flag - now a no-op pending PIP-9 Add docs/design/pip-9-parallel-receive-delta-wire-up-2026-05-22.md to track the future RJN-3 fan-out integration of ParallelDeltaApplier through a production reader. Update README, CHANGELOG, and the deferral notes in parallel-receive-delta-default-on.md, pip-4-closure-2026-05-21.md, br-6-sign-off-check-in-2026-05-21.md, and the PIP-7 doc itself (status: OPEN -> MITIGATED-PENDING-PIP-9). * fix(engine): use Components::next() walk for plan_directory_to_relative SkipWhile<Components, _> has no as_path() method on stable Rust 1.88; the previous skip_while-then-as_path call introduced in SEC-1.q (#4728) slipped through that PR's CI but breaks fmt+clippy on every subsequent master CI run. Switch to a manual Components::next() walk that consumes the leading Prefix/RootDir/CurDir components, then calls as_path() on the unwrapped Components iterator.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…-1.q2) (#4732) * feat(transfer): thread DirSandbox through receiver --delete path (SEC-1.q2) Replace the three unanchored syscalls in delete_extraneous_files with their sandbox-anchored siblings so a TOCTOU symlink swap on a top-level extraneous entry cannot redirect the listing or the unlink to an attacker-chosen inode outside the destination tree. Adds fast_io::read_dir_via_sandbox_or_fallback (mirrors the existing *_via_sandbox_or_fallback shape: openat(O_DIRECTORY | O_NOFOLLOW) + fdopendir for single-component scans, std::fs::read_dir fallback otherwise). Closes audit rows #5, #6, #7 from the SEC-1 path-syscall audit. Mirrors the SEC-1.r temp_guard/temp_cleanup carrier-threading pattern (PR #4723): the Option<Arc<DirSandbox>> is cloned once into the map_blocking worker closure and forwarded to every helper call. Sandbox-off and multi-component paths take the documented identical- behaviour fallback. No transfer-crate unsafe is introduced; all unsafe stays behind the existing fast_io safe wrappers. Windows continues through std::fs::remove_file / remove_dir_all / read_dir (NTFS handle semantics already close the symlink-swap window per the SEC-1.l audit). * fix(engine): use Components::next() walk for plan_directory_to_relative SkipWhile<Components, _> has no as_path() method on stable Rust 1.88; the previous skip_while-then-as_path call introduced in SEC-1.q (#4728) slipped through that PR's CI but breaks fmt+clippy on every subsequent master CI run. Switch to a manual Components::next() walk that consumes the leading Prefix/RootDir/CurDir components, then calls as_path() on the unwrapped Components iterator. * fix(transfer): cfg-gate rel_for_unlink to unix to silence Windows unused-var
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
Implements SEC-1.q per
docs/design/sec-1-q-delete-emitter-sandbox-2026-05-22.md. Closes 6 GAP sites from the SEC-1 audit (PR #4710 rows 22-27): daemon-reachableunlink/rmdir/remove_dir_allcalls in the engineDeleteFsimpl that weren't anchored onDirSandbox.This was previously opened as PR #4727 stacked on SEC-1.s (PR #4726). #4726 merged at sha
2a5d119, GitHub auto-closed #4727 when its base branch was deleted, and reopen is blocked. Re-opening here againstmasterwith the same source branch.Changes
crates/engine/src/delete/emitter/fs.rs): six new unix-only*_atsiblings takingBorrowedFd<'_> + &OsStr. Path-based methods preserved as no-sandbox/Windows fallback.RealDeleteFsroutes throughfast_io::unlinkatandfast_io::recursive_unlinkat(SEC-1.s helper);RecordingDeleteFsandScriptedDeleteFsdiscardparent_fdand record the leaf name so existing emitter tests pass unchanged;&Fblanket impl mirrors the six methods.Option<Arc<DirSandbox>>carrier field onDeleteEmitterpluswith_sandbox()builder andsandbox()accessor.drain_planopens a per-plan dirfd againstsandbox.root_dirfd();dispatchanddispatch_dirroute through the*_atmethods when the dirfd is available, otherwise transparently fall back to path-based methods. All cross-platform via#[cfg(unix)]gates.crates/engine/src/delete/emitter/tests/sandbox.rs): seven tests covering per-method sandbox dispatch, symlink-swap resistance (regular file, symlink, recursive peel against escape symlinks), sandbox-off fallback, device/special leaf dispatch, missing-plan-directory fallback.recursive_unlinkat(parent_dirfd, leaf)promoted from private topuband re-exported, so engine can drive the recursive peel directly.Deferred
Receiver loop in
crates/transfer/doesn't route throughDeleteEmitteryet; wiring that path is a separate follow-up (noted in the design doc).Constraints
refactor:per PR title.