60 lines
2.1 KiB
Python
60 lines
2.1 KiB
Python
"""Optional online recheck of the exact declared core tag; text scan only, no execution.
|
|
|
|
The archive is read in memory. Only a hash inventory and result are retained;
|
|
no upstream checkout, installation, weights or media are created.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import io
|
|
import json
|
|
import tarfile
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
OUT = Path(__file__).resolve().parent
|
|
REFERENCE = OUT.parent / "sdpose-reference"
|
|
|
|
|
|
def main():
|
|
identity = next(
|
|
e for e in json.loads((REFERENCE / "identity.json").read_bytes()) if e["repo"] == "core0150"
|
|
)
|
|
url = "https://api.github.com/repos/Comfy-Org/ComfyUI/tarball/" + identity["commit"]
|
|
with urllib.request.urlopen(url, timeout=45) as response:
|
|
raw = response.read()
|
|
files = []
|
|
with tarfile.open(fileobj=io.BytesIO(raw), mode="r:gz") as archive:
|
|
for member in archive.getmembers():
|
|
if not member.isfile() or not member.name.endswith(".py"):
|
|
continue
|
|
data = archive.extractfile(member).read()
|
|
files.append(
|
|
dict(
|
|
file=member.name.split("/", 1)[1],
|
|
sha256=hashlib.sha256(data).hexdigest(),
|
|
contains_sdpose=b"sdpose" in data.lower(),
|
|
)
|
|
)
|
|
files.sort(key=lambda e: e["file"])
|
|
result = dict(
|
|
source=url,
|
|
commit=identity["commit"],
|
|
archive_sha256=hashlib.sha256(raw).hexdigest(),
|
|
python_files_scanned=len(files),
|
|
matches=[e["file"] for e in files if e["contains_sdpose"]],
|
|
files=files,
|
|
limitations="仅本固定官方commit的Python文本搜索;不证明分叉、插件或目标安装状态。",
|
|
imported_or_executed=False,
|
|
)
|
|
assert result["python_files_scanned"] == 516 and result["matches"] == []
|
|
(OUT / "sdpose-gap-scan.json").write_text(
|
|
json.dumps(result, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
print("PASS fixed core0.15.0 516 Python files: no case-insensitive SDPose text; no execution")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|