raise instead of skipping model directories that cannot be listed - #652
Open
Support-itecz wants to merge 1 commit into
Open
raise instead of skipping model directories that cannot be listed#652Support-itecz wants to merge 1 commit into
Support-itecz wants to merge 1 commit into
Conversation
check_file_or_directory accepts any path that stats as a directory, but
glob("**/*") drops a subtree it cannot list without surfacing the error.
CPython swallows the failure inside the per-directory generator
(PermissionError on 3.10-3.12, OSError in glob._Globber on 3.13+), and the
manifest records only files, so an unreadable directory contributes zero
entries and nothing raises.
That leaves a model tree that verifies clean while part of it was never
hashed: mkdir model/evil; cp backdoor.py model/evil/; chmod 0111 model/evil
keeps backdoor.py out of the manifest and verify still reports success. Mode
0111 still grants search, so whatever loads the model opens the planted file
normally.
The helper now scandirs any directory it is handed and raises when the
listing fails, which its own docstring already claimed it did for permission
errors. Both the file and shard serializers call it, so one check covers both
walk loops.
Signed-off-by: Itecz Solution <support@itecz.au>
Support-itecz
force-pushed
the
unlistable-dir-raise
branch
from
July 29, 2026 18:07
29c4ccd to
91b5a85
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.
Summary
check_file_or_directoryaccepts any path that stats as a directory, butglob("**/*")drops a subtree it cannot list without surfacing the error.PermissionErroron 3.10-3.12,OSErroringlob._Globberon 3.13+)mkdir model/evil; cp backdoor.py model/evil/; chmod 0111 model/evilkeepsbackdoor.pyout of the manifest andverifystill reports success; mode 0111 still grants search, so whatever loads the model opens the planted file normallyThe docstring already said this call raises when there are permission errors. Signing or verifying a tree you cannot fully read now fails instead of quietly covering less than it appears to.
Checklist