Skip to main content

Use in CI

PySentry is built for CI: it exits non-zero when findings reach the --fail-on threshold, so any CI system can gate on it without extra flags. This page covers the GitHub Action and the generic recipe for other CI systems.

GitHub Action​

The first-party action (Marketplace listing) downloads a prebuilt binary (verified against the release checksums), runs the audit, and — on push to the default branch — uploads a SARIF report to GitHub Code Scanning so findings appear in the repository Security tab. On pull requests the SARIF upload is skipped by default (fork PRs get a read-only token, so the upload would fail); instead PySentry writes a compact report to the run's job summary, which it does whenever it runs in GitHub Actions.

name: Dependency Audit

on:
push:
branches: [main]
pull_request:

permissions:
contents: read
security-events: write # required for the SARIF upload

jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nyudenkov/[email protected]
with:
fail-on: high

Inputs​

All inputs are optional and map to CLI flags.

InputDefaultDescription
path.Project to audit
versionaction tagPySentry version to download
fail-onPySentry defaultMinimum severity causing a non-zero exit (low, medium, high, critical)
sourcesPySentry defaultSpace-separated vulnerability sources (pypa, pypi, osv)
formatsarifReport format
outputpysentry-results.sarifReport file path
ignore—Space-separated vulnerability IDs to suppress
upload-sariftrueUpload the report to Code Scanning
upload-sarif-on-prfalseAlso upload on pull_request events (off by default; fork PRs can't get the write token)
categorypysentryCode Scanning category
args—Extra raw CLI arguments

Outputs​

OutputDescription
exit-codePySentry exit code
output-filePath to the generated report

On push, the SARIF report is uploaded even when the audit fails, so findings always reach the Security tab; the job then fails with the audit's exit code. On pull requests, the job summary shows the compact report and the job still fails on findings at or above fail-on.

Other CI systems​

No installation step is needed on runners with uv:

uvx pysentry-rs --fail-on high

The exit code is the contract: 0 when no findings reach the threshold, non-zero otherwise. See the exit codes table for details.

GitLab CI example:

dependency-audit:
image: python:3.12-slim
script:
- pip install pysentry-rs
- pysentry-rs --fail-on high