GitHub composite action for running OpenGrep in CI.
The action installs a pinned OpenGrep release, validates all user-controlled inputs, runs the scan, and exposes JSON/SARIF outputs for downstream workflow steps.
Pin this action to a full commit SHA, never to a tag or branch. List every released tag with the SHA it points at, newest first, and copy the line you want:
gh api repos/platform-sec/opengrep-action/tags \
--jq '.[] | "uses: platform-sec/opengrep-action@\(.commit.sha) # \(.name)"'name: Security scan
on:
push:
pull_request:
permissions:
contents: read
jobs:
opengrep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: scan
# Placeholder — see "Pinning" above for the command that prints the real SHA
uses: platform-sec/opengrep-action@<REPLACE-WITH-COMMIT-SHA>
with:
target: .
output-format: json/sarif
strict: true
- uses: actions/upload-artifact@v4
if: always()
with:
name: opengrep-results
path: |
${{ steps.scan.outputs.json-file }}
${{ steps.scan.outputs.sarif-file }}| Input | Default | Description |
|---|---|---|
target |
. |
File or directory to scan. |
patterns |
auto |
OpenGrep rules, ruleset, or config path. |
config |
OpenGrep configuration file. | |
output-format |
json/sarif |
json/sarif, json, sarif, or text. |
severity |
Minimum severity: INFO, WARNING, or ERROR. |
|
include |
Include glob patterns. | |
exclude |
Exclude glob patterns. | |
timeout |
Per-rule timeout, in seconds. | |
jobs |
Number of parallel jobs. | |
enable-interfile |
false |
Cross-file taint analysis for rules that opt into it. OpenGrep 2.0.0 or later. See Cross-File Analysis. |
interfile-timeout |
600 |
Seconds the cross-file analysis of a rule may run. 0 removes the limit. |
strict |
true |
Return a non-zero exit code when findings exist. |
baseline-commit |
Git ref or commit hash for differential scans. | |
opengrep-version |
2.1.0 |
OpenGrep version to install. Use an explicit version for reproducibility or latest to opt into the newest release at runtime. |
opengrep-checksum |
Optional SHA256 checksum for the Linux x86 CLI asset of that version (opengrep_manylinux_x86 in 1.x, opengrep_linux_x86 from 2.0.0). |
|
verify-signature |
true |
Verify the Sigstore signature on the OpenGrep release asset. |
See action.yml for the full input list.
This action supports Linux x64 runners only (ubuntu-latest and friends).
Any other RUNNER_OS/RUNNER_ARCH combination fails during input validation
with an explicit message rather than a download error. Upstream publishes musl,
arm64, macOS, and Windows assets, so other platforms can be added; they are
unsupported here because CI does not exercise them.
By default, this action installs a reviewed OpenGrep release with a checksum
committed in action.yml. That keeps repeated workflow runs
reproducible.
Use an explicit version to pin a different OpenGrep release:
with:
opengrep-version: '1.25.0'For the strongest override, provide the matching SHA256 checksum of that release's Linux x86 CLI asset. Upstream renamed it in 2.0.0, and the action picks the name from the version:
| OpenGrep | Asset |
|---|---|
| 1.x | opengrep_manylinux_x86 |
| 2.0.0 and later | opengrep_linux_x86 |
with:
opengrep-version: '2.1.0'
opengrep-checksum: 'd6a68a84c01a3d8ee933f60847decf1b4d0fd7791a26833b32b95922baf28974'If opengrep-checksum is omitted for a non-default version, the action
resolves the checksum from OpenGrep release metadata before downloading the
asset. opengrep-version: latest is supported as an explicit opt-in and logs a
warning because it is not reproducible across workflow runs.
On github.com, the action sends the job's GITHUB_TOKEN with its calls to
api.github.com. Those calls are the release metadata lookup and the version
check. With the token, a lookup counts against the repository's rate limit,
not the anonymous limit of 60 calls an hour that every job on the same runner
IP shares. Reading a public release needs no permissions, so permissions: {} is enough. On GitHub Enterprise Server the token is not sent, and the calls
stay anonymous. Every download from GitHub is retried up to three times before
the step fails.
The pinned default is kept current by
update-opengrep.yml, which opens a
reviewable PR when upstream publishes a release. When the pin trails upstream
at scan time, the action logs a one-line notice; set disable-version-check to
suppress it.
The action installs the Linux x86 CLI asset, which upstream signs with
Sigstore. By default the action installs cosign and verifies the signature
before installing the binary. The certificate must come from this issuer and
name upstream's release workflow, run either on main or on the branch of the
release being installed:
identity: https://github.com/opengrep/opengrep/.github/workflows/rolling-release.yml@refs/heads/main
or: https://github.com/opengrep/opengrep/.github/workflows/rolling-release.yml@refs/heads/release-v<version>
issuer: https://token.actions.githubusercontent.com
Releases up to 1.30.0 were signed from main, 1.30.1 to 1.33.1 from a
branch named for the release (release-v1.33.1), and 2.0.0 and 2.1.0 from
main again. The action passes cosign an anchored expression that admits
exactly these two refs for the version it installs, built by
opengrep_signing_identity_regexp in
scripts/validators.sh. A certificate from another
branch, workflow or repository, or from the branch of another release, is
refused.
This is a provenance check — it proves the binary came from OpenGrep's own release workflow, which a checksum cannot establish. The pinned SHA256 is kept as a separate integrity gate, because it is reviewed at commit time and so resists a mutated upstream release.
Verification needs egress to GitHub releases and the Sigstore transparency log. On a runner that cannot reach them, disable it explicitly:
with:
verify-signature: falseBy default OpenGrep runs every rule one file at a time, so a taint rule misses
a flow whose source is in one file and whose sink is in another. Rules can opt
into cross-file analysis with interfile: true (or taint_interfile: true)
under options, and enable-interfile turns it on for those rules:
with:
enable-interfile: true
interfile-timeout: 900 # seconds per rule, 600 by default, 0 for no limitWithout it, OpenGrep 2.x logs interfile mode not enabled and lists the rules
it ran per file. Some rules in the auto ruleset are among them.
Things to know before turning it on:
- It needs OpenGrep 2.0.0 or later. On a 1.x
opengrep-versionthe action fails with a message naming the installed version, since OpenGrep 1.x has no such option. - OpenGrep builds a call graph of the project, so scans take longer and use
more memory. OpenGrep sets no time limit by default, so the action passes
interfile-timeout. To cap memory as well, pass--max-memory=<MiB>inadditional-safe-flags. - Rules that opt into interfile skip files under
test/andtests/directories (OpenGrep 2.1.0 logsabsent from the interfile graph).
| Output | Description |
|---|---|
results-file |
Primary results file. |
json-file |
JSON results file, when generated. |
sarif-file |
SARIF results file, when generated. |
findings-count |
Number of findings reported by OpenGrep. |
This repository treats the action shell boundary as security-sensitive.
- Inputs are passed through
env:blocks, not interpolated directly into shell scripts. - OpenGrep arguments are built as bash arrays, not command strings.
- Paths, enums, booleans, numeric limits, include patterns, and safe extra flags are validated before use.
- The default OpenGrep download is pinned and checksum-verified; explicit version overrides are checksum-verified before installation.
- The downloaded asset's Sigstore signature is verified against a pinned signing identity before the binary is installed.
- Structured scan output is asserted to be present and well-formed before the action reports success, so a truncated report cannot be read as "no findings" downstream.
- Workflows are linted and validated with
actionlint,yamllint, and security-focused checks. - The test suite includes local GitHub Actions runs through
act, pytest security tests, property-based tests, fuzzing support, and performance coverage.
Install prerequisites for your platform:
just ubuntu
# or
just macosUseful checks:
just validate-action
just lint-workflows
just test-basic
just test-securityFull local coverage:
just test-fullThe main implementation is action.yml. Shared validators live in
scripts/validators.sh, and security tests live in
tests/security/.
MIT. See LICENSE.