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 indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use super::severity::Severity;
use super::step::Step;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct TestDef {
    /// Identifiant stable (UUID v4) — obligatoire dans le YAML.
    pub uid: Uuid,
    pub name: String,
    #[serde(default)]
    pub description: Option<String>,
    pub severity: Severity,
    #[serde(default = "default_confidence")]
    pub confidence_base: f32,
    #[serde(default)]
    pub tags: Vec<String>,
    #[serde(default)]
    pub author: Option<String>,
    #[serde(default)]
    pub version: Option<String>,
    #[serde(default)]
    pub references: Vec<String>,

    /// CVE identifiers this vulnerability corresponds to — zero, one, or many.
    #[serde(default)]
    pub cves: Vec<String>,
    #[serde(default)]
    pub cvss: Option<f32>,
    #[serde(default)]
    pub category: Option<String>,

    /// Service names this test applies to (e.g. ["http", "https"]).
    /// Empty = run against every discovered port (or the single --port if no discovery).
    #[serde(default)]
    pub services: Vec<String>,

    /// Well-known TCP ports this test also applies to, whatever service name the
    /// scanner gave them (nmap often reports TCP/8291 Winbox as `unknown`).
    /// A discovered port runs the test when its service is in `services`
    /// **or** its port is in `ports`. Ignored when `services` is empty (the
    /// test already runs on every port).
    #[serde(default)]
    pub ports: Vec<u16>,

    /// Authenticated feed: when `true` and the scan request carries no
    /// `credentials`, the feed is skipped (no task, no finding, debug log).
    #[serde(default)]
    pub requires_credentials: bool,

    #[serde(default)]
    pub includes: Vec<String>,
    #[serde(default)]
    pub vars: IndexMap<String, serde_json::Value>,

    pub steps: Vec<Step>,
}

fn default_confidence() -> f32 {
    0.75
}