pub struct AuditEntry {
pub id: String,
pub timestamp: DateTime<Utc>,
pub profile: String,
pub operation: String,
pub key: Option<String>,
pub status: AuditStatus,
pub message: Option<String>,
pub context: Option<AuditContext>,
pub prev_entry_hmac: Option<String>,
}Expand description
One structured audit event. Written as a single JSON line (JSONL).
§Audit integrity contract (v2)
Entries are chronologically ordered (append-only JSONL) and each entry
carries a prev_entry_hmac field: the hex-encoded HMAC-SHA256 of the
immediately preceding entry’s canonical JSON, keyed by the session’s
ephemeral chain key held in AuditLog.
What this provides:
- Within-session tamper detection: modification, insertion, or deletion of
entries written during a single session can be detected via
AuditLog::verify_chain.
Explicit ceiling:
- The chain key is ephemeral (generated at
AuditLog::new(), never persisted). Cross-session verification is not possible. Old entries written before v2 (noprev_entry_hmac) are treated as chain anchors and do not cause verification failures on their own. - Filesystem-level attacks (deleting the file, swapping it entirely) are not detectable without an external root of trust.
Fields§
§id: String§timestamp: DateTime<Utc>§profile: String§operation: String§key: Option<String>§status: AuditStatus§message: Option<String>§context: Option<AuditContext>§prev_entry_hmac: Option<String>HMAC-SHA256 of the previous entry’s canonical JSON, hex-encoded.
None for the first entry in a session, for entries written before the
v2 chain was introduced, or after a cross-session chain break.
Verification is only meaningful within a single AuditLog session.
Implementations§
Source§impl AuditEntry
impl AuditEntry
Sourcepub fn success(profile: &str, operation: &str, key: Option<&str>) -> Self
pub fn success(profile: &str, operation: &str, key: Option<&str>) -> Self
Build a success entry with a new UUID and the current UTC timestamp.
Sourcepub fn failure(
profile: &str,
operation: &str,
key: Option<&str>,
message: &str,
) -> Self
pub fn failure( profile: &str, operation: &str, key: Option<&str>, message: &str, ) -> Self
Build a failure entry with a new UUID, the current UTC timestamp, and an error message.
Sourcepub fn with_context(self, context: AuditContext) -> Self
pub fn with_context(self, context: AuditContext) -> Self
Attach optional structured context without changing the legacy fields.
Trait Implementations§
Source§impl Clone for AuditEntry
impl Clone for AuditEntry
Source§fn clone(&self) -> AuditEntry
fn clone(&self) -> AuditEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more