Download handler.py from FrankLin00/exp-a-ct-sparsity: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/FrankLin00/exp-a-ct-sparsity/resolve/main/handler.py
- Command line
-
hf download hf://FrankLin00/exp-a-ct-sparsity/handler.py
-
curl -L -o handler.py https://huggingface.co/FrankLin00/exp-a-ct-sparsity/resolve/main/handler.py
1.55 kB
| # --------------------------------------------------------------------------- | |
| # INERT RESEARCH MARKER — NOT MALICIOUS | |
| # | |
| # 该文件属于一项针对 Hugging Face Hub 扫描器覆盖面的学术测量实验。 | |
| # 模块级代码仅向系统临时目录写入一个唯一命名的空标记文件,用于确认 | |
| # 本文件是否被执行。它不会: | |
| # * 执行 shell 命令或启动子进程 | |
| # * 发起任何网络连接 | |
| # * 读取环境变量中的凭证(HF_TOKEN / 云密钥等) | |
| # * 修改临时目录以外的任何路径 | |
| # | |
| # 对应的上游漏洞已修复且公开:huggingface/transformers PR #46342 (commit 4ae05b0fba) | |
| # 联系方式:ziyu.lin@ntu.edu.sg | |
| # --------------------------------------------------------------------------- | |
| import os | |
| import pathlib | |
| _MARKER = pathlib.Path( | |
| os.environ.get("TMPDIR", "/tmp"), "HFSCAN_EXPA_81fdba79c913" | |
| ) | |
| try: | |
| _MARKER.write_text("inert research marker — EXP-A-ct-sparsity\n") | |
| except OSError: | |
| pass | |
| class MARKER: | |
| """registry 查找返回的对象。 | |
| compressed_tensors 的 RegistryMixin.load_from_registry() 在名字含冒号时, | |
| 会把冒号前的部分当作文件路径交给 importlib.util.spec_from_file_location(), | |
| exec_module() 之后再 getattr() 取冒号后的属性名。此处提供一个宽松的 | |
| 构造函数,使得载荷执行后加载流程仍能继续,便于观察后续行为。 | |
| """ | |
| def __init__(self, **kwargs): | |
| self.kwargs = kwargs | |
| def __repr__(self): | |
| return "<MARKER inert research probe>" | |