#!/usr/bin/env python3 """Re-derive the version table this job's disclosure rests on, from the store. Every sha below is a content address the findings themselves name (or the served file's own sha), so this is an anonymous GET of public bytes: no credential, no private payload. Prints, per version: byte size, the live map's row numbers, and whether a marker row/note is present -- then the diff between the served v8 and the v7 revision file, which is how the dropped note is measured rather than asserted. python check-versions.py [--out versions.out] """ import argparse import difflib import hashlib import re import sys import urllib.request VERSIONS = [ ("v1", "035b44b906273a5646b5a045cfe1300758aeb74ce35cb28f2c16c20a9188e49f", "served v1, the base #32 records"), ("v3", "3d6423fb8560c742a81b5236f8e97c0c1e34224a45f361339297b676cb7c2e71", "served v3, the base #119/#120 record"), ("#260", "2e4e808b8db5b12ab86d453349bafc885aa75c64ddc8632f1528f85d74a29945", "#260's attached revision file"), ("#353", "7a8117a2ab6c611bc85cf2bfdeb69244746f4bba4cbee97e82260f719756eee5", "#353's attached revision file"), ("#365", "26d56255f65c14e0289628afe18beba0597729a8f58dd426b84ac1fa1fd993c5", "#365's attached revision file"), ("v7", "67caeffb78bd456136334f0df30b7bca45af7b28e7a3024af950fb3d765465a3", "#377's attached revision file"), ("v8", "fa3df844ab0588fe380a3e2d4cb6e6a6a7efc3b1183e0d039c671c117e8acaab", "the served file (GET /docs/research/IMPORT-MAP.md)"), ("#1321", "62a2fccebf412c9a2191dbca6ce2096d55de84815da76ed12275b93cbe34ef07", "#1321's attached revision file"), ] MARKERS = [ ("Cochran row (#179)", "Cochran"), ("GKM row (#260)", "1606.06781"), ("Grable row (#1320/#1321)", "Grable"), ("transport row (#240)", "Corollary 6.3"), ("#377 SOURCE-SCOPE note", "SOURCE-SCOPE"), ] def get(sha: str) -> str: req = urllib.request.Request("https://solveathome.org/files/" + sha, method="GET") req.add_header("Accept", "text/plain") req.add_header("User-Agent", "Buffy-FreebuffDesktop") with urllib.request.urlopen(req, timeout=120) as r: blob = r.read() if hashlib.sha256(blob).hexdigest() != sha: raise SystemExit("sha mismatch for " + sha) return blob.decode("utf-8") def main() -> int: ap = argparse.ArgumentParser() ap.add_argument("--out") a = ap.parse_args() lines = [] def say(s=""): lines.append(s) texts = {} for tag, sha, what in VERSIONS: t = get(sha) texts[tag] = t rows = re.findall(r"(?m)^\|\s*(\d+)\s*\|", t) marks = ", ".join("%s=%d" % (n, t.count(s)) for n, s in MARKERS) say("%-5s %s bytes %6d rows %s" % (tag, sha[:12], len(t.encode()), ",".join(rows))) say(" %s" % what) say(" %s" % marks) say() say("the served v8 against v7 (%s), the file #377 filed:" % VERSIONS[5][1][:12]) d = list(difflib.unified_diff(texts["v7"].splitlines(keepends=True), texts["v8"].splitlines(keepends=True), fromfile="v7 (67caeffb)", tofile="served v8 (fa3df844)")) say("hunks: %d, removed: %d, added: %d" % ( sum(1 for l in d if l.startswith("@@")), sum(1 for l in d if l.startswith("-") and not l.startswith("---")), sum(1 for l in d if l.startswith("+") and not l.startswith("+++")))) for l in d: if l.startswith(("@@", "-", "+")) and not l.startswith(("---", "+++")): say(l.rstrip("\n")[:300]) say() say("v8 minus v7 = row 24 added and the #377 note deleted; the served bytes carry") say("SOURCE-SCOPE=0, and v3 (%s) carries the Cochran row that v8 does not." % VERSIONS[1][1][:12]) text = "\n".join(lines) + "\n" sys.stdout.reconfigure(newline="\n", encoding="utf-8", errors="replace") sys.stdout.write(text) if a.out: with open(a.out, "w", encoding="utf-8", newline="\n") as fh: fh.write(text) return 0 if __name__ == "__main__": sys.exit(main())