pub mod log;
pub mod replay;
pub mod sandbox;
use std::hash::{Hash, Hasher};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuditLogEntry {
pub timestamp: String,
#[serde(default)]
pub session_id: String,
pub tool_name: String,
pub tool_input_summary: String,
pub decision: String,
pub reason: Option<String>,
pub matched_rules: usize,
pub skipped_rules: usize,
pub resolution: String,
#[serde(default)]
pub mode: Option<String>,
}
impl AuditLogEntry {
pub fn timestamp_secs(&self) -> Option<f64> {
self.timestamp.parse::<f64>().ok()
}
pub fn short_hash(&self) -> String {
compute_short_hash(&self.timestamp, &self.tool_name, &self.tool_input_summary)
}
}
pub fn compute_short_hash(timestamp: &str, tool_name: &str, tool_input_summary: &str) -> String {
let mut hasher = std::collections::hash_map::DefaultHasher::new();
timestamp.hash(&mut hasher);
tool_name.hash(&mut hasher);
tool_input_summary.hash(&mut hasher);
format!("{:07x}", hasher.finish() & 0x0FFF_FFFF)
}