GitHub Actions
Run zn-gate in CI: audit agent configs and scan prompts for injection and leaked secrets.
The zn-gate Action checks a repository on every push or pull request. It runs on the GitHub runner only, needs no account and no API key, and sends nothing anywhere. It has two checks:
- Scan (
mode: scan, the default) looks for prompt-injection traps and leaked secrets in prompts, tool definitions and config files. Details: Scan. - Audit (
mode: audit) reads what your coding agents are set up to trust (.claude/,.mcp.json,.codex/,.cursor/, hooks,AGENTS.md/CLAUDE.md, plugins and skills) and reports it without running anything from the repository. Details: Audit. mode: bothruns the two.
Minimal workflow
This runs the scan on every push and pull request. Findings appear as annotations and fail the step:
name: zn-gate
on: [push, pull_request]
permissions:
contents: read
jobs:
zn:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: usezn/zn@v1.17.0
Full workflow
This runs both checks, writes a SARIF report and uploads it to GitHub code scanning. Findings of medium severity or higher fail the step:
name: zn-gate
on:
pull_request:
permissions:
contents: read
jobs:
zn:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write # only for the SARIF upload
actions: read # private repositories only
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: usezn/zn@v1.17.0
id: zn
with:
mode: both
path: .
format: sarif
severity-threshold: medium
- uses: github/codeql-action/upload-sarif@v4
if: ${{ !cancelled() && steps.zn.outputs.sarif-file != '' }}
with:
sarif_file: ${{ steps.zn.outputs.sarif-file }}
Inputs
| Input | Default | What it does |
|---|---|---|
mode |
scan | scan, audit or both. |
version |
1.17.0 |
Exact zn-gate version to install. Ranges and latest are refused. |
path |
. |
Path to check, relative to the workspace. audit needs a directory; scan also accepts a single file. |
fail-on-threat |
true |
Fail the step on findings. false reports only. Must be true or false. |
severity-threshold |
high |
Audit only: lowest severity that fails the step when fail-on-threat is true (critical, high, medium, low). The scan has no severities: any finding fails. |
fail-on |
empty | Audit only: lowest severity that fails the step (low, medium, high, critical, none). When set, it overrides fail-on-threat and severity-threshold. |
agents |
empty (all) | Audit only: comma-separated list of agents to audit. |
format |
github |
github (inline annotations), text, json or sarif. |
sarif-file |
empty | With format: sarif: where to write the file, inside the workspace or the runner temp directory. Empty writes zn-gate.sarif in a new directory under the runner temp directory. |
package-sha256 |
empty | SHA-256 of the zn-gate wheel on PyPI for version, used by scan. |
npm-integrity |
empty | sha512-... integrity of the zn-gate npm tarball for version, used by audit. |
Version
usezn/zn@v1.17.0 installs zn-gate 1.17.0 unless you set version. Audit needs zn-gate 1.6.0 or later: with an older version, mode: audit fails and mode: both runs the scan only and prints a warning. Pin the Action to an exact release tag, as in the examples, so the same code runs every time. Releases are listed on the releases page.
Outputs and exit codes
The Action sets three outputs you can read in later steps:
sarif-file: path of the SARIF file (format: sarifonly); empty if none was written.scan-exit-code:0clean,1findings,2error; empty if the scan did not run.audit-exit-code:0clean,1findings at or above the threshold,2error; empty if the audit did not run.
With fail-on-threat: false the checks report without failing, so a finding gives 0; an error still gives 2.
Code scanning (SARIF)
With format: sarif and the upload step, each finding is an alert under Security > Code scanning, with the rule, the file and the line, and any secret value hidden. The scan and the audit are separate runs (categories zn-gate/scan/ and zn-gate/audit/), so you can filter by tool. Code scanning needs a public repository, or GitHub Code Security on a private one; without it, use format: github and leave out the security-events permission. On pull requests from forks, GitHub may not allow the upload; the check still runs and still sets the job status.
Permissions
The Action needs only contents: read. Add security-events: write only to upload SARIF, and actions: read too in private repositories. Use persist-credentials: false on actions/checkout so the token is not left in the workspace, and run the workflow on pull_request, not on pull_request_target.
Report without failing the build
To see findings without blocking merges, for example while you clean up an existing repository, set fail-on-threat: false: the step stays green and the findings still appear as annotations. To keep the checks strict but not stop the job, use continue-on-error: true and read the exit-code outputs (1 is findings, 2 is an error, so check for 2 before you ignore it):
- uses: usezn/zn@v1.17.0
id: zn
continue-on-error: true
with:
mode: both
- name: Report the result
if: always()
run: echo "scan=${{ steps.zn.outputs.scan-exit-code }} audit=${{ steps.zn.outputs.audit-exit-code }}"
Set fail-on-threat back to true (and remove continue-on-error) when the repository is clean, so new findings block the merge.
Verify the packages
To make the run refuse any other file, set npm-integrity (see npm view zn-gate@<version> dist.integrity) and package-sha256. The install stops with an error if a downloaded file has a different hash:
- uses: usezn/zn@v1.17.0
with:
mode: audit
npm-integrity: 'sha512-<integrity of the zn-gate npm tarball>'
package-sha256: '<sha-256 of the zn-gate wheel on PyPI>'
Badge
Show that the check runs with the status badge GitHub generates for your own workflow (replace <owner>, <repo> and the file name zn.yml). The Action adds no badge of its own:
[](https://github.com/<owner>/<repo>/actions/workflows/zn.yml)
Run the same check on your machine
The same checks run locally:
npx -y zn-gate scan .
npx -y zn-gate audit .