fix(yocto): recipe lint binds attack-surface findings to cra-ai-2 and counts suppressed findings #554

Merged
sharang merged 1 commits from fix/yocto-recipe-lint-followups into main 2026-10-09 16:49:28 +00:00
10 changed files with 366 additions and 70 deletions

No files matched your search

+40 -1
View File
@@ -175,7 +175,18 @@ pub fn control_statuses(
let (state, reason) = if !against.is_empty() {
(ControlState::NotSatisfied, None)
} else {
match (entry.status, scanned_languages) {
// A control otherwise outside static scans is assessed where
// one of its bindings checks the scanned code (cra-ai-2's
// recipe lint on a Yocto layer tree).
let status = match entry.status {
Coverage::NotCodeCheckable
if scanned_languages.is_some_and(|l| entry.checked_for(l)) =>
{
Coverage::Covered
}
status => status,
};
match (status, scanned_languages) {
(Coverage::NotCodeCheckable, _) => (ControlState::NotCodeCheckable, None),
(Coverage::NeedsTooling, _) => {
(ControlState::NotAssessed, Some(NotAssessedReason::NoTool))
@@ -294,6 +305,34 @@ mod tests {
status_of(statuses, control).state
}
#[test]
fn attack_surface_is_assessed_on_a_yocto_tree_only() {
let map = ControlMap::cra().expect("map");
let yocto = vec!["bitbake".to_string(), "c".to_string()];
let none = SbomCoverage::Complete;
let statuses = control_statuses(&map, &[], Some(&yocto), &[], &none);
assert_eq!(
state_of(&statuses, "cra-ai-2"),
ControlState::NoViolationFound
);
// Elsewhere it stays outside static scans.
for languages in [Some(python()), Some(c_only()), None] {
let statuses = control_statuses(&map, &[], languages.as_deref(), &[], &none);
assert_eq!(
state_of(&statuses, "cra-ai-2"),
ControlState::NotCodeCheckable
);
}
// oelint-adv did not complete: not assessed.
let statuses = control_statuses(&map, &[], Some(&yocto), &["oelint-adv"], &none);
assert_eq!(state_of(&statuses, "cra-ai-2"), ControlState::NotAssessed);
// A finding bound to it counts against it.
let mut network = finding("cra-ai-2", FindingStatus::Open);
network.scanner = "oelint-adv".into();
let statuses = control_statuses(&map, &[network], Some(&yocto), &[], &none);
assert_eq!(state_of(&statuses, "cra-ai-2"), ControlState::NotSatisfied);
}
#[test]
fn every_control_gets_exactly_one_state() {
let map = ControlMap::cra().expect("map");
+22 -1
View File
@@ -2288,7 +2288,28 @@ impl PipelineOrchestrator {
match lint.oelint_findings(tree, repo_id).await {
Ok(found) => {
completed.push(oelint::SCANNER);
findings.extend(found);
findings.extend(found.findings);
// Suppressed findings are not shown, so the run says how many.
if found.suppressed > 0 {
tracing::info!(
repo_id,
suppressed = found.suppressed,
"recipe comments (# nooelint) suppressed oelint-adv findings"
);
self.skip_stage(
scan_run_id,
SkippedStage::new(
recipe_lint::SUPPRESSED_STAGE,
SkipCode::SuppressedInSource,
format!(
"{} findings suppressed by recipe comments (# nooelint)",
found.suppressed
),
)
.about(found.suppressed.to_string()),
)
.await;
}
}
Err(e) => {
tracing::warn!("[{repo_id}] oelint-adv failed: {e}");
@@ -29,6 +29,9 @@ use crate::pipeline::source_text::{read_lines, read_text};
pub const STAGE: &str = "recipe_lint";
/// The stage id the upstream layers left out are recorded under.
pub const UPSTREAM_STAGE: &str = "recipe_lint_upstream";
/// The stage id the findings suppressed by `# nooelint` comments are
/// recorded under.
pub const SUPPRESSED_STAGE: &str = "recipe_lint_suppressed";
/// Directories never walked: version control and a build directory's output.
const SKIPPED_DIRS: &[&str] = &[".git", "build", "downloads", "sstate-cache"];
@@ -14,6 +14,11 @@
//! (`--release`): the syntax (`_append` before Kirkstone) and which rules
//! apply depend on it. `oelint.vars.srcurigittag`, for one, only applies up
//! to Walnascar; later BitBake checks the tag itself.
//!
//! A `# nooelint: <rule>` comment in a recipe suppresses a finding there, as
//! oelint-adv intends. oelint-adv drops suppressed findings without a trace,
//! so they are counted: the suppressions of our rules in the recipes, less
//! those oelint-adv reports as not needed (`oelint.file.inlinesuppress_na`).
use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
@@ -27,6 +32,12 @@ use super::{Cra, Hit, RecipeLint, RuleInfo};
/// The scanner name of oelint-adv's findings.
pub const SCANNER: &str = "oelint-adv";
/// oelint-adv's report of a `# nooelint` comment that suppressed nothing.
const UNUSED_SUPPRESSION: &str = "oelint.file.inlinesuppress_na";
/// The id of every image-feature rule at once, as a suppression may name it.
const IMAGE_FEATURES: &str = "oelint.var.badimagefeature";
/// How long one run may take before it is stopped and recorded as failed.
const TIMEOUT: Duration = Duration::from_secs(600);
@@ -171,12 +182,15 @@ pub static RULES: [RuleInfo; 13] = [
),
];
/// The rule file passed with `--rulefile`: only [`RULES`] are loaded. An
/// empty severity keeps oelint-adv's own; ours come from [`RULES`].
/// The rule file passed with `--rulefile`: only [`RULES`] are loaded, and
/// the report of suppressions that suppressed nothing. An empty severity keeps
/// oelint-adv's own; ours come from [`RULES`].
fn rulefile() -> String {
let entries: serde_json::Map<String, serde_json::Value> = RULES
.iter()
.map(|r| (r.id.to_string(), serde_json::Value::String(String::new())))
.map(|r| r.id)
.chain([UNUSED_SUPPRESSION])
.map(|id| (id.to_string(), serde_json::Value::String(String::new())))
.collect();
serde_json::Value::Object(entries).to_string()
}
@@ -200,6 +214,14 @@ struct Lines {
begin: u32,
}
/// What one oelint-adv run reported.
#[derive(Debug, Default)]
struct Report {
hits: Vec<Hit>,
/// `# nooelint` suppressions of our rules that suppressed nothing.
unused_suppressions: usize,
}
/// The hits in a `gitlab-codequality` `report`. An issue is reported once per
/// place, though oelint-adv repeats it for each configuration it tries; a
/// rule we did not ask for is dropped.
@@ -207,31 +229,79 @@ struct Lines {
/// # Errors
///
/// Returns the parse error when `report` is not that format.
fn parse_report(report: &str) -> Result<Vec<Hit>, serde_json::Error> {
fn parse_report(report: &str) -> Result<Report, serde_json::Error> {
let issues: Vec<Issue> = serde_json::from_str(report)?;
let mut seen = BTreeSet::new();
Ok(issues
.into_iter()
.filter_map(|issue| {
let rule = RULES.iter().find(|r| r.id == issue.check_name)?;
let path = issue
.location
.path
.strip_prefix("./")
.unwrap_or(&issue.location.path)
.to_string();
let line = issue.location.lines.begin.max(1);
if !seen.insert((rule.id, path.clone(), line)) {
return None;
let mut unused = BTreeSet::new();
let mut hits = Vec::new();
for issue in issues {
let path = issue
.location
.path
.strip_prefix("./")
.unwrap_or(&issue.location.path)
.to_string();
let line = issue.location.lines.begin.max(1);
if issue.check_name == UNUSED_SUPPRESSION {
// "Inline suppression for '<id>' is not needed"
if let Some(id) = issue.description.split('\'').nth(1) {
if is_ours(id) {
unused.insert((path, line, id.to_string()));
}
}
// `[branch:true]` names the configuration oelint-adv tried.
let detail = match issue.description.rsplit_once(" [") {
Some((text, matrix)) if matrix.ends_with(']') => text,
_ => issue.description.as_str(),
};
Some(Hit::new(rule, &path, line, detail.to_string()))
continue;
}
let Some(rule) = RULES.iter().find(|r| r.id == issue.check_name) else {
continue;
};
if !seen.insert((rule.id, path.clone(), line)) {
continue;
}
// `[branch:true]` names the configuration oelint-adv tried.
let detail = match issue.description.rsplit_once(" [") {
Some((text, matrix)) if matrix.ends_with(']') => text,
_ => issue.description.as_str(),
};
hits.push(Hit::new(rule, &path, line, detail.to_string()));
}
Ok(Report {
hits,
unused_suppressions: unused.len(),
})
}
/// Whether a suppression naming `id` can suppress one of our rules.
fn is_ours(id: &str) -> bool {
id == IMAGE_FEATURES || RULES.iter().any(|r| r.id == id)
}
/// How many suppressions of our rules the `# nooelint:` comments in `text`
/// name, read as oelint-adv reads them.
fn suppressions(text: &str) -> usize {
text.lines()
.filter_map(|line| {
let rest = line.trim_start().strip_prefix('#')?;
// `#\s+nooelint:\s+<ids>`, as oelint-adv matches it.
let ids = rest.trim_start().strip_prefix("nooelint:").filter(|ids| {
rest.starts_with(char::is_whitespace) && ids.starts_with(char::is_whitespace)
})?;
Some(
ids.split(|c: char| c == ',' || c.is_whitespace())
.filter(|id| is_ours(id))
.count(),
)
})
.collect())
.sum()
}
/// oelint-adv's findings, and how many it did not report because a
/// `# nooelint` comment suppressed them.
#[derive(Debug, Default)]
pub struct OelintOutput {
/// The findings.
pub findings: Vec<Finding>,
/// Suppressions of our rules in the recipes that took effect.
pub suppressed: usize,
}
/// A scanner error with `source` as its cause.
@@ -243,7 +313,8 @@ fn failed(source: Box<dyn std::error::Error + Send + Sync>) -> CoreError {
}
impl RecipeLint {
/// oelint-adv's findings in the customer's layers under `root`.
/// oelint-adv's findings in the customer's layers under `root`, and the
/// findings suppressed by comments there.
///
/// # Errors
///
@@ -253,24 +324,41 @@ impl RecipeLint {
&self,
root: &Path,
repo_id: &str,
) -> Result<Vec<Finding>, CoreError> {
) -> Result<OelintOutput, CoreError> {
let work = WorkDir::new().map_err(|e| failed(Box::new(e)))?;
let mut hits = Vec::new();
let mut unused = 0;
let mut named = 0;
for layer in self.own_layers() {
// Includes are read through the recipes, so their comments count.
named += layer
.files
.iter()
.filter(|f| {
let inner = layer.inner(f);
is_bitbake(inner) || inner.ends_with(".inc")
})
.filter_map(|f| super::read_text(root, f))
.map(|text| suppressions(&text))
.sum::<usize>();
let files: Vec<&String> = layer
.files
.iter()
.filter(|f| is_bitbake(layer.inner(f)))
.collect();
for chunk in files.chunks(FILES_PER_RUN) {
let report = run(root, layer.release, chunk, &work).await?;
hits.extend(parse_report(&report)?);
let report = parse_report(&run(root, layer.release, chunk, &work).await?)?;
hits.extend(report.hits);
unused += report.unused_suppressions;
}
}
Ok(hits
.into_iter()
.map(|hit| hit.into_finding(root, repo_id))
.collect())
Ok(OelintOutput {
findings: hits
.into_iter()
.map(|hit| hit.into_finding(root, repo_id))
.collect(),
suppressed: named.saturating_sub(unused),
})
}
}
@@ -371,12 +459,26 @@ mod tests {
{"description": "SRC_URI[sha256sum] is needed",
"check_name": "oelint.vars.srcurichecksum",
"fingerprint": "d", "location": {"path": "./recipes-app/web/web_2.1.bb", "lines": {"begin": 0}},
"severity": "critical"}
"severity": "critical"},
{"description": "Inline suppression for 'oelint.vars.autorev' is not needed",
"check_name": "oelint.file.inlinesuppress_na",
"fingerprint": "e", "location": {"path": "recipes-app/web/web_2.1.bb", "lines": {"begin": 9}},
"severity": "info"},
{"description": "Inline suppression for 'oelint.vars.autorev' is not needed",
"check_name": "oelint.file.inlinesuppress_na",
"fingerprint": "f", "location": {"path": "recipes-app/web/web_2.1.bb", "lines": {"begin": 9}},
"severity": "info"},
{"description": "Inline suppression for 'oelint.var.order.PV' is not needed",
"check_name": "oelint.file.inlinesuppress_na",
"fingerprint": "g", "location": {"path": "recipes-app/web/web_2.1.bb", "lines": {"begin": 3}},
"severity": "info"}
]"#;
#[test]
fn the_report_becomes_one_hit_per_rule_and_place() {
let hits = parse_report(REPORT).expect("report");
let report = parse_report(REPORT).expect("report");
assert_eq!(report.unused_suppressions, 1);
let hits = report.hits;
let got: Vec<(&str, &str, u32, Severity)> = hits
.iter()
.map(|h| (h.rule.id, h.path.as_str(), h.line, h.rule.severity.clone()))
@@ -404,35 +506,92 @@ mod tests {
limitless access without authentication"
);
assert!(parse_report("not json").is_err());
assert!(parse_report("[]").expect("empty").is_empty());
assert!(parse_report("[]").expect("empty").hits.is_empty());
}
#[test]
fn the_rule_file_lists_only_the_security_rules() {
let file: serde_json::Map<String, serde_json::Value> =
serde_json::from_str(&rulefile()).expect("json");
assert_eq!(file.len(), RULES.len());
assert_eq!(file.len(), RULES.len() + 1);
assert!(file.contains_key(UNUSED_SUPPRESSION));
assert!(file.keys().all(|id| id.starts_with("oelint.")));
assert!(!file.contains_key("oelint.var.badimagefeature"));
}
/// Runs the real oelint-adv over the nightly fixture when it is on the
/// PATH (the agent image has it); passes without it.
#[test]
fn suppressions_of_our_rules_are_counted_as_oelint_adv_reads_them() {
let text = "# nooelint: oelint.vars.autorev, oelint.var.order.PV\n\
SRCREV = \"${AUTOREV}\"\n\
# nooelint: oelint.var.badimagefeature oelint.task.network\n\
#nooelint: oelint.vars.insaneskip\n\
# nooelint:oelint.vars.insaneskip\n\
# a note about nooelint: oelint.vars.autorev\n";
// One of the two on the first comment and both on the second; the
// third lacks the space oelint-adv requires, the last is prose.
assert_eq!(suppressions(text), 3);
assert_eq!(suppressions("SRC_URI = \"x\"\n"), 0);
}
/// The fixture with `# nooelint` comments: one that suppresses a
/// finding and one in the wrong place.
#[tokio::test]
async fn the_fixture_layer_yields_the_security_findings() {
async fn suppressed_findings_are_counted() {
if !installed() {
return;
}
let fixture =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../fixtures/nightly/firmware/yocto-layer");
let read = |rel: &str| std::fs::read_to_string(fixture.join(rel)).expect("fixture");
let fw = read("recipes-app/pump-fw/pump-fw_git.bb")
.replace("SRCREV = ", "# nooelint: oelint.vars.autorev\nSRCREV = ");
let web = read("recipes-app/pump-web/pump-web_2.1.bb").replace(
"do_compile() {",
"# nooelint: oelint.task.network\ndo_compile() {",
);
let t = super::super::tests::tree(&[
("conf/layer.conf", &read("conf/layer.conf")),
("recipes-app/pump-fw/pump-fw_git.bb", &fw),
("recipes-app/pump-web/pump-web_2.1.bb", &web),
]);
let lint = RecipeLint::for_tree(&t.0, &["bitbake".to_string()], &[]).expect("lint");
let out = lint.oelint_findings(&t.0, "t").await.expect("oelint-adv");
let rules: Vec<&str> = out
.findings
.iter()
.filter_map(|f| f.rule_id.as_deref())
.collect();
assert!(!rules.contains(&"oelint.vars.autorev"));
assert!(rules.contains(&"oelint.task.network"));
assert_eq!(out.suppressed, 1);
}
/// Whether oelint-adv is on the PATH (the agent image has it).
fn installed() -> bool {
let found = std::process::Command::new(SCANNER)
.arg("--version")
.output()
.is_ok_and(|o| o.status.success());
if !found {
eprintln!("oelint-adv is not installed; skipping");
}
found
}
/// Runs the real oelint-adv over the nightly fixture when it is on the
/// PATH (the agent image has it); passes without it.
#[tokio::test]
async fn the_fixture_layer_yields_the_security_findings() {
if !installed() {
return;
}
let root =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../fixtures/nightly/firmware/yocto-layer");
let lint = RecipeLint::for_tree(&root, &["bitbake".to_string()], &[]).expect("lint");
let findings = lint.oelint_findings(&root, "t").await.expect("oelint-adv");
let mut got: Vec<String> = findings
let out = lint.oelint_findings(&root, "t").await.expect("oelint-adv");
assert_eq!(out.suppressed, 0);
let mut got: Vec<String> = out
.findings
.iter()
.map(|f| {
format!(
+4
View File
@@ -237,6 +237,10 @@ pub enum SkipCode {
UploadUnchanged,
/// Files too large for the malware scan; `subject` lists them.
TooLargeToScan,
/// Findings a rule reported that comments in the scanned files suppress
/// (`# nooelint` in a Yocto recipe), so they are not shown; `subject` is
/// how many.
SuppressedInSource,
}
/// Why a scan run failed, stable for the dashboard to word.
+23
View File
@@ -501,6 +501,10 @@ pub mod scans {
de: "Rezept-Prüfung (Yocto)",
en: "Recipe lint (Yocto)",
},
"recipe_lint_suppressed" => Text {
de: "Rezept-Prüfung: unterdrückte Befunde",
en: "Recipe lint: suppressed findings",
},
"recipe_lint_upstream" => Text {
de: "Upstream-Layer (Poky, OpenEmbedded, BSP)",
en: "Upstream layers (Poky, OpenEmbedded, BSP)",
@@ -661,6 +665,14 @@ pub mod scans {
(SkipCode::TooLargeToScan, Lang::En) => {
format!("Too large for the malware scan, not checked: {subject}")
}
(SkipCode::SuppressedInSource, Lang::De) => format!(
"{subject} Befunde sind per Kommentar in den Rezepten (# nooelint) unterdrückt \
und werden nicht angezeigt."
),
(SkipCode::SuppressedInSource, Lang::En) => format!(
"{subject} findings are suppressed by comments in the recipes (# nooelint) and \
are not shown."
),
(SkipCode::PlatformProjectGenerated, Lang::De) => format!(
"Für {subject} erzeugt Unity das App-Projekt erst beim Build; es liegt nicht \
im Repository. Info.plist bzw. Manifest, Berechtigungen und nativer Code sind \
@@ -3508,6 +3520,17 @@ mod skipped_reason_tests {
.starts_with("Für Pump Game – iOS (Xcode) erzeugt Unity das App-Projekt erst"));
assert!(skipped_reason(&unity, Lang::En)
.starts_with("For Pump Game – iOS (Xcode), Unity generates the app project"));
let suppressed = SkippedStage::new(
"recipe_lint_suppressed",
SkipCode::SuppressedInSource,
"2 findings suppressed by recipe comments (# nooelint)",
)
.about("2");
assert_eq!(
skipped_reason(&suppressed, Lang::De),
"2 Befunde sind per Kommentar in den Rezepten (# nooelint) unterdrückt und werden \
nicht angezeigt."
);
}
#[test]
+29 -17
View File
@@ -145,8 +145,33 @@
{
"control": "cra-ai-2",
"title": "Minimale Angriffsfläche",
"scans": [],
"note": "design property (minimal attack surface) — not derivable from local code patterns; architecture/threat-model review",
"scans": [
{
"tool": "oelint-adv",
"scan_type": "recipe_lint",
"languages": [
"bitbake"
],
"cwe": [],
"rules": [
"oelint.task.network"
],
"check": "The build must not open interfaces it does not need: a build task given network access fetches outside the checksummed fetcher and widens what can reach into the image, which violates it."
},
{
"tool": "yocto-config",
"scan_type": "recipe_lint",
"languages": [
"bitbake"
],
"cwe": [],
"rules": [
"yocto-src-uri-http"
],
"check": "The build must not take its sources over an unauthenticated interface: a source fetched over plain http can be swapped on the way, which violates it."
}
],
"note": "design property (minimal attack surface) — not derivable from local code patterns; architecture/threat-model review; on Yocto layer trees only, recipe lint checks build tasks with network access and plain-http fetches",
"status": "not_code_checkable"
},
{
@@ -215,22 +240,9 @@
"rules": [
"oelint.vars.srcurichecksum",
"oelint.vars.autorev",
"oelint.vars.srcurigittag",
"oelint.task.network"
"oelint.vars.srcurigittag"
],
"check": "What the image is built from must be verifiable: a download without a checksum, a source that follows a branch head (AUTOREV) or a movable tag, or a build task that fetches over the network outside the checksummed fetcher violates it."
},
{
"tool": "yocto-config",
"scan_type": "recipe_lint",
"languages": [
"bitbake"
],
"cwe": [],
"rules": [
"yocto-src-uri-http"
],
"check": "What the image is built from must be fetched over an authenticated channel: a source fetched over plain http violates it."
"check": "What the image is built from must be verifiable: a download without a checksum, or a source that follows a branch head (AUTOREV) or a movable tag, violates it."
}
],
"note": "covered by the grounded surface check (retrieve code surface + grounded LLM judge decides presence/absence); validated live",
+29 -4
View File
@@ -356,16 +356,17 @@ mod tests {
"oelint.vars.srcurichecksum",
"oelint.vars.autorev",
"oelint.vars.srcurigittag",
"oelint.task.network",
] {
assert_eq!(controls("oelint-adv", rule), ["cra-ai-6"], "{rule}");
}
// The attack-surface rules.
assert_eq!(controls("oelint-adv", "oelint.task.network"), ["cra-ai-2"]);
assert!(controls("oelint-adv", "oelint.vars.insaneskip").is_empty());
assert_eq!(
controls("yocto-config", "yocto-extrausers-password"),
["cra-ai-8"]
);
assert_eq!(controls("yocto-config", "yocto-src-uri-http"), ["cra-ai-6"]);
assert_eq!(controls("yocto-config", "yocto-src-uri-http"), ["cra-ai-2"]);
assert_eq!(
controls("yocto-config", "yocto-sshd-root-login"),
["cra-ai-1"]
@@ -375,7 +376,7 @@ mod tests {
assert!(controls("semgrep", debug).is_empty());
// A layer tree is checked for these controls.
let bitbake = ["bitbake".to_string()];
for id in ["cra-ai-1", "cra-ai-6", "cra-ai-8"] {
for id in ["cra-ai-1", "cra-ai-2", "cra-ai-6", "cra-ai-8"] {
assert!(map.coverage(id).expect(id).checked_for(&bitbake), "{id}");
}
}
@@ -455,7 +456,31 @@ mod tests {
for id in ["cra-ai-2", "cra-ai-3", "cra-ai-4", "cra-ai-5"] {
let c = map.coverage(id).unwrap();
assert_eq!(c.status, Coverage::NotCodeCheckable, "{id}");
assert!(c.scans.is_empty(), "{id} should carry no scan bindings");
// Only cra-ai-2 carries bindings, and only the Yocto recipe
// lint's attack-surface rules: no other code is checked for it.
let bound: Vec<(&str, &str, &[String])> = c
.scans
.iter()
.flat_map(|s| {
s.rules
.iter()
.map(move |r| (s.tool.as_str(), r.as_str(), s.languages.as_slice()))
})
.collect();
let bitbake = ["bitbake".to_string()];
let expected: Vec<(&str, &str, &[String])> = if id == "cra-ai-2" {
vec![
("oelint-adv", "oelint.task.network", &bitbake),
("yocto-config", "yocto-src-uri-http", &bitbake),
]
} else {
Vec::new()
};
assert_eq!(bound, expected, "{id}");
assert!(c
.scans
.iter()
.all(|s| s.scan_type == "recipe_lint" && s.cwe.is_empty()));
}
}
+2 -2
View File
@@ -30,9 +30,9 @@ For the **CRA** framework (40 controls) the split is **21 covered · 0 needs_too
- **Vendored semgrep packs** (GitLab, 0xdea, elttam; #492), bound **by CWE** like off-the-shelf tools, on a semgrep binding of their own per control whose `languages` are exactly those of the vendored rules under those CWEs (a test checks every vendored rule maps to a control that claims its languages). The few elttam rules without a CWE are bound by rule id. Because these bindings are `semgrep` bindings, a CWE they list also attaches our own semgrep findings with that CWE to the control.
- **mobsfscan** for Android and iOS apps, bound **by CWE** (a mobsfscan binding only ever attaches mobsfscan findings): `cra-ai-1` (debuggable, exported components, outdated `minSdkVersion`), `7`, `8`, `9`, `13`, `14`, `15` (cleartext, TLS, App Transport Security), `16` and `20`. Each binding lists only the languages mobsfscan has rules for under those CWEs, so `cra-ai-1` covers Java and Kotlin (its manifest checks) but not Swift.
- **DevSkim** for C# and VB.NET (#494), bound **by CWE** (each DevSkim rule gets its CWE in `pipeline/devskim.rs`; its SARIF carries none): `cra-ai-1` (tracing), `8`, `10` (cookies without Secure), `13`, `14` (DPAPI without entropy), `15`, `16` and `20` (deserialisation, XXE).
- **Yocto recipe lint** (oelint-adv and our `yocto-config` rules), bound **by rule id** with the language `bitbake`: `cra-ai-1` (debug and root-login image features, sshd root/password logins, a distro without `security_flags.inc`), `cra-ai-8` (empty-password image features, passwords in `EXTRA_USERS_PARAMS`) and `cra-ai-6` (downloads without a checksum, `AUTOREV`, git tags, network access in tasks, `http://` fetches). The attack-surface rules (network tasks, `http://`) bind to `cra-ai-6` because `cra-ai-2` stays not code-checkable.
- **Yocto recipe lint** (oelint-adv and our `yocto-config` rules), bound **by rule id** with the language `bitbake`: `cra-ai-1` (debug and root-login image features, sshd root/password logins, a distro without `security_flags.inc`), `cra-ai-8` (empty-password image features, passwords in `EXTRA_USERS_PARAMS`) `cra-ai-6` (downloads without a checksum, `AUTOREV`, git tags) and `cra-ai-2` (network access in tasks, `http://` fetches). `cra-ai-2` stays not code-checkable; these are its only bindings, so the CRA status assesses it only where the scanned languages include `bitbake` (a Yocto layer tree), and shows it as not code-checkable everywhere else.
- **8 grounded surface checks** (`cra-ai-6`, `11`, `12`, `24`, `27`, `28`, `29`, `30`): the absence-based controls (no rate limiting, no security logging, no update-signature check…) that have no syntactic pattern.
- **Marked not_code_checkable** (`cra-ai-2`, `3`, `4`, `5`, among the 19): minimal attack surface, secure architecture, least privilege, tamper protection.
- **Marked not_code_checkable** (`cra-ai-2`, `3`, `4`, `5`, among the 19): minimal attack surface, secure architecture, least privilege, tamper protection. A not-code-checkable control with a binding that applies to the scanned languages is assessed like a covered one there; today that is only `cra-ai-2` on Yocto layer trees.
### Languages, and what the CRA status may claim
+14 -4
View File
@@ -61,12 +61,14 @@ rules only, none of its style rules:
| `oelint.vars.srcurichecksum` (download without `SRC_URI[sha256sum]`) | medium | (2)(f) integrity | CRA-AI-6 |
| `oelint.vars.autorev` (`SRCREV = "${AUTOREV}"`) | medium | (2)(f) | CRA-AI-6 |
| `oelint.vars.srcurigittag` (git `tag=` instead of a commit; up to Walnascar) | low | (2)(f) | CRA-AI-6 |
| `oelint.task.network` (a task with `[network] = "1"`) | medium | (2)(j) attack surface | CRA-AI-6 |
| `oelint.task.network` (a task with `[network] = "1"`) | medium | (2)(j) attack surface | CRA-AI-2 |
| `oelint.vars.insaneskip` (QA checks skipped) | low | informational | none |
A `.oelint.cfg` in the repository is ignored, so it cannot switch rules off;
`# nooelint:` comments in a recipe do suppress a finding there, as oelint-adv
intends. If oelint-adv does not complete, the run lists **Rezept-Prüfung (Yocto)**
intends. Suppressed findings are not shown, so the run counts them and lists
"N Befunde sind per Kommentar in den Rezepten (# nooelint) unterdrückt" under
**Rezept-Prüfung: unterdrückte Befunde**. If oelint-adv does not complete, the run lists **Rezept-Prüfung (Yocto)**
under **Nicht ausgeführt**, and the controls it checks count as not assessed.
**Our own rules** (`yocto-config`):
@@ -74,7 +76,7 @@ under **Nicht ausgeführt**, and the controls it checks count as not assessed.
| Rule | Finds | Severity | CRA Annex I | Control |
| --- | --- | --- | --- | --- |
| `yocto-extrausers-password` | `useradd`/`usermod` with `-p`/`-P`/`--password` in `EXTRA_USERS_PARAMS` (a hash, clear text or an empty password; `'*'` and `'!'` lock the account and are fine, a `${VARIABLE}` is not judged). The value is hidden in the finding. | high | (2)(b) | CRA-AI-8 |
| `yocto-src-uri-http` | `http://` or `protocol=http` in `SRC_URI` | medium | (2)(j) | CRA-AI-6 |
| `yocto-src-uri-http` | `http://` or `protocol=http` in `SRC_URI` | medium | (2)(j) | CRA-AI-2 |
| `yocto-sshd-root-login` | `PermitRootLogin yes` in an `sshd_config*` shipped under `recipes-*` | high | (2)(b) | CRA-AI-1 |
| `yocto-sshd-password-auth` | `PasswordAuthentication yes` there | medium | (2)(b) | CRA-AI-1 |
| `yocto-distro-no-security-flags` | a `conf/distro/*.conf` that does not require `security_flags.inc`, itself or through the includes in the repository | medium | (2)(b) | CRA-AI-1 |
@@ -89,7 +91,15 @@ such a distro is not reported; an include in the repository is followed.
**Upstream layers** (OpenEmbedded-Core and Poky, meta-openembedded, and widely
used security, virtualisation and BSP layers, recognised by their
`BBFILE_COLLECTIONS`) are not linted: their findings are upstream's. The run names
them under **Nicht ausgeführt** as "Upstream-Layer".
them under **Nicht ausgeführt** as "Upstream-Layer". A layer is recognised by its
collection name, not its contents: a fork of an upstream layer that keeps the
upstream collection name (`core`, `openembedded-layer`, `freescale-layer`, …) is
skipped too. Give your fork its own collection name to have it linted.
CRA-AI-2 (minimal attack surface) is otherwise outside static scans. On a Yocto
layer tree, recipe lint checks it (network access in build tasks, plain-http
fetches), so the CRA status assesses it there; for every other target it stays
"not code-checkable".
## Recipe inventory