48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""Recheck mutable tag identity fields; byte SHA is only the saved observation."""
|
|
|
|
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())
|
|
rows = []
|
|
for entry in manifest["identity_observations"]:
|
|
raw = (ROOT / entry["local_file"]).read_bytes()
|
|
assert hashlib.sha256(raw).hexdigest() == entry["sha256"]
|
|
with urlopen(entry["raw_url"], timeout=30) as response:
|
|
now = json.loads(response.read())
|
|
assert now["ref"] == entry["ref"] and now["object"]["type"] == "commit"
|
|
assert now["object"]["sha"] == entry["commit"]
|
|
rows.append(
|
|
{
|
|
"id": entry["id"],
|
|
"url": entry["raw_url"],
|
|
"ref": now["ref"],
|
|
"commit": now["object"]["sha"],
|
|
"saved_observation_sha256": entry["sha256"],
|
|
"byte_identity_required": False,
|
|
}
|
|
)
|
|
(ROOT.parent / "h3-core-evidence/identity-refetched.json").write_text(
|
|
json.dumps(
|
|
{
|
|
"observations": rows,
|
|
"target_installation": "unknown",
|
|
"source_graph_identity": "unknown",
|
|
"upstream_executed": False,
|
|
},
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|