fix(yocto): a distro requiring a file outside the repository is not reported
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m46s

kas layouts keep only the customer's layer in the repository; a distro that
requires a BSP or Poky include fetched at build time may well get the
security flags from it. Such an include cannot be followed, so nothing is
claimed; an include in the repository is still followed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-09 17:38:36 +02:00
1 parent a50fdf44e8
commit effcbd535c
2 files changed
+26 -12

No files matched your search

@@ -399,10 +399,11 @@ impl<'a> ConfIndex<'a> {
Self { root, by_inner }
}
/// Whether the configuration `text` of `file` pulls in
/// `security_flags.inc`, itself or through what it requires. Poky's
/// distros include it; an include through a variable cannot be followed
/// and counts as hardened, so nothing is claimed that is not known.
/// Whether the configuration `text` of `file` may pull in
/// `security_flags.inc`, itself or through what it requires. An include
/// that is not in the tree (Poky's distros, a BSP layer kas fetches) or
/// goes through a variable cannot be followed and counts as hardened, so
/// nothing is claimed that is not known.
fn hardened(&self, file: &str, text: &str) -> bool {
let mut seen = BTreeSet::from([file.to_string()]);
self.follows(text, &mut seen)
@@ -420,11 +421,8 @@ impl<'a> ConfIndex<'a> {
if name == "security_flags.inc" || target.contains("${") {
return true;
}
if name.starts_with("poky") && name.ends_with(".conf") {
return true;
}
let Some(file) = self.by_inner.get(target) else {
return false;
return true;
};
if !seen.insert((*file).to_string()) {
return false;
@@ -525,11 +523,25 @@ mod tests {
"conf/distro/include/pump-base.inc",
"require conf/distro/include/security_flags.inc\n",
),
// Poky's distros include them too.
// Poky's distro, or a BSP include kas fetches: not in the tree,
// so not known.
(
"conf/distro/pump-poky.conf",
"require conf/distro/poky.conf\n",
),
(
"conf/distro/pump-imx.conf",
"require conf/distro/include/fsl-imx-base.inc\n",
),
// An include in the tree without the flags is followed.
(
"conf/distro/pump-lite.conf",
"include conf/distro/include/pump-lite.inc\n",
),
(
"conf/distro/include/pump-lite.inc",
"DISTRO_FEATURES = \"\"\n",
),
("conf/distro/bare.conf", "DISTRO = \"bare\"\n"),
(
"conf/templates/default/local.conf.sample",
@@ -554,6 +566,7 @@ mod tests {
rule_lines(&t.0),
[
"yocto-distro-no-security-flags conf/distro/bare.conf:1",
"yocto-distro-no-security-flags conf/distro/pump-lite.conf:1",
"yocto-files-certificate recipes-core/ca/files/ca.pem:2",
"yocto-local-conf-no-security-flags conf/templates/default/local.conf.sample:1",
"yocto-sshd-root-login recipes-connectivity/openssh/files/sshd_config:1",
+4 -3
View File
@@ -77,13 +77,14 @@ under **Nicht ausgeführt**, and the controls it checks count as not assessed.
| `yocto-src-uri-http` | `http://` or `protocol=http` in `SRC_URI` | medium | (2)(j) | CRA-AI-6 |
| `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 neither requires `security_flags.inc` nor a Poky distro or include that does | 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 |
| `yocto-local-conf-no-security-flags` | a `local.conf.sample` with no `DISTRO` (or `nodistro`) and no `security_flags.inc` | info | (2)(b) | CRA-AI-1 |
| `yocto-files-certificate` | a certificate shipped under `recipes-*` | info | none | none |
Private keys under `files/` are reported by the secret scan (gitleaks), not a
second time here. A `require` through a variable cannot be followed, so such a
distro is not reported.
second time here. A `require` through a variable, or of a file that is not in the
repository (Poky's distros, a BSP layer that kas fetches), cannot be followed, so
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