Skip to content

GitHub Action

github-actions[bot] edited this page Nov 11, 2026 · 8 revisions

GitHub Action

Marketplace action

The root action.yml, listed on the GitHub Marketplace as Tripcord Security, is the shortest way in. A static Scanned with Tripcord badge is Markdown and HTML only; it does not call this action.

name: tripcord
on:
  pull_request:

jobs:
  tripcord:
    runs-on: ubuntu-latest
    permissions:
      contents: read # checkout the repository being scanned
      pull-requests: read # read pull request reviews
      security-events: write # upload the SARIF report
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: vgmartinez/tripcord@v0.1.0

For gradual adoption, start in report-only mode. The SARIF upload and the optional pull request comment still happen, and findings show up as a warning with the finding count instead of failing the job:

      - uses: vgmartinez/tripcord@v0.1.0
        with:
          fail-on: none

Remove fail-on: none (or set a severity) to enforce. See report-only mode.

The root action has the same inputs and outputs as the composite action below and forwards every one of them unchanged. It is a thin wrapper: its one step runs vgmartinez/tripcord/.github/actions/tripcord at a full commit SHA, the same commit the reusable workflows pin. A composite action's uses: ./path resolves against the caller's workspace, not this repository, so the delegate is named by repository and commit. That composite action builds tripcord from source at that commit, so vgmartinez/tripcord@v0.1.0 runs the scanner the v0.1.0 tag pins. A pin to a full commit SHA of this repository works the same way.

Composite action

The composite action at ./.github/actions/tripcord builds tripcord from source and scans a repository. It does not download a release binary; release archives are on the Releases page (see Installation).

By default it builds the tree that contains the action (github.action_path). Set ref to build another commit of this action's repository instead. That checkout lives at tripcord-src in the workspace only long enough to compile. The binary is written under RUNNER_TEMP, and the checkout is removed before the scan, so the default path of . does not include Tripcord's own tree. Set binary to an existing executable to skip the build. actions/setup-go caches modules for the build.

path is a directory in the workspace. A path inside a Git repository scans that whole repository from its git root; it does not narrow discovery to the directory. Monorepo scoping is tracked in #59. The action fails before the scan when path is empty, does not exist, is not a directory, is an empty directory, or cannot be listed. An unreadable directory is reported as unreadable, not as empty.

An empty fail-on leaves the threshold to the CLI and the repository policy. The action passes --fail-on only when the caller sets the input to a severity (low, medium, high, or critical). The CLI default is enforce mode with fail-on high. A locked policy can reject a looser value. none is the action's report-only mode, below; it is not a CLI value. Any other value reaches the CLI, which exits 3, and the job fails.

Report-only mode

fail-on: none publishes everything and fails only on errors (#62). It works the same in the root action, the composite action, and both reusable workflows; the CLI does not change.

  • The scans run without --fail-on, so the policy's threshold decides what is a finding exit (1).
  • The SARIF upload and the pull request comment run as they do otherwise.
  • A scan exit 1 becomes a ::warning:: with the number of findings in the SARIF report, and the job passes. scan-exit-code is still 1.
  • A pr-context TC-CFG-014 denial (exit 1) becomes a ::warning::, and the job passes. pr-context-exit-code is still 1.
  • Exit 2, 3, and 4 still fail the job, from the scan or, with reviews-file, from pr-context. So do an invalid path and an unknown fail-on value.

The default, an empty fail-on, is unchanged.

The action runs three scans with that binary:

  • GitHub Actions annotations (::error output);
  • a SARIF report, uploaded to GitHub code scanning by default; and
  • a Markdown report, which can optionally be posted to a pull request.

It then runs tripcord pr-context with the same binary. Set reviews-file to a JSON array of pull request reviews to pass --reviews-file. An empty value skips the flag. The array stays on disk and is not printed. The action outputs is_agent, agents, and tc-cfg-014 are that command's GITHUB_OUTPUT values. After reports are published, a TC-CFG-014 denial (exit 1) fails the job, unless fail-on is none. An unapproved change of more than 64 agent-config paths is that denial: the report lists the first 64 paths and and N more. With reviews-file, incomplete or invalid review data (exit 3 or 4) fails the job; without it, exits 3 and 4 warn and leave the job green. The scan exit code also fails the job after reports are published, except exit 1 with fail-on: none.

pr-context reads commits between the pull request base and head. The checkout of the repository being scanned needs fetch-depth: 0. A shallow clone usually does not contain base, so commit and note signals are skipped and only the pull request login and branch remain.

base defaults to the pull request's base commit (github.event.pull_request.base.sha, empty on other events). When it is set, every scan runs with --base, so a pull request that removes or re-pins a Tripcord embed, or drops a harness from it, fails TC-CFG-016 even when the head tree has no embed left to check. The scan also uses the base's repository policy, not the head's, ignores .tripcord/policy.local.yaml, and reports a head policy that weakens the base's. The base commit must be in the checkout (fetch-depth: 0); if it is not, the action logs an error and the scan exits 3, which fails the job. A path that is not inside a Git repository has no history to compare, so the action logs a notice and scans without --base. Set base: "" to scan the head alone. The reusable workflows in this repository leave base at its default and call the composite action pinned at main@d01fb05, which defaults base to the pull request's base commit. Another repository pins those workflow files at main@12c7476, the commit whose copies call that action.

Publishing runs when the scan recorded an exit code. A pull request whose head repository differs from its base repository skips both the SARIF upload and the comment and emits a warning. A missing SARIF file, for example when the scan exits 3 before writing the report, warns that the file is missing. A read-only token warns that the token cannot upload code scanning results. When the token's identity cannot be read, the action posts no comment and edits no existing comment, and warns. None of these cases fails the job.

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  with:
    fetch-depth: 0
    persist-credentials: false
- uses: ./.github/actions/tripcord

Inputs and permissions

path defaults to .. As above, a path inside a Git repository scans that repository from its git root. upload-sarif defaults to true. Set comment: true to create or update a marked Markdown comment on pull-request events. When the token's identity cannot be read, the action posts no comment and edits no existing comment.

A job that calls the composite action directly needs security-events: write when SARIF upload is enabled and pull-requests: write when comment: true. A checkout of ref uses github-token.

Reusable workflows

GitHub checks the permissions of every job in a called workflow when the caller starts, before any if: condition and before inputs are read. Each file below is workflow_call only and contains one job. The caller picks the file. Both jobs request security-events: write, including when upload-sarif is false. Neither file uses pull_request_target. A fork pull request still skips the SARIF upload and the comment and emits the action's warning.

Each workflow checks out the calling repository with fetch-depth: 0 and runs the composite action at a full commit SHA, so the scanner is not taken from the tree being scanned. The inputs match the action's scan inputs (ref, binary, path, fail-on, upload-sarif, comment, github-token) and use the same defaults. Reviews are not an input. An empty github-token uses github.token, because a workflow_call default cannot be an expression. There is no policy input: an empty fail-on still leaves the threshold to the CLI and the repository policy. The outputs are is_agent and agents. The action step does not continue on error, so a TC-CFG-014 denial (exit 1) fails the scan job after publishing. An unapproved change of more than 64 agent-config paths is that denial. These workflows pass reviews-file, so exit 1 fails the job, and exit 3 or 4 also fails it.

The reviews step calls github.paginate on GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews. Owner, repository, and pull number come from the Actions context. The JSON array is written under RUNNER_TEMP and passed as reviews-file. The step does not print the array. If the event has no pull request, or the read fails, the step warns and the scan still runs. pr-context then runs without --reviews-file and reports an incomplete review set.

Scan

.github/workflows/tripcord-pr.yml needs contents: read, pull-requests: read, and security-events: write.

name: tripcord
on:
  pull_request:

jobs:
  tripcord:
    permissions:
      contents: read # checkout the repository being scanned
      pull-requests: read # read pull request reviews
      security-events: write # upload the SARIF report
    uses: ./.github/workflows/tripcord-pr.yml

Another repository pins the same file by full commit SHA:

permissions:
  contents: read # checkout the repository being scanned
  pull-requests: read # read pull request reviews
  security-events: write # upload the SARIF report
uses: vgmartinez/tripcord/.github/workflows/tripcord-pr.yml@12c7476ae05ea2c791ea39ef44bd4f1a0f5f9164 # main@12c7476

Comment

.github/workflows/tripcord-pr-comment.yml needs the same permissions, with pull-requests: write in place of pull-requests: read, because posting the Markdown comment requires write. write includes read, so the reviews fetch uses the same token.

name: tripcord
on:
  pull_request:

jobs:
  tripcord:
    permissions:
      contents: read # checkout the repository being scanned
      pull-requests: write # create or update the Markdown comment
      security-events: write # upload the SARIF report
    uses: ./.github/workflows/tripcord-pr-comment.yml
    with:
      comment: "true"

Another repository pins the same file by full commit SHA:

permissions:
  contents: read # checkout the repository being scanned
  pull-requests: write # create or update the Markdown comment
  security-events: write # upload the SARIF report
uses: vgmartinez/tripcord/.github/workflows/tripcord-pr-comment.yml@12c7476ae05ea2c791ea39ef44bd4f1a0f5f9164 # main@12c7476

Building from source in your own workflow

A repository that does not want to call the reusable workflows can build ./cmd/tripcord itself, write SARIF, and upload it. This workflow checks out the repository to scan and this repository, and pins every action by commit. ref: main builds the default branch of this repository. Pin the scanner with ref: v0.1.0 or with a full commit SHA. The root action is used via @v0.1.0, while the reusable workflows stay pinned to SHAs on main.

A high finding makes scan exit 1, which fails the job. The upload step still runs. Uploading SARIF on a private repository requires GitHub Code Security.

name: tripcord
on:
  pull_request:
permissions:
  contents: read
  actions: read
  security-events: write
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the repository to scan
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
          path: target

      - name: Checkout tripcord
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          repository: vgmartinez/tripcord
          ref: main
          persist-credentials: false
          path: tripcord

      - name: Setup Go
        uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: tripcord/go.mod
          cache: false

      - name: Build tripcord
        working-directory: tripcord
        run: CGO_ENABLED=0 go build -trimpath -o "$RUNNER_TEMP/tripcord" ./cmd/tripcord

      - name: Scan
        working-directory: target
        run: '"$RUNNER_TEMP/tripcord" scan . --format sarif --output "$RUNNER_TEMP/tripcord.sarif"'

      - name: Upload SARIF
        if: always() && !cancelled()
        uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
        with:
          sarif_file: ${{ runner.temp }}/tripcord.sarif

actions: read is what github/codeql-action/upload-sarif requires when the repository is private.

Clone this wiki locally