Download verify_cloudpickle_dill_load.py from AM-Core/modelscan-cloudpickle-dill-false-negative-poc: direct link, hf CLI and curl.
- Browser
- Download file 730 Bytes
-
https://huggingface.co/AM-Core/modelscan-cloudpickle-dill-false-negative-poc/resolve/main/verify_cloudpickle_dill_load.py
- Command line
-
hf download hf://AM-Core/modelscan-cloudpickle-dill-false-negative-poc/verify_cloudpickle_dill_load.py
-
curl -L -o verify_cloudpickle_dill_load.py https://huggingface.co/AM-Core/modelscan-cloudpickle-dill-false-negative-poc/resolve/main/verify_cloudpickle_dill_load.py
730 Bytes
| from pathlib import Path | |
| import cloudpickle | |
| import dill | |
| ROOT = Path(__file__).resolve().parent | |
| LOGS = ROOT / "logs" | |
| LOGS.mkdir(parents=True, exist_ok=True) | |
| marker = LOGS / "serialization_canary_loaded.txt" | |
| cases = [ | |
| ("cloudpickle", cloudpickle.load, ROOT / "canary_cloudpickle.pkl"), | |
| ("dill", dill.load, ROOT / "canary_dill.pkl"), | |
| ] | |
| for name, loader, path in cases: | |
| marker.unlink(missing_ok=True) | |
| print(f"===== CONTROLLED LOAD: {name} =====") | |
| print(f"file={path}") | |
| print(f"exists_before={marker.exists()}") | |
| with path.open("rb") as f: | |
| loader(f) | |
| print(f"exists_after={marker.exists()}") | |
| if marker.exists(): | |
| print(f"marker_content={marker.read_text().strip()}") | |
| print() | |