Skip to the content.

Continuous Git commit scanning (webhook + polling)

The LLM commit-scanning pipeline (security-model.md) scans a commit when one flows through the Git pull-through backend. The continuous commit scanner runs that same pipeline proactively over a set of watched repositories: it detects new commits — reactively from a push webhook, or by polling — and scans only the commits it has not already scanned, so risky commits are caught as they land rather than only when something pulls them.

It is built on three guarantees:

How new commits are detected

Trigger When Scope
Push webhook A Git host POSTs a push event to the receiver endpoint. The pushed ref range before..after (fast, near-real-time).
Polling Every pollInterval. The difference between each tracked ref’s current upstream head and the cursor (a safety net that also catches missed/unconfigured webhooks).
Backfill On first sighting (if enabled) or on demand. Reachable history, in bounded maxCommitsPerScan chunks.

All three converge on the same incremental cursor logic, so they compose safely: a webhook and a poll can never double-scan or race a repository (per-repo processing is serialized), and in an HA deployment only the coordination leader runs the polling sweep (webhook scans are idempotent and are not gated).

Commit enumeration and diff extraction use the git binary against a local bare mirror of each repository (kept under mirrorDir), so the scanner reads real commit diffs, not just the truncated commit list a webhook payload carries.

Diffs are read with the repository’s own attributes switched off (git -c attr.tree=<empty tree> show …). A .gitattributes line such as dist/** -diff, which projects set on generated or bundled code, makes git print “Binary files differ” for a text file, and a change to such a file would reach the model as “binary file; contents omitted” — the file the tj-actions/changed-files attacker changed. Git’s own content test (a NUL byte) decides what is binary instead, so real binaries stay omitted. The known-malware suite holds that attack as a regression test.

The push-webhook endpoint

The receiver is mounted at webhookPath (default /webhooks/git), outside the /v1 client access-control envelope — the external Git host posting to it has no proxy client credentials. It authenticates deliveries itself.

Signature verification (GitHub-style)

Set webhookSecret and the receiver verifies the X-Hub-Signature-256: sha256=<hex> header: an HMAC-SHA256 of the raw request body keyed by the secret, compared in constant time. A missing or invalid signature is rejected with 401 and the payload is never parsed.

Configure the same secret on the Git host:

Leaving webhookSecret empty disables verification (the receiver then accepts any well-formed payload). This is strongly discouraged outside a trusted network.

Repository routing

An inbound push is matched to a watched repository by fullName (repository.full_name, e.g. acme/widgets) or by clone URL (clone_url, ssh_url, git_url, html_url, compared ignoring a trailing .git). A push for a repository that is not watched is rejected with 404 — unless allowUnconfiguredWebhooks is set, in which case it is scanned ad hoc with the repository derived from the payload.

Configuration

Under scanning.watch (continuous scanning reuses the scanning provider, models, budget, and deterministic secret detector — see configuration-reference.md):

scanning:
  enabled: true
  provider: claude            # or codex/openai; deterministic-only also works
  apiKey: ${ANTHROPIC_API_KEY}
  commit:
    storeDir: /var/lib/pts/verdicts   # durable verdict cache (recommended)
  watch:
    enabled: true
    mirrorDir: /var/lib/pts/commit-mirrors   # required: bare mirrors for enumeration
    stateDir: /var/lib/pts/commit-cursors    # durable per-repo cursors (recommended)
    pollInterval: 5m           # 0 disables polling (webhook-only)
    maxCommitsPerScan: 500     # per repo per cycle; remainder picked up next cycle
    backfill: false            # true = scan history on first sighting
    webhookPath: /webhooks/git
    webhookSecret: ${GIT_WEBHOOK_SECRET}     # HMAC secret; supports ${ENV} and enc:v1:
    allowUnconfiguredWebhooks: false
    repos:
      - name: widgets          # stable id (cursor key, findings key, webhook routing)
        url: https://github.com/acme/widgets.git
        fullName: acme/widgets # webhook routing (repository.full_name)
        branches: [main, release]   # empty = default branch only
        username: x-access-token    # optional HTTPS credentials
        token: ${ACME_GIT_TOKEN}    # supports ${ENV} and enc:v1:

Notes:

What happens to a scanned commit

  1. The commit is scanned by the configured pipeline (deterministic secret detection + LLM triage → deep analysis, per the normal pipeline).
  2. The verdict is persisted keyed by commit SHA (shared verdict cache).
  3. A flagged verdict (malicious, or any finding) is recorded in the findings store as a commitscan/suspicious-commit finding (secret findings map to secretscan/exposed-credential), keyed by coordinate git/<repo>@<sha>, and surfaced in the SARIF export, the admin findings view, and the tenant portal.
  4. The scan is written to the tamper-evident audit log (scan_verdict, with the repository, commit, risk score, severity, and allow/deny decision).
  5. A flagged verdict raises a notification (commit_scan event) through the configured sinks.
  6. When a package is later associated with this commit (via build-provenance attestation or other provenance), the package-to-commit link surfaces this verdict on the artifact — so a risky commit blocks or flags the artifacts built from it.

Observability

Operational notes