fix(drive,docs): guard the audit log's exemption against a resolved OMNI_DEV_LOG_FILE - #1717
Merged
Merged
Conversation
…MNI_DEV_LOG_FILE omni-dev log prune refused --audit outright, but nothing stopped OMNI_DEV_LOG_FILE from being pointed at audit.jsonl directly, via a `..` segment, or via a symlink -- the obvious workaround, which let log prune or OMNI_DEV_LOG_MAX_SIZE rotation destroy the fail-closed audit trail ADR-0080 Section 11 promises is unprunable. request_log::prune and size-capped rotation now both refuse outright when the path they were handed resolves to the audit file, compared by file identity via the same-file crate (inode on unix, a file handle on Windows) where both sides exist, else a lexically-..-collapsed canonicalized comparison so a not-yet-created symlink target is still caught. record_audit's own collision guard is upgraded to the same file-identity comparison. Fixes #1694.
CoverageTotal: 97.27% ⚪ 0 pp vs Comparing
🔇 5 ignored region(s), 0 tolerated region(s)
Patch coveragePatch: 96.39% (187/194 new lines covered)
Uncovered new lines (7)
Indirect coverage changes🔴 0 lines lost coverage, 🟢 6 lines gained coverage on unchanged code. Indirect changes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
omni-dev log prune/OMNI_DEV_LOG_MAX_SIZErotation now refuse outright when the path they're handed resolves to the audit file — closing the..-segment/relative/symlink workaround around the--auditflag check.record_audit's own collision guard upgraded to the same file-identity comparison.Test plan
cargo buildcargo test --lib(9505 passed)cargo clippy --all-targets -- -D warningscargo doc --no-deps --document-private-items(the CI Docs job's exact command)/code-review high. The original hand-rolled(dev, ino)file-identity check had no real equivalent on non-unix, silently weakening this exact guard on the one non-unix platform this project ships binaries for (Windows) — switched to thesame-filecrate (already in the dependency graph transitively viawalkdir), which does real cross-platform file identity (inode on unix, a file handle on Windows), keeping the hand-rolled symlink-following logic only as a fallback for the not-yet-existing-target casesame-filecan't handle. Also extracted a magic literal to a named constant and documented the residual TOCTOU window between the check and the destructive read/rewrite (narrows it, does not close it — same shape as an existing inode re-check elsewhere in this codebase).