Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle arbitrary newline terminators #26

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

McPatate
Copy link
Collaborator

picklescan (well technically pickletools) fails to parse https://huggingface.co/Narsil/totallysafe/blob/main/pytorch_model.bin as it is newline terminated given it was handcrafted in an editor.

The following PR should address that.

@McPatate McPatate requested a review from mmaitre314 March 25, 2024 16:14
@McPatate
Copy link
Collaborator Author

Note that I'm not happy with the way the code looks, but I feel we need a fix for such cases since pickle loads it anyway

src/picklescan/scanner.py Outdated Show resolved Hide resolved
@McPatate McPatate force-pushed the fix/handle_aribtrary_newlines_terminators branch from 133bac0 to f5edabf Compare March 26, 2024 17:34
@McPatate
Copy link
Collaborator Author

Refactored, this is much better imo. Lmk what you think, the difference here is that if there is an error, at least return the already extracted globals.
I think this will better mimick the actual behaviour of pickle.load in the wild.

@McPatate McPatate force-pushed the fix/handle_aribtrary_newlines_terminators branch from 2f75026 to e10a0f5 Compare March 28, 2024 17:46
@mmaitre314 mmaitre314 self-requested a review March 28, 2024 21:48
@mmaitre314 mmaitre314 merged commit 752369a into main Mar 28, 2024
3 checks passed
@McPatate McPatate deleted the fix/handle_aribtrary_newlines_terminators branch March 29, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants