Resolve package root in inspect.member() before containment checks #2

Merged
Batushn merged 1 commit from upstream-pr/2 into main 2026-11-23 20:20:22 +00:00
Batushn commented 2026-11-23 20:05:08 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Batushn on 2026-11-23T20:05:08Z.


Summary

  • Resolve root = Path(root).resolve() at the start of project_tuxbox.inspect.member().
  • Add a unit test in tests/test_inspect.py verifying unresolved/relative package roots work in both member() and manifest() while symlinks escaping the package directory are still rejected.

Why

member() resolved each matched path (folder = matches[0].resolve()) and checked folder.is_relative_to(root), without resolving root first. Callers passing an unresolved path to member() or manifest() ? such as a relative directory, a path with .., a symlinked/junctioned package directory, or a Windows 8.3 short temp path ? hit a false ValueError: Package member leaves the package directory.

Verification

  • Ran python -m unittest tests/test_inspect.py tests/test_package_binaries.py -v on Windows (Python 3.12.10): 13 tests, all non-skipped tests pass (test_case_collision skipped on case-insensitive FS).
  • Verified member(Path("."), "README.md") previously raised ValueError and now resolves cleanly.

(Disclosure: assisted by an AI coding agent; all changes were reviewed and verified locally.)

<!-- greyfinch-sync:brcly/TuxBox:issue:6567769784 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/2). Originally posted by [Batushn](https://github.com/Batushn) on 2026-11-23T20:05:08Z. --- ## Summary - Resolve `root = Path(root).resolve()` at the start of `project_tuxbox.inspect.member()`. - Add a unit test in `tests/test_inspect.py` verifying unresolved/relative package roots work in both `member()` and `manifest()` while symlinks escaping the package directory are still rejected. ## Why `member()` resolved each matched path (`folder = matches[0].resolve()`) and checked `folder.is_relative_to(root)`, without resolving `root` first. Callers passing an unresolved path to `member()` or `manifest()` ? such as a relative directory, a path with `..`, a symlinked/junctioned package directory, or a Windows 8.3 short temp path ? hit a false `ValueError: Package member leaves the package directory`. ## Verification - Ran `python -m unittest tests/test_inspect.py tests/test_package_binaries.py -v` on Windows (Python 3.12.10): 13 tests, all non-skipped tests pass (`test_case_collision` skipped on case-insensitive FS). - Verified `member(Path("."), "README.md")` previously raised `ValueError` and now resolves cleanly. *(Disclosure: assisted by an AI coding agent; all changes were reviewed and verified locally.)*
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!2
No description provided.