This commit was merged in pull request #328.
This commit is contained in:
1 parent
27e8c866ba
commit
f90bfcc5c6
12 files changed
+370
-51
No files matched your search
@@ -591,9 +591,11 @@ pub async fn applicable_scans_for_target(
|
||||
.map(|o| ScanOptionDto {
|
||||
scan: o.scan.to_string(),
|
||||
default_on: o.default_on,
|
||||
// A scan nothing runs yet reads as blocked to every client, so the
|
||||
// wizard neither pre-selects nor offers it.
|
||||
blocked_reason: o.unrunnable_reason(),
|
||||
rationale: o.rationale,
|
||||
required_artifact: o.required_artifact.map(|k| k.to_string()),
|
||||
blocked_reason: o.blocked_reason,
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -500,6 +500,12 @@ impl PipelineOrchestrator {
|
||||
) -> Result<u32, AgentError> {
|
||||
let target_id = target.id.map(|id| id.to_hex()).unwrap_or_default();
|
||||
let plan = build_scan_plan(target);
|
||||
// An attached artifact nothing analyses is recorded, never passed over:
|
||||
// a completed run must not read as "we looked and found nothing".
|
||||
for entry in &plan.unavailable {
|
||||
self.skip_stage(scan_run_id, &entry.scan_type.to_string(), entry.reason)
|
||||
.await;
|
||||
}
|
||||
tracing::info!(
|
||||
target_id = %target_id,
|
||||
target_type = %target.target_type,
|
||||
@@ -578,17 +584,21 @@ impl PipelineOrchestrator {
|
||||
.await;
|
||||
}
|
||||
None => {
|
||||
// No code to scan (a migrated DAST target). Firmware/mobile static
|
||||
// scanners land in #128/#129; DAST for a running URL works when a
|
||||
// DastTarget row exists (provisioned above from a LiveUrl, or from
|
||||
// a migrated target).
|
||||
tracing::info!(
|
||||
target_id = %target_id,
|
||||
"Unified pipeline: no code artifact; attempting DAST"
|
||||
);
|
||||
self.update_phase(scan_run_id, ScanPhase::DastScanning)
|
||||
.await;
|
||||
self.maybe_trigger_dast(&target_id, scan_run_id).await;
|
||||
// No code to scan. DAST is attempted for a target the matrix
|
||||
// plans it for, and for a migrated DAST target, which carries no
|
||||
// artifacts at all and relies on its DastTarget row. Anywhere
|
||||
// else (a firmware image, a mobile package, a container image)
|
||||
// DAST does not apply, and reporting it as skipped would suggest
|
||||
// it otherwise would have run.
|
||||
if plan.has(ScanType::Dast) || target.artifacts.is_empty() {
|
||||
tracing::info!(
|
||||
target_id = %target_id,
|
||||
"Unified pipeline: no code artifact; attempting DAST"
|
||||
);
|
||||
self.update_phase(scan_run_id, ScanPhase::DastScanning)
|
||||
.await;
|
||||
self.maybe_trigger_dast(&target_id, scan_run_id).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(new_count)
|
||||
|
||||
@@ -22,11 +22,24 @@ pub struct ScanStep {
|
||||
pub artifact_id: String,
|
||||
}
|
||||
|
||||
/// A scan this target carries the artifact for, which no pipeline stage runs
|
||||
/// yet. Recorded on the scan run as a skipped stage, so an artifact nothing
|
||||
/// looked at is visible instead of silently ignored.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct UnavailableScan {
|
||||
/// The scan that is not implemented.
|
||||
pub scan_type: ScanType,
|
||||
/// What covers the ground instead.
|
||||
pub reason: &'static str,
|
||||
}
|
||||
|
||||
/// The ordered set of scans to run for a target.
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
pub struct ScanPlan {
|
||||
/// The scans, in matrix order.
|
||||
pub steps: Vec<ScanStep>,
|
||||
/// Scans whose artifact is attached but which nothing runs yet.
|
||||
pub unavailable: Vec<UnavailableScan>,
|
||||
}
|
||||
|
||||
impl ScanPlan {
|
||||
@@ -49,7 +62,22 @@ pub fn build_scan_plan(target: &OnboardedTarget) -> ScanPlan {
|
||||
let disabled = &target.scan_config.disabled_scans;
|
||||
|
||||
let mut steps = Vec::new();
|
||||
let mut unavailable = Vec::new();
|
||||
for option in applicable_scans(target) {
|
||||
// Nothing runs this scan yet. When the target carries the artifact it
|
||||
// would consume, the run says so rather than passing over it.
|
||||
if let Some(reason) = option.unavailable_with_artifact() {
|
||||
if !disabled.contains(&option.scan) {
|
||||
unavailable.push(UnavailableScan {
|
||||
scan_type: option.scan,
|
||||
reason,
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if option.unavailable.is_some() {
|
||||
continue;
|
||||
}
|
||||
// Required artifact missing → not runnable.
|
||||
if option.blocked_reason.is_some() {
|
||||
continue;
|
||||
@@ -71,7 +99,10 @@ pub fn build_scan_plan(target: &OnboardedTarget) -> ScanPlan {
|
||||
artifact_id: artifact.id.clone(),
|
||||
});
|
||||
}
|
||||
ScanPlan { steps }
|
||||
// A scan another rule does run (the firmware SBOM off the sources, say) is
|
||||
// not reported as unavailable because its image-bound rule is.
|
||||
unavailable.retain(|u| !steps.iter().any(|s| s.scan_type == u.scan_type));
|
||||
ScanPlan { steps, unavailable }
|
||||
}
|
||||
|
||||
/// Resolve the artifact a scan consumes. A "code" requirement (represented by
|
||||
@@ -159,18 +190,68 @@ mod tests {
|
||||
assert_eq!(sast.artifact_id, arc_id);
|
||||
}
|
||||
|
||||
fn unavailable_for<'a>(plan: &'a ScanPlan, scan: ScanType) -> Option<&'a UnavailableScan> {
|
||||
plan.unavailable.iter().find(|u| u.scan_type == scan)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn firmware_sbom_and_cve_bind_to_the_firmware_image() {
|
||||
let fw = Artifact::firmware_image("fw.bin");
|
||||
let fw_id = fw.id.clone();
|
||||
let t = target(TargetType::FirmwareBareMetal, vec![fw]);
|
||||
fn a_firmware_image_plans_nothing_and_is_recorded_as_unanalysed() {
|
||||
let t = target(
|
||||
TargetType::FirmwareBareMetal,
|
||||
vec![Artifact::firmware_image("fw.bin")],
|
||||
);
|
||||
let plan = build_scan_plan(&t);
|
||||
let sbom = step_for(&plan, ScanType::Sbom).expect("sbom planned");
|
||||
assert_eq!(sbom.artifact_id, fw_id);
|
||||
assert!(step_for(&plan, ScanType::FirmwareStatic).is_some());
|
||||
// Nothing runs on the image, so no step claims to.
|
||||
assert!(plan.steps.is_empty(), "{:?}", plan.steps);
|
||||
for scan in [ScanType::FirmwareStatic, ScanType::Sbom, ScanType::Cve] {
|
||||
assert!(unavailable_for(&plan, scan).is_some(), "{scan} recorded");
|
||||
}
|
||||
assert!(!plan.has(ScanType::Dast));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_scan_that_runs_off_the_sources_is_not_reported_unavailable() {
|
||||
// Firmware sources plus an image: the SBOM runs off the sources, so only
|
||||
// the image-only scans are recorded as unanalysed.
|
||||
let t = target(
|
||||
TargetType::FirmwareRtos,
|
||||
vec![
|
||||
Artifact::git_repo("https://git/fw", "main"),
|
||||
Artifact::firmware_image("fw.bin"),
|
||||
],
|
||||
);
|
||||
let plan = build_scan_plan(&t);
|
||||
assert!(plan.has(ScanType::Sbom));
|
||||
assert!(unavailable_for(&plan, ScanType::Sbom).is_none());
|
||||
assert!(unavailable_for(&plan, ScanType::Cve).is_none());
|
||||
assert!(unavailable_for(&plan, ScanType::FirmwareStatic).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_container_image_is_recorded_as_unscanned() {
|
||||
let t = target(
|
||||
TargetType::BackendService,
|
||||
vec![
|
||||
Artifact::git_repo("https://git/x", "main"),
|
||||
Artifact::container_image("registry/app:1.2.3"),
|
||||
],
|
||||
);
|
||||
let plan = build_scan_plan(&t);
|
||||
assert!(plan.has(ScanType::Sast));
|
||||
assert!(unavailable_for(&plan, ScanType::ContainerScan).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_explicitly_disabled_unavailable_scan_is_not_recorded() {
|
||||
let mut t = target(
|
||||
TargetType::AndroidApp,
|
||||
vec![Artifact::mobile_package("app.apk")],
|
||||
);
|
||||
t.scan_config.disabled_scans.push(ScanType::MobileStatic);
|
||||
let plan = build_scan_plan(&t);
|
||||
assert!(unavailable_for(&plan, ScanType::MobileStatic).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plc_plans_only_control_logic() {
|
||||
let plc = Artifact::plc_project("p.xml", PlcFormat::PlcopenXml);
|
||||
|
||||
@@ -6,9 +6,28 @@
|
||||
//! module encodes that as a table — one rule set per target type — and resolves
|
||||
//! it against a concrete [`OnboardedTarget`] into a list of [`ScanOption`]s the
|
||||
//! onboarding wizard and the scan pipeline both consume.
|
||||
//!
|
||||
//! A rule may also be marked *unavailable*: the scan belongs to the target type,
|
||||
//! but no pipeline stage runs it yet (unpacking firmware images, mobile packages,
|
||||
//! container images). Those are never offered, and when the target does carry the
|
||||
//! artifact they would consume, the run records a skipped stage naming the reason
|
||||
//! — so a finished scan never implies something was examined that was not.
|
||||
|
||||
use crate::models::{ArtifactKind, OnboardedTarget, ScanType, TargetType};
|
||||
|
||||
/// Why a firmware *image* is not analysed: the firmware path today is the source
|
||||
/// tree (Firmwerk build-plan analysis) or an SBOM imported from a Firmwerk bundle.
|
||||
const UNPACKING_IMAGES: &str =
|
||||
"firmware images are not unpacked or analysed yet: scan the firmware sources, \
|
||||
or import a Firmwerk bundle for the image";
|
||||
const SBOM_FROM_IMAGE: &str =
|
||||
"no SBOM is extracted from a firmware image yet: it comes from the firmware \
|
||||
sources, or from an imported Firmwerk bundle";
|
||||
const CVE_FROM_IMAGE: &str =
|
||||
"CVE matching needs an SBOM, and none is extracted from a firmware image yet";
|
||||
const CONTAINER_IMAGES: &str =
|
||||
"container images are not scanned yet: only the sources that build them are";
|
||||
|
||||
/// What an artifact a scan needs in order to run.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ArtifactRequirement {
|
||||
@@ -44,9 +63,32 @@ pub struct ScanRule {
|
||||
pub rationale: &'static str,
|
||||
/// The artifact the scan consumes.
|
||||
pub requires: ArtifactRequirement,
|
||||
/// Set when no pipeline stage runs this scan yet: what covers the ground
|
||||
/// instead. Such a scan is never offered, and a target that carries its
|
||||
/// artifact records it as a skipped stage, so "scanned" never means
|
||||
/// "nothing looked at this".
|
||||
pub unavailable: Option<&'static str>,
|
||||
}
|
||||
|
||||
impl ScanRule {
|
||||
/// A rule for a scan the matrix knows about but no pipeline stage runs yet.
|
||||
/// `reason` is what a user is told instead, and what the scan run records.
|
||||
const fn unavailable(
|
||||
scan: ScanType,
|
||||
rationale: &'static str,
|
||||
requires: ArtifactRequirement,
|
||||
reason: &'static str,
|
||||
) -> Self {
|
||||
Self {
|
||||
unavailable: Some(reason),
|
||||
scan,
|
||||
default_on: false,
|
||||
rationale,
|
||||
requires,
|
||||
}
|
||||
}
|
||||
|
||||
/// A rule for a scan the pipeline runs.
|
||||
const fn new(
|
||||
scan: ScanType,
|
||||
default_on: bool,
|
||||
@@ -54,6 +96,7 @@ impl ScanRule {
|
||||
requires: ArtifactRequirement,
|
||||
) -> Self {
|
||||
Self {
|
||||
unavailable: None,
|
||||
scan,
|
||||
default_on,
|
||||
rationale,
|
||||
@@ -64,12 +107,12 @@ impl ScanRule {
|
||||
|
||||
/// A resolved scan choice for a specific target: a rule intersected with the
|
||||
/// artifacts actually present. `blocked_reason` is `Some` when the required
|
||||
/// artifact is missing.
|
||||
/// artifact is missing; `unavailable` when no pipeline stage runs the scan yet.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ScanOption {
|
||||
/// The scan.
|
||||
pub scan: ScanType,
|
||||
/// Whether to pre-select the scan (false when blocked).
|
||||
/// Whether to pre-select the scan (false when blocked or unavailable).
|
||||
pub default_on: bool,
|
||||
/// Why the scan is offered.
|
||||
pub rationale: String,
|
||||
@@ -77,6 +120,26 @@ pub struct ScanOption {
|
||||
pub required_artifact: Option<ArtifactKind>,
|
||||
/// Set when the required artifact is absent, explaining the block.
|
||||
pub blocked_reason: Option<String>,
|
||||
/// Set when no pipeline stage runs this scan yet, explaining what covers the
|
||||
/// ground instead. Such a scan is never offered; when the target does carry
|
||||
/// its artifact, the scan run records it as a skipped stage.
|
||||
pub unavailable: Option<&'static str>,
|
||||
}
|
||||
|
||||
impl ScanOption {
|
||||
/// The reason this scan cannot run, for the user: not implemented outranks a
|
||||
/// missing artifact, since attaching one would not help.
|
||||
pub fn unrunnable_reason(&self) -> Option<String> {
|
||||
self.unavailable
|
||||
.map(str::to_string)
|
||||
.or_else(|| self.blocked_reason.clone())
|
||||
}
|
||||
|
||||
/// The scan is not implemented **and** the target carries the artifact it
|
||||
/// would consume: the run records this, so an unscanned artifact is visible.
|
||||
pub fn unavailable_with_artifact(&self) -> Option<&'static str> {
|
||||
self.unavailable.filter(|_| self.blocked_reason.is_none())
|
||||
}
|
||||
}
|
||||
|
||||
/// The SAST umbrella: every static-analysis sub-scan that runs over source code.
|
||||
@@ -138,6 +201,21 @@ fn sast_umbrella() -> Vec<ScanRule> {
|
||||
/// The rule set for a target type. Scans that are never applicable to a type are
|
||||
/// simply absent (e.g. DAST is not listed for a PLC target).
|
||||
pub fn rules_for(target_type: TargetType) -> Vec<ScanRule> {
|
||||
let mut rules = target_rules(target_type);
|
||||
// Any target may carry a container image, and nothing scans one; say so
|
||||
// rather than accepting the artifact in silence.
|
||||
rules.push(ScanRule::unavailable(
|
||||
ScanType::ContainerScan,
|
||||
"Scan the container image for OS and package vulnerabilities",
|
||||
ArtifactRequirement::Container,
|
||||
CONTAINER_IMAGES,
|
||||
));
|
||||
rules
|
||||
}
|
||||
|
||||
/// The rules specific to a target type (see [`rules_for`], which adds the rules
|
||||
/// that apply to every target).
|
||||
fn target_rules(target_type: TargetType) -> Vec<ScanRule> {
|
||||
use ArtifactRequirement::{Firmware, HttpUrl, Mobile, Plc, RunningUrl};
|
||||
match target_type {
|
||||
TargetType::WebApp | TargetType::BackendService => {
|
||||
@@ -153,55 +231,55 @@ pub fn rules_for(target_type: TargetType) -> Vec<ScanRule> {
|
||||
TargetType::DesktopApp => sast_umbrella(),
|
||||
TargetType::AndroidApp | TargetType::IosApp => {
|
||||
let mut r = sast_umbrella();
|
||||
r.push(ScanRule::new(
|
||||
r.push(ScanRule::unavailable(
|
||||
ScanType::MobileStatic,
|
||||
true,
|
||||
"Static analysis of the mobile package (manifest, permissions, libs)",
|
||||
Mobile,
|
||||
"mobile packages are not analysed yet: only the app's source code is scanned",
|
||||
));
|
||||
r
|
||||
}
|
||||
TargetType::FirmwareBareMetal | TargetType::FirmwareRtos => {
|
||||
let mut r = sast_umbrella();
|
||||
r.push(ScanRule::new(
|
||||
r.push(ScanRule::unavailable(
|
||||
ScanType::FirmwareStatic,
|
||||
true,
|
||||
"Unpack and statically analyze the firmware image",
|
||||
Firmware,
|
||||
UNPACKING_IMAGES,
|
||||
));
|
||||
r.push(ScanRule::new(
|
||||
r.push(ScanRule::unavailable(
|
||||
ScanType::Sbom,
|
||||
true,
|
||||
"SBOM from the firmware image (binwalk / firmwerk)",
|
||||
"SBOM from the firmware image",
|
||||
Firmware,
|
||||
SBOM_FROM_IMAGE,
|
||||
));
|
||||
r.push(ScanRule::new(
|
||||
r.push(ScanRule::unavailable(
|
||||
ScanType::Cve,
|
||||
true,
|
||||
"Match firmware components against known CVEs",
|
||||
Firmware,
|
||||
CVE_FROM_IMAGE,
|
||||
));
|
||||
r
|
||||
}
|
||||
TargetType::EmbeddedLinuxYocto => {
|
||||
let mut r = sast_umbrella();
|
||||
r.push(ScanRule::new(
|
||||
r.push(ScanRule::unavailable(
|
||||
ScanType::FirmwareStatic,
|
||||
true,
|
||||
"EMBA / binwalk static analysis of the image",
|
||||
Firmware,
|
||||
UNPACKING_IMAGES,
|
||||
));
|
||||
r.push(ScanRule::new(
|
||||
r.push(ScanRule::unavailable(
|
||||
ScanType::Sbom,
|
||||
true,
|
||||
"SBOM from image layers / recipes",
|
||||
Firmware,
|
||||
SBOM_FROM_IMAGE,
|
||||
));
|
||||
r.push(ScanRule::new(
|
||||
r.push(ScanRule::unavailable(
|
||||
ScanType::Cve,
|
||||
true,
|
||||
"Match image components against known CVEs",
|
||||
Firmware,
|
||||
CVE_FROM_IMAGE,
|
||||
));
|
||||
r.push(ScanRule::new(
|
||||
ScanType::Dast,
|
||||
@@ -231,23 +309,23 @@ pub fn rules_for(target_type: TargetType) -> Vec<ScanRule> {
|
||||
// apply only when a firmware image is attached, and firmware-image
|
||||
// SBOM/CVE *execution* is shared with the firmware families and
|
||||
// still landing (#151/#128), so they must not silently auto-run.
|
||||
ScanRule::new(
|
||||
ScanRule::unavailable(
|
||||
ScanType::FirmwareStatic,
|
||||
false,
|
||||
"Static analysis of the device firmware image (OS + runtime)",
|
||||
Firmware,
|
||||
UNPACKING_IMAGES,
|
||||
),
|
||||
ScanRule::new(
|
||||
ScanRule::unavailable(
|
||||
ScanType::Sbom,
|
||||
false,
|
||||
"SBOM from the device firmware image (OS packages + CODESYS runtime)",
|
||||
Firmware,
|
||||
SBOM_FROM_IMAGE,
|
||||
),
|
||||
ScanRule::new(
|
||||
ScanRule::unavailable(
|
||||
ScanType::Cve,
|
||||
false,
|
||||
"Match device firmware components against known CVEs",
|
||||
Firmware,
|
||||
CVE_FROM_IMAGE,
|
||||
),
|
||||
ScanRule::new(
|
||||
ScanType::Dast,
|
||||
@@ -351,10 +429,11 @@ pub fn applicable_scans(target: &OnboardedTarget) -> Vec<ScanOption> {
|
||||
};
|
||||
ScanOption {
|
||||
scan: rule.scan,
|
||||
default_on: rule.default_on && satisfied,
|
||||
default_on: rule.default_on && satisfied && rule.unavailable.is_none(),
|
||||
rationale: rule.rationale.to_string(),
|
||||
required_artifact,
|
||||
blocked_reason,
|
||||
unavailable: rule.unavailable,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
@@ -403,17 +482,79 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn firmware_offers_firmware_static_and_not_dast() {
|
||||
fn a_firmware_image_is_listed_as_unanalysed_never_offered() {
|
||||
let t = target_with(
|
||||
TargetType::FirmwareBareMetal,
|
||||
vec![Artifact::firmware_image("fw.bin")],
|
||||
);
|
||||
let opts = applicable_scans(&t);
|
||||
let fw = option(&opts, ScanType::FirmwareStatic).expect("firmware static offered");
|
||||
assert!(fw.default_on && fw.blocked_reason.is_none());
|
||||
// Nothing unpacks an image yet, so it is never pre-selected or offered,
|
||||
// and the reason says what to do instead. SBOM and CVE are listed twice
|
||||
// (once off the sources, once off the image); this is the image rule.
|
||||
let image_option = |scan: ScanType| {
|
||||
opts.iter().find(|o| {
|
||||
o.scan == scan && o.required_artifact == Some(ArtifactKind::FirmwareImage)
|
||||
})
|
||||
};
|
||||
for (scan, reason) in [
|
||||
(ScanType::FirmwareStatic, UNPACKING_IMAGES),
|
||||
(ScanType::Sbom, SBOM_FROM_IMAGE),
|
||||
(ScanType::Cve, CVE_FROM_IMAGE),
|
||||
] {
|
||||
let opt = image_option(scan).expect("listed for a firmware target");
|
||||
assert!(!opt.default_on, "{scan} must not be pre-selected");
|
||||
assert_eq!(opt.unrunnable_reason().as_deref(), Some(reason));
|
||||
// The artifact is attached, so the run records it as passed over.
|
||||
assert_eq!(opt.unavailable_with_artifact(), Some(reason));
|
||||
}
|
||||
assert!(option(&opts, ScanType::Dast).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unavailable_scan_without_its_artifact_is_not_recorded() {
|
||||
// No image attached: there is nothing the run passed over, so it has
|
||||
// nothing to record — only the reason shown in the wizard.
|
||||
let t = target_with(
|
||||
TargetType::FirmwareBareMetal,
|
||||
vec![Artifact::git_repo("https://git/fw", "main")],
|
||||
);
|
||||
let opts = applicable_scans(&t);
|
||||
let fw = option(&opts, ScanType::FirmwareStatic).expect("listed");
|
||||
assert!(fw.unavailable_with_artifact().is_none());
|
||||
assert!(fw.unrunnable_reason().is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_container_image_is_listed_as_unscanned_for_any_target() {
|
||||
let t = target_with(
|
||||
TargetType::WebApp,
|
||||
vec![Artifact::container_image("registry/app:1.2.3")],
|
||||
);
|
||||
let opts = applicable_scans(&t);
|
||||
let container = option(&opts, ScanType::ContainerScan).expect("container scan listed");
|
||||
assert!(!container.default_on);
|
||||
assert_eq!(
|
||||
container.unavailable_with_artifact(),
|
||||
Some(CONTAINER_IMAGES)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_mobile_package_is_listed_as_unanalysed() {
|
||||
let t = target_with(
|
||||
TargetType::AndroidApp,
|
||||
vec![Artifact::mobile_package("app.apk")],
|
||||
);
|
||||
let opts = applicable_scans(&t);
|
||||
let mobile = option(&opts, ScanType::MobileStatic).expect("mobile static listed");
|
||||
assert!(!mobile.default_on);
|
||||
assert!(mobile
|
||||
.unavailable_with_artifact()
|
||||
.is_some_and(|r| r.contains("mobile packages")));
|
||||
// Its source code is still scanned.
|
||||
assert!(option(&opts, ScanType::Sast).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plc_control_logic_is_default_on_and_device_scans_block_without_artifacts() {
|
||||
// A PLC project alone: control-logic runs; the device-level scans are
|
||||
|
||||
+6
-4
@@ -8,7 +8,7 @@ the control application *and* the device it runs on.
|
||||
| --- | --- |
|
||||
| PLC project (PLCopen XML / ST, or a `.projectarchive`) | **Control-logic SAST** — semantic security rules over ST **and** graphical FBD/LD |
|
||||
| A `.projectarchive` | **Control-app SBOM** — the referenced CODESYS libraries + the runtime version, matched against known CVEs |
|
||||
| A device firmware image | Firmware SBOM / CVE (opt-in) |
|
||||
| A device firmware image | *Not analysed yet* — the run records it as skipped, and says so. Firmware is covered from its **sources**, or from an imported Firmwerk bundle |
|
||||
| A reachable endpoint (WebVisu, OPC UA) | DAST / pentest (opt-in) |
|
||||
|
||||
## Anatomy: a soft PLC is a SoC + Linux + runtime
|
||||
@@ -46,7 +46,7 @@ flowchart TB
|
||||
|
||||
subgraph CERT["What Prüfwerk scans — one layer per artifact"]
|
||||
direction LR
|
||||
S1["Firmware layer<br/>FirmwareStatic · SBOM · CVE"]
|
||||
S1["Firmware layer<br/>not analysed yet — recorded as skipped"]
|
||||
S2["Control-logic layer<br/>PLC SAST — ST + FBD/LD"]
|
||||
S3["Control-app SBOM<br/>libraries + runtime → CVE"]
|
||||
S4["Running layer<br/>ICS probe · DAST (WebVisu)"]
|
||||
@@ -71,8 +71,10 @@ flowchart TB
|
||||
Yocto is **Track A** — the *build system* for the device platform. It produces
|
||||
the Linux image and bakes in the CODESYS runtime, so it is the **firmware
|
||||
layer**, entirely separate from the control application. Hand it to Prüfwerk as
|
||||
its own **firmware image** artifact (scanned by the firmware pipeline, not the
|
||||
PLC pipeline). The device OS need not be Yocto — Raspbian/Debian/Buildroot, or
|
||||
its own **firmware image** artifact. Nothing unpacks an image yet: the scan run
|
||||
records that layer as skipped and names the reason, so an unanalysed image is
|
||||
never mistaken for a clean one. Until it lands, the firmware layer is covered
|
||||
from its **sources** or from an SBOM imported out of a Firmwerk bundle. The device OS need not be Yocto — Raspbian/Debian/Buildroot, or
|
||||
even an RTOS / bare-metal, are all possible — but Yocto is the common,
|
||||
product-grade industrial choice.
|
||||
:::
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"container_scan"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"cve",
|
||||
"firmware_static",
|
||||
"sbom"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"mobile_static"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -227,6 +227,42 @@
|
||||
"pin": "38a6d9b276ed434454900130cacc87d058d3ac62"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "unscanned-firmware-image",
|
||||
"name": "Firmware image (nothing unpacks it yet)",
|
||||
"target_type": "firmware_bare_metal",
|
||||
"description": "A firmware image on its own. No stage unpacks an image today, so the run must record firmware_static, sbom and cve as skipped with the reason, never complete as if the image had been analysed (#319).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "firmware_image",
|
||||
"upload": "fixtures/nightly/unscanned/pump-ctl.bin"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "unscanned-mobile-package",
|
||||
"name": "Android package (not analysed yet)",
|
||||
"target_type": "android_app",
|
||||
"description": "An APK on its own. Mobile packages are not analysed, so the run must record mobile_static as skipped (#319).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "mobile_package",
|
||||
"upload": "fixtures/nightly/unscanned/pump-ctl.apk"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "unscanned-container-image",
|
||||
"name": "Container image (not scanned yet)",
|
||||
"target_type": "backend_service",
|
||||
"description": "A container image reference on its own. Nothing scans container images, so the run must record container_scan as skipped (#319).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "container_image",
|
||||
"source_ref": "registry.example.com/pump-ctl:1.4.2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Artifacts nothing scans yet (#319)
|
||||
|
||||
Each of these is an artifact kind the onboarding wizard accepts but no pipeline
|
||||
stage analyses. The nightly asserts that the scan run *records* that — a skipped
|
||||
stage naming the scan and why — instead of completing as if the artifact had
|
||||
been examined and found clean.
|
||||
|
||||
| File | Artifact | Recorded as skipped |
|
||||
|---|---|---|
|
||||
| `pump-ctl.bin` | firmware image (ELF header + padding; nothing parses it) | `firmware_static`, `sbom`, `cve` |
|
||||
| `pump-ctl.apk` | Android package (a zip, as APKs are) | `mobile_static` |
|
||||
| (no file) | container image, referenced by name | `container_scan` |
|
||||
|
||||
When one of these scans is implemented, its skipped stage disappears from the
|
||||
baseline and real components or findings take its place.
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user