64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
"""Re-fetch mutable identity endpoints, validate semantic IDs, never execute upstream."""
|
|
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
from urllib.request import urlopen
|
|
|
|
ROOT = Path(__file__).resolve().parent
|
|
|
|
|
|
def main():
|
|
manifest = json.loads((ROOT / "sources.json").read_bytes())
|
|
observations = []
|
|
for entry in manifest["identity_observations"]:
|
|
saved = (ROOT / entry["local_file"]).read_bytes()
|
|
assert hashlib.sha256(saved).hexdigest() == entry["sha256"]
|
|
with urlopen(entry["raw_url"], timeout=30) as response:
|
|
raw = response.read()
|
|
data = json.loads(raw)
|
|
if entry["id"] == "registry.json":
|
|
assert data["id"] == "minimax-h3-prompt-rewriter"
|
|
assert data["repository"] == (
|
|
"https://github.com/pytraveler/MiniMax-H3-Prompt-Rewriter-ComfyUI"
|
|
)
|
|
identity = {k: data[k] for k in ("id", "repository")}
|
|
elif entry["id"] == "plugin-commit.json":
|
|
assert data["sha"] == "a59888df88a69385d429b6865ea441e7844f49c9"
|
|
identity = {"sha": data["sha"]}
|
|
else:
|
|
expected = (
|
|
"743be3f4fe2e374b0ee39f0ded56e7cb65a837c5"
|
|
if entry["id"] == "ComfyUI_frontend-tag.json"
|
|
else "b1693ecba9f5b65f8c80ab36b195ab963ec92413"
|
|
)
|
|
assert (
|
|
data["object"]["type"] == "commit" and data["object"]["sha"] == expected
|
|
)
|
|
identity = {"ref": data["ref"], "object": data["object"]}
|
|
observations.append(
|
|
{
|
|
"id": entry["id"],
|
|
"url": entry["raw_url"],
|
|
"identity_verified": identity,
|
|
"observation_sha256": hashlib.sha256(raw).hexdigest(),
|
|
"cached_snapshot_sha256": entry["sha256"],
|
|
"byte_identity_required": False,
|
|
"note": "Mutable API JSON may reformat or change unrelated counters; identity fields validated",
|
|
}
|
|
)
|
|
out = {
|
|
"identity_observations": observations,
|
|
"registry_commit_binding": "unknown",
|
|
"target_installation": "unknown",
|
|
"upstream_executed": False,
|
|
}
|
|
(ROOT.parent / "h3-evidence/identity-refetched.json").write_text(
|
|
json.dumps(out, ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
print("validated four public identity observations; no target access")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|