feat: add sbom Makefile target#805
Open
MarkAtwood wants to merge 1 commit into
Open
Conversation
Adds sbom target that produces CycloneDX and SPDX SBOM files for a specific TARGET+SIGN combination. Sources extracted from OBJS variable via wildcard. wolfcrypt sources compiled into wolfBoot are listed as wolfBoot's own sources (not a separate component). Requires GEN_SBOM or WOLFBOOT_LIB_WOLFSSL set.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds a make sbom target to generate CycloneDX and SPDX SBOMs for wolfBoot based on the selected build configuration.
Changes:
- Introduces Makefile variables and an
sbomtarget to derive sources from$(OBJS)and runscripts/gen-sbom - Extracts version from
include/wolfboot/version.hto name output artifacts - Adds a host-side preprocessor pass (
cc -dM -E) to provide configuration defines to the SBOM generator
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+791
to
+795
| # Usage: make sbom TARGET=<target> SIGN=<scheme> [HASH=SHA256] [EXT_FLASH=0] | ||
| # | ||
| # TARGET and SIGN select the build configuration; they default to stm32f4 and | ||
| # ED25519 (via tools/config.mk) if not supplied. Pass them explicitly to get | ||
| # an SBOM that reflects your actual build configuration. |
Comment on lines
+808
to
+817
| WOLFBOOT_VERSION:=$(shell sed -n \ | ||
| 's/.*LIBWOLFBOOT_VERSION_STRING[[:space:]]*"\([^"]*\)".*/\1/p' \ | ||
| include/wolfboot/version.h) | ||
| GEN_SBOM:=$(WOLFBOOT_LIB_WOLFSSL)/scripts/gen-sbom | ||
| SBOM_CDX_OUT:=wolfboot-$(WOLFBOOT_VERSION).cdx.json | ||
| SBOM_SPDX_OUT:=wolfboot-$(WOLFBOOT_VERSION).spdx.json | ||
| SBOM_PYTHON?=$(or $(CRA_PYTHON),python3) | ||
|
|
||
| sbom: | ||
| @echo "wolfBoot SBOM: version=$(WOLFBOOT_VERSION) target=$(TARGET) sign=$(SIGN)" |
| WOLFBOOT_VERSION:=$(shell sed -n \ | ||
| 's/.*LIBWOLFBOOT_VERSION_STRING[[:space:]]*"\([^"]*\)".*/\1/p' \ | ||
| include/wolfboot/version.h) | ||
| GEN_SBOM:=$(WOLFBOOT_LIB_WOLFSSL)/scripts/gen-sbom |
| -DWOLFSSL_USER_SETTINGS \ | ||
| -x c /dev/null >"$$_dh" 2>/dev/null || \ | ||
| { echo "ERROR: cc -dM -E failed; install a host C compiler." >&2; exit 1; }; \ | ||
| $(SBOM_PYTHON) "$(GEN_SBOM)" \ |
| --supplier "wolfSSL Inc." \ | ||
| --license-file "$(WOLFBOOT_ROOT)/LICENSE" \ | ||
| --options-h "$$_dh" \ | ||
| --srcs $(_SBOM_SRCS) \ |
| @set -e; \ | ||
| _dh=$$(mktemp /tmp/wolfboot-sbom-defines.XXXXXX); \ | ||
| trap 'rm -f "$$_dh"' EXIT; \ | ||
| cc -dM -E \ |
| -I"$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src" \ | ||
| -DWOLFSSL_USER_SETTINGS \ | ||
| -x c /dev/null >"$$_dh" 2>/dev/null || \ | ||
| { echo "ERROR: cc -dM -E failed; install a host C compiler." >&2; exit 1; }; \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
make sbomtarget that produces CycloneDX and SPDX SBOM files for wolfBoot.wolfBoot is unique in that its SBOM must be TARGET- and SIGN-specific: different build configurations compile different sets of wolfcrypt source files directly into the bootloader image.
$(OBJS)via$(wildcard $(patsubst %.o,%.c,...))— no build requiredinclude/wolfboot/version.hTARGETandSIGNmust be set (same as for a normal build)Usage
```sh
make sbom TARGET=stm32h7 SIGN=ECC256 GEN_SBOM=/path/to/gen-sbom
```
Or if wolfssl is present as the
lib/wolfsslsubmodule:```sh
make sbom TARGET=stm32h7 SIGN=ECC256
```
Outputs:
wolfboot-<version>.cdx.json,wolfboot-<version>.spdx.jsonRequirements
GEN_SBOMmust point toscripts/gen-sbomfrom a wolfssl tree with thefeat/sbom-embeddedbranch, ORlib/wolfsslsubmodule must be checked outpython3on the build hostTARGETandSIGNmust match a real build configurationTest plan
make sbom TARGET=stm32h7 SIGN=ECC256 GEN_SBOM=...