use serde::Serialize;
use std::path::PathBuf;
pub const DOCTOR_REPORT_SCHEMA: &str = "assay.doctor_report.v0";
#[derive(Debug, Serialize, Clone)]
pub struct DiagnosticReport {
pub schema: &'static str,
pub assay_version: String,
pub platform: String,
pub kernel: Option<String>,
pub lsms: Vec<String>,
pub landlock: LandlockStatus,
pub bpf_lsm: BpfLsmStatus,
pub helper: HelperStatus,
pub backend: BackendSelection,
pub sandbox_features: SandboxFeatures,
pub metrics: std::collections::HashMap<String, u64>,
pub status: SystemStatus,
pub suggestions: Vec<String>,
}
#[derive(Debug, Serialize, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum LandlockAbiProbeStatus {
Ok,
Unsupported,
Disabled,
Error,
}
#[derive(Debug, Serialize, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum LandlockNetProbeStatus {
Usable,
Unsupported,
Failed,
}
#[derive(Debug, Serialize, Clone)]
pub struct LandlockStatus {
pub available: bool,
pub fs_enforce: bool,
pub net_enforce: bool,
pub abi_version: Option<u32>,
pub abi_version_source: &'static str,
pub abi_probe_status: LandlockAbiProbeStatus,
pub abi_probe_errno: Option<i32>,
pub net_connect_tcp_supported: bool,
pub net_bind_tcp_supported: bool,
pub no_new_privs_settable: bool,
pub net_connect_ruleset_probe: LandlockNetProbeStatus,
pub net_connect_ruleset_errno: Option<i32>,
}
#[derive(Debug, Serialize, Clone)]
pub struct BpfLsmStatus {
pub available: bool,
}
#[derive(Debug, Serialize, Clone)]
pub struct HelperStatus {
pub path: PathBuf,
pub exists: bool,
pub version: Option<String>,
pub socket: PathBuf,
pub socket_exists: bool,
}
#[derive(Debug, Serialize, Clone)]
pub struct BackendSelection {
pub selected: String,
pub mode: String,
pub reason: String,
}
#[derive(Debug, Serialize, Clone, PartialEq)]
pub enum SystemStatus {
Ready,
Degraded,
Unsupported,
}
#[derive(Debug, Serialize, Clone)]
pub struct SandboxFeatures {
pub env_scrubbing: bool,
pub scoped_tmp: bool,
pub fork_safe_preexec: bool,
pub deny_conflict_detection: bool,
}
impl Default for SandboxFeatures {
fn default() -> Self {
Self {
env_scrubbing: true,
scoped_tmp: true,
fork_safe_preexec: true,
deny_conflict_detection: true,
}
}
}