Plans: Every plan. Who: an owner or admin creates the API token; a project maintainer adds the CI/CD variable and the job.
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 CI/CD variable
In GitLab, open the project’s Settings → CI/CD → Variables and add a variable with the key
PHARUS_TOKEN and the token as its value. Mask it, so it doesn’t show in job logs.If you also mark the variable as protected, GitLab only passes it to pipelines on protected branches and tags. Protect the tags the job runs on, or leave the variable unprotected.
The job
Add this job to.gitlab-ci.yml:
- Trigger:
rules: - if: $CI_COMMIT_TAGruns the job only in pipelines for a Git tag. - Generate: the job installs curl in a small Alpine image, downloads one Syft release, checks its SHA-256, and Syft writes
sbom.cdx.jsonfrom the repository. - Version: the tag, such as
v4.2, becomes the product version in Pharus. - Send: the last command 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 to the job. - 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 job and prints Pharus’ message in the log. - Release anyway:
allow_failure: trueshows a failed upload as a warning instead of failing the pipeline. Remove the line if a release must not pass without its SBOM in Pharus.
warnings list gaps in the SBOM quality and components past end of life upstream; the SBOM is stored either way. See the response.
The job uses the deploy stage, one of GitLab’s default stages. If your .gitlab-ci.yml lists its own stages, use one of those.
Pharus has no source label for GitLab, so these SBOMs show API as their Source. The Pipeline card still links to the GitLab job.
Update Syft
The job 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 jobs build and deploy, so the job runs only the file you chose: if the download doesn’t match the hash,sha256sum -c fails, and GitLab stops the job before Syft runs.
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 variables
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.If your job pipes Syft’s
install.sh into sh, from an earlier copy of this page, replace those lines with these.Variations
Send SPDX instead of CycloneDX
Send SPDX instead of CycloneDX
Use
syft dir:. -o spdx-json=sbom.spdx.json and gzip sbom.spdx.json in the last command. 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 registry.gitlab.com/acme/gateway-g3:4.2. For a private registry, give Syft credentials as Syft’s documentation describes.Run on an ARM64 runner
Run on an ARM64 runner
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. In the job, uname -m prints x86_64 for amd64 and aarch64 for ARM64.Check that it worked
The job 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, and the token’s Last used time changes under Settings → API tokens.
All codes are listed under errors.