diff --git a/compliance-agent/src/pipeline/recipe_lint/rules.rs b/compliance-agent/src/pipeline/recipe_lint/rules.rs index e1f134f..36159f0 100644 --- a/compliance-agent/src/pipeline/recipe_lint/rules.rs +++ b/compliance-agent/src/pipeline/recipe_lint/rules.rs @@ -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", diff --git a/docs/guide/yocto.md b/docs/guide/yocto.md index 559029a..41177c9 100644 --- a/docs/guide/yocto.md +++ b/docs/guide/yocto.md @@ -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