GitHub Action for Vulnerability Scanning

February 4, 2026 ยท View on GitHub

:zap: Find threats in files or containers at lightning speed :zap:

Test Status GitHub release License: MIT Join our Discourse

This is a GitHub Action for invoking the Grype scanner and returning the vulnerabilities found, and optionally fail if a vulnerability is found with a configurable severity level.

Use this in your workflows to quickly verify files or containers' content after a build and before pushing, allowing PRs, or deploying updates.

The action invokes the grype command-line tool, with these benefits:

  • Runs locally, without sending data outbound - no credentials required!
  • Speedy scan operations
  • Scans both paths and container images
  • Easy failure evaluation depending on vulnerability severity

The example workflows have lots of usage examples for scanning both containers and directories.

By default, a scan will produce very detailed output on system packages like an RPM or DEB, but also language-based packages. These are some of the supported packages and libraries:

Supported Linux Distributions:

  • Alpine
  • BusyBox
  • CentOS and RedHat
  • Debian and Debian-based distros like Ubuntu

Supported packages and libraries:

  • Ruby Bundles
  • Python Wheel, Egg, requirements.txt
  • JavaScript NPM/Yarn
  • Java JAR/EAR/WAR, Jenkins plugins JPI/HPI
  • Go modules

Tip

Security best practice: For production workflows, pin actions to a full commit SHA rather than a version tag. You can find the latest SHA for each release on the action's releases page.

Container scanning

The simplest workflow for scanning a localbuild/testimage container:

- name: Set up Docker Buildx
  uses: docker/setup-buildx-action@v3

- name: build local container
  uses: docker/build-push-action@v6
  with:
    tags: localbuild/testimage:latest
    push: false
    load: true

- name: Scan image
  uses: anchore/scan-action@v7
  with:
    image: "localbuild/testimage:latest"

Directory scanning

To scan a directory, add the following step:

- name: Scan current project
  uses: anchore/scan-action@v7
  with:
    path: "."

The path key allows any valid path for the current project. The root of the path ("." in this example) is the repository root.

Scanning an SBOM file

Use the sbom key to scan an SBOM file:

- name: Create SBOM
  uses: anchore/sbom-action@v0
  with:
    format: spdx-json
    output-file: "${{ github.event.repository.name }}-sbom.spdx.json"

- name: Scan SBOM
  uses: anchore/scan-action@v7
  with:
    sbom: "${{ github.event.repository.name }}-sbom.spdx.json"

Failing a build on vulnerability severity

By default, if any vulnerability at medium or higher is seen, the build fails. To have the build step fail in cases where there are vulnerabilities with a severity level different than the default, set the severity-cutoff field to one of low, high, or critical:

With a different severity level:

- name: Scan image
  uses: anchore/scan-action@v7
  with:
    image: "localbuild/testimage:latest"
    fail-build: true
    severity-cutoff: critical

Optionally, change the fail-build field to false to avoid failing the build regardless of severity:

- name: Scan image
  uses: anchore/scan-action@v7
  with:
    image: "localbuild/testimage:latest"
    fail-build: false

Action Inputs

The inputs image, path, and sbom are mutually exclusive to specify the source to scan; all the other keys are optional. These are all the available keys to configure this action, along with the defaults:

Input NameDescriptionDefault Value
imageThe image to scanN/A
pathThe file path to scanN/A
sbomThe SBOM to scanN/A
registry-usernameThe registry username to use when authenticating to an external registry
registry-passwordThe registry password to use when authenticating to an external registry
fail-buildFail the build if a vulnerability is found with a higher severity. That severity defaults to medium and can be set with severity-cutoff.true
output-formatSet the output parameter after successful action execution. Valid choices are json, sarif, cyclonedx-xml, cyclonedx-json, and table; where table output will also display in the logs.sarif
output-fileFile to output the Grype scan results to. Defaults to a file in the system temp directory, available in the action outputs
severity-cutoffOptionally specify the minimum vulnerability severity to trigger a failure. Valid choices are "negligible", "low", "medium", "high" and "critical". Any vulnerability with a severity less than this value will lead to a "warning" result. Default is "medium".medium
only-fixedSpecify whether to only report vulnerabilities that have a fix available.false
add-cpes-if-noneSpecify whether to autogenerate missing CPEs.false
by-cveSpecify whether to orient results by CVE rather than GHSA.false
vexSpecify a list of VEX documents to consider when producing scanning results.false
cache-dbCache the Grype DB in GitHub action cache and restore before checking for updatesfalse
grype-versionAn optional Grype version to download, defaults to the pinned version in GrypeVersion.js.
configOptional Grype configuration files (newline-separated). Setting this will disable auto-detection of configuration files (e.g. .grype.yaml) - only the specified files will be loaded..

Action Outputs

Output NameDescriptionType
sarifPath to the SARIF report file, if output-format is sarifstring
jsonPath to the report file , if output-format is jsonstring
cyclonedx-xmlPath to the CycloneDX report file, if output-format is cyclonedxstring
cyclonedx-jsonPath to the CycloneDX JSON report file, if output-format is cyclonedx-jsonstring

Example Workflows

Assuming your repository has a Dockerfile in the root directory:

name: Container Image CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: Build the container image
        run: docker build . --file Dockerfile --tag localbuild/testimage:latest
      - uses: anchore/scan-action@v7
        with:
          image: "localbuild/testimage:latest"
          fail-build: true

Same example as above, but with SARIF output format - as is the default, the action will generate a SARIF report, which can be uploaded and then displayed as a Code Scanning Report in the GitHub UI.

:bulb: Code Scanning is a Github service that is currently in Beta. Follow the instructions on how to enable this service for your project.

name: Container Image CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    # Permissions key is required for CodeQL SARIF Upload, per the docs:
    # https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github
    permissions:
      security-events: write
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: Build the Container image
        run: docker build . --file Dockerfile --tag localbuild/testimage:latest
      - uses: anchore/scan-action@v7
        id: scan
        with:
          image: "localbuild/testimage:latest"
      - name: upload Anchore scan SARIF report
        uses: github/codeql-action/upload-sarif@v4
        with:
          sarif_file: ${{ steps.scan.outputs.sarif }}

Optionally, you can add a step to inspect the SARIF report produced:

- name: Inspect action SARIF report
  run: cat ${{ steps.scan.outputs.sarif }}

Additional configuration

You may add a .grype.yaml file at your repository root for more Grype configuration such as ignoring certain matches.

anchore/scan-action/download-grype

A sub-action to download Grype and optionally cache the Grype DB.

Input parameters:

ParameterDescriptionDefault
grype-versionAn optional Grype version to download, defaults to the pinned version in GrypeVersion.js.
cache-dbCache the Grype DB in GitHub action cache and restore before checking for updatesfalse

Output parameters:

ParameterDescription
cmda reference to the Grype binary.

cmd can be referenced in a workflow like other output parameters: ${{ steps.<step-id>.outputs.cmd }}

Example usage:

- uses: anchore/scan-action/download-grype@v3
  id: grype
- run: ${{steps.grype.outputs.cmd}} dir:.

Contributing

We love contributions, feedback, and bug reports. For issues with the invocation of this action, file issues in this repository.

For contributing, see Contributing.

More Information

For documentation on Grype itself, including other output capabilities, see the grype project

Connect with the community directly on Discourse.

Diagnostics

This action makes extensive use of GitHub Action debug logging, which can be enabled as described here by setting a secret in your repository of ACTIONS_STEP_DEBUG to true.