Repository navigation
Audit fixes - #28
Merged
Merged
Audit fixes#28
Conversation
- Only compare hashes present in the audit file, so md5 only hashdeep files no longer report every file as modified - Resolve relative paths against hashdeep's "Invoked from" directory and treat ./file and file as the same, so audits work with absolute paths - Parse hashdeep lines without CSV so filenames with commas or quotes work - Accept md5sum/sha256sum style files (GNU and BSD tag) as audit input - Skip the audit file itself when it is inside the audited directory - Fail the audit on moved files, matching hashdeep - Report results in audit file order, then new files sorted - Escape filenames in sum output the same way md5sum does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Open the audit database read-only, without running migrations, and leave generated databases out of WAL mode so audits create no files - Track seen files in an on disk temporary table and stream the final report, so memory stays flat regardless of database size - Calculate the hashes stored in the database rather than using --hash - Store the invoked from directory in a metadata table so relative databases can be audited using absolute paths or from elsewhere - Detect moves using the strongest stored hash, handling duplicates - Skip the output file and SQLite sidecar files when processing - Restore hashdeep cross verification tests dropped on the branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hashdeep and md5sum keep the ./ when run against . or ./dir, while we cleaned it away, so hashdeep reported every file in an audit file we generated from . as moved. Running with no arguments is unchanged. SQLite audits now try paths with and without ./ so databases created either way still match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An mtime read error returned from the worker, which leaked the open file and stopped that worker processing any further files. Now the error is reported and the file is still hashed with mtime left unset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With --mtime the sum format wrote a "date file" line per file which md5sum -c reported as improperly formatted. It is now written as "# mtime date file". The audit parser still skips the old style lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SQLite audits calculate the hashes requested with --hash, or the defaults, and compare those the database also stores, warning when there are none in common. Output is labelled as a SQLite audit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Writing to an existing database merged into it, leaving rows for files which no longer exist so later audits reported them missing. Writing now fails unless --overwrite is passed, which replaces the database and is only allowed when the existing file is a SQLite database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every format now refuses to write over an existing --output file unless --overwrite is passed. Also report errors writing the output file, and exit non zero for a failed audit when writing to an output file. 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.
hashdeep audit fixes
Reproduced the failures reported in #12, which had four causes:
-c md5(e.g. by 1.4.0) have no sha256 column, and the empty value wascompared against the calculated sha256. Only hashes present in the audit file are now calculated and compared, along with size.
## Invoked from:directory as well as the current directory, and./fileandfileare treated as the same.,or"broke parsing. Lines are split by column position as hashdeep does not quote filenames, rather than parsed as CSV.files.
Also:
./the user supplied is kept in output paths, as hashdeep and md5sum do, sohashdeep -acan verifyhashit -f hashdeep .output.sum format
md5sum/sha256sumstyle (text and binary mode, escaped names), BSD--tagstyle, and hashit's own multi hashsum output. The hash is determined by file extension, then by length.
\or newlines the same way md5sum does, somd5sum -ccan verify it.--mtimelines are written as# mtime ...comments whichmd5sum -cignores.SQLite audit
Merges
sqliteauditand finishes it:-wal/-shmfiles.for a hashdeep file audit.
metadatatable so relative databases can be audited using absolute paths or from another directory.Older databases without it still work.
--hash(or the defaults) are calculated and compared where the database also has them, with a warning when there arenone in common.
hashit: SQLite Audit passed/failed.test-all.sh.Other fixes
Behaviour changes for release notes
./supplied on the command line is kept in output, e.g.hashit .prints./file. Running with no arguments is unchanged.--mtimein sum format is written as# mtime <time> <file>comment lines.--outputno longer replaces an existing file unless--overwriteis passed. For SQLite this replaces the database rather than merging into it,and is refused if the existing file is not a SQLite database.
--output.Testing
processor/audit_parser_test.goandprocessor/audit_test.go.test-all.shhas new tests covering the Add Audit Mode #12 scenarios: audit file inside the directory, absolute vs relative paths, md5 only hashdeep files,hashdeep verifying hashit output from
.and./sub, md5sum/sha256sum/BSD tag files,md5sum -cverifying sum output with and without--mtime,SQLite path resolution, no files left behind, moves, and overwrite protection.
test-all.shpasses in full.