mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1535] restofworld_index: validate scan bounds, fix carve index .bk2/BOM, harden I/O (RESTOFWORLD-INDEX-VALIDATION-AND-IO) #1564
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#1564
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/1535
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/restofworld-index-hardening📝 Commits (1)
1ca8b83restofworld_index: validate scan bounds, fix carve index .bk2/BOM, harden I/O📊 Changes
2 files changed (+169 additions, -29 deletions)
View changed files
📝
tests/test_restofworld_index.py(+80 -0)📝
tools/restofworld_index.py(+89 -29)📄 Description
What changed
tools/restofworld_index.py:scan_rpf,scan_dir): rejectbool,<= 0limit/max_inflate, and non-integerstartwithValueError. Previouslyscan_rpf(..., limit=0)silently scanned the entire archive, negativelimitproduced a negativespan, andmax_inflate <= 0silently skipped every stream.tools/restofworld_index.py:scan_rpf): requires + 0x1C <= endbefore reading header dimensions (matchingtools/rpf9_carve.py) and bound the slice passed toclassify()bys + blen..bk2mapping, and summary validation (tools/restofworld_index.py:_carve_index):index.jsonwithencoding="utf-8-sig"so UTF-8 BOM-prefixed indexes are not silently ignored.type == "bink2"rows to<off>.bk2(matchingrpf9_carve.py) instead of hardcoding.bin.off,stored,span,zero_padding, andunread_bytesare non-negative non-bool integers so malformed summary values fall back cleanly instead of crashingscan_dir().tools/restofworld_index.py:write_output,main):report_paths.same_report_path(withos.path.samestatfor hardlinks) so case-folding, NFD, and dangling symlink aliases to the source archive or carved directory payloads/index.jsonare caught before scanning.allow_nan=Falseand a trailing LF, publish viareplace_retry.replace, allow optionalargv=Noneinmain(argv=None), and catchValueErroralongsideOSErrorwhen writing.tests/test_restofworld_index.py): added 3 synthetic regression tests covering API validation, BOM/.bk2/malformed-summary carve indexes, strict JSON/trailing LF, and dangling-symlink overwrite guards.Claimed in the coordination issue as:
RESTOFWORLD-INDEX-VALIDATION-AND-IO(https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7152205891)How it was tested
python3 -I -W error tests/test_restofworld_index.py: 37/37 passed (0 warnings).python3 -I tests/test_bad_input_errors.py: 11/11 passed.python3 -I tests/test_csv_line_endings.py: 2/2 passed.python3 -I tests/test_limit_window.py: 1/1 passed.python3 -I tests/test_printable_bytes.py: 4/4 passed.python3 -I tests/test_zero_span.py: 3/3 passed.python3 -I tests/test_text_write_line_endings.py: 3/3 passed.python3 -I scripts/check_no_game_data.py tools/restofworld_index.py tests/test_restofworld_index.py: passed.python3 -m compileall -q tools/restofworld_index.py tests/test_restofworld_index.py: passed.main:tools/restofworld_index.py: all 3 new tests fail (FAILED (failures=3)), all 34 baseline tests pass.Metadata
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.