Repository navigation
Resolve symlinks in check_contained and normalize local paths in rsync / ReferenceFileSystem.get - #2522
Open
liuc99 wants to merge 1 commit into
Open
Resolve symlinks in check_contained and normalize local paths in rsync / ReferenceFileSystem.get#2522liuc99 wants to merge 1 commit into
liuc99 wants to merge 1 commit into
Conversation
…c / ReferenceFileSystem.get
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.
Summary
Follow-up improvements to destination path containment checks (#2299, #2300):
Symlink-aware containment for paths with
..(fsspec/utils.py):os.path.abspathcheck incheck_containedfor all paths...segments belowroot(or does not share a literal prefix withroot), lazily verifyos.path.realpath(path)againstos.path.realpath(root)as well...(including user-configured symlinks and avoiding per-pathlstatoverhead on large bulk copies) as well as benign in-tree..segments.Anchored path mapping and protocol normalization in
generic.rsync(fsspec/generic.py):str.replace(..., 1)with anchored prefix extraction and joining that handles bothroot_marker == "/"(memory://) androot_marker == ""(dir://,reference://,zip://) bare scheme roots...segment depth directly on extracted relative names across both local and non-local backends.LocalFileSystem,DirFileSystem,AsyncFileSystemWrapper,ChainedFileSystem) to stripped OS paths before callingcheck_contained, rather than passingfile://URLs toos.path.abspath/os.path.realpath.to_deleteonly whendelete_missingis enabled.Normalize local destination paths in
ReferenceFileSystem.get(fsspec/implementations/reference.py):~viaLocalFileSystem._strip_protocolbeforeother_pathsandcheck_containedso the checked path matches the path passed topipe_file.Tests
fsspec/tests/test_utils.py:test_check_contained_resolves_symlinks_with_dotdot(POSIX)test_check_contained_preserves_outward_symlink_without_dotdottest_get_resolves_symlinks_in_containment(POSIX)fsspec/tests/test_generic.py:test_rsync_rejects_names_escaping_memory_destinationtest_rsync_passes_local_paths_to_check_containedtest_rsync_resolves_symlinks_in_containment(POSIX)test_rsync_wrapped_local_dirfs_containment(POSIX)test_rsync_wrapped_local_async_wrapper_containment(POSIX)test_rsync_bare_root_dirfsfsspec/implementations/tests/test_reference.py:test_get_file_url_destination_containmenttest_get_file_url_resolves_symlinks_in_containment(POSIX)