@@ -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.
488488BOMSH_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
496489bomshdir = $(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