EXE-SHA-PREFLIGHT: add an executable identity preflight #437

Manually merged
github merged 1 commit from gh-pr/437/head into gh-pr/437/base 2026-11-26 09:00:08 +00:00
Owner

@⁠bobcatchris on GitHub · 2026-11-24 05:19 UTC · original
bobcatchris:exe-sha-preflight → main · +300 −0 · 3 files · 1 commits · merged 2026-11-24 08:51 UTC

Claimed in the coordination issue as: EXE-SHA-PREFLIGHT

What and why

Contributors run tools against their own copy of the game, but nothing currently checks that those copies are the same image the measurements were made on. A truncated or patched executable still reports as found, and every RVA a note quotes is then quietly measured against something else.

This adds tools/exe_sha.py, a small offline preflight that prints the size and SHA-256 of the image it is given, compares them with the manifest's optional expected_exe_size / expected_exe_sha256 fields (or with --expect SHA256), exits non-zero on a mismatch, checks the size before hashing so a truncated image is reported cheaply, and can emit JSON or the manifest keys for scripts. docs/design.md now lists it first in the day-one setup sequence.

No game data, keys, or decryption are included. Tests use synthetic files and the repository's existing manifest keys only.

Tested

  • python -I tests/test_exe_sha.py — 11 tests OK
  • python -I tests/test_docs_cli_flags.py — 4 tests OK
  • python -I tests/test_docs_links.py — 16 tests OK
  • python -m compileall -q tools tests — OK
  • git diff --check — clean

GPUs tested: n/a (CPU-only CLI and unit tests)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • No new translator rule.
**@⁠bobcatchris** on GitHub · 2026-11-24 05:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/437) `bobcatchris:exe-sha-preflight` → `main` · +300 −0 · 3 files · 1 commits · merged 2026-11-24 08:51 UTC Claimed in the coordination issue as: EXE-SHA-PREFLIGHT ### What and why Contributors run tools against their own copy of the game, but nothing currently checks that those copies are the same image the measurements were made on. A truncated or patched executable still reports as found, and every RVA a note quotes is then quietly measured against something else. This adds `tools/exe_sha.py`, a small offline preflight that prints the size and SHA-256 of the image it is given, compares them with the manifest's optional `expected_exe_size` / `expected_exe_sha256` fields (or with `--expect SHA256`), exits non-zero on a mismatch, checks the size before hashing so a truncated image is reported cheaply, and can emit JSON or the manifest keys for scripts. `docs/design.md` now lists it first in the day-one setup sequence. No game data, keys, or decryption are included. Tests use synthetic files and the repository's existing manifest keys only. ### Tested - `python -I tests/test_exe_sha.py` — 11 tests OK - `python -I tests/test_docs_cli_flags.py` — 4 tests OK - `python -I tests/test_docs_links.py` — 16 tests OK - `python -m compileall -q tools tests` — OK - `git diff --check` — clean GPUs tested: n/a (CPU-only CLI and unit tests) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] No new translator rule.
Contributors run the tools in `tools/` against their own copy of the game, and nothing checks that the copies are the
same file. A truncated or patched image still reports as "Executable found", and every RVA a note quotes is quietly
measured on something else (#8041).

`tools/exe_sha.py` prints the size and SHA-256 of the image it is given and compares them with the numbers the package
manifest records (`expected_exe_size`, `expected_exe_sha256`, both optional, read from the `game/*.json` whose
`expected_exe` names the file), or with `--expect SHA256` when a hash is quoted directly. It exits 1 on a mismatch and
0 when the numbers match or nothing is recorded, checks the size before hashing so a truncated 120 MB copy is reported
without reading it all, and `--print-keys` emits the two manifest lines for the file in hand. `--json` gives a script
the same numbers. `docs/design.md`'s "Day one" list now starts with it.

Measured on the retail Xbox 1.0.2.1 package: 120,181,760 bytes and sha256 e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993, the same pair #7123 records for the build preflight; that PR and this one are
the two halves of #8041.

Tests: `python -I tests/test_exe_sha.py` 11 OK (match, wrong hash, wrong size, manifest without the keys, `--expect`
both ways, a non-hash `--expect`, `--json`, `--print-keys`, a missing file, and the repository's own manifest).
`tests/test_docs_cli_flags.py` and `tests/test_docs_links.py` each have one failure that is already on `main`
(`docs/embedded_shaders.md`'s pass flags, `docs/dev-tools.md`'s `../runtime/README` link); the lists are identical
before and after this change. No game files or game-derived bytes in the diff.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:00:06 +00:00
github manually merged commit 49c81019c7 into gh-pr/437/base 2026-11-26 09:00:08 +00:00
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 08:51 UTC · original

Merging. Why merged: adds a read-only, standard-library-only check that a contributor's executable matches the recorded size and SHA-256 (no hashes of the game embedded; nothing downloaded).
Why it's good: security-reviewed; tested on Windows 11 + RTX 4070 SUPER on main 1c93c86: clean merge, exe_sha tests 9 -> 20 passed; the repo-consistency set stays 563/563 with 0 failures.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 08:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/437#issuecomment-7126659791) Merging. Why merged: adds a read-only, standard-library-only check that a contributor's executable matches the recorded size and SHA-256 (no hashes of the game embedded; nothing downloaded). Why it's good: security-reviewed; tested on Windows 11 + RTX 4070 SUPER on main 1c93c86: clean merge, exe_sha tests 9 -> 20 passed; the repo-consistency set stays 563/563 with 0 failures. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.