- GitHub Actions
- GitLab CI
- CircleCI
Output formats
Switch Trust CLI writes results as JSON or as SARIF (Static Analysis Results Interchange Format), an open standard for reporting analysis findings.
Tools that read SARIF ingest results from any SARIF-producing tool without a custom parser, so your findings land alongside the rest of your security results instead of in a file nobody opens. Switch Trust CLI writes SARIF 2.1.0.
Set the format
switch-trust scan and switch-trust eval run write JSON unless you ask for something else. Pass --format sarif (short form -f) to write SARIF instead. The output filename follows the format you choose:
What SARIF output contains
- switch-trust scan
- switch-trust eval run
Findings map to file locations with line numbers, and severity maps to SARIF levels: critical and high findings become Findings then appear in the Security tab of your repository and as annotations on the pull request, so reviewers see them without downloading an artifact.
error, medium becomes warning, and everything else becomes note.This is the output GitHub code scanning is built to read.Upload to GitHub code scanning:Exit codes
switch-trust scan and switch-trust eval run return the same exit codes, so a pipeline can tell a clean run from one that needs attention.
The codes come in ranges a script can branch on:
20–39 need a fix before you rerun, and 60–79 are temporary, so a retry may succeed. For example:
Upgrading from 1.7: these runs used to exit
0, and now fail:- A scanner tool, such as OpenGrep, is missing:
26 - A configured scanner model has no API key, or its key is rejected mid-scan:
20, or another configuration or retry code - An evaluation run scored nothing, including when every evaluation errored, or stopped before every evaluation ran:
6
22 instead of 1.Fail the build on findings or scores
A completed run exits0 unless you set a gate:
switch-trust scan --fail-on <severity>: Exits5if any finding is at or abovecritical,high,medium,low, orinfo, after triage. A finding whose severity can’t be read also trips it.switch-trust eval run --fail-under <score>: Exits5if any evaluation scores below the value, from0to1.
2 before anything runs. In CI, the CLI prints a warning when no gate is set.
The CLI writes the results file before it checks the gate, so you can still save it as an artifact when the build fails. A missing scanner tool exits 26 even if findings would have tripped --fail-on.
Other CI systems
The core pattern works anywhere:1
Provide Python 3.11 to 3.13
Switch Trust CLI requires Python 3.11 to 3.13 on a Linux or macOS runner. Use a prebuilt image where you can, such as
python:3.11.2
Install Switch Trust CLI
3
Install OpenGrep and put it on PATH
$HOME/.opengrep/cli/latest to PATH. This is the part that differs most between systems, because most of them run each step in a fresh shell: GitHub Actions writes the path to $GITHUB_PATH, CircleCI appends an export to $BASH_ENV, and GitLab CI runs the whole job in one shell, so a plain export carries. Find the equivalent on your system for persisting environment changes between steps.4
Set your LLM API key
Store the key as a secret and expose it to the job as an environment variable:
GEMINI_API_KEY, OPENAI_API_KEY, or ANTHROPIC_API_KEY.5
Run the scan
6
Save the results as a build artifact
Use your CI system’s artifact mechanism so the file outlives the job and reviewers can reach it from the pull request.

