Manage artifact software bill of materials
This topic describes how to upload software bill of materials (SBOM) files and associate them with an artifact version in the HCP Packer registry.
Overview
A software bill of materials stores a reference of an artifact's package metadata, and is useful to help with security and compliance audits. You can upload existing SBOM files to HCP Packer and associate them with an artifact version with the hcp-sbom
provisioner or the HCP Packer registry API.
Create a software bill of materials
Packer does not generate SBOM files, so you must use a third-party tool to create them. HCP Packer requires SBOM files to be in either SPDX or CycloneDX format. For an example Packer template that uses the provisioner, refer to the Track Packer artifact package bill of materials tutorial.
Upload the software bill of materials
You can upload SBOM files to the HCP Packer registry using either the hcp-sbom
provisioner or by using the HCP Packer API.
Upload using the provisioner
You can use the hcp-sbom
provisioner in your Packer template to upload an SBOM from your artifact to the HCP Packer registry.
Add the
hcp-sbom
provisioner to your Packer template, for example:Refer to the
hcp-sbom
provisioner reference for more information.Run the
packer init
command to install the provisioner.Run
packer build
to upload the SBOM file.
Upload using the API
You can upload SBOM files using the HCP Packer registry API. You must upload the file during the Packer build. You cannot associate SBOM files with an artifact version after Packer completes the build. To upload an SBOM:
Compress the SBOM using
zstd
, then encode it as base64.The following example compresses and encodes a CycloneDX SBOM stored at
/tmp/sbom.json
, assigns it to theSBOM
variable:Send a
PUT
request to the/sboms
HCP Packer API endpoint. The following example usescurl
to send the API request to upload the SBOM:
Refer to the UploadSboms
API reference for more information.
Download artifact software bill of materials
You can download SBOM files from the HCP Packer registry using the UI or the API.
Download from the UI
- Open the artifact version overview page.
- Click the Download SBOM drop-down and choose the SBOM you want to download.
Download using the API
Send a GET
request to the /GetSbom
HCP Packer API endpoint to download SBOM files using the HCP Packer registry API.