feat(scan): implement service fingerprinting and wire up end-to-end vulnerability pipeline

This commit is contained in:
Lucas Rayan committed 2026-11-02 00:39:03 -03:00
1 parent 4ce5d7f595
commit 3e41c169d0
9 files changed
+724 -22

No files matched your search

+14 -4
View File
@@ -25,6 +25,7 @@ use ulid::Ulid;
use crate::batch::{SweepBatch, SweepStatus};
use crate::scan::{HostState, PortState};
use crate::targets::{parse_target, IpRange};
use crate::vuln::Finding;
/// How many consecutive sweeps without a positive observation are needed before an asset or
/// port is considered gone.
@@ -84,7 +85,7 @@ impl PortStatus {
}
/// Current state of one port.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq)]
pub struct ServiceState {
/// Transport protocol; only `tcp` is produced today.
pub protocol: String,
@@ -104,10 +105,12 @@ pub struct ServiceState {
pub version: Option<String>,
/// Observed CPE.
pub cpe: Option<String>,
/// Security and vulnerability findings discovered on this service.
pub findings: Vec<Finding>,
}
/// Current state of one asset.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq)]
pub struct AssetState {
/// `(rede_logica, ip)` identity.
pub asset_key: String,
@@ -128,7 +131,7 @@ pub struct AssetState {
}
/// Deduplicated current state, as stored by [`crate::storage`].
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[derive(Debug, Clone, Default, PartialEq)]
pub struct CurrentState {
/// Assets sorted by `asset_key`.
pub assets: Vec<AssetState>,
@@ -251,7 +254,7 @@ pub struct Event {
}
/// Next state plus the events that explain the transition.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[derive(Debug, Clone, Default, PartialEq)]
pub struct DiffResult {
/// Events in deterministic order.
pub events: Vec<Event>,
@@ -414,6 +417,7 @@ pub fn diff_batch(
product: None,
version: None,
cpe: None,
findings: Vec::new(),
};
apply_service(&mut service, observed_service);
port_events.push(event(
@@ -606,6 +610,10 @@ fn apply_service(
changed = true;
}
}
if target.findings != observed.findings {
target.findings = observed.findings.clone();
changed = true;
}
changed
}
@@ -732,6 +740,7 @@ mod tests {
product: None,
version: None,
cpe: None,
findings: Vec::new(),
}
}
@@ -935,6 +944,7 @@ mod tests {
product: Some("OpenSSH".to_string()),
version: Some("9.8p1".to_string()),
cpe: None,
findings: Vec::new(),
}],
),
&DiffOptions::default(),