feat(yocto): recipes are checked with oelint-adv and our own secure-by-default rules #552

Merged
sharang merged 2 commits from feat/yocto-recipe-lint into main 2026-10-09 15:48:32 +00:00
Owner

Tier 1 recipe lint for Yocto layer trees (no build), on top of the detection and matrix from #550.

What runs

  • oelint-adv 9.11.2 (BSD-2-Clause, pinned in Dockerfile.agent, own small block). It gets a rule file that holds only the security rules, so no style rules run: oelint.var.badimagefeature.{debug-tweaks,allow-empty-password,empty-root-password,serial-autologin-root,allow-root-login,tools-debug,dbg-pkgs,dev-pkgs}, oelint.vars.srcurichecksum, oelint.vars.autorev, oelint.vars.srcurigittag, oelint.task.network, oelint.vars.insaneskip. It runs through tool_cmd (env_clear, kill on drop, 10 min timeout) with OELINT_SKIP_CONFIG set, so a .oelint.cfg in the repo cannot switch rules off. The output is read as gitlab-codequality JSON. Each layer is read with the oldest release its LAYERSERIES_COMPAT names (srcurigittag only exists up to Walnascar). If oelint-adv does not complete, the run records the skipped stage recipe_lint (ToolFailed), and tool_of_stage maps it to oelint-adv.
  • Our own rules (yocto-config, a Rust pass in pipeline/recipe_lint/rules.rs):
    • a password in EXTRA_USERS_PARAMS (-p/-P/--password, value hidden in the snippet);
    • http:// or protocol=http in SRC_URI;
    • PermitRootLogin yes or PasswordAuthentication yes in a shipped sshd_config*;
    • certificates shipped under recipes-* (info);
    • a distro conf or local.conf.sample without security_flags.inc. This follows require/include, so Poky-based distros pass.
    • Private keys are left to gitleaks, so they are not reported twice.
  • Upstream layers (identified by BBFILE_COLLECTIONS: core/yocto/meta-openembedded/BSP vendors…) are not linted. The run records them under the skipped stage recipe_lint_upstream (VendorCode).
  • The stage is gated on the tree's languages: .bb/.bbappend/.bbclass now count as bitbake, so the CRA status can assess the bound controls.

CRA

  • Findings have the scan type recipe_lint, and their description names the CRA Annex I requirement: (2)(b) secure by default, (2)(j) attack surface, or (2)(f) integrity.
  • In the control map they bind by rule id with language bitbake:
    • cra-ai-1: image features, sshd, security flags;
    • cra-ai-8: empty-password features, EXTRA_USERS_PARAMS;
    • cra-ai-6: checksum, AUTOREV, tag, network task, http fetch.

Elsewhere

  • RECIPE_LINT = None in the matrix. The dashboard gets the findings type filter entry and the tool names (DE/EN), plus the upstream stage text.
  • Docs: rule list in docs/guide/yocto.md; short entries in docs/reference/tools.md and docs/features/control-mapping.md.
  • Nightly fixture yocto-layer: the image recipe (debug-tweaks, allow-empty-password, usermod -p), an http recipe without a checksum and with a network task, an AUTOREV recipe, sshd_config with PermitRootLogin yes, and a distro without flags. Baseline updated with the exact rule ids, and recipe_lint is removed from the skipped stages.

Needs a product decision

  1. Attack surface → cra-ai-2. The control map keeps cra-ai-2 not code-checkable, and a test pins that, so the attack-surface findings (network task, http fetch) bind to cra-ai-6 instead. Should cra-ai-2 get bindings?
  2. oelint.vars.insaneskip and certificates are unmapped (informational).
  3. Inline # nooelint: suppressions in a customer recipe are honoured, as with oelint-adv itself.
  4. The upstream layer list is a fixed set of collection names. A customer fork of a BSP layer under the same collection name is skipped.

Coordination

The recipe-inventory branch also adds recipes-core/images/pump-image.bb. This PR's version is a superset of theirs (same header), plus allow-empty-password and EXTRA_USERS_PARAMS. The Dockerfile block pins oelint-parser 8.13.2 / regex / deprecated at the same versions as theirs; the duplicate goes on rebase.

Tests

  • recipe_lint: layers, release, upstream, vendor; the oelint report parser and rule file; every own rule with positive and negative cases.
  • The fixture checked against the baseline, for our rules, and for real oelint-adv when it is on PATH (skips otherwise; ran locally with 9.11.2).
  • Control-map bindings; the Rust tables matched against the LUT.
  • Matrix and plan; languages; tool_of_stage; dashboard tool names.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Tier 1 recipe lint for Yocto layer trees (no build), on top of the detection and matrix from #550. ## What runs - **oelint-adv 9.11.2** (BSD-2-Clause, pinned in `Dockerfile.agent`, own small block). It gets a rule file that holds only the security rules, so no style rules run: `oelint.var.badimagefeature.{debug-tweaks,allow-empty-password,empty-root-password,serial-autologin-root,allow-root-login,tools-debug,dbg-pkgs,dev-pkgs}`, `oelint.vars.srcurichecksum`, `oelint.vars.autorev`, `oelint.vars.srcurigittag`, `oelint.task.network`, `oelint.vars.insaneskip`. It runs through `tool_cmd` (`env_clear`, kill on drop, 10 min timeout) with `OELINT_SKIP_CONFIG` set, so a `.oelint.cfg` in the repo cannot switch rules off. The output is read as `gitlab-codequality` JSON. Each layer is read with the oldest release its `LAYERSERIES_COMPAT` names (`srcurigittag` only exists up to Walnascar). If oelint-adv does not complete, the run records the skipped stage `recipe_lint` (ToolFailed), and `tool_of_stage` maps it to `oelint-adv`. - **Our own rules** (`yocto-config`, a Rust pass in `pipeline/recipe_lint/rules.rs`): - a password in `EXTRA_USERS_PARAMS` (`-p`/`-P`/`--password`, value hidden in the snippet); - `http://` or `protocol=http` in `SRC_URI`; - `PermitRootLogin yes` or `PasswordAuthentication yes` in a shipped `sshd_config*`; - certificates shipped under `recipes-*` (info); - a distro conf or `local.conf.sample` without `security_flags.inc`. This follows `require`/`include`, so Poky-based distros pass. - Private keys are left to gitleaks, so they are not reported twice. - **Upstream layers** (identified by `BBFILE_COLLECTIONS`: core/yocto/meta-openembedded/BSP vendors…) are not linted. The run records them under the skipped stage `recipe_lint_upstream` (VendorCode). - The stage is gated on the tree's languages: `.bb/.bbappend/.bbclass` now count as `bitbake`, so the CRA status can assess the bound controls. ## CRA - Findings have the scan type `recipe_lint`, and their description names the CRA Annex I requirement: (2)(b) secure by default, (2)(j) attack surface, or (2)(f) integrity. - In the control map they bind by rule id with language `bitbake`: - **cra-ai-1**: image features, sshd, security flags; - **cra-ai-8**: empty-password features, `EXTRA_USERS_PARAMS`; - **cra-ai-6**: checksum, AUTOREV, tag, network task, http fetch. ## Elsewhere - `RECIPE_LINT = None` in the matrix. The dashboard gets the findings type filter entry and the tool names (DE/EN), plus the upstream stage text. - Docs: rule list in `docs/guide/yocto.md`; short entries in `docs/reference/tools.md` and `docs/features/control-mapping.md`. - Nightly fixture `yocto-layer`: the image recipe (debug-tweaks, allow-empty-password, `usermod -p`), an http recipe without a checksum and with a network task, an AUTOREV recipe, `sshd_config` with PermitRootLogin yes, and a distro without flags. Baseline updated with the exact rule ids, and `recipe_lint` is removed from the skipped stages. ## Needs a product decision 1. **Attack surface → cra-ai-2.** The control map keeps cra-ai-2 not code-checkable, and a test pins that, so the attack-surface findings (network task, http fetch) bind to cra-ai-6 instead. Should cra-ai-2 get bindings? 2. **`oelint.vars.insaneskip` and certificates are unmapped** (informational). 3. **Inline `# nooelint:` suppressions** in a customer recipe are honoured, as with oelint-adv itself. 4. **The upstream layer list is a fixed set of collection names.** A customer fork of a BSP layer under the same collection name is skipped. ## Coordination The recipe-inventory branch also adds `recipes-core/images/pump-image.bb`. This PR's version is a superset of theirs (same header), plus `allow-empty-password` and `EXTRA_USERS_PARAMS`. The Dockerfile block pins oelint-parser 8.13.2 / regex / deprecated at the same versions as theirs; the duplicate goes on rebase. ## Tests - recipe_lint: layers, release, upstream, vendor; the oelint report parser and rule file; every own rule with positive and negative cases. - The fixture checked against the baseline, for our rules, and for real oelint-adv when it is on PATH (skips otherwise; ran locally with 9.11.2). - Control-map bindings; the Rust tables matched against the LUT. - Matrix and plan; languages; tool_of_stage; dashboard tool names. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-09 15:26:32 +00:00
feat(yocto): recipes are checked with oelint-adv and our own secure-by-default rules
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) Failing after 2m11s
a50fdf44e8
Recipe lint over a Yocto layer tree, without a build:

- oelint-adv 9.11.2 (BSD-2-Clause, pinned in the agent image) runs with a
  rule file holding only its security rules (bad image features, missing
  checksums, AUTOREV, git tags, network tasks, INSANE_SKIP), with an empty
  environment, OELINT_SKIP_CONFIG and a 10-minute timeout. Each layer is read
  with the oldest release its LAYERSERIES_COMPAT names. A run that does not
  complete is recorded as the skipped stage recipe_lint.
- Our own rules (yocto-config): passwords in EXTRA_USERS_PARAMS (value
  hidden), http:// in SRC_URI, PermitRootLogin/PasswordAuthentication yes in a
  shipped sshd_config, certificates shipped with a recipe (info), and a distro
  or local.conf.sample without security_flags.inc (following require/include).
- Upstream layers (Poky, OpenEmbedded, BSP vendors, by BBFILE_COLLECTIONS) are
  not linted and are named as a skipped stage.
- Findings carry the type recipe_lint, the CRA Annex I requirement, and bind
  by rule id to cra-ai-1, cra-ai-8 and cra-ai-6 in the control map; .bb files
  count as the language bitbake, so those controls can be assessed.
- The scan matrix turns recipe_lint on; the dashboard lists the type in the
  findings filter and names both tools; docs list the rules; the nightly
  fixture gains an insecure image, recipes, distro and sshd_config.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-09 15:38:38 +00:00
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
effcbd535c
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
sharang force-pushed feat/yocto-recipe-lint from 12c3c38d0b to effcbd535c 2026-10-09 15:38:38 +00:00 Compare
sharang merged commit 7e3856db31 into main 2026-10-09 15:48:32 +00:00
Sign in to join this conversation.