-
Notifications
You must be signed in to change notification settings - Fork 36
feat: add make sbom / install-sbom / uninstall-sbom targets #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MarkAtwood
wants to merge
2
commits into
wolfSSL:master
Choose a base branch
from
MarkAtwood:feat/add-make-sbom
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| name: SBOM Test | ||
|
|
||
| # Full SBOM generation for wolfProvider using the vendored wolfGlass toolkit | ||
| # under tools/sbom/. This job builds the OpenSSL + wolfSSL + wolfProvider | ||
| # stack, so it is not a cheap PR check. | ||
| # | ||
| # Triggers (Aidan, PR #410): | ||
| # * Nightly, via nightly-osp.yml (out-of-wave, like static-analysis). | ||
| # * On a PR, add the `ci:sbom` label (pr-osp-select.yml). | ||
| # * Manual: workflow_dispatch. | ||
| # | ||
| # A per-PR smoke that only ran `make sbom` + pyspdxtools would still pay the | ||
| # full stack build, so it is not cheaper than this job. Use nightly + label. | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| wolfssl_ref: | ||
| description: 'wolfSSL git ref to build and link (not the generator)' | ||
| required: false | ||
| type: string | ||
| default: 'master' | ||
| workflow_dispatch: | ||
| inputs: | ||
| wolfssl_ref: | ||
| description: 'wolfSSL git ref to build and link (not the generator)' | ||
| required: false | ||
| default: 'master' | ||
|
|
||
| # run-scoped: a reusable workflow's group keys off the caller, so a shared | ||
| # group would let one nightly run cancel another's SBOM job. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.run_id }} | ||
| cancel-in-progress: false | ||
|
|
||
| # This workflow only reads the repo and uploads artefacts; no API writes. | ||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| sbom: | ||
| name: wolfProvider SBOM generation (linux) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 45 | ||
| steps: | ||
| - name: Checkout wolfprovider | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Verify vendored wolfGlass generator | ||
| run: | | ||
| test -f tools/sbom/gen-sbom | ||
| test -f tools/sbom/sbom.am | ||
| test -f tools/sbom/.wolfglass-rev | ||
| python3 -m py_compile tools/sbom/gen-sbom | ||
| echo "wolfGlass pin: $(cat tools/sbom/.wolfglass-rev) $(cat tools/sbom/VERSION)" | ||
|
|
||
| - name: Install build tooling and SBOM validator (pyspdxtools) | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y build-essential autoconf automake libtool \ | ||
| pkg-config | ||
| python3 -m pip install --user 'spdx-tools==0.8.*' | ||
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | ||
|
|
||
| # Build the full stack (OpenSSL + wolfSSL + wolfProvider) from source using | ||
| # the project's maintained script. WOLFPROV_SKIP_TEST keeps it a | ||
| # build-only run (the SBOM only needs the built libwolfprov artifact). | ||
| # This also runs autogen + ./configure in-tree, so `make sbom` picks up the | ||
| # AC_PATH_PROG(PYTHON3/PYSPDXTOOLS/GIT) substitutions. wolfSSL defaults to | ||
| # master; override with WOLFSSL_TAG / the wolfssl_ref input. | ||
| - name: Build wolfProvider stack (openssl + wolfssl + wolfprovider) | ||
| env: | ||
| WOLFSSL_TAG: ${{ inputs.wolfssl_ref || 'master' }} | ||
| run: WOLFPROV_SKIP_TEST=1 ./scripts/build-wolfprovider.sh | ||
|
|
||
| # Record the versions of the wolfSSL and OpenSSL that were actually | ||
| # linked, so the SBOM's dependency versions match the deployed binaries. | ||
| - name: Resolve linked wolfSSL / OpenSSL versions | ||
| id: vers | ||
| run: | | ||
| wv="" | ||
| if [ -f wolfssl-source/wolfssl/version.h ]; then | ||
| wv=$(sed -n 's/.*LIBWOLFSSL_VERSION_STRING[ \t]*"\([^"]*\)".*/\1/p' \ | ||
| wolfssl-source/wolfssl/version.h) | ||
| fi | ||
| ov="" | ||
| if [ -x openssl-install/bin/openssl ]; then | ||
| # Pass the raw string (may include BUILD_METADATA, e.g. | ||
| # 3.5.4+wolfProvider-nonfips). gen-sbom keeps it in versionInfo | ||
| # and drops the +suffix from CPE 2.3 and PURL. | ||
| ov=$(openssl-install/bin/openssl version | awk '{print $2}') | ||
| fi | ||
| echo "wolfssl=$wv" >> "$GITHUB_OUTPUT" | ||
| echo "openssl=$ov" >> "$GITHUB_OUTPUT" | ||
| echo "linked wolfSSL=$wv openssl=$ov" | ||
|
|
||
| - name: Generate SBOM | ||
| run: | | ||
| make sbom \ | ||
| WOLFSSL_DIR="$GITHUB_WORKSPACE/wolfssl-source" \ | ||
| SBOM_WOLFSSL_VERSION="${{ steps.vers.outputs.wolfssl }}" \ | ||
| SBOM_OPENSSL_VERSION="${{ steps.vers.outputs.openssl }}" | ||
|
|
||
| - name: Outputs exist and SPDX validates | ||
| run: | | ||
| ls wolfprovider-*.cdx.json wolfprovider-*.spdx.json wolfprovider-*.spdx | ||
| pyspdxtools --infile wolfprovider-*.spdx.json | ||
| python3 tools/sbom/validate_sbom.py \ | ||
| --name-prefix wolfprovider \ | ||
| --require-dep-version wolfssl \ | ||
| --require-dep-version openssl \ | ||
| wolfprovider-*.cdx.json wolfprovider-*.spdx.json | ||
|
|
||
| - name: CycloneDX identity and licence | ||
| run: | | ||
| python3 - <<'PY' | ||
| import glob, json | ||
| cdx = json.load(open(glob.glob('wolfprovider-*.cdx.json')[0])) | ||
| assert cdx['bomFormat'] == 'CycloneDX', cdx.get('bomFormat') | ||
| assert cdx['specVersion'] == '1.6', cdx.get('specVersion') | ||
| m = cdx['metadata']['component'] | ||
| assert m['name'] == 'wolfprovider', m['name'] | ||
| # purl-spec: github namespace and name are lowercased. | ||
| assert m['purl'].startswith('pkg:github/wolfssl/wolfprovider@'), m['purl'] | ||
| # Default override must land as GPL-3.0-or-later (matches source headers). | ||
| ids = [l.get('license', {}).get('id') for l in m.get('licenses', [])] | ||
| assert 'GPL-3.0-or-later' in ids, ids | ||
| # Identity is the hashed library artifact. | ||
| assert {h['alg'] for h in m.get('hashes', [])}, 'no component hash' | ||
| print('CDX ok:', m['name'], m['purl'], ids) | ||
| PY | ||
|
|
||
| - name: Assert no host path leak | ||
| run: | | ||
| if grep -REn '"/(home|Users|root)/' wolfprovider-*.cdx.json \ | ||
| wolfprovider-*.spdx.json; then | ||
| echo "ERROR: absolute host path found in SBOM (scrub failed)." >&2 | ||
| exit 1 | ||
| fi | ||
| echo "OK: no host path leak." | ||
|
|
||
| - name: Reproducible across two runs (SOURCE_DATE_EPOCH) | ||
| run: | | ||
| rm -f wolfprovider-*.cdx.json wolfprovider-*.spdx.json wolfprovider-*.spdx | ||
| SOURCE_DATE_EPOCH=1700000000 make sbom \ | ||
| WOLFSSL_DIR="$GITHUB_WORKSPACE/wolfssl-source" \ | ||
| SBOM_WOLFSSL_VERSION="${{ steps.vers.outputs.wolfssl }}" \ | ||
| SBOM_OPENSSL_VERSION="${{ steps.vers.outputs.openssl }}" | ||
| sha256sum wolfprovider-*.cdx.json wolfprovider-*.spdx.json > /tmp/a.sums | ||
| rm -f wolfprovider-*.cdx.json wolfprovider-*.spdx.json wolfprovider-*.spdx | ||
| SOURCE_DATE_EPOCH=1700000000 make sbom \ | ||
| WOLFSSL_DIR="$GITHUB_WORKSPACE/wolfssl-source" \ | ||
| SBOM_WOLFSSL_VERSION="${{ steps.vers.outputs.wolfssl }}" \ | ||
| SBOM_OPENSSL_VERSION="${{ steps.vers.outputs.openssl }}" | ||
| sha256sum wolfprovider-*.cdx.json wolfprovider-*.spdx.json > /tmp/b.sums | ||
| diff /tmp/a.sums /tmp/b.sums | ||
|
|
||
| - name: wolfssl recorded as a dependency | ||
| run: | | ||
| python3 - <<'PY' | ||
| import glob, json | ||
| d = json.load(open(glob.glob('wolfprovider-*.spdx.json')[0])) | ||
| assert 'wolfssl' in {p['name'] for p in d['packages']}, \ | ||
| [p['name'] for p in d['packages']] | ||
| rels = [(r['spdxElementId'], r['relationshipType'], | ||
| r['relatedSpdxElement']) for r in d['relationships']] | ||
| assert ('SPDXRef-Package-wolfprovider', 'DEPENDS_ON', | ||
| 'SPDXRef-Package-wolfssl') in rels, rels | ||
| print('wolfssl dependency ok') | ||
| PY | ||
|
|
||
| - name: openssl recorded as a dependency | ||
| run: | | ||
| python3 - <<'PY' | ||
| import glob, json | ||
| d = json.load(open(glob.glob('wolfprovider-*.spdx.json')[0])) | ||
| pkgs = {p['name']: p for p in d['packages']} | ||
| assert 'openssl' in pkgs, list(pkgs) | ||
| rels = [(r['spdxElementId'], r['relationshipType'], | ||
| r['relatedSpdxElement']) for r in d['relationships']] | ||
| assert ('SPDXRef-Package-wolfprovider', 'DEPENDS_ON', | ||
| 'SPDXRef-Package-openssl') in rels, rels | ||
| openssl = pkgs['openssl'] | ||
| # versionInfo keeps BUILD_METADATA when openssl version prints it. | ||
| # CPE 2.3 and PURL must not contain a raw '+'. | ||
| refs = {r['referenceType']: r['referenceLocator'] | ||
| for r in openssl.get('externalRefs', [])} | ||
| cpe = refs.get('cpe23Type', '') | ||
| purl = refs.get('purl', '') | ||
| assert cpe.startswith('cpe:2.3:a:openssl:openssl:'), cpe | ||
| assert '+' not in cpe, cpe | ||
| assert purl.startswith('pkg:github/openssl/openssl@openssl-'), purl | ||
| assert '+' not in purl, purl | ||
| print('openssl dependency ok:', openssl.get('versionInfo'), cpe, purl) | ||
| PY | ||
|
|
||
| - name: Upload SBOM artefacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wolfprovider-sbom-${{ github.sha }} | ||
| path: | | ||
| wolfprovider-*.cdx.json | ||
| wolfprovider-*.spdx.json | ||
| wolfprovider-*.spdx | ||
| if-no-files-found: warn | ||
| retention-days: 90 | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.