Plans: Every plan. Who: an owner or admin creates the API token; anyone who can edit the pipeline adds the steps.
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 completeazure-pipelines.yml that runs on every push to main. The name: line sets the build number, which becomes the product version in Pharus.
name: to your product version.
What it does:
- Generate SBOM installs Syft into the agent’s temporary directory and writes
sbom.cdx.jsonfrom 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 removesrefs/heads/from the branch. --fail-with-bodyfails the step on any error and prints Pharus’ message in the log.
Variations
Send SPDX instead of CycloneDX
Send SPDX instead of CycloneDX
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.Scan a container image
Scan a container image
Replace
dir:. with the image reference, for example myregistry.azurecr.io/gateway-g3:4.2. The agent must be able to pull the image.Send the release version instead of the build number
Send the release version instead of the build number
Each build number, such as
4.2.17, is its own product version in Pharus, so every build adds an active SBOM to the family. If you build often, put your release version in X-Pharus-Version instead, for example from a variable such as $(productVersion). A new SBOM for a version replaces the previous SBOM of that version. 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 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.