Skip to main content

AuditEvent

Struct AuditEvent 

Source
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: u64

Unix milliseconds. A number rather than a formatted string so the log stays sortable without a date parser.

§kind: String

What 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

Source

pub fn new(kind: impl Into<String>) -> Self

Start an event of the given kind, stamped now.

Source

pub fn with_identity(self, identity: Option<Identity>) -> Self

Attach the caller’s identity.

Source

pub fn with_client(self, client: impl Into<String>) -> Self

Attach the client address.

Source

pub fn with_route(self, route: impl Into<String>) -> Self

Attach the request route.

Source

pub fn with_command(self, command: impl Into<String>) -> Self

Attach the command line that ran.

Source

pub fn with_session(self, session_id: u64) -> Self

Attach the session the command ran in.

Source

pub fn with_outcome( self, exit_code: Option<i32>, timed_out: bool, duration_ms: u64, ) -> Self

Attach the outcome of an execution.

Source

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.

Source

pub fn with_denial(self, status: u16, reason: impl Into<String>) -> Self

Attach a refusal.

Source

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.

Source

pub fn with_digest(self, verified: bool) -> Self

Record whether the declared digest matched.

Source

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

Source§

fn clone(&self) -> AuditEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuditEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AuditEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for AuditEvent

Source§

fn eq(&self, other: &AuditEvent) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AuditEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AuditEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more