Skip to content

GitHub Action & Pre-Commit Hooks

Automate MCP server, tool schema, client config, and Python source security scanning across every local commit and pull request using the official JMartynov/verity-scan-action@v1 composite GitHub Action and .pre-commit-hooks.yaml.


Overview & Architecture

JMartynov/verity-scan-action@v1 runs a deterministic, single-pass verity scan --format json inside an isolated ${{ runner.temp }}/verity/ workspace without polluting your repository working tree.

  1. Tooling & Cache Setup: Installs Python and uv via astral-sh/setup-uv@v6, restores ${{ runner.temp }}/verity-cache via actions/cache@v4 (when cache: "true"), and provisions an isolated virtualenv at ${{ runner.temp }}/verity/.venv with verity-redteam-core (plus any extra-packages).
  2. Single-Pass Deterministic Scan: Invokes verity scan --format json --output ${{ runner.temp }}/verity/verity-results.json with your configured --path, --config-file, --schema-file, --offline, and --live-probe flags, then canonicalizes file_path values relative to the repository root.
  3. Optional PR Diff Filtering (diff-pr: "true"): On pull requests, checks out the base commit into a detached git worktree at ${{ runner.temp }}/verity/base-checkout, scans the base ref, removes the temporary worktree, and filters out findings whose fingerprint (or fallback (rule_id, file_path, title) tuple) already existed on the base branch.
  4. Structured Outputs & Step Summary: Computes 8 steps.<id>.outputs.* values, enforces fail-on-severity, and writes a formatted # Verity Scan Report Markdown table directly to $GITHUB_STEP_SUMMARY.
  5. Boundary-Safe [Pro] SARIF Upload: When upload-sarif: "true" is set, probes verity.cli._load_sarif_exporter(). If verity-pro is installed (for example via extra-packages: "verity-pro"), normalizes artifactLocation.uri with uriBaseId: "%SRCROOT%", emits verity-results.sarif, sets sarif-generated: "true", and uploads via github/codeql-action/upload-sarif@v3. In Open-Core Free (verity-redteam-core), no SARIF exporter is loaded, sarif-generated cleanly evaluates to "false", and the upload step is skipped with zero errors.
flowchart LR
    CO["actions/checkout@v5"] --> UV["astral-sh/setup-uv@v6 + actions/cache@v4"]
    UV --> VENV["${{ runner.temp }}/verity/.venv<br/>(verity-redteam-core + extra-packages)"]
    VENV --> SCAN["verity scan --format json<br/>-> verity-results.json"]
    SCAN --> DIFF{"diff-pr == 'true'<br/>& PR base SHA?"}
    DIFF -- yes --> WT["Detached git worktree scan<br/>filter base fingerprints"]
    DIFF -- no --> POST["Post-process counts,<br/>exit-code & $GITHUB_STEP_SUMMARY"]
    WT --> POST
    POST --> OUT["8 structured step outputs"]
    POST --> SARIF{"upload-sarif == 'true'<br/>& Pro exporter present?"}
    SARIF -- "Pro installed" --> UP["Normalize %SRCROOT% URIs<br/>github/codeql-action/upload-sarif@v3"]
    SARIF -- "Free (M40 boundary)" --> SKIP["sarif-generated = 'false'<br/>(skip upload, 0 errors)"]

Zero-Config Free Compatibility

upload-sarif defaults to "true", yet Open-Core Free workflows never fail on missing SARIF support: action.yml gates github/codeql-action/upload-sarif@v3 on steps.scan.outputs.sarif-generated == 'true', preserving the deterministic Free M40 boundary without requiring extra flags.


Quickstart Workflow

Create .github/workflows/verity-security.yml in your repository to gate pushes and pull requests on HIGH and CRITICAL findings:

name: Verity MCP Security Scan

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

jobs:
  verity-scan:
    name: MCP & Agent Security Gate
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

      - name: Run Verity MCP Security Scan
        uses: JMartynov/verity-scan-action@v1
        with:
          fail-on-severity: "HIGH"

After the job runs, open the GitHub Actions run summary to inspect the generated # Verity Scan Report Markdown table directly in $GITHUB_STEP_SUMMARY.


Workflow Recipes

1. PR Diff-Aware Mode (Zero-Config Brownfield Adoption)

Adopt Verity on an existing repository with pre-existing technical debt without blocking unrelated pull requests. Setting fetch-depth: 0 alongside diff-pr: "true" compares the PR head against github.event.pull_request.base.sha using a detached git worktree and fails only when the PR introduces new findings at or above fail-on-severity:

name: Verity PR Regression Gate

on:
  pull_request:

permissions:
  contents: read

jobs:
  pr-diff-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0

      - name: Scan only findings introduced by this PR
        uses: JMartynov/verity-scan-action@v1
        with:
          diff-pr: "true"
          fail-on-severity: "HIGH"
          offline: "true"

fetch-depth: 0 is required for diff-pr: \"true\"

Shallow clones (fetch-depth: 1, the default for actions/checkout@v5) do not contain github.event.pull_request.base.sha. Always set fetch-depth: 0 when enabling diff-pr: "true".

2. Committed Baseline Mode (.verity-baseline.json)

When you want explicit, peer-reviewed tracking of accepted legacy findings across pushes to main (not only pull requests), use a committed .verity-baseline.json file alongside inline suppressions and .verityignore.

Approach Best For Push to main Audit Trail
diff-pr: "true" Zero-config PR onboarding on brownfield repos Scans full head (no PR base) Ephemeral PR diff
.verity-baseline.json Regulated teams requiring PR-reviewed debt sign-off Gates regressions on every push and PR Committed verity-baseline.v1.json in Git

Capture a deterministic baseline locally (sorted by (file_path, rule_id, fingerprint), with pre-redaction verity:v1: hashes and zero plaintext secrets):

verity scan --path . --offline --save-baseline .verity-baseline.json

Gate pushes and PRs against the committed baseline:

- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v6
  with:
    python-version: "3.12"
- run: uv tool install verity-redteam-core
- name: Fail only on newly introduced findings
  run: |
    verity scan --path . --offline \
      --baseline .verity-baseline.json \
      --fail-on-new \
      --fail-on-severity HIGH

Suppress intentional test fixtures or vetted exceptions in source files using # verity-ignore (or # nosemgrep):

# verity-ignore: VERITY-AST-CWE-78-SHELL -- sandboxed fixture test
subprocess.run(cmd, shell=True, check=True)

Exclude generated directories or monorepo test fixtures via .verityignore (supports gitignore globs, :include .gitignore, and !negation):

:include .gitignore
tests/fixtures/vulnerable_*.py
!tests/fixtures/must_scan.py

3. Air-Gapped & Strict Offline Mode

Run Verity with zero outbound network requests on self-hosted or air-gapped runners. Setting offline: "true" passes --offline (which sets VERITY_OFFLINE=1) so Verity relies strictly on its bundled 6,062+ MCP server passports and 856+ OSV v1.6.0 advisories:

- uses: actions/checkout@v5
- uses: JMartynov/verity-scan-action@v1
  with:
    offline: "true"
    fail-on-severity: "MEDIUM"

4. Multi-Path, Client Config & Tool Schema Scanning

Scan multiple directories, MCP client configs, and exported tool JSON schemas in one pass. Space-separated lists in path and config-file map directly to --path and --config-file:

- uses: actions/checkout@v5
- uses: JMartynov/verity-scan-action@v1
  with:
    path: "src/mcp_servers packages/agent_tools"
    config-file: ".mcp.json .cursor/mcp.json"
    schema-file: "schemas/mcp_tools.json"
    live-probe: "false"
    version: "0.2.8"
    python-version: "3.12"
    fail-on-severity: "HIGH"
  • version options: Use "latest" (default) for the newest verity-redteam-core PyPI release, an exact version like "0.2.8" for reproducible builds, or "local" to install from ${{ github.action_path }} when testing a fork.
  • live-probe: "true": Opt-in active probing of configured MCP servers (disabled by default to avoid unexpected runner egress).

5. Consuming Step Outputs in Downstream Jobs & PR Gates

Set an id: on the action step to read all 8 structured outputs in subsequent steps, comment builders, or artifact uploads. Use if: always() on downstream reporting steps so JSON reports are still preserved when fail-on-severity exits non-zero:

jobs:
  scan-and-archive:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Verity Security Scan
        id: verity
        continue-on-error: true
        uses: JMartynov/verity-scan-action@v1
        with:
          offline: "true"
          fail-on-severity: "HIGH"

      - name: Inspect scan telemetry
        if: always()
        run: |
          echo "Total findings: ${{ steps.verity.outputs.findings-count }}"
          echo "Critical: ${{ steps.verity.outputs.critical-count }}"
          echo "High: ${{ steps.verity.outputs.high-count }}"
          echo "Has CRITICAL/HIGH: ${{ steps.verity.outputs.has-critical-or-high }}"
          echo "JSON report: ${{ steps.verity.outputs.json-file }}"
          echo "SARIF file: ${{ steps.verity.outputs.sarif-file }}"
          echo "SARIF generated: ${{ steps.verity.outputs.sarif-generated }}"
          echo "Exit code: ${{ steps.verity.outputs.exit-code }}"

      - name: Upload Verity JSON report
        if: always() && steps.verity.outputs.json-file != ''
        uses: actions/upload-artifact@v4
        with:
          name: verity-scan-report
          path: ${{ steps.verity.outputs.json-file }}

      - name: Enforce policy gate after artifact upload
        if: steps.verity.outputs.exit-code != '0'
        run: exit "${{ steps.verity.outputs.exit-code }}"

6. GitHub Code Scanning SARIF v2.1.0 Upload ([Pro])

When verity-pro is installed via extra-packages, JMartynov/verity-scan-action@v1 emits OASIS SARIF v2.1.0, rewrites physicalLocation.artifactLocation.uri to repo-relative POSIX paths with uriBaseId: "%SRCROOT%", and uploads annotations directly to the GitHub Security → Code scanning tab:

name: Verity Code Scanning (Pro)

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read
  security-events: write

jobs:
  code-scanning:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Run Verity Scan & Upload SARIF
        uses: JMartynov/verity-scan-action@v1
        with:
          extra-packages: "verity-pro"
          upload-sarif: "true"
          sarif-category: "verity-mcp-scan"
          fail-on-severity: "HIGH"

Free vs. Pro SARIF Contract

Without verity-pro, verity.cli._load_sarif_exporter() is absent, so action.yml sets sarif-file="" and sarif-generated="false" and skips github/codeql-action/upload-sarif@v3 without failing the job. Calling verity scan --format sarif directly in Free exits with code 2 and returns PRO_FEATURE_REQUIRED (zero partial writes). See Compliance & SARIF Reporting.


Complete Action Inputs Reference

All 13 inputs defined in action.yml are optional (required: false):

Input Default Required Description
path '.' false Path(s) to scan (space-separated for multiple).
config-file '' false MCP config file(s) to scan (space-separated for multiple).
schema-file '' false JSON file containing MCP tool definitions.
fail-on-severity 'HIGH' false Return non-zero when a finding meets or exceeds this severity (CRITICAL, HIGH, MEDIUM, LOW, INFO, or NONE to report-only).
offline 'false' false Run in offline mode (use cached snapshots only).
live-probe 'false' false Actively probe configured MCP servers (opt-in).
upload-sarif 'true' false Upload SARIF to GitHub Code Scanning (requires Pro SARIF exporter).
sarif-category 'verity-mcp-scan' false SARIF category label passed to github/codeql-action/upload-sarif@v3.
diff-pr 'false' false Only report findings introduced by this PR (requires fetch-depth: 0).
version 'latest' false Verity version to install ('latest', 'local', or explicit PyPI version such as '0.2.8').
python-version '3.12' false Python version for the Verity virtualenv.
cache 'true' false Whether to cache the Verity virtualenv (${{ runner.temp }}/verity-cache).
extra-packages '' false Extra packages to install in the virtualenv (space-separated, e.g., 'verity-pro').

Complete Action Outputs Reference

All 8 outputs emitted by JMartynov/verity-scan-action@v1 from steps.scan.outputs.*:

Output Example Value Description
findings-count "3" Number of findings in the scan report (filtered to PR-introduced findings when diff-pr: "true").
critical-count "1" Number of CRITICAL findings.
high-count "2" Number of HIGH findings.
has-critical-or-high "true" Whether any CRITICAL or HIGH finding exists ("true" or "false").
sarif-file "/tmp/verity/verity-results.sarif" Path to the generated SARIF file (empty "" when no Pro exporter is installed).
json-file "/tmp/verity/verity-results.json" Path to the raw JSON scan report.
sarif-generated "false" Whether SARIF was actually emitted ("true" or "false").
exit-code "1" Computed exit code for the run (0 or 1 based on fail-on-severity).

Release Pinning & Supply-Chain Hygiene

Choose the pinning strategy that matches your security policy:

  • Floating major tag (@v1): Receives non-breaking action improvements and verity-redteam-core patches automatically.
  • Exact semver tag (@v1.0.0) or full commit SHA: Locks the composite action YAML and post-processing script; combine with version: "0.2.8" to pin both the action and scanner wheel.
  • Automated release synchronization: Every verity-redteam-core PyPI release (and action.yml change on main) triggers sync-scan-action.yml to notify JMartynov/verity-scan-action, where sync_and_release.yml validates the action across a 5-job E2E matrix (vulnerable fail gate, clean pass gate, PR diff mode, offline mode, and Free M40 SARIF boundary check) before publishing tags.

Companion Pre-Commit Hooks

Catch poisoned MCP configs, hardcoded secrets, and unsafe Python AST sinks before code ever leaves a developer workstation using .pre-commit-hooks.yaml. All three hooks run strictly --offline for <1s local commits.

Add Verity to .pre-commit-config.yaml:

repos:
  - repo: https://github.com/JMartynov/verityredteam-free
    rev: v0.2.8
    hooks:
      - id: verity-scan
      # Optional:
      # - id: verity-scan-configs
      # - id: verity-scan-uvx

Hook Comparison

Hook ID language pass_filenames require_serial CLI Entrypoint & Scope
verity-scan python true true verity scan --offline --fail-on-findings --path on staged Python, JSON, and YAML files
verity-scan-configs python true true verity scan --offline --fail-on-findings --config-file on staged MCP client & workspace configs
verity-scan-uvx system false false uvx verity-redteam-core scan --offline --fail-on-findings --path . with zero pre-commit virtualenv build overhead

Matched MCP Client Config Paths (verity-scan-configs)

The verity-scan-configs hook matches staged files against the following pattern so secrets, shell droppers, and OSV CVEs in client configs are caught immediately:

  • .cursor/mcp.json
  • .vscode/mcp.json
  • .mcp.json
  • claude.json
  • claude_desktop_config.json
  • mcp.json
  • librechat.yaml

Daily pre-commit Commands

# Install the git pre-commit hook into .git/hooks/
pre-commit install

# Run Verity hooks across every tracked file in the repository
pre-commit run --all-files

# Run a specific Verity hook on demand
pre-commit run verity-scan-configs --all-files

# Bump rev: to the latest verityredteam-free tag
pre-commit autoupdate

Next Steps