Skip to content

audit

diapason.security.audit

Audit logger — persist security events to SQLite with Merkle hash chain.

AuditLogger

Append-only SQLite audit log for security events.

Parameters

db_path: Path to the SQLite database file. bus: Optional event bus — if provided, subscribes to security events (SECURITY_SCAN, SECURITY_ALERT, SECURITY_BLOCK).

close()

Close the SQLite connection.

count()

Return the total number of logged security events.

log(event)

Insert a security event into the audit log with Merkle hash chain.

query(*, event_type=None, since=None, limit=100)

Query logged security events with optional filters.

tail_hash()

Return the hash of the last row in the chain, or empty string.

verify_chain()

Verify the Merkle hash chain integrity.

Returns

tuple (True, None) if the chain is valid, or (False, row_id) where row_id is the first broken link.