pub struct AuditEvent {Show 18 fields
pub at_ms: u64,
pub kind: String,
pub identity: Option<Identity>,
pub client: Option<String>,
pub route: Option<String>,
pub command: Option<String>,
pub session_id: Option<u64>,
pub exit_code: Option<i32>,
pub timed_out: Option<bool>,
pub duration_ms: Option<u64>,
pub output_bytes: Option<u64>,
pub status: Option<u16>,
pub reason: Option<String>,
pub file: Option<String>,
pub bytes: Option<u64>,
pub entries: Option<u64>,
pub digest_ok: Option<bool>,
pub upload_id: Option<String>,
}Expand description
One recorded event.
Fields§
§at_ms: u64Unix milliseconds. A number rather than a formatted string so the log stays sortable without a date parser.
kind: StringWhat happened: execute, denied, …
identity: Option<Identity>Caller identity, when the request was authenticated.
client: Option<String>Client address as the server saw it.
route: Option<String>Request method and path, for correlating with access logs.
command: Option<String>The command line, for execution events.
This is the substance of the trail — “someone called POST /execute” says almost nothing on its own. It also means a command that embeds a secret puts that secret in the log, which is the trade an audit trail makes.
session_id: Option<u64>Session the command ran in, when it was not a one-shot.
exit_code: Option<i32>Process exit code, when the command completed.
timed_out: Option<bool>Whether the command hit its timeout.
duration_ms: Option<u64>How long it took.
output_bytes: Option<u64>Bytes the command’s output ran to, when more than the response carried.
Present only on an execution whose output was capped, so its presence is the signal: a trail entry without it describes a response that carried everything. Recorded because the response itself is not kept — without this, “why was that result short?” has no answer after the fact, and a short answer is indistinguishable from a short command.
Separate from bytes, which counts what a transfer moved. Reusing it
would make one field mean two things depending on kind.
status: Option<u16>HTTP status, for denial events.
reason: Option<String>Why a request was refused (missing-token, invalid-token, …).
file: Option<String>Path a file operation touched, relative to the configured root.
bytes: Option<u64>Bytes transferred. Present on terminal transfer events.
entries: Option<u64>Entries a tree operation counted or removed. Present on fs.delete
events that acted on a directory.
digest_ok: Option<bool>Whether the declared digest matched what arrived.
upload_id: Option<String>The upload session’s id.
Recorded on upload.start and on any event that cannot carry file
(see with_upload_id’s doc comment) so the two can still be joined
into one session’s story.
Implementations§
Source§impl AuditEvent
impl AuditEvent
Sourcepub fn with_identity(self, identity: Option<Identity>) -> Self
pub fn with_identity(self, identity: Option<Identity>) -> Self
Attach the caller’s identity.
Sourcepub fn with_client(self, client: impl Into<String>) -> Self
pub fn with_client(self, client: impl Into<String>) -> Self
Attach the client address.
Sourcepub fn with_route(self, route: impl Into<String>) -> Self
pub fn with_route(self, route: impl Into<String>) -> Self
Attach the request route.
Sourcepub fn with_command(self, command: impl Into<String>) -> Self
pub fn with_command(self, command: impl Into<String>) -> Self
Attach the command line that ran.
Sourcepub fn with_session(self, session_id: u64) -> Self
pub fn with_session(self, session_id: u64) -> Self
Attach the session the command ran in.
Sourcepub fn with_outcome(
self,
exit_code: Option<i32>,
timed_out: bool,
duration_ms: u64,
) -> Self
pub fn with_outcome( self, exit_code: Option<i32>, timed_out: bool, duration_ms: u64, ) -> Self
Attach the outcome of an execution.
Sourcepub fn with_truncated_output(self, truncated: bool, total_bytes: u64) -> Self
pub fn with_truncated_output(self, truncated: bool, total_bytes: u64) -> Self
Record that an execution produced more output than was returned.
A no-op when nothing was discarded, so callers can hand over both figures unconditionally and the field stays a truncation signal rather than a size that is present on every entry.
Sourcepub fn with_denial(self, status: u16, reason: impl Into<String>) -> Self
pub fn with_denial(self, status: u16, reason: impl Into<String>) -> Self
Attach a refusal.
Sourcepub fn with_file(self, path: impl Into<String>, bytes: Option<u64>) -> Self
pub fn with_file(self, path: impl Into<String>, bytes: Option<u64>) -> Self
Attach the file a transfer touched, and how many bytes moved.
Recorded on terminal events only. A chunk-level trail would turn one gigabyte-scale transfer into hundreds of lines and bury everything else in the log.
Sourcepub fn with_digest(self, verified: bool) -> Self
pub fn with_digest(self, verified: bool) -> Self
Record whether the declared digest matched.
Sourcepub fn with_upload_id(self, id: impl Into<String>) -> Self
pub fn with_upload_id(self, id: impl Into<String>) -> Self
Attach the upload session’s id.
Every terminal upload event but one can name its subject through
file (the destination). The exception is upload.orphaned: a
.part staging file found at startup carries only the id encoded in
its own filename — the destination it was headed for lived in the
in-memory session that a restart already discarded, so there is
nothing left to attach as file. upload_id is how a reader
recovers that link anyway: it is also recorded on upload.start
(which does have file), so grepping the trail for one upload’s id
still surfaces both ends of its story.
Trait Implementations§
Source§impl Clone for AuditEvent
impl Clone for AuditEvent
Source§fn clone(&self) -> AuditEvent
fn clone(&self) -> AuditEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more