Skip to content

fix(scripts): protect latency CSV from cache path collisions - #368

Open
skyc1e wants to merge 1 commit into
circlefin:mainfrom
skyc1e:fix/protect-latency-report-csv
Open

fix(scripts): protect latency CSV from cache path collisions#368
skyc1e wants to merge 1 commit into
circlefin:mainfrom
skyc1e:fix/protect-latency-report-csv

Conversation

@skyc1e

@skyc1e skyc1e commented Sep 7, 2026

Copy link
Copy Markdown

Passing the same file to --csv and --db with --rebuild-db deletes the source before reading it. With a valid header-only CSV, the command even exits successfully after replacing the input with a SQLite database.

Reject matching file identities before opening the cache or rebuilding it, including relative paths, symlinks, and hardlinks. The CLI now reports --csv and --db must refer to different files, exits with status 1, and leaves the source unchanged. Normal reporting with a separate cache is preserved.

Validation:

  • cd scripts && python -m unittest test_tx_latency_report -q: 54 tests, successful with one symlink subtest skipped because Windows requires additional privileges. The hardlink case passes.
  • Added seven regression/success tests; the rejection cases fail against the original script.
  • Confirmed the real CLI changes from exit 0 with overwritten input to exit 1 with identical source bytes, using a temporary CSV.
  • git diff --check passes. Tested with Python 3.12.14; Rust/node integration tests were not run for this Python-only change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant