restofworld_index: validate scan bounds, fix carve index .bk2/BOM, harden I/O (RESTOFWORLD-INDEX-VALIDATION-AND-IO) #1535
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1535
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/restofworld-index-hardening"
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 successfully merged and closed
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
Red/green:
pytest tests/test_restofworld_index.pyfails on main (3 failed, 34 passed, 8 subtests passed) and passes on head 1ca8b83b4a55 merged with main (36 passed, 1 skipped, 8 subtests passed).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)