From 264d784daa72c996c3bf476ae5081febe956bd51 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Mon, 30 Nov 2026 21:45:35 +0100 Subject: [PATCH] feat(demo): the pump station demo runs on a Siemens S7-1500 CPU Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9 --- compliance-agent/src/demo_seed.rs | 1 + compliance-agent/src/fixtures.rs | 31 ++++++++++++++++++++++++++++++ compliance-agent/tests/nightly.rs | 1 + fixtures/demo-targets/targets.json | 9 ++++++++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/compliance-agent/src/demo_seed.rs b/compliance-agent/src/demo_seed.rs index fdb45d9..ef83ae2 100644 --- a/compliance-agent/src/demo_seed.rs +++ b/compliance-agent/src/demo_seed.rs @@ -167,6 +167,7 @@ async fn seed_one( compliance_core::models::OnboardedTarget::new(full_name.to_string(), demo.target_type); target.description = demo.description.clone(); target.demo = true; + target.devices = demo.devices.clone(); for a in demo.artifacts.iter().filter(|a| !a.is_upload()) { match a.resolved_source_ref() { Some(source_ref) => target.artifacts.push(targets::reference_artifact( diff --git a/compliance-agent/src/fixtures.rs b/compliance-agent/src/fixtures.rs index f0acf8f..a45cd39 100644 --- a/compliance-agent/src/fixtures.rs +++ b/compliance-agent/src/fixtures.rs @@ -117,6 +117,10 @@ pub struct DemoTarget { /// Applied by the nightly harness to the fixtures it onboards itself. #[serde(default)] pub enabled_scans: Vec, + /// Siemens controllers the target runs on (SPS item 4a), stored with the + /// target so its SBOM lists them and Siemens' advisories match them. + #[serde(default)] + pub devices: Vec, /// Golden baseline for the nightly regression. #[serde(default)] pub expect: Expect, @@ -491,6 +495,32 @@ mod tests { assert_eq!(on_disk.name_prefix, bundled.name_prefix); } + #[test] + fn demo_devices_are_stored_as_the_api_would_store_them() { + // Arrange + let m = manifest(); + let pump = m + .targets + .iter() + .find(|t| t.key == "plc-pump-station") + .expect("pump station in the manifest"); + + // Assert: a controller on a firmware Siemens names as affected + // (SSA-876787: below V2.9.8), so the demo SBOM is not empty. + assert!(!pump.devices.is_empty()); + for t in &m.targets { + for d in &t.devices { + let normalised = compliance_core::models::PlcDevice::new( + &d.order_number, + &d.firmware, + d.label.as_deref(), + ) + .expect("a valid controller"); + assert_eq!(&normalised, d, "{}: store it normalised", t.key); + } + } + } + #[test] fn manifest_is_well_formed() { let m = manifest(); @@ -589,6 +619,7 @@ mod tests { optional: true, }], enabled_scans: Vec::new(), + devices: Vec::new(), expect: Expect::default(), }; assert!(t.source_only()); diff --git a/compliance-agent/tests/nightly.rs b/compliance-agent/tests/nightly.rs index 4a3cd4f..e9c4962 100644 --- a/compliance-agent/tests/nightly.rs +++ b/compliance-agent/tests/nightly.rs @@ -285,6 +285,7 @@ async fn seed_nightly( "target_type": t.target_type, "description": t.description, "artifacts": references, + "devices": t.devices, }), ) .await; diff --git a/fixtures/demo-targets/targets.json b/fixtures/demo-targets/targets.json index b4c9963..8fc53e8 100644 --- a/fixtures/demo-targets/targets.json +++ b/fixtures/demo-targets/targets.json @@ -6,7 +6,7 @@ "key": "plc-pump-station", "name": "PLC pump station (ST + FBD, composite)", "target_type": "plc_sps", - "description": "Composite PlcSps demo: Structured Text + FBD-as-PLCopen-XML control logic, plus an optional live Modbus endpoint (in-cluster plc-sim) and an optional device firmware image. Exercises PLC SAST, ICS probe, semantic control mapping.", + "description": "Composite PlcSps demo: Structured Text + FBD-as-PLCopen-XML control logic, plus an optional live Modbus endpoint (in-cluster plc-sim) and an optional device firmware image. Runs on a Siemens S7-1500 CPU with an old firmware, so its SBOM lists the controller and Siemens' advisories match it. Exercises PLC SAST, ICS probe, semantic control mapping, Siemens advisory matching.", "artifacts": [ { "kind": "plc_project", @@ -30,6 +30,13 @@ "optional": true } ], + "devices": [ + { + "order_number": "6ES7511-1AK02-0AB0", + "firmware": "2.9.4", + "label": "Pump station CPU" + } + ], "expect": { "min_findings": 16, "sast_rule_ids": [ -- 2.54.1