---
title: "CI and integrations"
description: "Run openaudit in GitHub Actions, GitLab CI, pre-commit or the Docker image, upload SARIF to code scanning and fail builds on new findings."
url: https://openaudit.se/docs/ci/
---

# CI and integrations

Ways to run openaudit without installing it by hand. The Docker image is the only one that also brings the scanners (gitleaks, Semgrep, Trivy and so on); the others use whatever is on `PATH`, and `openaudit doctor` shows what is missing.

## GitHub Action

The repository is also a GitHub Action. On pull requests it reports only findings in changed files, uploads SARIF to code scanning, attaches the reports as an artifact and writes a job summary:

```yaml
permissions:
  contents: read
  security-events: write

steps:
  - uses: actions/checkout@v7
    with:
      fetch-depth: 0 # diff mode compares against the base branch
  - uses: wezter96/openaudit@main # pin to a commit SHA in real use
    with:
      fail-on: high
```

Inputs: `target`, `fail-on`, `diff` (defaults to the PR base; `none` audits everything), `only`, `exclude`, `config`, `upload-sarif`, `upload-report`. Outputs: `score`, `grade`, `report-dir`.

Elsewhere, run the CLI: `bunx @openaudit/cli . --diff origin/main -f html,sarif -o openaudit-report --fail-on high`. `--fail-on <severity>` sets the exit code, and `--baseline previous.json` reports only findings that are new since an earlier run. This repository audits itself in [`ci.yml`](https://github.com/wezter96/openaudit/blob/main/.github/workflows/ci.yml) and publishes the result to [openaudit.se/report](https://openaudit.se/report/) with [`site.yml`](https://github.com/wezter96/openaudit/blob/main/.github/workflows/site.yml).

### Inputs

| Input | Default | Description |
| --- | --- | --- |
| `target` | `.` | Directory, URL or image:<ref> to audit. |
| `fail-on` | `high` | Fail the step on findings at or above this severity (critical, high, medium, low, info, none). |
| `diff` | empty | Only report findings in files changed since this git ref. Defaults to the pull request's base branch on pull_request events; "none" audits everything. Needs history: use actions/checkout with fetch-depth 0. |
| `only` | empty | Comma-separated auditor ids or prefixes to run (e.g. "code,iac"). |
| `exclude` | empty | Comma-separated auditor ids or prefixes to skip. |
| `config` | empty | Config file to trust (e.g. openaudit.config.jsonc), for opt-in auditors and settings. Pass it only on push, where the file is reviewed, never on pull_request or pull_request_target. Without it the repository's config is still read, as untrusted. |
| `upload-sarif` | `true` | Upload SARIF to GitHub code scanning (needs security-events write). |
| `upload-report` | `true` | Upload the HTML, JSON, SARIF and Markdown reports as a workflow artifact. |

### Outputs

| Output | Description |
| --- | --- |
| `score` | Overall score, 0-100. |
| `grade` | Overall grade, A-F. |
| `report-dir` | Directory holding the reports. |

## SARIF and code scanning

The simplest setup is the bundled GitHub Action (`action.yml` at the repository root). On pull requests it audits only the files the PR changed, uploads SARIF, attaches the reports (HTML, JSON, SARIF, Markdown) as an artifact, writes a job summary and fails on findings at or above `fail-on`. Inputs: `target`, `fail-on`, `diff` (defaults to the PR base; `none` audits everything), `only`, `exclude`, `config`, `upload-sarif`, `upload-report`. Outputs: `score`, `grade`, `report-dir`. Check out with `fetch-depth: 0` so the base branch's history is available. The job needs `security-events: write`.

The repository's own config is found inside the target, so even in its own CI it is untrusted: it cannot turn on opt-in auditors or the settings that need `--config`. To use them, pass the file through the `config` input, but only on events where its content has been reviewed:

```yaml
- uses: wezter96/openaudit@<sha>
  with:
    fail-on: high
    # Trusted on pushes, where the file is what was merged or pushed by someone
    # with write access. On pull_request and pull_request_target the PR can edit it.
    config: ${{ github.event_name == 'push' && 'openaudit.config.jsonc' || '' }}
```

On pull requests, either let the config stay untrusted (it can still narrow the audit and suppress findings, which the report discloses), or trust the base branch's copy, which the PR cannot change: run `git show "origin/$GITHUB_BASE_REF:openaudit.config.jsonc" > "$RUNNER_TEMP/openaudit.config.jsonc"` in a step before the Action and pass `config: ${{ runner.temp }}/openaudit.config.jsonc`. A PR's own changes to the config then take effect only after it is merged. There is deliberately no "trust the config" switch: one copied into a `pull_request` workflow would hand fork authors the trusted settings, while tying the path to the event keeps the decision visible.

To run the CLI directly instead:

```yaml
- uses: oven-sh/setup-bun@v2
- name: openaudit
  run: bunx @openaudit/cli . --format sarif,markdown --out openaudit --fail-on high
- name: Upload SARIF
  if: always()
  uses: github/codeql-action/upload-sarif@v4
  with:
    sarif_file: openaudit/openaudit-report.sarif
    category: openaudit
- name: Job summary
  if: always()
  run: cat openaudit/openaudit-report.md >> "$GITHUB_STEP_SUMMARY"
```

Run the audit from the repository root, so that SARIF file paths line up with the files in the repository. The job needs the `security-events: write` permission to upload SARIF.

## Docker

`ghcr.io/wezter96/openaudit` bundles openaudit with the free scanners, pinned to exact versions. Images are multi-arch (`linux/amd64`, `linux/arm64`) and ship with provenance and an SBOM. Release tags are built with each release; `edge` is built from `main` every Monday.

| Tag | Contents |
| --- | --- |
| `latest`, `1.2.3`, `1.2`, `edge` (weekly from main) | slim: openaudit and the scanners below |
| `latest-full`, `1.2.3-full`, `edge-full` | slim plus Chromium, Lighthouse and pa11y (for `--browser` and the web auditors) and the Go, Ruby, Rust, Node, PHP and Java scanners |

```bash
# Audit the current directory. Run as yourself: git refuses repositories owned by
# another user, and reports are written as you
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/src" -w /src \
  ghcr.io/wezter96/openaudit . -f html,sarif -o openaudit-report --fail-on high

# Audit a live site with a real browser
docker run --rm ghcr.io/wezter96/openaudit:latest-full https://example.com --browser

# See which tools are installed
docker run --rm ghcr.io/wezter96/openaudit doctor
```

Included: gitleaks, trufflehog, osv-scanner, Trivy, Grype, Syft, hadolint, actionlint, kube-linter, kubeconform, TFLint (with the AWS, Azure and Google rulesets), ShellCheck, zizmor, OpenSSF Scorecard, oxlint, Biome, Spectral, oasdiff, jscpd, Semgrep, Bandit, pip-audit, Checkov, Ruff, mobsfscan, GuardDog, sslyze. The `-full` images add Chromium, Lighthouse and pa11y, plus PHPStan (with PHP), PMD (with a Java runtime), gosec, staticcheck, govulncheck and golangci-lint (with a Go toolchain), brakeman (with Ruby), cargo-audit, and npm and pnpm (with Node.js) for npm and pnpm audit. The versions are the `ARG`s at the top of the [`Dockerfile`](https://github.com/wezter96/openaudit/tree/main/Dockerfile).

Not included: ZAP (needs Docker), Prowler (needs cloud credentials), clippy (needs a full Rust toolchain), tsc, ESLint, knip and mypy (need the audited project's own dependencies), and in the slim images everything `-full` adds. Those auditors report `skipped` with an install hint. Network-backed scanners (Trivy, OSV, Semgrep rules) need outbound access; add `--offline` to forbid it.

Always pass `--user "$(id -u):$(id -g)"`. The image does not disable git's ownership check (`safe.directory`), which protects scanners from a hostile repository's `.git/config`, so a mount owned by another uid makes git-based features such as `--diff` fail with "dubious ownership". GitLab runners and pre-commit already match ownership (see below).

Build it yourself: `docker build -t openaudit .` (slim) or `docker build --target full -t openaudit:full .`.

## GitLab CI

```yaml
include:
  - remote: https://raw.githubusercontent.com/wezter96/openaudit/main/integrations/gitlab/openaudit.gitlab-ci.yml

variables:
  OPENAUDIT_FAIL_ON: high   # optional
```

On merge requests the job audits only changed files (`--diff origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME`); on the default branch and schedules it audits everything. Results:

- **openaudit report** link on the MR: the artifact folder with the HTML, SARIF, JSON and Markdown reports.
- **Code Quality** widget on the MR, converted from the findings. GitLab's `reports:sast` expects GitLab's own schema rather than SARIF, so SARIF stays a plain artifact.

The job runs as root on a root-owned checkout, so ownership matches. Pin `OPENAUDIT_IMAGE` to a version tag for reproducible runs. See the comments in the template for the other variables.

## pre-commit

```yaml
repos:
  - repo: https://github.com/wezter96/openaudit
    rev: main # pin to a tag or commit
    hooks:
      - id: openaudit          # needs Bun on PATH
      # - id: openaudit-docker # or: the Docker image, nothing else to install
```

The hooks audit the whole working tree with `--offline --fail-on high`, so staged changes are covered and a commit stays quick. They do not use `--diff`: it compares commits (`<ref>...HEAD`) and staged changes are not committed yet, so `--diff HEAD` would find nothing. To check a branch's committed changes instead, run the hook on `pre-push` with your own arguments:

```yaml
      - id: openaudit
        stages: [pre-push]
        args: [".", "--diff", "origin/main", "--fail-on", "high", "--quiet"]
```

`openaudit-docker` runs the container with your uid and gid (pre-commit does this itself), so ownership matches. Offline mode skips the checks that query advisory databases; CI covers those.
