Plans: Every plan. Who: an owner or admin creates the API token; anyone who can edit the repository’s workflows adds the step.
anchore/sbom-action (Syft) whenever you publish a release, and sends it to Pharus. It is the same workflow as the GitHub Actions tab of Connect a pipeline on the SBOMs page.
Before you start
1
Create a token
In Pharus, go to Settings → API tokens and create a token for the product family. See create a token.
2
Store it as a secret
In GitHub, open the repository’s Settings → Secrets and variables → Actions and add a repository secret named
PHARUS_TOKEN with the token as its value.The workflow
Save this as.github/workflows/pharus-sbom.yml:
- Trigger: every published release, and by hand from the Actions tab (
workflow_dispatch). - Generate:
anchore/sbom-action, pinned to the commit of its v0.24.2 release, runs Syft on the checked-out repository and writessbom.cdx.json. - Version: the release tag becomes the product version in Pharus. A run started by hand uses the branch or tag name.
- Send: the step gzips the file and posts it to
POST /api/v1/sboms. TheX-Pharus-*headers fill in the Pipeline card on the SBOM’s page, with a link back to the run. - Retry, then report: curl tries again through a short outage at Pharus (a 5xx answer, a timeout or a refused connection) for about a minute. Pharus answers a file it already has as a duplicate, so a retry is safe. If the upload still fails,
--fail-with-bodyfails the step and prints Pharus’ message in the log.set -o pipefailmakes a failed upload fail the step although its output goes on totee. - Release anyway:
continue-on-error: truekeeps a failed upload from failing the run; the step still shows as failed. Remove the line if a release must not pass without its SBOM in Pharus. - Warnings:
jqprints each line of the answer’swarningsas a warning on the run: gaps in the SBOM quality and components past end of life upstream. The SBOM is stored either way.
Update the action
The workflow pinsanchore/sbom-action to a full commit SHA, with the release in a comment. A tag such as v0 can be moved to other code at any time; a commit SHA can’t, so the workflow keeps running the code you chose. Each release of the action installs one Syft version: v0.24.2 installs Syft 1.51.1 and checks the download against that Syft release’s checksum file.
To move to a newer release, pick one from sbom-action’s releases and look up the commit its tag points to:
^{} if there is one; otherwise the tag points straight at the commit. Replace the SHA and the comment together. Dependabot version updates for GitHub Actions can open these pull requests for you and update the comment too.
Variations
Send SPDX instead of CycloneDX
Send SPDX instead of CycloneDX
Set
format: spdx-json and output-file: sbom.spdx.json on anchore/sbom-action, and gzip sbom.spdx.json in the last step. Pharus reads SPDX JSON 2.2 and 2.3.Scan a container image
Scan a container image
Add
image: with the image reference to anchore/sbom-action, for example image: ghcr.io/acme/gateway-g3:4.2, to describe the image instead of the source tree.Already using sbomify-action
Already using sbomify-action
sbomify-action saves the SBOM it uploads as
sbom_output.json. Add the Send SBOM to Pharus step after it, with gzip -c sbom_output.json and X-Pharus-Source: sbomify. The sbomify tab of Connect a pipeline has the step ready to copy.Check that it worked
A successful run logs Pharus’ answer, for example:"duplicate":true.
If the step fails, the log shows the error code. The most common:
All codes are listed under errors.