Skip to main content
Plans: Every plan. Who: an owner or admin creates the API token; anyone who can edit the pipeline adds the steps.
These two steps install Syft, generate a CycloneDX JSON SBOM of the repository and send it to Pharus. They are the same steps as the Azure DevOps 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 variable

In Azure DevOps, edit the pipeline, select Variables, and add a variable named PHARUS_TOKEN with the token as its value. Tick Keep this value secret. A variable group works too.
Azure Pipelines doesn’t pass secret variables to scripts by itself. The env: block on the second step maps PHARUS_TOKEN into the script; keep it.

The pipeline

A complete azure-pipelines.yml that runs on every push to main. The name: line sets the build number, which becomes the product version in Pharus.
To add Pharus to an existing pipeline, copy only the two steps, and set name: to your product version.
Each build number, such as 4.2.17, is its own product version in Pharus, so by default every build adds an active SBOM to the family and the same vulnerabilities show once per build. If only the newest build is in use, as for a service you run yourselves, turn on Only the newest SBOM is in use for the family: each upload then retires the SBOMs before it. See only the newest SBOM in use. If devices with older releases are in the field, send the release version instead (see the variations below).
What it does:
  • Generate SBOM downloads one Syft release into the agent’s temporary directory, checks its SHA-256, and writes sbom.cdx.json from the checked-out repository.
  • Send SBOM to Pharus gzips the file and posts it to POST /api/v1/sboms. Azure DevOps fills in the $(…) values before the script runs. Pharus removes refs/heads/ from the branch.
  • 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-body fails the step and prints Pharus’ message in the log.
  • continueOnError: true marks the run partially succeeded instead of failed when the upload fails. Remove the line if a build must not pass without its SBOM in Pharus.
  • jq prints each line of the answer’s warnings as a warning on the run: gaps in the SBOM quality and components past end of life upstream. The SBOM is stored either way.

Update Syft

The first step pins Syft to one release and the SHA-256 of its download. Anything that runs in your pipeline can change the checked-out code that later steps build and deploy, so the step runs only the file you chose: if the download doesn’t match the hash, sha256sum -c fails the step before Syft runs. Keep set -euo pipefail as the first line. Azure Pipelines runs scripts in bash without -e, so without it a failed check doesn’t stop the step. To move to a newer Syft:
1

Pick a release

Open Syft’s releases and download syft_<version>_checksums.txt from the release you want.
2

Change both values

Set SYFT_VERSION to the version without the v, for example 1.52.0, and SYFT_SHA256 to the hash on the syft_<version>_linux_amd64.tar.gz line of that file.
The values are for Linux on x86-64 (amd64), the architecture of Microsoft-hosted Ubuntu agents. For a self-hosted ARM64 agent, see the variation below.
If your pipeline pipes Syft’s install.sh into sh, from an earlier copy of this page, replace that step with this one.

Variations

Use -o spdx-json=sbom.spdx.json in the first step and gzip sbom.spdx.json in the second. Pharus reads SPDX JSON 2.2 and 2.3.
Replace dir:. with the image reference, for example myregistry.azurecr.io/gateway-g3:4.2. The agent must be able to pull the image.
Change linux_amd64 to linux_arm64 in the download URL, and set SYFT_SHA256 to the hash on the syft_<version>_linux_arm64.tar.gz line. For Syft 1.52.0 that is c46d5e4c28e12aa4c5becfaa343ef1c7f89045b6b895f2c21d471c62db09c706. On the agent, uname -m prints x86_64 for amd64 and aarch64 for ARM64.
When devices with older releases stay in the field, put your release version in X-Pharus-Version instead of the build number, for example from a variable such as $(productVersion). A new SBOM for a version replaces the previous SBOM of that version, and the SBOMs of older releases stay active. You can also retire old SBOMs on their page in Pharus.

Check that it worked

The Send SBOM to Pharus log shows Pharus’ answer, with "status":"parsed" for a new SBOM, "retired" counting the older SBOMs it retired, and "duplicate":true when Pharus already had the file. In Pharus, the SBOM appears under SBOMs with Azure DevOps as its Source, and the token’s Last used time changes under Settings → API tokens. All codes are listed under errors.

Upload an SBOM

API introduction

GitHub Actions

GitLab CI