arsenal-core · audit
Declared module signatures, types, configuration, and source documentation.
Source: arsenal/crates/arsenal-core/src/audit.rs. SHA-256: 2ab608239c5af9cc3d66b8ddefc3d5559f66b2d108b566125c05190dee89a546.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
audit::AuditEvent
Audit event - a single auditable occurrence
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuditEvent {
/// Unique event ID
pub id: AuditEventId,
/// When the event occurred
pub timestamp: chrono::DateTime<chrono::Utc>,
/// Event kind
pub kind: AuditEventKind,
/// Severity level
pub severity: AuditSeverity,
/// Tenant context
pub tenant_id: TenantId,
/// Agent involved (if any)
#[serde(skip_serializing_if = "Option::is_none")]
pub agent_id: Option<AgentId>,
/// Session involved (if any)
#[serde(skip_serializing_if = "Option::is_none")]
pub session_id: Option<SessionId>,
/// Token involved (if any)
#[serde(skip_serializing_if = "Option::is_none")]
pub token_id: Option<TokenId>,
/// Outcome of the operation
pub outcome: AuditOutcome,
/// Human-readable description
pub description: String,
/// Additional structured data
#[serde(default)]
pub metadata: HashMap<String, serde_json::Value>,
/// Client IP address (if available)
#[serde(skip_serializing_if = "Option::is_none")]
pub client_ip: Option<String>,
/// User agent (if available)
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
/// Request ID for correlation
#[serde(skip_serializing_if = "Option::is_none")]
pub request_id: Option<Uuid>,
/// Hash of the previous event (for chain integrity)
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_hash: Option<[u8; 32]>,
/// Hash of this event
#[serde(skip_serializing_if = "Option::is_none")]
pub event_hash: Option<[u8; 32]>
}Source line: 20.
audit::AuditEvent::builder
Create a new audit event builder
#[must_use]
pub fn builder(kind: AuditEventKind, tenant_id: TenantId) -> AuditEventBuilder;Source line: 67.
audit::AuditEvent::compute_hash
Compute the hash of this event
#[must_use]
pub fn compute_hash(&self) -> [u8; 32];Source line: 73.
audit::AuditEvent::verify_hash
Verify the event hash
#[must_use]
pub fn verify_hash(&self) -> bool;Source line: 95.
audit::AuditEvent::to_json
Serialize to JSON
Errors
Returns an error if serialization fails
pub fn to_json(&self) -> Result<String, serde_json::Error>;Source line: 114.
audit::AuditEvent::to_json_pretty
Serialize to JSON (pretty)
Errors
Returns an error if serialization fails
pub fn to_json_pretty(&self) -> Result<String, serde_json::Error>;Source line: 122.
audit::AuditEventId
Audit event ID
#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct AuditEventId(Uuid);Source line: 130.
audit::AuditEventId::generate
Generate a new event ID
#[must_use]
pub fn generate() -> Self;Source line: 135.
audit::AuditEventId::as_uuid
Get the inner UUID
#[must_use]
pub const fn as_uuid(&self) -> &Uuid;Source line: 141.
audit::AuditEventKind
Categories of audit events
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AuditEventKind {
// Authentication events
/// Agent authentication attempt
AgentAuthentication,
/// Session started
SessionStarted,
/// Session ended
SessionEnded,
/// Session renewed
SessionRenewed,
/// Session revoked
SessionRevoked,
// Token events
/// Token issued
TokenIssued,
/// Token verified
TokenVerified,
/// Token rejected
TokenRejected,
/// Token revoked
TokenRevoked,
/// Token expired
TokenExpired,
// Capability events
/// Capability requested
CapabilityRequested,
/// Capability granted
CapabilityGranted,
/// Capability denied
CapabilityDenied,
/// Capability delegated
CapabilityDelegated,
// Secret events
/// Secret created
SecretCreated,
/// Secret accessed
SecretAccessed,
/// Secret rotated
SecretRotated,
/// Secret deleted
SecretDeleted,
/// Secret unwrapped
SecretUnwrapped,
// Policy events
/// Policy created
PolicyCreated,
/// Policy updated
PolicyUpdated,
/// Policy deleted
PolicyDeleted,
/// Policy evaluated
PolicyEvaluated,
// Administrative events
/// Agent created
AgentCreated,
/// Agent updated
AgentUpdated,
/// Agent deactivated
AgentDeactivated,
/// Tenant created
TenantCreated,
/// Tenant updated
TenantUpdated,
/// Tenant suspended
TenantSuspended,
// Security events
/// Rate limit exceeded
RateLimitExceeded,
/// Budget exhausted
BudgetExhausted,
/// Constraint violated
ConstraintViolated,
/// Suspicious activity detected
SuspiciousActivity,
/// Security alert
SecurityAlert,
// System events
/// System startup
SystemStartup,
/// System shutdown
SystemShutdown,
/// Configuration changed
ConfigurationChanged,
/// Key rotation
KeyRotation,
// Proxy events
/// Proxy request processed
ProxyRequest,
/// Proxy request denied by policy or binding
ProxyRequestDenied,
/// Proxy destination binding violated
ProxyDestinationViolation,
/// Proxy resolved credential variables for a request
ProxyCredentialResolved,
// Fingerprint events
/// Agent fingerprint verified successfully
FingerprintVerified,
/// Agent fingerprint mismatch detected (potential key theft)
FingerprintMismatch,
/// Agent fingerprint state was reset
FingerprintReset,
// Consent events
/// Consent was requested from a human
ConsentRequested,
/// Consent was granted by a human
ConsentGranted,
/// Consent was denied by a human
ConsentDenied,
/// Consent was revoked
ConsentRevoked,
// Delegated credential token events
/// Delegated credential token was issued
DctIssued,
/// Delegated credential token was used in a proxy request
DctUsed,
}Source line: 161.
audit::AuditEventKind::default_severity
Get the default severity for this event kind
#[must_use]
pub const fn default_severity(&self) -> AuditSeverity;Source line: 292.
audit::AuditEventKind::is_security_relevant
Check if this is a security-relevant event
#[must_use]
pub const fn is_security_relevant(&self) -> bool;Source line: 329.
audit::AuditSeverity
Severity levels for audit events
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AuditSeverity {
/// Informational - routine operations
Low,
/// Medium - notable but expected operations
Medium,
/// High - significant security events
High,
/// Critical - requires immediate attention
Critical,
}Source line: 356.
audit::AuditSeverity::as_str
Get string representation
#[must_use]
pub const fn as_str(&self) -> &'static str;Source line: 370.
audit::AuditOutcome
Outcome of an audited operation
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AuditOutcome {
/// Operation succeeded
Success,
/// Operation failed
Failure,
/// Operation was denied by policy
Denied,
/// Operation timed out
Timeout,
/// Operation had an error
Error,
}Source line: 389.
audit::AuditOutcome::is_success
Check if the outcome indicates success
#[must_use]
pub const fn is_success(&self) -> bool;Source line: 405.
audit::AuditEventBuilder
Builder for audit events
#[derive(Debug)]
pub struct AuditEventBuilder {
}Source line: 412.
audit::AuditEventBuilder::new
Create a new builder
#[must_use]
pub fn new(kind: AuditEventKind, tenant_id: TenantId) -> Self;Source line: 431.
audit::AuditEventBuilder::severity
Set severity
#[must_use]
pub fn severity(mut self, severity: AuditSeverity) -> Self;Source line: 451.
audit::AuditEventBuilder::agent
Set agent ID
#[must_use]
pub fn agent(mut self, agent_id: AgentId) -> Self;Source line: 458.
audit::AuditEventBuilder::session
Set session ID
#[must_use]
pub fn session(mut self, session_id: SessionId) -> Self;Source line: 465.
audit::AuditEventBuilder::token
Set token ID
#[must_use]
pub fn token(mut self, token_id: TokenId) -> Self;Source line: 472.
audit::AuditEventBuilder::outcome
Set outcome
#[must_use]
pub fn outcome(mut self, outcome: AuditOutcome) -> Self;Source line: 479.
audit::AuditEventBuilder::description
Set description
#[must_use]
pub fn description(mut self, description: impl Into<String>) -> Self;Source line: 486.
audit::AuditEventBuilder::metadata
Add metadata
#[must_use]
pub fn metadata(mut self, key: impl Into<String>, value: impl Serialize) -> Self;Source line: 493.
audit::AuditEventBuilder::client_ip
Set client IP
#[must_use]
pub fn client_ip(mut self, ip: impl Into<String>) -> Self;Source line: 502.
audit::AuditEventBuilder::user_agent
Set user agent
#[must_use]
pub fn user_agent(mut self, ua: impl Into<String>) -> Self;Source line: 509.
audit::AuditEventBuilder::request_id
Set request ID
#[must_use]
pub fn request_id(mut self, id: Uuid) -> Self;Source line: 516.
audit::AuditEventBuilder::previous_hash
Set previous hash for chain integrity
#[must_use]
pub fn previous_hash(mut self, hash: [u8; 32]) -> Self;Source line: 523.
audit::AuditEventBuilder::build
Build the audit event
#[must_use]
pub fn build(self) -> AuditEvent;Source line: 530.
audit::AuditLog
Audit log for collecting events
#[derive(Debug, Default)]
pub struct AuditLog {
}Source line: 563.
audit::AuditLog::new
Create a new audit log
#[must_use]
pub fn new() -> Self;Source line: 573.
audit::AuditLog::append
Add an event to the log
pub fn append(&mut self, mut event: AuditEvent);Source line: 578.
audit::AuditLog::events
Get all events
#[must_use]
pub fn events(&self) -> &[AuditEvent];Source line: 589.
audit::AuditLog::events_by_kind
Get events by kind
#[must_use]
pub fn events_by_kind(&self, kind: AuditEventKind) -> Vec<&AuditEvent>;Source line: 595.
audit::AuditLog::events_by_severity
Get events by severity
#[must_use]
pub fn events_by_severity(&self, min_severity: AuditSeverity) -> Vec<&AuditEvent>;Source line: 601.
audit::AuditLog::verify_chain
Verify chain integrity
#[must_use]
pub fn verify_chain(&self) -> bool;Source line: 610.
audit::AuditLog::len
Get the number of events
#[must_use]
pub fn len(&self) -> usize;Source line: 632.
audit::AuditLog::is_empty
Check if the log is empty
#[must_use]
pub fn is_empty(&self) -> bool;Source line: 638.