text_tables: refuse a report that would overwrite a file read from a source directory (TEXT-TABLES-SOURCE-FILE-GUARD) #1655
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1655"
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?
Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T07:19:02Z.
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 #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
Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T11:12:50Z.
Independent verification (Windows, Python 3.11.9):
input_under()reusesgamedata_index.carved_stream()for carve dirs and walks plain dirs viasame_report_pathonly when the report already exists — wired for all three outputs,ap.errorexit 2 before writes.test_text_tables.py36 OK; neighbors report_paths/report_path_case/missing_input_exit_codes/gamedata_index all OK; manual probes correct (existing file in source dir -> exit 2 preserved; new file -> written). check_no_game_data clean. Minor non-blocking: TOCTOU window between pre-scan and write; a report naming a directory inside the source is allowed (fails later at write). AI-assisted verification.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:43:33Z.
Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 18 PRs (their tests, the tests importing the changed modules, the docs tests) on main
3ca0707: no new failure, Linux / Python 3.13.AI-assisted (Claude Code, Claude Opus 5.5)