fix(plugin): reject SQLite snapshot self-copy - #513
Conversation
|
I reproduced this against current |
3d066b2 to
c829688
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Thanks for the pointer. I rebased onto current |
Hughhhhcoder
left a comment
There was a problem hiding this comment.
I checked the rebased head 3655b37a locally. The focused regression passes (1 passed) and Ruff lint is clean, but the repository-pinned formatter (ruff==0.16.1) still reports plugins/codex-security/tests/test_snapshot_sqlite.py as unformatted: the multiline assertion at the end is collapsed to one line. Running uv run --project plugins/codex-security --extra test ruff format plugins/codex-security/tests/test_snapshot_sqlite.py (then the corresponding ruff format --check) should clear the gate before fork CI is approved.
|
Thanks for catching the formatter gate. I ran the repository-pinned Ruff formatter on the regression, verified ruff format --check, reran the focused snapshot test (1 passed), and pushed 606ee03 to the same branch. |
Hughhhhcoder
left a comment
There was a problem hiding this comment.
Rechecked the updated head 606ee037. The focused self-copy/hard-link regression passes, Ruff lint and the repository-pinned format check are clean, and git diff --check passes. The formatter issue is resolved; I do not see a remaining correctness blocker in this scoped patch.
|
Thanks for rechecking the updated head and the formatter gate. Appreciate the approval. |
Summary
Fail fast when
snapshot_sqlite.pyis asked to back up a SQLite database onto the same filesystem object.Fixes #512.
Problem
The helper opens the source database read-only, opens the destination separately, and calls
sqlite3.Connection.backup(). When both connections refer to the same database file, the backup does not make progress and the command can remain stuck indefinitely.A string comparison is insufficient because another path, including a hard-link alias, can identify the same database.
Changes
mainand moved the fix to the canonical plugin source underplugins/codex-security.Path.samefile()to compare filesystem identity with the resolved source.argparsebefore either SQLite connection is opened.Validation
The regression covers:
Pushed-head CI is required for the full repository validation.
Risk
Low. The normal snapshot path is unchanged. The new check runs only when the destination already exists and rejects only destinations that the operating system reports as the same file as the source.