Skip to content

Audit tests and fixes - #38

Merged
boyter merged 4 commits into
masterfrom
audit-tests-and-fixes
Nov 3, 2026
Merged

boyter merged 4 commits into
masterfrom
audit-tests-and-fixes

Conversation

@boyter

@boyter boyter commented Nov 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

boyter and others added 2 commits November 3, 2026 11:09
…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>
@pr-insights pr-insights Bot added M/size Normal or medium sized change VH/complexity Very high complexity labels Nov 3, 2026
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 thread processor/audit.go
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`)
Comment thread main_audit_test.go Outdated
if !s.resolvable() {
return ""
}
w := t.TempDir()
Comment thread main_audit_test.go
Comment on lines +488 to +489
case rc == 2:
problem = "audit error"
Comment thread processor/formatters.go Outdated
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>
@boyter
boyter merged commit 3fab78e into master Nov 3, 2026
1 check passed
@boyter
boyter deleted the audit-tests-and-fixes branch November 3, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M/size Normal or medium sized change VH/complexity Very high complexity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants