Repository navigation
Conversation
A product that shares one user_settings.h with wolfSSL, such as wolfCert, captures every wolfSSL macro along with its own, so its SBOM recorded wolfSSL's configuration as the product's build properties. gen-sbom now takes --macro-prefix PREFIX (repeatable) and records only the captured macros whose name starts with one of the prefixes. It applies to --options-h and --user-settings alike. --crypto-only auto still reads the full capture, since that decision depends on wolfSSL's macros, so the recorded subset basis can rest on a macro the document filtered out. The prefixes are recorded in the document (a wolfssl:sbom:macro-prefix property in CycloneDX, an annotation in SPDX) and folded into the configuration identity only when set, so an unscoped SBOM keeps its serialNumber. A prefix that matches none of the captured macros, or a prefix given when nothing was captured, prints a warning. An empty prefix, one with surrounding whitespace, or one holding a comma is an error, since the recorded value is a comma-joined list. The driver forwards --macro-prefix only when gen-sbom advertises it and prints a note when it has to drop it, as sbom.am does. The CMake helper takes MACRO_PREFIX, sbom.mk and sbom.am take SBOM_MACRO_PREFIX. sbom.am also gains SBOM_USER_SETTINGS (with SBOM_USER_SETTINGS_INCLUDES and SBOM_USER_SETTINGS_DEFINES), so an autotools product configured by a user_settings.h can use the same capture as the CMake and Make paths. Tests cover the filter and its warnings in test_gen_sbom.py, the identity fold, the driver forwarding, and the wiring in each build fragment: CMake and sbom.mk through their generated driver command, sbom.am through the autotools fixture.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The scoped filtering, backward-compatible identity handling, and build integrations are consistent with the stated behavior, with no unresolved blocking findings.
No open issues 🎉
What changed in this PR
Adds macro-prefix filtering to the shared SBOM generator so products can record their own configuration macros from a header shared with wolfSSL.
Changes:
- Filters recorded macros while preserving full-capture crypto-only detection and unchanged document identities when no prefix is set.
- Forwards prefixes through the driver, CMake, Make, and Autotools; adds Autotools user-settings inputs.
- Adds tests for filtering, validation, identity, and build integration, plus usage documentation.
| File | Description |
|---|---|
tests/test_sbom.py |
Tests driver forwarding, fallback notes, and Make integration. |
tests/test_sbom_identity.py |
Tests prefix-sensitive identity and default compatibility. |
tests/test_sbom_cmake_install.py |
Tests CMake prefix forwarding. |
tests/test_sbom_autotools.py |
Tests prefix filtering and user-settings input checks. |
tests/test_gen_sbom.py |
Tests filtering, metadata, warnings, and validation. |
share/sbom.am |
Adds prefix forwarding and user-settings capture inputs. |
share/sbom-driver.py |
Forwards prefixes when supported by the generator. |
share/README.md |
Documents filtering and Autotools configuration. |
share/gen-sbom |
Implements filtering, scope metadata, and identity handling. |
share/build/sbom.mk |
Forwards SBOM_MACRO_PREFIX to the driver. |
share/build/sbom.cmake |
Adds the MACRO_PREFIX argument. |
README.md |
Documents the Autotools user-settings option. |
Review effort: Balanced
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.
What
gen-sbom --macro-prefix PREFIX(repeatable) records only the captured build macros whose name starts with one of the prefixes. It is meant for a product that shares oneuser_settings.hwith wolfSSL, such as wolfCert, whose SBOM today records every wolfSSL macro as the product's own configuration.--options-hand--user-settingsalike.--crypto-only autostill reads the full capture.wolfssl:sbom:macro-prefixproperty in CycloneDX, annotation in SPDX) and folded into the config identity only when set, so existing SBOMs keep their serialNumber.--crypto-only auto,wolfssl-subset-basis=capturedcan rest on a macro the prefix filtered out of the document (for exampleWOLFCRYPT_ONLY); that is intended, and the docstring says so.MACRO_PREFIX,sbom.mkandsbom.amSBOM_MACRO_PREFIX.sbom.amalso gainsSBOM_USER_SETTINGS/SBOM_USER_SETTINGS_INCLUDES/SBOM_USER_SETTINGS_DEFINES, matching the CMake and Make paths.--macro-prefixoption.Tests
TestMacroPrefixintest_gen_sbom.py(12 tests), identity coverage intest_sbom_identity.py, end-to-end generate plus driver forwarding intest_sbom.py.MACRO_PREFIXintest_sbom_cmake_install.py,sbom.mkintest_sbom.py, andsbom.am(SBOM_MACRO_PREFIXplus the threeSBOM_USER_SETTINGSerrors) intest_sbom_autotools.py. TheSBOM_USER_SETTINGScapture itself needs pcpp and runs in CI.