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

Manually merged
github merged 1 commit from gh-pr/2/head into gh-pr/2/base 2026-11-26 06:24:36 +00:00
Owner

@⁠Batushn on GitHub · 2026-11-23 20:05 UTC · original
Batushn:fix/inspect-resolve-root → main · +24 −0 · 2 files · 1 commits · merged 2026-11-23 20:20 UTC

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.)

**@⁠Batushn** on GitHub · 2026-11-23 20:05 UTC · [original](https://github.com/brcly/TuxBox/pull/2) `Batushn:fix/inspect-resolve-root` → `main` · +24 −0 · 2 files · 1 commits · merged 2026-11-23 20:20 UTC ## 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.)*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:24:33 +00:00
github manually merged commit 115fccedb2 into gh-pr/2/base 2026-11-26 06:24:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.