Skip to content

Commit efa5977

Browse files
committed
fix(bomsh): use bomsh_sbom.py -g to insert ArtifactID, not -f
-f hashes the file then maps it through bomsh_omnibor_doc_mapping to the bom_id (a different sha1 than the artefact's gitoid), which never matches the verifier's manifest. -g inserts our gitoid verbatim. Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
1 parent be88063 commit efa5977

2 files changed

Lines changed: 24 additions & 29 deletions

File tree

.github/workflows/sbom.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,14 +1077,11 @@ jobs:
10771077
- name: Upload bomsh trace diagnostics
10781078
# Diagnostic-only, short retention. Kept separate so the
10791079
# provenance bundle above stays slim for downstream consumers
1080-
# who don't need to debug ptrace gaps. `_bomsh.artefact` and
1081-
# `_bomsh.snapshot` are included here (not in the provenance
1082-
# bundle) because they are CI-internal: the manifest is a
1083-
# pointer file, and the snapshot is the byte-identical copy
1084-
# of the bomtrace3-traced library taken before `make sbom`'s
1085-
# libtool relink. Bundling the snapshot lets a reviewer
1086-
# reproduce check (C) by hand (`sha1("blob "+len+"\\0"+bytes)`)
1087-
# to confirm the SPDX externalRef gitoid is honest.
1080+
# who don't need to debug ptrace gaps. `_bomsh.artefact` is
1081+
# included here (not in the provenance bundle) because it is
1082+
# CI-internal: a pointer file recording the path and gitoid of
1083+
# the bomtrace3-traced library that bomsh_sbom.py was told to
1084+
# cite in the SPDX externalRef.
10881085
if: always()
10891086
uses: actions/upload-artifact@v4
10901087
with:
@@ -1093,7 +1090,6 @@ jobs:
10931090
bomsh_raw_logfile.sha1
10941091
_bomsh.conf
10951092
_bomsh.artefact
1096-
_bomsh.snapshot
10971093
if-no-files-found: warn
10981094
retention-days: 14
10991095

@@ -1110,5 +1106,3 @@ jobs:
11101106
test ! -d omnibor || (echo "omnibor/ not cleaned"; exit 1)
11111107
test ! -f _bomsh.artefact \
11121108
|| (echo "_bomsh.artefact not cleaned"; exit 1)
1113-
test ! -f _bomsh.snapshot \
1114-
|| (echo "_bomsh.snapshot not cleaned"; exit 1)

Makefile.am

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,6 @@ BOMSH_SPDX_OUT = omnibor.wolfssl-$(PACKAGE_VERSION).spdx.json
486486
# the on-disk gitoid disagrees, so the install-time relink remains
487487
# visible.
488488
BOMSH_ARTEFACT_MANIFEST = $(abs_builddir)/_bomsh.artefact
489-
# Byte-identical copy of the traced library, captured BEFORE `make sbom`
490-
# runs `make install` (during which libtool relinks src/.libs/lib*.so*
491-
# in place to fix RPATH). bomsh_sbom.py hashes the file at -f at call
492-
# time rather than reading the ADG, so pointing -f at this snapshot keeps
493-
# the SPDX externalRef pinned to the bomsh-traced gitoid -- otherwise it
494-
# would hash the post-relink bytes and disagree with the manifest.
495-
BOMSH_ARTEFACT_SNAPSHOT = $(abs_builddir)/_bomsh.snapshot
496489
bomshdir = $(datadir)/doc/$(PACKAGE)
497490

498491
.PHONY: bomsh install-bomsh uninstall-bomsh
@@ -521,10 +514,15 @@ bomsh:
521514
@printf 'raw_logfile=%s\n' '$(BOMSH_RAWLOG_BASE)' > '$(BOMSH_CONF)'
522515
$(BOMTRACE3) -c '$(BOMSH_CONF)' $(MAKE)
523516
$(BOMSH_CREATE_BOM) -r '$(BOMSH_RAWLOG)' -b '$(BOMSH_OMNIBORDIR)'
524-
@# Snapshot the traced library before `make sbom`'s install-time
525-
@# libtool relink rewrites it (RPATH fix). -f points at the snapshot
526-
@# so bomsh_sbom.py emits the bomsh-traced gitoid; the manifest's path
527-
@# field stays on the live library so the verifier's NOTE keeps firing.
517+
@# Capture the ArtifactID (file gitoid) of the bomtrace3-traced
518+
@# library and record it in the manifest. Below we feed this gitoid
519+
@# to bomsh_sbom.py via -g (NOT -f): with -f, bomsh_sbom.py hashes
520+
@# the file then maps that hash through omnibor/metadata/bomsh/
521+
@# bomsh_omnibor_doc_mapping to a bom_id (the gitoid of the
522+
@# artefact's OmniBOR document) -- a different sha1 than the
523+
@# artefact's own content gitoid, which never matches what the
524+
@# verifier records. -g inserts our gitoid verbatim, so
525+
@# SPDX externalRef == manifest gitoid == artefact ArtifactID.
528526
@bomsh_artifact=""; \
529527
for lib in \
530528
$(addprefix "$(abs_builddir)/src/.libs"/,$(WOLFSSL_LIB_DSO_BASENAMES)) \
@@ -533,8 +531,7 @@ bomsh:
533531
if test -f "$$lib"; then bomsh_artifact="$$lib"; break; fi; \
534532
done; \
535533
if test -n "$$bomsh_artifact"; then \
536-
cp "$$bomsh_artifact" '$(BOMSH_ARTEFACT_SNAPSHOT)'; \
537-
bomsh_artifact_gid=`$(PYTHON3) -c 'import hashlib,sys;d=open(sys.argv[1],"rb").read();h=hashlib.sha1();h.update(("blob %d\0"%len(d)).encode());h.update(d);print(h.hexdigest())' '$(BOMSH_ARTEFACT_SNAPSHOT)'`; \
534+
bomsh_artifact_gid=`$(PYTHON3) -c 'import hashlib,sys;d=open(sys.argv[1],"rb").read();h=hashlib.sha1();h.update(("blob %d\0"%len(d)).encode());h.update(d);print(h.hexdigest())' "$$bomsh_artifact"`; \
538535
printf '%s\t%s\n' "$$bomsh_artifact" "$$bomsh_artifact_gid" \
539536
> '$(BOMSH_ARTEFACT_MANIFEST)'; \
540537
fi
@@ -544,18 +541,22 @@ bomsh:
544541
echo " The OmniBOR graph in $(BOMSH_OMNIBORDIR) is still produced."; \
545542
exit 0; \
546543
fi; \
547-
if test ! -f '$(BOMSH_ARTEFACT_MANIFEST)' \
548-
|| test ! -f '$(BOMSH_ARTEFACT_SNAPSHOT)'; then \
544+
if test ! -f '$(BOMSH_ARTEFACT_MANIFEST)'; then \
549545
echo "NOTE: no built libwolfssl artifact found in $(abs_builddir)/src/.libs/"; \
550546
echo " OmniBOR graph produced; SPDX enrichment skipped."; \
551547
exit 0; \
552548
fi; \
553549
bomsh_artifact=`awk 'NR==1 {print $$1}' '$(BOMSH_ARTEFACT_MANIFEST)'`; \
554-
echo "Enriching SPDX with OmniBOR ExternalRefs (artifact: $$bomsh_artifact, snapshot: $(BOMSH_ARTEFACT_SNAPSHOT))..."; \
550+
bomsh_artifact_gid=`awk 'NR==1 {print $$2}' '$(BOMSH_ARTEFACT_MANIFEST)'`; \
551+
if test -z "$$bomsh_artifact_gid"; then \
552+
echo "ERROR: $(BOMSH_ARTEFACT_MANIFEST) is missing the gitoid field"; \
553+
exit 1; \
554+
fi; \
555+
echo "Enriching SPDX with OmniBOR ExternalRefs (artifact: $$bomsh_artifact, gitoid: $$bomsh_artifact_gid)..."; \
555556
$(BOMSH_SBOM) \
556557
-b '$(BOMSH_OMNIBORDIR)' \
557558
-i '$(abs_builddir)/$(SBOM_SPDX)' \
558-
-f '$(BOMSH_ARTEFACT_SNAPSHOT)' \
559+
-g "$$bomsh_artifact_gid" \
559560
-s spdx-json \
560561
-O '$(abs_builddir)'
561562

@@ -572,7 +573,7 @@ uninstall-bomsh:
572573
-rm -rf '$(DESTDIR)$(bomshdir)/omnibor'
573574
-rm -f '$(DESTDIR)$(bomshdir)/$(BOMSH_SPDX_OUT)'
574575

575-
CLEANFILES += $(BOMSH_RAWLOG) $(BOMSH_RAWLOG_BASE).sha256 $(BOMSH_CONF) $(BOMSH_SPDX_OUT) $(BOMSH_ARTEFACT_MANIFEST) $(BOMSH_ARTEFACT_SNAPSHOT)
576+
CLEANFILES += $(BOMSH_RAWLOG) $(BOMSH_RAWLOG_BASE).sha256 $(BOMSH_CONF) $(BOMSH_SPDX_OUT) $(BOMSH_ARTEFACT_MANIFEST)
576577

577578
# Hook SBOM/Bomsh cleanup into `make uninstall` so packagers don't leave
578579
# stale artefacts behind after install-sbom/install-bomsh. uninstall-sbom

0 commit comments

Comments
 (0)