feat(yocto): layer trees are detected as Embedded Linux / Yocto, and the scan matrix says what runs (#550)
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Successful in 1m15s
CI / Deploy MCP (push) Successful in 4m46s
CI / Deploy Dashboard (push) Successful in 6m40s
CI / Deploy Agent (push) Successful in 8m49s

This commit was merged in pull request #550.
This commit is contained in:
sharang committed 2026-10-09 14:58:09 +00:00
1 parent 528c9d4f7f
commit 750f1d7308
13 files changed
+581 -21

No files matched your search

+200 -1
View File
@@ -1,7 +1,7 @@
//! Heuristic target-type classification from artifact kinds and source markers.
//!
//! Complements the Firmwerk firmware detector: this handles web / backend /
//! mobile / desktop / PLC by sniffing manifest files and file extensions in the
//! mobile / desktop / PLC / Yocto by sniffing manifest files and file extensions in the
//! ingested code trees, plus strong priors from the artifact kinds themselves
//! (a PLC-project artifact is a PLC target; an `.ipa` is an iOS app).
@@ -40,6 +40,7 @@ const LOCATED_FILES: &[&str] = &[
"androidmanifest.xml",
"build.gradle",
"build.gradle.kts",
"layer.conf",
"projectversion.txt",
"pubspec.yaml",
"web.config",
@@ -280,6 +281,74 @@ fn package_json_is_frontend(root: &Path) -> bool {
.any(|f| c.contains(f))
}
/// The markers of a Yocto / OpenEmbedded layer tree.
#[derive(Default)]
struct YoctoShape {
/// The layers: directories holding a `conf/layer.conf` (`.` for the root).
layers: Vec<String>,
/// BitBake recipes, appends or includes (`.bb`, `.bbappend`, `.inc`
/// beside a `recipes-*` directory).
recipes: bool,
/// A kas project file (`kas*.yml`, or YAML beside a `kas/` directory).
kas: bool,
/// A build directory's `bblayers.conf` / `local.conf`, or poky's
/// `oe-init-build-env`.
build_setup: bool,
/// `meta-*` layer directories or distro configurations: common enough
/// elsewhere (`META-INF`) to only back up another signal.
corroborated: bool,
}
impl YoctoShape {
/// The confidence that the tree is a Yocto layer tree: a layer with its
/// recipes is as clear as an Android manifest; a kas file or a build
/// directory's configuration alone is weaker. `None` without any signal.
fn confidence(&self) -> Option<f32> {
let layer = !self.layers.is_empty();
let base = if layer && self.recipes {
return Some(0.8);
} else if layer || self.recipes {
0.65
} else if self.kas {
0.6
} else if self.build_setup {
0.5
} else {
return None;
};
Some(if self.corroborated { base + 0.05 } else { base })
}
}
/// What of a Yocto layer tree the markers show.
fn yocto_shape(m: &Markers) -> YoctoShape {
const LAYER_CONF: &str = "conf/layer.conf";
let is_yaml = |name: &str| name.ends_with(".yml") || name.ends_with(".yaml");
YoctoShape {
layers: m
.located_ending(LAYER_CONF)
.filter_map(|p| p.get(..p.len().saturating_sub(LAYER_CONF.len())))
.map(|dir| match dir.trim_end_matches('/') {
"" => ".".to_string(),
dir => dir.to_string(),
})
.collect(),
recipes: m.has_ext("bb")
|| m.has_ext("bbappend")
|| (m.has_ext("inc") && m.dirs.iter().any(|d| d.starts_with("recipes-"))),
kas: m.files.iter().any(|f| f.starts_with("kas") && is_yaml(f))
|| (m.dirs.contains("kas") && (m.has_ext("yml") || m.has_ext("yaml"))),
build_setup: ["bblayers.conf", "local.conf", "oe-init-build-env"]
.iter()
.any(|f| m.has_file(f)),
corroborated: m
.dirs
.iter()
.any(|d| d.starts_with("meta-") && d != "meta-inf")
|| (m.dirs.contains("distro") && m.has_ext("conf")),
}
}
/// The heuristic classifier: artifact-kind priors + source-tree markers.
pub struct HeuristicClassifier;
@@ -519,6 +588,28 @@ impl HeuristicClassifier {
));
}
}
// Yocto / OpenEmbedded. The C sources a recipe carries in
// `files/` do not make it firmware: a layer with its recipes
// outranks Firmwerk's guess from loose sources (0.3).
let yocto = yocto_shape(&m);
if let Some(confidence) = yocto.confidence() {
let mut facts = facts_lang("bitbake");
facts.push(DetectedFact::new("build_system", "bitbake", "heuristic"));
// Each layer, for the stages that read the recipes.
facts.extend(
yocto
.layers
.iter()
.take(10)
.map(|layer| DetectedFact::new("yocto_layer", layer, "heuristic")),
);
out.push(verdict(
TargetType::EmbeddedLinuxYocto,
confidence,
"Yocto layer / BitBake recipes / kas project",
facts,
));
}
// Container-only.
if m.has_file("dockerfile") && out.is_empty() {
out.push(verdict(
@@ -902,6 +993,114 @@ mod tests {
assert!(!v.iter().any(|x| x.target_type == TargetType::AndroidApp));
}
/// Assert the Yocto verdict's confidence (`None`: no Yocto verdict).
fn assert_yocto(verdicts: &[ClassifierVerdict], want: Option<f32>) {
let got = verdicts
.iter()
.find(|v| v.target_type == TargetType::EmbeddedLinuxYocto)
.map(|v| v.confidence);
match (got, want) {
(Some(got), Some(want)) => assert!((got - want).abs() < 1e-6, "{got} != {want}"),
_ => assert_eq!(got.is_some(), want.is_some(), "{got:?} != {want:?}"),
}
}
#[tokio::test]
async fn a_layer_with_recipes_is_confidently_yocto_and_names_its_layers() {
let v = classify_tree(|root| {
write_all(
root,
&[
(
"meta-pump/conf/layer.conf",
"BBFILE_COLLECTIONS += \"pump\"",
),
(
"meta-pump/recipes-app/pump/pump_1.0.bb",
"LICENSE = \"CLOSED\"",
),
(
"meta-pump/recipes-app/pump/files/pump.c",
"int main(void){}",
),
(
"meta-pump/recipes-app/pump/files/Makefile",
"all:\n\tcc pump.c",
),
("meta-pump/recipes-core/images/pump-image.bbappend", ""),
("conf/layer.conf", ""),
("recipes-x/x/x_1.0.bb", ""),
],
);
})
.await;
assert_eq!(top(&v), TargetType::EmbeddedLinuxYocto);
assert_yocto(&v, Some(0.8));
let facts = &v
.iter()
.find(|x| x.target_type == TargetType::EmbeddedLinuxYocto)
.expect("yocto verdict")
.facts;
let value = |key: &str| -> Vec<&str> {
facts
.iter()
.filter(|f| f.key == key)
.map(|f| f.value.as_str())
.collect()
};
assert_eq!(value("build_system"), ["bitbake"]);
assert_eq!(value("yocto_layer"), [".", "meta-pump"]);
}
#[tokio::test]
async fn weaker_yocto_signals_give_a_lower_confidence() {
let kas = classify_tree(|root| {
write_all(root, &[("kas-pump.yml", "header:\n version: 14\n")]);
})
.await;
assert_yocto(&kas, Some(0.6));
let kas_dir = classify_tree(|root| {
write_all(root, &[("kas/pump.yaml", "header:\n version: 14\n")]);
})
.await;
assert_yocto(&kas_dir, Some(0.6));
// A poky checkout: the build environment script and meta-* layers.
let poky = classify_tree(|root| {
write_all(
root,
&[("oe-init-build-env", "#!/bin/sh"), ("meta-poky/README", "")],
);
})
.await;
assert_yocto(&poky, Some(0.55));
let recipes_only = classify_tree(|root| {
write_all(root, &[("recipes-app/pump/pump_1.0.bb", "")]);
})
.await;
assert_yocto(&recipes_only, Some(0.65));
}
#[tokio::test]
async fn meta_inf_and_loose_conf_files_are_not_yocto() {
let v = classify_tree(|root| {
write_all(
root,
&[
("app/src/main/resources/META-INF/MANIFEST.MF", ""),
("pom.xml", "<project/>"),
("etc/distro/default.conf", ""),
("lib/defs.inc", ""),
],
);
})
.await;
assert_yocto(&v, None);
assert_eq!(top(&v), TargetType::BackendService);
}
#[tokio::test]
async fn structured_text_is_plc() {
let v = classify_tree(|root| {
+102
View File
@@ -260,6 +260,108 @@ mod tests {
assert_eq!(target.detected_type(&c), Some(TargetType::PlcSps));
}
/// What Firmwerk reports for loose C sources, or for a Makefile.
fn firmwerk_found(provider: &str, confidence: &str) -> MockFirmwareDetector {
MockFirmwareDetector {
detection: Some(FirmwareDetection {
provider: provider.to_string(),
confidence: confidence.to_string(),
build_system: provider.to_string(),
framework: Some("bare-metal".to_string()),
target: FirmwareTarget::default(),
gaps: vec![],
}),
}
}
/// Classify the tree `files` (relative path, content) as one source
/// archive, with `detector` standing in for Firmwerk.
async fn classify_files(
files: &[(&str, &str)],
detector: &MockFirmwareDetector,
) -> Classification {
let scratch = Scratch::new();
for (rel, content) in files {
let path = scratch.0.join(rel);
fs::create_dir_all(path.parent().expect("parent")).expect("mkdir");
fs::write(path, content).expect("write");
}
let artifact = Artifact::source_archive("upload.zip");
let mut wp = HashMap::new();
wp.insert(artifact.id.clone(), scratch.0.clone());
let mut target = OnboardedTarget::new("t".to_string(), TargetType::BackendService);
target.artifacts.push(artifact);
classify_target(&target, &wp, detector)
.await
.expect("classify")
}
#[tokio::test]
async fn the_nightly_yocto_fixture_is_typed_yocto() {
let fixture =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../fixtures/nightly/firmware/yocto-layer");
let artifact = Artifact::source_archive("yocto-layer.zip");
let mut wp = HashMap::new();
wp.insert(artifact.id.clone(), fixture);
let mut target = OnboardedTarget::new("y".to_string(), TargetType::BackendService);
target.artifacts.push(artifact);
let c = classify_target(&target, &wp, &no_firmware())
.await
.expect("classify");
assert_eq!(c.suggested, TargetType::EmbeddedLinuxYocto);
assert!(c
.facts
.iter()
.any(|f| f.key == "build_system" && f.value == "bitbake"));
assert!(c
.facts
.iter()
.any(|f| f.key == "yocto_layer" && f.value == "."));
}
#[tokio::test]
async fn a_plain_c_firmware_repo_stays_bare_metal() {
let c = classify_files(
&[
("Makefile", "CC=arm-none-eabi-gcc\nCFLAGS=-mcpu=cortex-m4"),
("Core/Src/main.c", "int main(void){}"),
// A config file in `conf/` is not a layer.
("conf/board.conf", "BOARD=nucleo"),
],
&firmwerk_found("make", "medium"),
)
.await;
assert_eq!(c.suggested, TargetType::FirmwareBareMetal);
assert!(!c
.candidates
.iter()
.any(|x| x.target_type == TargetType::EmbeddedLinuxYocto));
}
#[tokio::test]
async fn a_layer_shipping_c_sources_is_yocto_not_bare_metal() {
// Firmwerk's source archaeology fires on the recipe's C sources.
let c = classify_files(
&[
("conf/layer.conf", "BBFILE_COLLECTIONS += \"pump\""),
(
"recipes-app/pump/pump_1.0.bb",
"SRC_URI = \"file://pump.c\"",
),
("recipes-app/pump/files/pump.c", "int main(void){}"),
("recipes-app/pump/files/pump.h", "#pragma once"),
],
&firmwerk_found("source-archaeology", "low"),
)
.await;
assert_eq!(c.suggested, TargetType::EmbeddedLinuxYocto);
// The firmware reading stays a lower candidate.
assert!(c
.candidates
.iter()
.any(|x| x.target_type == TargetType::FirmwareBareMetal));
}
#[tokio::test]
async fn no_signal_falls_back_to_declared_type() {
let scratch = Scratch::new();
+20 -4
View File
@@ -1781,6 +1781,8 @@ impl PipelineOrchestrator {
let working_paths = ingest_set.working_paths();
self.record_upload_hashes(target, &ingest_set).await;
let mut detected_firmware = false;
// Without a classification the declared type decides.
let mut yocto = target.target_type == TargetType::EmbeddedLinuxYocto;
self.update_step(scan_run_id, ScanStep::DetectProjectType)
.await;
match crate::classify::classify_target(
@@ -1798,6 +1800,7 @@ impl PipelineOrchestrator {
);
detected_firmware =
crate::pipeline::firmware_sbom::is_firmware_target(classification.suggested);
yocto = classification.suggested == TargetType::EmbeddedLinuxYocto;
if let (Some(oid), Ok(bson)) = (target.id, mongodb::bson::to_bson(&classification))
{
let mut set = doc! { "classification": bson };
@@ -1834,12 +1837,25 @@ impl PipelineOrchestrator {
// Analysis-based firmware SBOM: for embedded targets, derive components
// (resolved libraries + cross-toolchain) from Firmwerk's build-plan
// analysis over the already-ingested source — no build, no binary
// upload. When no build plan forms (e.g. a Yocto layer), the run says
// so rather than completing as if the firmware had no components.
// upload. When no build plan forms, the run says so rather than
// completing as if the firmware had no components.
// What the code is decides, not only the type picked at onboarding: an
// STM32 project onboarded as "backend service" still gets its SBOM.
if detected_firmware
|| crate::pipeline::firmware_sbom::is_firmware_target(target.target_type)
// A Yocto layer tree is not a firmware build: Firmwerk would read the
// C sources a recipe ships in `files/` as a bare-metal project.
if yocto && target.code_artifact().is_some() {
self.skip_stage(
scan_run_id,
SkippedStage::new(
"firmware_sbom",
SkipCode::NotAnalysedYet,
compliance_core::scan_matrix::YOCTO_BUILD_PLANNED,
),
)
.await;
} else if !yocto
&& (detected_firmware
|| crate::pipeline::firmware_sbom::is_firmware_target(target.target_type))
{
if let Some(code) = target.code_artifact() {
if let Some(path) = working_paths.get(&code.id) {
+19 -2
View File
@@ -124,8 +124,8 @@ fn resolve_artifact(target: &OnboardedTarget, required: Option<ArtifactKind>) ->
/// The pipeline phase reported while a given scan runs.
fn phase_for(scan: ScanType) -> ScanPhase {
match scan {
ScanType::Sast => ScanPhase::Sast,
ScanType::Sbom => ScanPhase::SbomGeneration,
ScanType::Sast | ScanType::RecipeLint => ScanPhase::Sast,
ScanType::Sbom | ScanType::RecipeInventory => ScanPhase::SbomGeneration,
ScanType::Cve => ScanPhase::CveScanning,
ScanType::Gdpr | ScanType::OAuth => ScanPhase::PatternScanning,
ScanType::SecretDetection => ScanPhase::SecretDetection,
@@ -175,6 +175,23 @@ mod tests {
assert_eq!(dast.artifact_id, url_id);
}
#[test]
fn a_yocto_layer_tree_runs_its_source_scans_and_records_the_planned_recipe_stages() {
let t = target(
TargetType::EmbeddedLinuxYocto,
vec![Artifact::source_archive("meta-pump.zip")],
);
let plan = build_scan_plan(&t);
assert!(plan.has(ScanType::Sast) && plan.has(ScanType::Sbom));
assert!(!plan.has(ScanType::Dast));
let recorded: Vec<ScanType> = plan.unavailable.iter().map(|u| u.scan_type).collect();
assert_eq!(
recorded,
[ScanType::RecipeInventory, ScanType::RecipeLint],
"only the recipe stages: no image is attached"
);
}
#[test]
fn webapp_without_url_omits_dast() {
let t = target(TargetType::WebApp, vec![Artifact::git_repo("u", "main")]);
+8
View File
@@ -33,6 +33,12 @@ pub enum ScanType {
/// Malware signatures (ClamAV) and the committed binaries of a tree
/// (#465).
Malware,
/// The recipe inventory of a Yocto layer tree: the components its BitBake
/// recipes build (SBOM) and their known vulnerabilities.
RecipeInventory,
/// Security lint of a Yocto layer tree's BitBake recipes and image
/// configuration.
RecipeLint,
}
impl std::fmt::Display for ScanType {
@@ -55,6 +61,8 @@ impl std::fmt::Display for ScanType {
Self::IcsProbe => write!(f, "ics_probe"),
Self::Pentest => write!(f, "pentest"),
Self::Malware => write!(f, "malware"),
Self::RecipeInventory => write!(f, "recipe_inventory"),
Self::RecipeLint => write!(f, "recipe_lint"),
}
}
}
+99 -7
View File
@@ -27,6 +27,22 @@ 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";
/// Why a Yocto image has no SBOM or CVE match yet: that needs the build's
/// artefacts (tier 2), not the layer tree.
const YOCTO_IMAGE_SBOM: &str = "a Yocto image SBOM needs build artefacts (SPDX/manifest), planned";
const YOCTO_IMAGE_CVE: &str =
"CVE matching for a Yocto image needs build artefacts (SPDX/manifest), planned";
/// Why the firmware SBOM stage passes over a Yocto layer tree: Firmwerk forms
/// no build plan from BitBake recipes. The agent records it with this text.
pub const YOCTO_BUILD_PLANNED: &str =
"Yocto build analysis is planned (tier 2): a layer tree is not a firmware build";
/// The recipe inventory of a Yocto layer tree (SBOM and CVEs from its BitBake
/// recipes): `Some(reason)` while no stage runs it, `None` once one does.
const RECIPE_INVENTORY: Option<&str> =
Some("the recipe inventory (SBOM and CVEs from the BitBake recipes) is planned");
/// Recipe lint (oelint-adv and our own rules) over a Yocto layer tree, likewise.
const RECIPE_LINT: Option<&str> = Some("recipe lint (oelint-adv) over the layers is planned");
/// What an artifact a scan needs in order to run.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -216,7 +232,7 @@ pub fn rules_for(target_type: TargetType) -> Vec<ScanRule> {
/// 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};
use ArtifactRequirement::{Code, Firmware, HttpUrl, Mobile, Plc, RunningUrl};
match target_type {
TargetType::WebApp | TargetType::BackendService => {
let mut r = sast_umbrella();
@@ -263,6 +279,26 @@ fn target_rules(target_type: TargetType) -> Vec<ScanRule> {
}
TargetType::EmbeddedLinuxYocto => {
let mut r = sast_umbrella();
// Tier 1: the layer tree itself. Each turns on by setting its
// constant to `None`.
r.push(ScanRule {
unavailable: RECIPE_INVENTORY,
..ScanRule::new(
ScanType::RecipeInventory,
true,
"Recipe inventory (SBOM and CVEs) from the layers' BitBake recipes",
Code,
)
});
r.push(ScanRule {
unavailable: RECIPE_LINT,
..ScanRule::new(
ScanType::RecipeLint,
true,
"Security lint of the BitBake recipes and image configuration",
Code,
)
});
r.push(ScanRule::unavailable(
ScanType::FirmwareStatic,
"EMBA / binwalk static analysis of the image",
@@ -271,15 +307,15 @@ fn target_rules(target_type: TargetType) -> Vec<ScanRule> {
));
r.push(ScanRule::unavailable(
ScanType::Sbom,
"SBOM from image layers / recipes",
"SBOM from the image's build artefacts",
Firmware,
SBOM_FROM_IMAGE,
YOCTO_IMAGE_SBOM,
));
r.push(ScanRule::unavailable(
ScanType::Cve,
"Match image components against known CVEs",
Firmware,
CVE_FROM_IMAGE,
YOCTO_IMAGE_CVE,
));
r.push(ScanRule::new(
ScanType::Dast,
@@ -348,7 +384,8 @@ fn target_rules(target_type: TargetType) -> Vec<ScanRule> {
///
/// Pentest runs as its own session (not a [`ScanType`] scan) and needs a
/// reachable running target, so it is offered only for the network-reachable
/// families.
/// families. Not for Embedded Linux / Yocto until an image can be booted in an
/// emulation sandbox: a pentest of the customer's device is out of scope.
pub fn supports_pentest(target_type: TargetType) -> bool {
matches!(
target_type,
@@ -356,7 +393,6 @@ pub fn supports_pentest(target_type: TargetType) -> bool {
| TargetType::BackendService
| TargetType::AndroidApp
| TargetType::IosApp
| TargetType::EmbeddedLinuxYocto
// A PLC/SPS device exposes reachable runtime services (WebVisu, OPC UA,
// the CODESYS programming protocol), so an active pentest applies.
| TargetType::PlcSps
@@ -671,13 +707,69 @@ mod tests {
fn pentest_support_matches_reachable_families() {
assert!(supports_pentest(TargetType::WebApp));
assert!(supports_pentest(TargetType::BackendService));
assert!(supports_pentest(TargetType::EmbeddedLinuxYocto));
assert!(!supports_pentest(TargetType::EmbeddedLinuxYocto));
// A PLC/SPS device is network-reachable (WebVisu / OPC UA / 11740).
assert!(supports_pentest(TargetType::PlcSps));
assert!(!supports_pentest(TargetType::FirmwareBareMetal));
assert!(!supports_pentest(TargetType::DesktopApp));
}
#[test]
fn a_yocto_layer_tree_lists_the_planned_recipe_stages_and_runs_its_source_scans() {
let t = target_with(
TargetType::EmbeddedLinuxYocto,
vec![Artifact::git_repo("https://git/meta-pump", "main")],
);
let opts = applicable_scans(&t);
for (scan, reason) in [
(ScanType::RecipeInventory, RECIPE_INVENTORY),
(ScanType::RecipeLint, RECIPE_LINT),
] {
let opt = option(&opts, scan).expect("listed for a Yocto target");
assert!(!opt.default_on, "{scan} must not be pre-selected yet");
// The layer tree is there, so the run records the stage as not
// done instead of passing over it.
assert_eq!(opt.unavailable_with_artifact(), reason);
}
// The source scans (secrets, malware, the source SBOM) still run.
let sast = option(&opts, ScanType::Sast).expect("sast");
assert!(sast.default_on && sast.unavailable.is_none());
// DAST stays opt-in and needs a web address.
let dast = option(&opts, ScanType::Dast).expect("dast listed");
assert!(!dast.default_on && dast.blocked_reason.is_some());
}
#[test]
fn a_yocto_image_has_no_sbom_until_build_artefacts_can_be_imported() {
let t = target_with(
TargetType::EmbeddedLinuxYocto,
vec![
Artifact::firmware_image("core-image.wic"),
Artifact::live_url("https://device.local"),
],
);
let opts = applicable_scans(&t);
let image_option = |scan: ScanType| {
opts.iter().find(|o| {
o.scan == scan && o.required_artifact == Some(ArtifactKind::FirmwareImage)
})
};
for (scan, reason) in [
(ScanType::Sbom, YOCTO_IMAGE_SBOM),
(ScanType::Cve, YOCTO_IMAGE_CVE),
] {
let opt = image_option(scan).expect("image rule listed");
assert!(!opt.default_on);
assert_eq!(opt.unavailable_with_artifact(), Some(reason));
assert!(reason.contains("build artefacts (SPDX/manifest), planned"));
}
// With a web address DAST is unblocked but still opt-in; no pentest
// until an image boots in an emulation sandbox.
let dast = option(&opts, ScanType::Dast).expect("dast listed");
assert!(dast.blocked_reason.is_none() && !dast.default_on);
assert!(!supports_pentest(t.target_type));
}
#[test]
fn every_target_type_has_at_least_one_rule() {
for tt in [
+68 -1
View File
@@ -493,6 +493,14 @@ pub mod scans {
de: "Firmware-SBOM",
en: "Firmware SBOM",
},
"recipe_inventory" => Text {
de: "Rezept-Inventar (Yocto)",
en: "Recipe inventory (Yocto)",
},
"recipe_lint" => Text {
de: "Rezept-Prüfung (Yocto)",
en: "Recipe lint (Yocto)",
},
"plc_archive_sbom" => Text {
de: "SPS-Bibliotheken (SBOM)",
en: "PLC libraries (SBOM)",
@@ -1774,6 +1782,8 @@ pub mod findings {
ScanType::IcsProbe => ("Industrieprotokolle (ICS)", "Industrial protocols (ICS)"),
ScanType::Pentest => ("Penetrationstest", "Penetration test"),
ScanType::Malware => ("Schadsoftware und Binärdateien", "Malware and binaries"),
ScanType::RecipeInventory => ("Rezept-Inventar (Yocto)", "Recipe inventory (Yocto)"),
ScanType::RecipeLint => ("Rezept-Prüfung (Yocto)", "Recipe lint (Yocto)"),
};
Text { de, en }
}
@@ -3208,6 +3218,17 @@ pub mod coverage {
ScanType::Gdpr => ("Prüft Datenschutz-Muster", "Checks privacy patterns"),
ScanType::OAuth => ("Prüft die OAuth-Konfiguration", "Checks the OAuth setup"),
ScanType::CodeReview => ("Code-Review", "Code review"),
ScanType::RecipeInventory => (
"Listet die Komponenten aus den BitBake-Rezepten der Layer und gleicht sie mit \
bekannten Schwachstellen ab",
"Lists the components the layers' BitBake recipes build and matches them against \
known vulnerabilities",
),
ScanType::RecipeLint => (
"Prüft die BitBake-Rezepte und die Image-Konfiguration auf unsichere \
Einstellungen",
"Checks the BitBake recipes and the image configuration for insecure settings",
),
};
Text { de, en }
}
@@ -3263,6 +3284,23 @@ pub mod coverage {
de: "App-Pakete werden noch nicht analysiert",
en: "app packages are not analysed yet",
};
pub const YOCTO_BUILD_ARTEFACTS: Text = Text {
de: "braucht die Build-Artefakte des Images (SPDX/Manifest), geplant",
en: "needs the image's build artefacts (SPDX/manifest), planned",
};
pub const YOCTO_BUILD_PLANNED: Text = Text {
de: "Die Analyse von Yocto-Builds ist geplant (Stufe 2); ein Layer-Baum ist kein \
Firmware-Build",
en: "Yocto build analysis is planned (tier 2); a layer tree is not a firmware build",
};
pub const RECIPE_INVENTORY_PLANNED: Text = Text {
de: "Das Rezept-Inventar (Stückliste und CVEs aus den BitBake-Rezepten) ist in Arbeit",
en: "the recipe inventory (SBOM and CVEs from the BitBake recipes) is in progress",
};
pub const RECIPE_LINT_PLANNED: Text = Text {
de: "Die Rezept-Prüfung (oelint-adv) ist in Arbeit",
en: "recipe lint (oelint-adv) is in progress",
};
pub const OFF_HERE: Text = Text {
de: "In dieser Umgebung nicht aktiviert:",
en: "Not enabled in this environment:",
@@ -3275,7 +3313,16 @@ pub mod coverage {
let r = raw.to_ascii_lowercase();
// Missing artifacts name the kind as `no <kind> artifact provided`;
// scans no stage runs yet explain themselves in prose.
let text = if r.contains("uploaded archive") {
// Yocto first: its image reasons also name firmware images.
let text = if r.contains("yocto build analysis") {
YOCTO_BUILD_PLANNED
} else if r.contains("build artefacts") {
YOCTO_BUILD_ARTEFACTS
} else if r.contains("recipe inventory") {
RECIPE_INVENTORY_PLANNED
} else if r.contains("recipe lint") {
RECIPE_LINT_PLANNED
} else if r.contains("uploaded archive") {
UPLOAD_BESIDE_GIT
} else if r.contains("http(s) live url") {
NEEDS_WEB_URL
@@ -3346,6 +3393,26 @@ mod coverage_tests {
"mobile packages are not analysed yet: only the app's source code is scanned",
coverage::MOBILE_NOT_ANALYSED,
),
(
"a Yocto image SBOM needs build artefacts (SPDX/manifest), planned",
coverage::YOCTO_BUILD_ARTEFACTS,
),
(
"CVE matching for a Yocto image needs build artefacts (SPDX/manifest), planned",
coverage::YOCTO_BUILD_ARTEFACTS,
),
(
"Yocto build analysis is planned (tier 2): a layer tree is not a firmware build",
coverage::YOCTO_BUILD_PLANNED,
),
(
"the recipe inventory (SBOM and CVEs from the BitBake recipes) is planned",
coverage::RECIPE_INVENTORY_PLANNED,
),
(
"recipe lint (oelint-adv) over the layers is planned",
coverage::RECIPE_LINT_PLANNED,
),
];
for (raw, want) in cases {
assert_eq!(reason(raw), Some(want), "{raw}");
+1
View File
@@ -44,6 +44,7 @@ export default withMermaid(defineConfig({
{ text: 'Prüfobjekte anlegen', link: '/guide/repositories' },
{ text: 'Prüfungen', link: '/guide/scanning' },
{ text: 'SPS / PLC (CODESYS)', link: '/guide/plc' },
{ text: 'Embedded Linux / Yocto', link: '/guide/yocto' },
{ text: '.NET-Projekte', link: '/guide/dotnet' },
{ text: '.NET projects (English)', link: '/guide/dotnet-en' },
{ text: 'Befunde', link: '/guide/findings' },
+1 -1
View File
@@ -39,7 +39,7 @@ Under **Maschine und Gerät** (Machine and device):
| **SPS / PLC** | CODESYS, PLCopen XML, Structured Text (IEC 61131-3) |
| **Firmware — ohne Betriebssystem** | Microcontroller without an operating system, e.g. STM32 with HAL |
| **Firmware — RTOS** | FreeRTOS, Zephyr and other real-time operating systems |
| **Embedded Linux / Yocto** (preview) | BSP + image. Today a scan covers secrets, malware and SAST over patches and files; there is no recipe or image SBOM yet. |
| **Embedded Linux / Yocto** (preview) | BSP + image. Today a scan covers secrets, malware and SAST over patches and files; there is no recipe or image SBOM yet. See [Embedded Linux / Yocto](./yocto.md). |
Under **Weitere Software** (Other software): **Backend / API**,
**Webanwendung**, **Desktop-Anwendung**, **Android-App**, **iOS-App**.
+50
View File
@@ -0,0 +1,50 @@
# Embedded Linux / Yocto
Yocto support is a **preview**. Prüfwerk recognises a Yocto / OpenEmbedded layer
tree and scans its sources today; the Yocto-specific analyses are being added in
three tiers, by what you can give us.
## Detection
A git repository or source archive is typed **Embedded Linux / Yocto** from what
it holds:
| Signal | Confidence |
| --- | --- |
| `conf/layer.conf` **and** BitBake recipes (`*.bb`, `*.bbappend`, `*.inc` under `recipes-*`) | high (0.8) |
| only one of the two | medium (0.65) |
| a kas project file (`kas*.yml`, `kas/*.yml`) | 0.6 |
| a build directory's `bblayers.conf` / `local.conf`, or poky's `oe-init-build-env` | low (0.5) |
`meta-*` layer directories and `conf/distro/*.conf` raise a medium or low verdict
slightly, but never decide on their own (`META-INF` is everywhere). C sources a
recipe ships in `files/` do not make the tree bare-metal firmware: the layer
outranks Firmwerk's reading of loose sources. A Zephyr or ESP-IDF project inside
the tree is still detected as RTOS firmware.
The wizard proposes the type after the first scan has read the code, as for every
other source-based type. The detection is stored on the target as facts:
`build_system = bitbake` and one `yocto_layer` per layer (the directory holding
its `conf/layer.conf`, `.` for the repository root). A `build/` directory is not
searched.
## What runs today
| Scan | Status |
| --- | --- |
| Secrets (Gitleaks), malware and committed binaries (ClamAV) | runs over the layer tree |
| Code analysis (Semgrep, Cppcheck) | runs over patches and the sources in `files/` |
| SBOM from lockfiles (Syft) | runs, but a layer has no lockfiles, so it is usually empty |
| Firmware SBOM (Firmwerk) | not run: listed under **Nicht ausgeführt** as "Yocto build analysis is planned (tier 2)" |
| Recipe inventory, recipe lint | in progress (tier 1), listed under **Nicht ausgeführt** until they land |
| Image SBOM / CVE | needs build artefacts (SPDX / manifest), planned (tier 2) |
| DAST | opt-in, with an http(s) address of the running device |
| Penetration test | not offered until an image can be booted in an emulation sandbox |
## What is planned
| Tier | Input | Analysis |
| --- | --- | --- |
| **1: layer tree** (in progress) | the layers in git, no build | **Recipe inventory**: every recipe's name, version, `SRC_URI`, `CVE_PRODUCT` and `CVE_STATUS`, matched against NVD; labelled as a recipe inventory, not the image's SBOM. **Recipe lint**: oelint-adv plus our own rules (debug and empty-password image features, `http://` fetches, keys under `files/`, missing `security_flags.inc`) |
| **2: build artefacts** | `tmp/deploy/spdx` (SPDX 3.0, or 2.2 up to Scarthgap), `*.vex.json`, the image `.manifest`, the kernel `.config` | **SPDX import** into the SBOM view and CycloneDX export; **sbom-cve-check** with the Yocto VEX annotations; kernel CVEs filtered by the configuration; a nightly re-check without a rebuild |
| **3: image / rootfs** | `.wic`, tar, ext4, squashfs | unpacking, ELF hardening of every binary, secrets and default credentials in the root filesystem; DAST and pentest only for a qemu build in an isolated sandbox |
@@ -2,7 +2,9 @@
"scan_status": "completed",
"skipped_stages": [
"firmware_sbom",
"malware"
"malware",
"recipe_inventory",
"recipe_lint"
],
"sbom": [],
"findings": [],
+1 -1
View File
@@ -19,7 +19,7 @@ SBOM reads as declared dependencies (#317):
| `freertos-lostbuild` | `lostbuild` | source archaeology: no build system, FreeRTOS found from its headers |
| `c-sensor-node` | (ours) | Make; C/C++ SAST (#334): planted flaws in `Core/`, a vendored HAL in `Drivers/` that must not be reported |
| `embedded-libs` | (ours) | Make; FreeRTOS 10.3.1, lwIP 2.1.2 and Mbed TLS 2.16.2 vendored as source: versions read from their headers, CVEs matched in NVD by CPE. The headers hold only the version defines |
| `yocto-layer` | (ours) | none: Yocto is not analysed yet, so the scan must record it |
| `yocto-layer` | (ours) | none: detected as a BitBake layer tree (`build_system = bitbake`); its recipe inventory and lint are recorded as not run yet |
`make` is also onboarded as a backend service (`fw-make-onboarded-as-service`):
the firmware SBOM follows detection, not the type picked in the wizard.
+9 -3
View File
@@ -264,15 +264,21 @@
},
{
"key": "fw-yocto-layer",
"name": "Firmware · Yocto layer (unsupported)",
"name": "Firmware · Yocto layer",
"target_type": "embedded_linux_yocto",
"description": "A Yocto layer. Not analysed yet, so the run must record a skipped firmware_sbom stage with the reason instead of completing as if there were no components.",
"description": "A Yocto layer (conf/layer.conf + one recipe). Detected as a BitBake layer tree; the firmware SBOM, the recipe inventory and recipe lint are recorded as skipped with their reasons until those stages land, never completing as if there were no components.",
"artifacts": [
{
"kind": "source_archive",
"upload": "fixtures/nightly/firmware/yocto-layer"
}
]
],
"expect": {
"detected_facts": {
"build_system": "bitbake",
"yocto_layer": "."
}
}
},
{
"key": "fw-zephyr-example-pinned",