There is no Azure DevOps extension from TRUSTIVAN. The recipe downloads the trustivan CLI, a single static binary, and runs trustivan gate in a script step. The gate requests a scan, waits for it, asks for a verdict and exits 1 when the policy blocks the build.

Prerequisites

  • An API key with scans:create, scans:read and verdicts:request, plus findings:read for the SARIF file. Add it as a secret pipeline variable (or a variable group) named TRUSTIVAN_API_KEY. See Scopes.
  • An enabled policy in the organization, or a policy id to pass with --policy. Without one the verdict request answers 409. See Gate a pipeline on a policy.
  • The image already pushed to a registry TRUSTIVAN can pull from. TRUSTIVAN pulls it itself; a private registry such as Azure Container Registry needs a credential stored in TRUSTIVAN first. See Scan a private registry image.

The pipeline

azure-pipelines.yml
The env: mapping is required: Azure Pipelines does not put a secret variable into a script’s environment unless the step names it. TRUSTIVAN_URL is not a secret and reaches the script without one. $(Build.BuildId) is the idempotency key, so a re-run of a failed job reuses its scan instead of queueing a second one. To pin a CLI release, replace latest/download with download/<tag>.

What it gates on

Azure Pipelines fails the step on both. A failed scan is never treated as a pass. The default wait is 20 minutes; change it with --timeout 30m.

See the results

  • The step log has the verdict, the policy and version, the scan id and every rule, with ! beside the ones that fired.
  • The CodeAnalysisLogs artifact holds trustivan.sarif. That artifact name is the one Microsoft’s SARIF SAST Scans Tab extension reads, so with that extension installed the findings appear on a Scans tab of the run. The file is written before the verdict is acted on, so it exists for a blocked build too.
  • The dashboard has the scan and its findings under the asset.

Report without blocking

Accept exit 1 and nothing else, so an outage still fails the step:

Troubleshooting

See also