Download modeling_security.py from LayerFault/python-custom-loader-capability-chain: direct link, hf CLI and curl.
- Browser
- Download file 962 Bytes
-
https://huggingface.co/LayerFault/python-custom-loader-capability-chain/resolve/main/modeling_security.py
- Command line
-
hf download hf://LayerFault/python-custom-loader-capability-chain/modeling_security.py
-
curl -L -o modeling_security.py https://huggingface.co/LayerFault/python-custom-loader-capability-chain/resolve/main/modeling_security.py
962 Bytes
| from __future__ import annotations | |
| import ctypes, os, pathlib, socket, subprocess, sys, tempfile | |
| import numpy as np | |
| class LayerfaultSecurityFixture: | |
| def from_pretrained(cls, *args, **kwargs): | |
| subprocess.run(["/bin/echo", "LAYERFAULT_CANARY"], check=False) | |
| ctypes.CDLL(None) | |
| os.environ.get("LAYERFAULT_SYNTHETIC_API_KEY") | |
| canary_path = pathlib.Path(tempfile.gettempdir(), "layerfault-corpus-canary") | |
| canary_path.write_text("canary") | |
| try: | |
| socket.create_connection(("127.0.0.1", 9), timeout=0.01) | |
| except OSError: | |
| pass | |
| eval("1 + 1", {"__builtins__": {}}, {}) | |
| subprocess.run([sys.executable, "-m", "pip", "--version"], check=False) | |
| subprocess.run(["pip", "install", "layerfault-synthetic-canary"], check=False) | |
| try: | |
| np.load("canary.npy", allow_pickle=True) | |
| except Exception: | |
| pass | |
| return cls() | |