Skip to content

Yocto

The meta-trowl layer scans Yocto images after a successful build. It adds scanner dependencies to do_build and leaves image-generation tasks and outputs unchanged. It locates the image, SBOM and kernel inputs automatically.

It is tested on Scarthgap (5.0) and Wrynose with core-image-minimal for qemux86-64.

  1. Clone the layer next to your other layers.

    Terminal window
    git clone https://github.com/corefense-security/meta-trowl.git
  2. From your build directory, add the layer and turn the scan on.

    Terminal window
    bitbake-layers add-layer /path/to/meta-trowl
    echo 'INHERIT += "trowl"' >> conf/local.conf
  3. Build the image as usual.

    Terminal window
    bitbake core-image-minimal

bitbake builds Trowl and the image, then runs the scan. By default, an image is rescanned only when newer than its report. When the build finishes, the scan output follows the task summary.

Reports default to trowl/<image>/ in the build directory, outside TMPDIR.

BitBake build configuration listing the meta-trowl layer, followed by the task summary

Trowl scan output after the BitBake task summary, ending with the path to the report

The trowl recipe pins the release with TROWL_TAG and its commit with SRCREV. The same recipe supports both Yocto releases on x86-64 or aarch64 build hosts.

The scan runs on the build host, so the class uses only native recipes:

Recipe Provides Used by the class
trowl Trowl, versioned by release trowl-native
trowl-llama llama.cpp’s llama-server trowl-llama-native when TROWL_LLM = "1"
trowl-model-native Selected model weights trowl-model-native:do_fetch when TROWL_LLM = "1"

trowl and trowl-llama are programs, so they set BBCLASSEXTEND = "native" as Yocto recipes usually do. The model is data for the build host, so its recipe is native only.

Both trowl-llama and trowl-model-native are excluded from bitbake world because only the optional summary needs them, and the model is a multi-GB download.

No Trowl package appears in the image, or its SBOM.

Build dependencies are pinned separately:

  • Go 1.26 and Node 22 match the versions in install.sh. Scarthgap ships Go 1.22, and neither supported Yocto release ships Node.
  • Go modules are downloaded from the Go proxy with pinned checksums and verified against go.sum. Scarthgap has no gomod fetcher.
  • Dashboard dependencies use files/package-lock.json, copied from the pinned commit’s ui/package-lock.json. Each tarball is checked against its SHA-512. Wrynose disables the npmsw fetcher, so tarballs are fetched individually.

In the layer repository:

  1. Rename the recipe for the new release version and update TROWL_TAG and SRCREV.
  2. Copy that release’s ui/package-lock.json to recipes-devtools/trowl/files/package-lock.json.
  3. Update TROWL_GOMODS if go.sum changed.

Yocto saves each image’s build variables in testdata.json in the deploy folder. The layer reads this file for each image on the bitbake command line because scanning runs after BitBake finishes, outside the image recipe.

DEPLOY_DIR_IMAGE identifies the deploy folder. IMAGE_LINK_NAME is the shared filename prefix without the build timestamp.

Example output for core-image-minimal on Scarthgap:

tmp/deploy/images/qemux86-64/
├── core-image-minimal-qemux86-64.rootfs.testdata.json variables the layer reads
├── core-image-minimal-qemux86-64.rootfs.ext4 image
├── core-image-minimal-qemux86-64.rootfs.tar.bz2 image, not used
└── core-image-minimal-qemux86-64.rootfs.spdx.tar.zst SBOM

Image and SBOM filenames use IMAGE_LINK_NAME plus a suffix. Kernel paths come from the same JSON. Missing inputs trigger a warning.

Input How the layer finds it When it is missing
Image The first type in TROWL_FSTYPES that the build also lists in IMAGE_FSTYPES. Above, that is ext4 Scan skipped
SBOM The first suffix in TROWL_SBOM_NAMES that exists: .sbom-cve-check.spdx.json, then .spdx.json (SPDX 3.0), then .spdx.tar.zst (SPDX 2.2) Image scanned without an SBOM
Kernel config TROWL_KERNEL_CONFIG if set, else .config in STAGING_KERNEL_BUILDDIR. Used only when the image carries no config Only the image’s config, if any
Kernel source TROWL_KERNEL_TREE if set, else STAGING_KERNEL_DIR Kernel CVEs remain version matches

IMAGE_FSTYPES defines the formats Yocto builds. TROWL_FSTYPES sets Trowl’s preference order for supported formats and can be overridden in local.conf.

Scarthgap defaults to SPDX 2.2 and Wrynose to SPDX 3.0. The layer prefers Wrynose’s sbom-cve-check SBOM when core/yocto/sbom-cve-check is enabled.

A local kernel build provides the config and source under tmp/work-shared. These directories may be absent when BitBake restores the kernel from sstate, such as in a fresh TMPDIR with a shared cache.

Set either or both paths in local.conf to supply the missing inputs. Unset variables keep the defaults listed above. Relative paths are resolved from the build directory.

Terminal window
TROWL_KERNEL_TREE = "/path/to/linux"
TROWL_KERNEL_CONFIG = "/path/to/.config"

The source tree must match the commit and patches used to build the image’s kernel so Trowl reads the correct config gates.

Set these in local.conf.

Variable Default Meaning
TROWL_SCAN 1 0 turns the scan off
TROWL_REPORT_DIR ${TOPDIR}/trowl Where reports go, one folder per image
TROWL_ALWAYS 0 1 scans after every build, not only when the image changed
TROWL_FSTYPES ext4, squashfs, tar, cpio and wic variants Image types the layer looks for, in order
TROWL_SBOM_NAMES see above SBOM names the layer looks for, in order
TROWL_KERNEL_TREE empty Kernel source tree used instead of STAGING_KERNEL_DIR
TROWL_KERNEL_CONFIG empty Kernel .config used instead of the one in STAGING_KERNEL_BUILDDIR, when the image carries none
TROWL_LLM 0 1 adds the Overview summary
TROWL_LLM_MODEL qwen3.5-4b qwen3-4b, qwen3.5-4b or qwen3.5-9b

LLM inference is off by default. To enable AI-based scan summary, add this to local.conf.

Terminal window
TROWL_LLM = "1"

The next bitbake also builds trowl-llama-native from llama.cpp and fetches the model into DL_DIR, checked against its SHA-256. The server includes every CPU variant as a backend and loads the best one at runtime, so one build is shared through sstate across build hosts. The model is read directly from DL_DIR and never copied into a sysroot.

Set BB_NO_NETWORK = "1" for offline scans. CVE feeds must already be cached in ~/.cache/trowl from an online scan. See Data fetching and caching.

With the sbom-cve-check fragment enabled, Wrynose’s do_sbom_cve_check fails when its CVE database updates but the image doesn’t change. It looks for the SBOM under the new build’s timestamp. The issue is in OE-Core and occurs with or without meta-trowl.

The build fails causing Trowl to skip the scan.

To avoid it, pin both databases in local.conf with :forcevariable, which the fragment can’t override:

SRCREV:pn-sbom-cve-check-update-nvd-native:forcevariable = "<commit>"
SRCREV:pn-sbom-cve-check-update-cvelist-native:forcevariable = "<commit>"

After a failure, run bitbake -c cleansstate <image> to rebuild the image and clear the error.