Allow subtree traversal from filesystem roots - #141
Open
Str0k wants to merge 1 commit into
Open
Conversation
Co-authored-by: Codex <noreply@openai.com>
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.
The new
subdirtraversal support rejects valid subtrees when the root is a filesystem root._get_sub_path_safe()appends another separator to the root, so/requires a//prefix andC:\requires a doubled backslash. Equivalent Windows paths with different casing are also rejected.Use
os.path.commonpath()for the descendant check andnormcase()for root equality. This preserves rejection of parent paths and sibling paths that happen to share the root's string prefix. It does not change symlink-following behavior.Related to #126. A minimal reproduction that does not scan the filesystem is:
Tests cover actual traversal through both
iter_tree_files()anditer_tree_entries()with absolute and relative subdirectories, equivalent Windows root casing, the root itself, and rejected parent/sibling paths. The filesystem-root tests traverse only their temporary directory.Validation on Windows / Python 3.12:
python -m unittest discover -t . -s tests/succeeds (219 tests, 14 skipped because symlink creation is unavailable).f9a833e; the diagnostics are unchanged by this patch.AI assistance: Codex helped implement and test this patch. This is a traversal correctness fix; no security vulnerability is claimed.