noctis 0.6.0

Open-source black-box vulnerability scanner: readable YAML checks that prove each bug on the live service, QoD-graded findings, REST API.
use std::path::PathBuf;

use clap::{Parser, Subcommand};

#[derive(Parser, Debug)]
#[command(
    name = "noctis",
    about = "Vulnerability scanner — YAML-driven, Rust-native",
    version
)]
pub struct Cli {
    /// Log verbosity (-v INFO, -vv DEBUG, -vvv TRACE)
    #[arg(short, long, action = clap::ArgAction::Count, global = true)]
    pub verbose: u8,

    #[command(subcommand)]
    pub command: Command,
}

#[derive(Subcommand, Debug)]
pub enum Command {
    /// Start the REST API daemon
    Serve(ServeArgs),
    /// Install or locate the detection feed set
    Feeds(FeedsArgs),
}

#[derive(Parser, Debug)]
pub struct FeedsArgs {
    /// Feeds directory [default: $NOCTIS_FEEDS_DIR, $XDG_DATA_HOME/noctis/feeds,
    /// ~/.local/share/noctis/feeds, %LOCALAPPDATA%\noctis\feeds on Windows]
    #[arg(long, global = true)]
    pub feeds_dir: Option<PathBuf>,

    #[command(subcommand)]
    pub command: FeedsCommand,
}

#[derive(Subcommand, Debug)]
pub enum FeedsCommand {
    /// Download the feed set of a GitHub Release and install it into the feeds directory
    Update {
        /// Release to take the feeds from: vX.Y.Z or "latest" [default: this binary's version]
        #[arg(long, conflicts_with = "archive")]
        tag: Option<String>,
        /// Install a noctis-feeds.tar.gz already on disk instead of downloading it
        /// (checked against <ARCHIVE>.sha256 when that file exists)
        #[arg(long, value_name = "ARCHIVE")]
        archive: Option<PathBuf>,
    },
    /// Print the feeds directory
    Path,
}

#[derive(Parser, Debug)]
pub struct ServeArgs {
    /// Address to listen on
    #[arg(long, default_value = "0.0.0.0")]
    pub host: String,

    /// Port to listen on
    #[arg(long, default_value_t = 8080)]
    pub port: u16,

    /// Enable the integrated OOB callback server (HTTP and LDAP/JNDI on the same port)
    #[arg(long)]
    pub oob: bool,

    /// OOB server host — must be reachable from scan targets
    #[arg(long, default_value = "127.0.0.1")]
    pub oob_host: String,

    /// OOB server listening port
    #[arg(long, default_value_t = 9090)]
    pub oob_port: u16,

    /// Feeds directory: relative `tests` entries of a scan request that match nothing
    /// from the working directory are looked up here (see `noctis feeds update`)
    /// [default: $NOCTIS_FEEDS_DIR, then the `noctis feeds path` default]
    #[arg(long)]
    pub feeds_dir: Option<PathBuf>,
}