Repository navigation
text_tables: refuse a report that would overwrite a file read from a source directory (TEXT-TABLES-SOURCE-FILE-GUARD) - #1655
Conversation
|
Independent verification (Windows, Python 3.11.9): |
…source directory The output guard compared --dialogue/--tables/--strings only with the named sources and a carve's index.json. blobs() also reads every file below a plain source directory and every carved <offset>.bin/.bk2 beside index.json, so `text_tables.py src --tables src/notes.txt` read the file and then replaced it with the CSV (exit 0). Refuse such a report before anything is written; carved streams go through gamedata_index's carved_stream(). A new report inside a source directory is still allowed: it is written after the scan, so it was never an input. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73d744e to
e231d2c
Compare
|
Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). |
What changes
tools/text_tables.pychecked--dialogue/--tables/--stringsonly against the named sources and a carve'sindex.json. Butblobs()also reads every file below a plain source directory and every carved<offset:012x>.bin/.bk2besideindex.json, so a report path naming one of those files was read as input and then replaced by the CSV, with exit 0:The tool now refuses such a report before anything is written (
--tables would overwrite the input src/notes.txt, exit 2):report_paths.same_report_path) with every file below the source, only when the report already exists;gamedata_index.carved_stream()is reused, the same guardgamedata_index.pyapplies to its own reports (so the case/hard-link hardening proposed in gamedata_index: keep UTF-8 continuations in declared XML, fix ArchiveSource cleanup, and harden carved_stream/atomic I/O (GAMEDATA-INDEX-UTF8-DECL-AND-IO) #1578 applies here too).A new report inside a source directory is still written: it is created after the scan, so it was never an input (covered by a test).
The new check sits right after the existing
index.jsoncheck; it does not touch the lines changed by #1228, #738 or #818.Tests
Run in a sandbox (Linux, no network):
tests/test_text_tables.py: 36 OK (1 Windows-only skip) on this branch; with the new tests on main's tool,test_report_cannot_replace_a_file_read_from_a_source_directoryandtest_report_cannot_replace_a_carved_streamfail.test_report_paths.py,test_report_path_case.py,test_missing_input_exit_codes.py,test_gamedata_index.py: OK.scripts/check_no_game_data.py tools/text_tables.py tests/test_text_tables.py: clean. Synthetic fixtures only, no game data.Claimed in the coordination issue as: TEXT-TABLES-SOURCE-FILE-GUARD
AI-assisted.
🤖 Generated with Claude Code