keyhog 0.5.44

keyhog detects leaked credentials in source trees, git history, archives, and remote sources
Documentation
use std::path::PathBuf;

use clap::Parser;

/// Subcommand args for `keyhog daemon {start, stop, status}`.
#[derive(Parser)]
pub struct DaemonArgs {
    #[command(subcommand)]
    pub action: DaemonAction,
}

#[derive(clap::Subcommand)]
pub enum DaemonAction {
    /// Start a daemon process that holds a compiled scanner and
    /// serves scan requests over a Unix socket. Blocks until
    /// `daemon stop` is invoked.
    Start {
        /// Override the default socket path. KeyHog otherwise uses
        /// $XDG_RUNTIME_DIR/keyhog.sock, then the OS user-cache directory,
        /// then the OS temporary directory.
        ///
        /// A daemon started here is reachable by `daemon stop`/`status --socket`
        /// AND by scans via `keyhog scan --daemon --daemon-socket <same path>`.
        /// Pass the matching path so a fixed-location daemon (e.g. a systemd
        /// unit) actually serves scans, not just admin commands.
        #[arg(long, value_name = "PATH")]
        socket: Option<PathBuf>,
        /// Detector directory (same default as `keyhog scan --detectors`).
        #[arg(long, default_value = "detectors")]
        detectors: PathBuf,
        #[arg(skip)]
        detectors_cli_explicit: bool,
        /// Override the Hyperscan compiled-database cache directory.
        #[arg(long, value_name = "DIR")]
        cache_dir: Option<PathBuf>,
        /// Force a daemon scan backend instead of using persisted autoroute.
        ///
        /// The default `auto` mode uses persisted calibration. Missing or
        /// invalid evidence is reported per request while scalar correctness
        /// recovery scans every byte. Use an explicit backend only for
        /// diagnostics and hermetic daemon tests.
        #[arg(
            long,
            value_name = "BACKEND",
            value_parser = clap::builder::PossibleValuesParser::new(
                keyhog_scanner::hw_probe::BACKEND_OVERRIDE_VALUES
            )
        )]
        backend: Option<String>,
        /// Max seconds a client connection may sit without completing one
        /// request frame before the daemon closes it and reclaims the slot.
        #[arg(
            long,
            default_value_t = 300,
            value_name = "SECS",
            value_parser = crate::value_parsers::parse_daemon_request_timeout_secs
        )]
        request_timeout_secs: u64,
    },
    /// Stop the running daemon by sending it a `Shutdown` over the socket.
    Stop {
        #[arg(long, value_name = "PATH")]
        socket: Option<PathBuf>,
    },
    /// Print uptime, scans served, active scans, detector count, and backend policy.
    Status {
        #[arg(long, value_name = "PATH")]
        socket: Option<PathBuf>,
    },
}