Skip to main content

AuditLog

Struct AuditLog 

Source
pub struct AuditLog { /* private fields */ }
Expand description

Audit log for recording and verifying security events.

Implementations§

Source§

impl AuditLog

Source

pub fn open(path: impl AsRef<Path>, runtime_key: KeyPair) -> AuditResult<Self>

Create a new audit log with SurrealKV persistence.

§Errors

Returns an error if the storage backend fails to open at the given path.

Source

pub fn in_memory(runtime_key: KeyPair) -> Self

Create an in-memory audit log (for testing).

Source

pub fn append( &self, session_id: SessionId, action: AuditAction, authorization: AuthorizationProof, outcome: AuditOutcome, ) -> AuditResult<AuditEntryId>

Append a new audit entry.

§Errors

Returns an error if the entry cannot be stored or the chain head cannot be updated.

Source

pub fn append_with_principal( &self, session_id: SessionId, principal: PrincipalId, action: AuditAction, authorization: AuthorizationProof, outcome: AuditOutcome, ) -> AuditResult<AuditEntryId>

Append a new audit entry tagged with the acting principal.

Use this when the action was performed on behalf of a specific user (e.g., cross-principal KV write, tool execution). The principal is included in the cryptographic signing data.

§Errors

Returns an error if the entry cannot be stored or the chain head cannot be updated.

Source

pub fn get(&self, id: &AuditEntryId) -> AuditResult<Option<AuditEntry>>

Get an entry by ID.

§Errors

Returns an error if the storage backend fails to retrieve the entry.

Source

pub fn get_session_entries( &self, session_id: &SessionId, ) -> AuditResult<Vec<AuditEntry>>

Get all entries for a session.

§Errors

Returns an error if the storage backend fails to retrieve entries.

Source

pub fn verify_chain( &self, session_id: &SessionId, ) -> AuditResult<ChainVerificationResult>

Verify the integrity of all audit chains in a session.

Each principal (and the system chain) is verified independently. A session with entries from principals “alice” and “bob” plus system entries will verify three independent chains.

§Errors

Returns an error if entries cannot be retrieved from storage.

Source

pub fn verify_principal_chain( &self, session_id: &SessionId, principal: Option<&PrincipalId>, ) -> AuditResult<ChainVerificationResult>

Verify the integrity of a single principal’s chain within a session.

Pass None to verify the system chain (entries without a principal).

§Errors

Returns an error if entries cannot be retrieved from storage.

Source

pub fn get_principal_entries( &self, session_id: &SessionId, principal: Option<&PrincipalId>, ) -> AuditResult<Vec<AuditEntry>>

Get entries for a specific principal within a session.

Pass None to get system entries (no principal).

§Errors

Returns an error if entries cannot be retrieved from storage.

Source

pub fn verify_all( &self, ) -> AuditResult<Vec<(SessionId, ChainVerificationResult)>>

Verify the entire audit log (all sessions).

§Errors

Returns an error if sessions cannot be listed or verified.

Source

pub fn count(&self) -> AuditResult<usize>

Count total entries.

§Errors

Returns an error if the storage backend fails.

Source

pub fn count_session(&self, session_id: &SessionId) -> AuditResult<usize>

Count entries for a session.

§Errors

Returns an error if the storage backend fails.

Source

pub fn list_sessions(&self) -> AuditResult<Vec<SessionId>>

List all sessions.

§Errors

Returns an error if the storage backend fails.

Source

pub fn flush(&self) -> AuditResult<()>

Flush pending writes.

§Errors

Returns an error if the storage backend fails to flush.

Source

pub fn runtime_public_key(&self) -> PublicKey

Get the runtime public key.

Trait Implementations§

Source§

impl Debug for AuditLog

Source§

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

Formats the value using the given formatter. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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