Repository navigation
Audit tests and fixes - #38
Merged
Merged
Conversation
…dit tests and fuzzers Each file now votes for every directory a relative record names it through, and is checked against the record for the chosen directory rather than the first found. Sum files group lines naming the same file through the chosen directory, or every tied one. A record naming the audit file through the working directory is decided after the directory is chosen when there is no invoked from line. SQLite statements are prepared once, and the collate check ignores names. Adds main_audit_test.go (matrix, regressions, FuzzAudit, sweep), parser fuzzers, test-audit.sh run from test-all.sh, and a Testing section in the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When as many files matched through two directories, the audit was matched through the first in priority order, so a file moved onto the path of a known file could match another record through it with the record it should have matched reported as moved. A tree copied with its manifest kept in a subdirectory, with README moved onto meta/README, passed with --allow-moved for hashdeep and SQLite. The audit is now checked through each tied directory and passes only when it passes through every one, with a warning naming the directory it fails through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sha1sum, sha224sum, sha256sum, sha384sum, sha512sum and b2sum verify hashit's sum files and fail them once a file is modified, as hashit does, and md5sum fails the tie scenario as hashit does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Active findings identify a critical path-indexing flaw that can hide modifications with --allow-moved, plus report-memory growth, sweep disk accumulation, and test checks that can accept terminated audits.
4 open issues
What changed in this PR
This PR strengthens hashit’s audit validation across hashdeep, sum, and SQLite formats, focusing on ambiguous paths and files moved onto known paths.
Changes:
- Reworks candidate matching and checks audits through every equally matched directory.
- Refines manifest self-entry handling, sum-file grouping, and SQLite collation detection.
- Adds regression, matrix, fuzz, and command-line tests, with expanded testing documentation.
| File | Description |
|---|---|
test-audit.sh |
Adds audit scenarios checked against external checksum tools. |
test-all.sh |
Integrates the audit scenario script. |
README.md |
Documents testing and updated path-matching behavior. |
processor/formatters.go |
Adds per-directory audit judgment and tied-directory handling. |
processor/audit.go |
Updates SQLite candidate lookup, statement caching, and schema validation. |
processor/audit_test.go |
Tests collation-clause detection. |
processor/audit_parser.go |
Tracks per-directory candidates and refines record grouping and exclusion. |
processor/audit_fuzz_test.go |
Adds parser and path-resolution fuzz tests. |
main_audit_test.go |
Adds end-to-end audit matrices, regressions, fuzzing, and sweeps. |
Review effort: Balanced
Comment on lines
371
to
+372
| select rid, filepath from temp.paths where abs = ? and level = ? | ||
| ) order by rid limit 1`, append(candidates, abs, level)...).Scan(&filePath) | ||
| ) order by rid limit 1`) |
| if !s.resolvable() { | ||
| return "" | ||
| } | ||
| w := t.TempDir() |
Comment on lines
+488
to
+489
| case rc == 2: | ||
| problem = "audit error" |
Comment on lines
+317
to
+318
| var output bytes.Buffer | ||
| stdout = &checkedWriter{w: &output} |
…ng their report A database path such as ././README is looked up through temp.paths, which kept only the most preferred directory for each absolute path. In a copied tree with the database in meta, the record naming meta/README through the working directory was lost to the one naming it through meta, so an unchanged copy failed and a file moved onto meta/README with a backup kept passed --allow-moved. Each directory now has its own entry, as for hashdeep and sum files. A tied audit is judged through each directory with its report discarded, then the one reported is judged again writing it, rather than holding the report in memory. The audit tests remove each scenario's directory when it returns, as a sweep runs every seed in one test, and treat any exit other than 0 or 1, such as being killed, as an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.


No description provided.