Repository navigation
Conversation
read_file refused a database but not its -wal/-shm/-journal siblings, so the model received lossy text and could write it back over a live WAL generation. The shared helper now strips a journal suffix and re-checks.
|
Implemented on Verified before closing: this PR's three tests ( You opened this before #114220 and my pre-flight sweep missed it, so the PR body did not credit you — that is on me. Recorded here: @strzhao is the first submitter of the read-side fix, and also the one who reproduced the write-side hole on main in #114091. If you want the |
|
Thanks for the close-out and for recording the first-submitter credit.
Taking you up on the offer: please cherry-pick |
A SQLite database's
-wal/-shm/-journalsiblings extend the database name instead of adding an extension (state.db→state.db-wal), so_has_extension_in— which compares the last dot-suffix,.db-wal— never matched them againstBINARY_EXTENSIONS. The main file was refused while its live sidecars passed every binary check, soread_filehanded the model lossy mojibake that a followingwrite_filecould put back over a live WAL generation.has_binary_extensionnow also matches a.db/.sqlite/.sqlite3name carrying one of those suffixes, so the shared helper sees the sidecars and the read guard refuses them — the same round trip #114091 closes at the write end.Reproduction, driven through the real tool entry points rather than read off the diff (Python 3.11.16 / SQLite 3.53.1, clean
origin/main98f758ae7echeckout):read_file("<dir>/state.db-wal")returns lossy text;write_file("<dir>/state.db-wal", "PLAIN TEXT OVERWRITE")lands 20 bytes; the nextsqlite3.connect("<dir>/state.db")raisesfile is not a database.Tests:
tests/tools/test_sqlite_sidecar_read_guard.py— 3 passed on this head, 2 of those failing on base98f758ae7e(the third case is the.sqlplain-text control, green on both revisions).tests/tools/test_binary_document_write_guard.pystays green; 20 passed together.Found while reviewing #114091. It is sent standalone so that PR stays a single concern; cherry-picking this commit into it is fine if you would rather keep the read and write halves in one place.