feat: scope-compliance audit trail for every request#17
Merged
Conversation
Adds an append-only audit log that records the scope decision (pass/fail/skip) for every request the scanner makes. ScopeGuard already enforced scope but kept no record; on a real engagement you often need to prove after the fact that every request stayed inside the authorized allowlist. This is that record. - New audit_log.AuditLog: append-only JSONL at ~/.hermes/audit.jsonl, one line per request (url, method, scope_check, ts, schema_version, optional session_id/status). Size-rotated, fcntl-locked, fail-closed validation, tolerant reads, and a summary() rollup that flags out-of-scope hosts. - SecurityScanner gains an optional audit_log; _make_request routes both the initial and redirect scope checks through _scope_check, which records the outcome. Wiring is behaviour-preserving: with no audit log attached it is identical to the previous inline scope.check, and audit I/O never breaks a scan. - Tests for the module and the engine wiring. Pattern adapted from shuvonsec/claude-bug-bounty (MIT), whose memory/audit_log.py logs scope_check per request. Reworked to this project's conventions and consolidated (schema + rotation) into one dependency-free module. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 12, 2026
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.
What
Adds a scope-compliance audit trail: an append-only log recording the scope decision (
pass/fail/skip) for every request the scanner makes.ScopeGuardalready enforces scope, but keeps no record — this is the accountability layer that lets you prove, after an engagement, that every request stayed inside the authorized allowlist.Pieces
audit_log.AuditLog— append-only JSONL (default~/.hermes/audit.jsonl), one line per request:url,method,scope_check,ts,schema_version, plus optionalsession_id/response_status. Size-rotated withkeep-backups,fcntl-locked appends, fail-closed validation, corruption-tolerant reads, and asummary()rollup that flags out-of-scope hosts. Dependency-free (stdlib only).SecurityScannergains an optionalaudit_log._make_requestroutes both the initial and redirect scope checks through a new_scope_check, which records the outcome.Safety of the wiring
Behaviour-preserving by construction: with no
audit_logattached,_scope_checkis identical to the previous inlineself.scope.check(url)— same enforcement, sameOutOfScopeErrorhard-stop. Audit I/O and validation errors are swallowed inside_record_scope, so a full disk or lock contention can never break a scan. It's an accountability log only — it carries the scope decision, never findings, payloads, or secrets.Tests
tests/test_audit_log.py(module: counts, rotation, locking-safe append, fail-closed validation, corruption tolerance, session id) andtests/test_scope_audit.py(engine wiring: pass/fail/skip recorded,OutOfScopeErrorstill propagates, inert without a log). Verified locally by executing the module directly and simulating the_scope_checklogic against realScopeGuard/AuditLoginstances.Attribution
Pattern adapted from shuvonsec/claude-bug-bounty (MIT) — its
memory/audit_log.pylogsscope_checkper request. Reworked to this repo's conventions and consolidated (schema + rotation into one module).🤖 Generated with Claude Code