Skip to content

feat(gen-sbom): add embedded / custom-builder SBOM path#10753

Closed
MarkAtwood wants to merge 5 commits into
wolfSSL:masterfrom
MarkAtwood:feat/sbom-embedded
Closed

feat(gen-sbom): add embedded / custom-builder SBOM path#10753
MarkAtwood wants to merge 5 commits into
wolfSSL:masterfrom
MarkAtwood:feat/sbom-embedded

Conversation

@MarkAtwood

@MarkAtwood MarkAtwood commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Depends on

Summary

Adds support for generating wolfSSL SBOMs from IAR, Keil, MPLAB, and other custom/embedded build systems that configure wolfSSL via user_settings.h rather than autotools or cmake.

New arguments

Build configuration source (one of --options-h / --user-settings required):

Flag Description
--user-settings PATH Path to user_settings.h; preprocessed to extract enabled features
--user-settings-include DIR Add include directory for preprocessing (repeat as needed)
--user-settings-define MACRO Pre-define a macro before preprocessing (repeat as needed)

Artifact hash source (at least one required):

Flag Description
--srcs FILE … Compiled source files; deterministic combined SHA-256
--srcs-file PATH File listing sources one per line; blank and # lines ignored
--no-artifact-hash No hash available; placeholder + wolfSSL contact note recorded

--lib and --options-h remain fully supported (autotools/cmake path unchanged).

Preprocessor strategy for --user-settings

  1. pcpp (pip install pcpp): pure Python, host-independent — preferred for cross-compilation
  2. CC -dM -E fallback: set CC=arm-none-eabi-gcc for cross builds

Source file combined hash

--srcs / --srcs-file computes SHA-256 per file, sorts by path, then SHA-256s the manifest — deterministic regardless of argument order. Recorded as wolfssl:sbom:hash-source=srcs.

--no-artifact-hash

Records a 64-zero placeholder and a wolfssl:sbom:no-artifact-hash-note property directing integrators to contact wolfSSL. Use only when neither a compiled library nor a source list is accessible.

Documentation

doc/SBOM.md updated with a "Build System Integration" section covering all three paths with worked examples.

Bug fixes in this update

  • pcpp.Preprocessor.parse() keyword arg (f2a77c56e): called as parse(..., filename=path) but pcpp 1.30 uses source= for that parameter. The pcpp path crashed on every invocation with TypeError. Fixed to source=path.

Note on cmake target cherry-pick

37630ea84 cherry-picks the sbom/install-sbom/uninstall-sbom cmake targets from feat/sbom-cmake (#10752) onto this branch. This was done so the CRA Kit cmake mode (CRA_SBOM_MODE=cmake) can be tested end-to-end against this branch without requiring #10752 to be merged first. If #10752 merges before this PR, the cherry-pick becomes a no-op at merge time. Reviewers: the cmake target content is identical to what is reviewed in #10752 — no need to re-review it here.

Test plan

  • --user-settings + --srcs: output has wolfssl:sbom:hash-source=srcs, digest matches, pyspdxtools validates
  • --user-settings + --srcs-file: same digest as --srcs for identical file list; blank/comment/duplicate lines handled
  • --user-settings + --no-artifact-hash: 64-zero hash, contact note in properties, pyspdxtools validates
  • --options-h + --lib (existing autotools/cmake path): unchanged output, hash-source=lib
  • Mutual-exclusion validation: --options-h + --user-settings → clear error, exit non-zero
  • Mutual-exclusion validation: --no-artifact-hash + --srcs → clear error, exit non-zero
  • Missing hash source (none of lib/srcs/srcs-file/no-artifact-hash) → clear error, exit non-zero
  • pyspdxtools validates both srcs and none (no-artifact-hash) SPDX outputs

MarkAtwood and others added 2 commits April 28, 2026 13:36
Adds `make sbom` producing CycloneDX 1.6 and SPDX 2.3 SBOMs
for EU Cyber Resilience Act compliance.

Generation is handled by scripts/gen-sbom (Python 3, stdlib only).
The script stages a `make install`, hashes the installed
libwolfssl.so, generates both formats, then removes the staging
directory. pyspdxtools validates the SPDX JSON and converts it
to tag-value (.spdx).

Output files (all versioned):
  wolfssl-<ver>.cdx.json   CycloneDX 1.6 JSON
  wolfssl-<ver>.spdx.json  SPDX 2.3 JSON
  wolfssl-<ver>.spdx       SPDX 2.3 tag-value

SBOMs include: SHA-256 of the library, CPE, PURL, license
detected from the LICENSING file, copyright, and build
configuration (options.h defines as CDX properties). Optional
external dependencies (liboqs, libxmss, liblms, libz) appear as
separate components when enabled.

Version detection for deps without pkg-config (libxmss, liblms)
uses `git describe --tags --always` on the source tree root.

configure.ac changes:
- AC_SUBST ENABLED_LIBOQS/LIBXMSS/LIBLMS/LIBZ so the dep flags
  set during ./configure are visible in the generated Makefile
- AC_SUBST LIBLMS_ROOT (XMSS_ROOT was already exported by
  wolfssl) so gen-sbom can locate the source tree for git describe
- AC_PATH_PROG([GIT]) to find git robustly at configure time
  rather than relying on PATH at make sbom time
- Initialize LIBLMS_ROOT="" before the liblms detection block,
  mirroring how XMSS_ROOT is defaulted in the disabled branch

Also adds: doc/SBOM.md, INSTALL section 21, README one-liner,
install-sbom / uninstall-sbom targets.
Add --user-settings (pcpp/CC -dM -E), --srcs, --srcs-file,
and --no-artifact-hash to gen-sbom for IAR/Keil/MPLAB builds.
Makes --lib and --options-h optional; validate combinations.
Document the three build paths in doc/SBOM.md.
@MarkAtwood

Copy link
Copy Markdown
Contributor Author

Waiting on #10343 and #10752 to merge before this is ready to land. Review welcome in the meantime — no code changes needed in either dependency will affect this PR.

Copilot AI review requested due to automatic review settings June 22, 2026 20:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

pcpp 1.30 Preprocessor.parse() uses source= not filename= for the
filename parameter. Wrong keyword caused TypeError crash when taking
the pcpp code path.
Cherry-picked from feat/sbom-cmake (ff31dbb). Adds cmake custom
targets for SBOM generation alongside the existing autotools/embedded
paths. Stub targets fire a clear error when python3 or pyspdxtools
are missing instead of silently failing.
@sameehj

sameehj commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

#10343 already has the embedded --user-settings/--srcs path on a more hardened, OmniBOR-gitoid base, and the only net-new bits here (--srcs-file, --no-artifact-hash, hash-source) are being ported there directly.
I think it can be dropped.

@MarkAtwood

Copy link
Copy Markdown
Contributor Author

Closing per discussion with @sameehj — the embedded path (--user-settings, --srcs, --srcs-file, --no-artifact-hash, hash-source) has been ported into #10343. Work is not lost, just consolidated there.

@MarkAtwood MarkAtwood closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants