fix(sync): keep all writes inside --dest - #13
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens tools/wolfglass-sync against path traversal/escape via --subdir so syncing cannot overwrite files outside the intended --dest tree, and adds CI-backed regression tests for the new guard.
Changes:
- Add
--subdirvalidation to require a relative path that resolves within--dest. - Add unit tests covering absolute and
..-based escape attempts, plus a valid relative subdir case. - Wire the new test into
selftest.yml(compile + unittest execution).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/wolfglass-sync | Adds --subdir containment checks to prevent writing outside --dest. |
| tests/test_wolfglass_sync.py | New tests validating the containment guard (absolute and .. rejected; relative allowed). |
| .github/workflows/selftest.yml | Runs the new unit test in CI and includes it in the syntax-compile step. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+61
to
+66
| dest_abs = os.path.realpath(args.dest) | ||
| dest_root_abs = os.path.realpath(dest_root) | ||
| if dest_root_abs != dest_abs and \ | ||
| not dest_root_abs.startswith(dest_abs + os.sep): | ||
| sys.exit(f"ERROR: --subdir {args.subdir!r} escapes --dest; it must " | ||
| f"resolve to a path inside {args.dest!r}.") |
sameehj
force-pushed
the
master
branch
4 times, most recently
from
July 24, 2026 14:09
3ab77f9 to
9bdf5b7
Compare
MarkAtwood
force-pushed
the
fix/wolfglass-sync-path-guard
branch
from
August 13, 2026 01:15
a6770c6 to
481f19f
Compare
MarkAtwood
force-pushed
the
fix/wolfglass-sync-path-guard
branch
from
September 29, 2026 00:57
481f19f to
d1d67d3
Compare
wolfglass-sync joins --subdir onto --dest and copies files there with shutil.copy2. An absolute --subdir replaces --dest entirely, a --subdir containing .. walks out of it, and a symlink already under the vendored path redirects a copy to wherever it points. Require --subdir to be relative and to resolve inside --dest, and resolve every write target (share files, VERSION, .wolfglass-rev) before copying. If any lands outside the vendored path, exit non-zero without writing. Containment uses os.path.commonpath, so --dest / works. Adds tests/test_wolfglass_sync.py, wired into selftest.yml.
MarkAtwood
force-pushed
the
fix/wolfglass-sync-path-guard
branch
from
October 1, 2026 20:54
157fa0a to
4f22eb4
Compare
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.
wolfglass-syncjoins--subdironto--destand copies files there withshutil.copy2. An absolute--subdirreplaces--destentirely, a--subdircontaining..walks out of it, and a symlink already under the vendored path redirects a copy to wherever it points.This requires
--subdirto be relative and to resolve inside--dest, and resolves every write target (share files,VERSION,.wolfglass-rev) before copying. If any lands outside the vendored path it exits non-zero without writing anything. Containment usesos.path.commonpath, so--dest /works.tests/test_wolfglass_sync.pycovers absolute and..subdirs, file and directory symlinks pointing outside, a--subdirthat is itself a symlink out of--dest,--dest /, and a normal relative copy. Wired intoselftest.yml.