mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:25:53 +01:00
[PR #616] exe_sha: validate 64-hex SHA-256, reject bool size, and fail on unreadable --manifest (EXE-SHA-VALIDATE) #657
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#657
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/616
Author: @hamdog0203
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/exe-sha-validate📝 Commits (1)
c09daf1exe_sha: validate 64-hex SHA-256, reject bool size, and fail on unreadable --manifest (EXE-SHA-VALIDATE)📊 Changes
2 files changed (+74 additions, -9 deletions)
View changed files
📝
tests/test_exe_sha.py(+48 -0)📝
tools/exe_sha.py(+26 -9)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.