Repository navigation
fix: sync pull keeps every write inside the destination - #114
Merged
Merged
Conversation
A pull takes its paths from the sandbox's listing and archive. They now go through the same check before any local write: - listing paths get the archive member check (no absolute or .. paths), before anything is fetched; - join_local refuses a path whose parents under the destination include a symlink, for archive members, oversized downloads and deletes alike; - extracted files and the download's .part file are opened with O_NOFOLLOW; - directory modes and mtimes, applied last, skip a path that is no longer a directory. Symlinks themselves are still kept as sent, like rsync -l; sync just never writes through them. This also fixes a pull with delete=True where a directory became a symlink: its old children were deleted through the new link, in the link's target.
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.
Why
filesystem.sync(direction="pull")writes local paths that come from the sandbox: the listing (GET /files/list)and the archive (
GET /files/archive). Until now only archive member names were checked (no leading/, no..).Listing paths were joined as given, and writes went through whatever sat on the path: a symlink extracted earlier in
the same pull, or one already in the destination. A pull should never write outside its destination, whatever the
sandbox's tree holds.
What changed
All pull writes now go through
join_local, which:..paths refused), plus a containment check that alsocovers Windows separators and drives;
On top of that:
download_file's.partfile are opened withO_NOFOLLOW(where the platform has it);Symlinks themselves are still kept as sent, like
rsync -l: sync just never writes through them.Behavior changes:
SandboxFilesystemErrorinstead of writing it.delete=Truewhere a directory became a symlink no longer deletes the directory's old childrenthrough the new link (they were removed from the link's target). The delete still counts.
download_filerefuses a symlink at<local_path>.partinstead of writing through it.docs/sandbox.mdis regenerated for the new docstrings (clean_path,open_nofollow,join_local,sync).How it was verified
uv run pytest: 1857 passed.symlink, listing paths outside the destination, oversized downloads through a symlink, a
.partsymlink, adir → symlink flip with
delete=True,join_localrefusals; sync and async pulls) fail onmainand pass here.black --checkon the changed files.