sgd5_effects: enforce database bounds in program_groups, guard program_identity EOF, validate layout (SGD5-EFFECTS-BOUNDARY-VALIDATION) #1589

Open
github-bot wants to merge 1 commit from github-bot/gh-1589 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 05:19 UTC · original
IlyassRS3:fix/sgd5-effects-boundary-validation → main · +69 −4 · 2 files · 1 commits · open

Item: SGD5-EFFECTS-BOUNDARY-VALIDATION (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/sgd5_effects.py).

Summary

  • Enforce limit before every read in program_groups() (group count headers, per-group count upper bound against the 176-byte minimum program record size, program label/tag/size framing, and effect-count header in read_database()) so malformed records in database 1 never read past limit into following archive data.
  • Guard program_identity() against negative offsets, EOF, short length bytes (< 2), and truncated windows so it raises ValueError instead of crashing with IndexError on stream.read(1)[0] or window[pos - 1].
  • Validate layout ordering (0 <= database, first_group >= database + 4, end > first_group) up front in read_database(), and pass allow_nan=False to json.dumps() in main().

Verification

  • python3 -W error -I tests/test_sgd5_effects.py -v: 12 passed, 1 skipped (retail package test without LEONIDA_GAME_DIR).
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/sgd5_effects.py tests/test_sgd5_effects.py: passed.
  • python3 -m compileall -q tools/sgd5_effects.py tests/test_sgd5_effects.py: passed.
  • Mutation check (running tests/test_sgd5_effects.py against unpatched main:tools/sgd5_effects.py): failures=7, errors=2 across all new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python binary metadata parser; synthetic SGD5 blobs only, no game data)

**@⁠IlyassRS3** on GitHub · 2026-11-25 05:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1589) `IlyassRS3:fix/sgd5-effects-boundary-validation` → `main` · +69 −4 · 2 files · 1 commits · open Item: `SGD5-EFFECTS-BOUNDARY-VALIDATION` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/sgd5_effects.py`). ### Summary - Enforce `limit` before every read in `program_groups()` (group count headers, per-group count upper bound against the 176-byte minimum program record size, program label/tag/size framing, and effect-count header in `read_database()`) so malformed records in database 1 never read past `limit` into following archive data. - Guard `program_identity()` against negative offsets, EOF, short length bytes (`< 2`), and truncated windows so it raises `ValueError` instead of crashing with `IndexError` on `stream.read(1)[0]` or `window[pos - 1]`. - Validate `layout` ordering (`0 <= database`, `first_group >= database + 4`, `end > first_group`) up front in `read_database()`, and pass `allow_nan=False` to `json.dumps()` in `main()`. ### Verification - `python3 -W error -I tests/test_sgd5_effects.py -v`: 12 passed, 1 skipped (retail package test without `LEONIDA_GAME_DIR`). - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/sgd5_effects.py tests/test_sgd5_effects.py`: passed. - `python3 -m compileall -q tools/sgd5_effects.py tests/test_sgd5_effects.py`: passed. - Mutation check (running `tests/test_sgd5_effects.py` against unpatched `main:tools/sgd5_effects.py`): `failures=7, errors=2` across all new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python binary metadata parser; synthetic SGD5 blobs only, no game data)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:57:24 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 05:19 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 05:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1589#pullrequestreview-6052229800) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1589/head:github-bot/gh-1589'
git switch 'github-bot/gh-1589'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1589'
git switch 'github-bot/gh-1589'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1589'
git switch 'github-bot/gh-1589'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1589'
git switch 'main'
git merge --squash 'github-bot/gh-1589'
git switch 'main'
git merge --ff-only 'github-bot/gh-1589'
git switch 'main'
git merge 'github-bot/gh-1589'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.