exe_sha: validate 64-hex SHA-256, reject bool size, and fail on unreadable --manifest (EXE-SHA-VALIDATE) #616
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/616"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by hamdog0203 on 2026-11-24T10:00:03Z.
Claimed in the coordination issue as: EXE-SHA-VALIDATE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128088818)
Depends on: none
What and why
Fixes four validation gaps in
tools/exe_sha.py:check()andrecorded()only checkedlen == 64for SHA-256 digests, so 64 non-hex characters (e.g."z" * 64) bypassed the format check, hashed the entire file, and reported a hash mismatch instead of"is not a SHA-256 (64 hex digits)".recorded()also didn't strip surrounding whitespace.recorded()acceptedboolforexpected_exe_size(isinstance(True, int)isTruein Python).result["status"]as"unrecorded"instead of"match".--manifestsilently fell back tounrecorded(exit 0) instead of exiting2, and UTF-8 BOM manifests were rejected byjson.load.The fix
_valid_sha256()(strip + lowercase + 64 hex-digit check) and used it in bothrecorded()andcheck().boolinrecorded()(not isinstance(size, bool)), switched manifest reads infind_manifest()andrecorded()toencoding="utf-8-sig", and addedstrict=(manifest is not None)so explicit--manifesterrors propagate tomain()and exit2.status = "match"incheck().if __name__ == "__main__":untouched to avoid conflicting with #605.tests/test_exe_sha.py.Tested
Windows 11 (26200.9974), Python 3.12.10, CPU only, no game files.
python -I tests/test_exe_sha.py -v: 16/16 OKmain21625bca8'stools/exe_sha.py): FAILED (failures=5)python -m compileall -q tools/exe_sha.py tests/test_exe_sha.py: exit 0python -I scripts/check_no_game_data.py tools/exe_sha.py tests/test_exe_sha.py: exit 0python -I tests/test_text_write_line_endings.py: 3/3 OKgit diff --check: cleanAI-assisted: yes.
Imported from ubiquitarianism/leonida. Originally posted by madvillain91 on 2026-11-24T10:30:52Z.
Review: COMMENTED
Tested locally on Windows 11 — all 16 tests in \ ests/test_exe_sha.py\ pass. The _valid_sha256()\ helper, \ool\ size guard, \utf-8-sig\ BOM handling, and strict --manifest\ error path all look clean. LGTM.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T13:03:36Z.
Red/green: tests/test_exe_sha.py fails on main (1 failed, -x), passes with the PR (16 passed).
Targeted batch of 30 PRs (their tests, the tests importing the changed modules, the docs tests, the translator suite) on main
a997a3c: no new failure, Windows 11 / Python.AI-assisted (Claude Code, Claude Opus 5.5)