fix(scan): removing a target's last controller clears its components and alerts
CI / Check (push) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-11-28 12:34:25 +01:00
1 parent 4d6737a9d7
commit e702b86184
1 file changed
+5 -4
@@ -1928,7 +1928,9 @@ impl PipelineOrchestrator {
// A control application known only by the Siemens controllers
// it runs on (SPS item 4a): they are its SBOM, matched against
// Siemens' advisories as with a project.
if !target.devices.is_empty() {
// Also when the last one was removed, so its components and
// alerts go with it.
if target.target_type == TargetType::PlcSps || !target.devices.is_empty() {
let devices =
crate::pipeline::sbom::devices::entries(&target.devices, &target_id);
if let Err(e) = self
@@ -2321,9 +2323,8 @@ impl PipelineOrchestrator {
scan_run_id: &str,
mut entries: Vec<SbomEntry>,
) -> Result<(), AgentError> {
if entries.is_empty() {
return Ok(());
}
// Empty entries are stored too: the components and alerts of the
// last scan are then gone (callers skip it when nothing was read).
crate::pipeline::component_changes::record(
&self.db,
scan_run_id,