Skip to content

Commit 532c3be

Browse files
committed
Make our sbom generation useful
We currently have an SBOM file, but its not at all useful, in that its just a template that downstream consumers might use to build their own sboms, but thats not really what an SBOM is for. SBOMs provide a level of assurance that the release production process was done securely. OpenSSL produces source releases, for which we leverage git archive when done on a github CI runner, which we don't have direct control over (at least not the contents of the runner image), so what we really should be doing, is generating an SBOM on the fly, for which we validate the computed SHA256 sum of each file in the tarball against the SHA256 sum of the corresponding file from the source git tree (to ensure that tooling local to the system didn't modify the files during archive construction. Replace the static sbom file with some additional ci work to do that, and make the sbom part of the release process so that downstream users can properly consume it.
1 parent cd79a23 commit 532c3be

File tree

2 files changed

+32
-48
lines changed

2 files changed

+32
-48
lines changed

.github/workflows/make-release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
release:
1919
runs-on: "releaser"
2020
steps:
21+
- name: "Install syft"
22+
run: |
23+
sudo curl -sSfL https://get.anchore.io/syft | sudo sh -s -- -b /usr/local/bin
2124
- name: "Checkout"
2225
uses: "actions/checkout@v5"
2326
with:
@@ -38,6 +41,35 @@ jobs:
3841
openssl sha1 -r "$GITHUB_REF_NAME.tar.gz" > "$GITHUB_REF_NAME.tar.gz.sha1"
3942
openssl sha256 -r "$GITHUB_REF_NAME.tar.gz" > "$GITHUB_REF_NAME.tar.gz.sha256"
4043
gpg -u "$SIGNING_KEY_UID" -o "$GITHUB_REF_NAME.tar.gz.asc" -sba "$GITHUB_REF_NAME.tar.gz"
44+
- name: "Build and validate SBOM against git tree"
45+
run: |
46+
cd "$GITHUB_REF_NAME"
47+
# extract the generated tarball
48+
mkdir sbom
49+
cd sbom
50+
tar xvf ../assets/$GITHUB_REF_NAME.tar.gz
51+
cd ../assets
52+
# build our sbom based on the tarball contents
53+
export SYFT_FILE_METADATA_SELECTION=all
54+
export SYFT_LICENSE_CONTENT=all
55+
syft scan --select-catalogers +sbom-cataloger,+nix-cataloger --source-name OpenSSL --source-version $GITHUB_REF_NAME --source-supplier OpenSSL --base-path ../sbom/$GITHUB_REF_NAME/ --output spdx-json=./$GITHUB_REF_NAME-sbom.json --from dir ../sbom/$GITHUB_REF_NAME/
56+
57+
# Validate each file listed in the sbom against the corresponding git tree
58+
for sbomfile in $(jq -r '.files[] | select(has("fileName")) | .fileName' ./$GITHUB_REF_NAME-sbom.json); do
59+
if [ -d ../$sbomfile ]; then
60+
continue
61+
fi
62+
GITSHA256=$(sha256sum i../$sbomfile | awk '{print $1}')
63+
SBOM256=$(jq -r --arg sbfile "$sbomfile" '.files[] | select(has("fileName")) | select(.fileName==$sbfile) | .checksums[1].checksumValue' ./$GITHUB_REF_NAME-sbom.json)
64+
if [ "$GITSHA256" != "$SBOM256" ]; then
65+
echo "$sbomfile sha256sums don't match between git and release tarball!"
66+
exit 1
67+
fi
68+
done
69+
# fixup license info
70+
sed -i -e "s/\"licenseDeclared\":\"NOASSERTION\"/\"licenseDeclared\":\"Apache-2.0\"/g" ./$GITHUB_REF_NAME-sbom.json
71+
sed -i -e "s/\"licenseConcluded\":\"NOASSERTION\"/\"licenseConcluded\":\"Apache-2.0\"/g" ./$GITHUB_REF_NAME-sbom.json
72+
gpg -u "$SIGNING_KEY_UID" -o "$GITHUB_REF_NAME-sbom.json.asc" -sba "$GITHUB_REF_NAME-sbom.json"
4173
- name: "Create release"
4274
env:
4375
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

doc/sbom.cdx.json

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)