Skip to content
Latchkey

Docker Image Scanners workflow (ory/oathkeeper)

The Docker Image Scanners workflow from ory/oathkeeper, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: ory/oathkeeper.github/workflows/cve-scan.yamlLicense Apache-2.0View source

What it does

This is the Docker Image Scanners workflow from the ory/oathkeeper repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# AUTO-GENERATED, DO NOT EDIT!
# Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/server/.github/workflows/cve-scan.yaml

name: Docker Image Scanners
on:
  workflow_dispatch:
  push:
    branches:
      - "master"
    tags:
      - "v*.*.*"
  pull_request:
    branches:
      - "master"

permissions:
  contents: read
  security-events: write

jobs:
  scanners:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7
      - name: Setup Env
        id: vars
        shell: bash
        run: |
          # Store values in local variables
          SHA_SHORT=$(git rev-parse --short HEAD)
          REPO_NAME=${{ github.event.repository.name }}

          IMAGE_NAME="oryd/${REPO_NAME}:${SHA_SHORT}"

          # Output values for debugging
          echo "Values to be set:"
          echo "SHA_SHORT:  ${SHA_SHORT}"
          echo "REPO_NAME:  ${REPO_NAME}"
          echo "IMAGE_NAME: ${IMAGE_NAME}"

          # Set GitHub Environment variables
          echo "SHA_SHORT=${SHA_SHORT}" >> "${GITHUB_ENV}"
          echo "IMAGE_NAME=${IMAGE_NAME}" >> "${GITHUB_ENV}"
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v4
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v4
        with:
          driver: docker
      - name: Build images
        shell: bash
        run: |
          IMAGE_TAG="${{ env.SHA_SHORT }}" make docker

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Anchore Scanner
        uses: anchore/scan-action@v7
        id: grype-scan
        with:
          image: ${{ env.IMAGE_NAME }}
          fail-build: true
          severity-cutoff: high
          add-cpes-if-none: true
      - name: Inspect action SARIF report
        shell: bash
        if: ${{ always() }}
        run: |
          echo "::group::Anchore Scan Details"
          jq '.runs[0].results' ${{ steps.grype-scan.outputs.sarif }}
          echo "::endgroup::"
      - name: Anchore upload scan SARIF report
        if: always()
        uses: github/codeql-action/upload-sarif@v4
        with:
          sarif_file: ${{ steps.grype-scan.outputs.sarif }}
      - name: Kubescape scanner
        uses: kubescape/github-action@main
        id: kubescape
        with:
          image: ${{ env.IMAGE_NAME }}
          verbose: true
          format: pretty-printer
          # can't whitelist CVE yet: https://github.com/kubescape/kubescape/pull/1568
          severityThreshold: critical
      - name: Dockle Linter
        uses: erzz/dockle-action@v1
        if: ${{ always() }}
        with:
          image: ${{ env.IMAGE_NAME }}
          exit-code: 42
          failure-threshold: high
      - name: Hadolint
        uses: hadolint/hadolint-action@v3.3.0
        id: hadolint
        if: ${{ always() }}
        with:
          dockerfile: .docker/Dockerfile-build
          verbose: true
          format: "json"
          failure-threshold: "error"
      - name: View Hadolint results
        if: ${{ always() }}
        shell: bash
        run: |
          echo "::group::Hadolint Scan Details"
          echo "${HADOLINT_RESULTS}" | jq '.'
          echo "::endgroup::"

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

# AUTO-GENERATED, DO NOT EDIT!
# Please edit the original at https://github.com/ory/meta/blob/master/templates/repository/server/.github/workflows/cve-scan.yaml
 
name: Docker Image Scanners
on:
  workflow_dispatch:
  push:
    branches:
      - "master"
    tags:
      - "v*.*.*"
  pull_request:
    branches:
      - "master"
 
permissions:
  contents: read
  security-events: write
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  scanners:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Checkout
        uses: actions/checkout@v7
      - name: Setup Env
        id: vars
        shell: bash
        run: |
          # Store values in local variables
          SHA_SHORT=$(git rev-parse --short HEAD)
          REPO_NAME=${{ github.event.repository.name }}
 
          IMAGE_NAME="oryd/${REPO_NAME}:${SHA_SHORT}"
 
          # Output values for debugging
          echo "Values to be set:"
          echo "SHA_SHORT:  ${SHA_SHORT}"
          echo "REPO_NAME:  ${REPO_NAME}"
          echo "IMAGE_NAME: ${IMAGE_NAME}"
 
          # Set GitHub Environment variables
          echo "SHA_SHORT=${SHA_SHORT}" >> "${GITHUB_ENV}"
          echo "IMAGE_NAME=${IMAGE_NAME}" >> "${GITHUB_ENV}"
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v4
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v4
        with:
          driver: docker
      - name: Build images
        shell: bash
        run: |
          IMAGE_TAG="${{ env.SHA_SHORT }}" make docker
 
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
 
      - name: Anchore Scanner
        uses: anchore/scan-action@v7
        id: grype-scan
        with:
          image: ${{ env.IMAGE_NAME }}
          fail-build: true
          severity-cutoff: high
          add-cpes-if-none: true
      - name: Inspect action SARIF report
        shell: bash
        if: ${{ always() }}
        run: |
          echo "::group::Anchore Scan Details"
          jq '.runs[0].results' ${{ steps.grype-scan.outputs.sarif }}
          echo "::endgroup::"
      - name: Anchore upload scan SARIF report
        if: always()
        uses: github/codeql-action/upload-sarif@v4
        with:
          sarif_file: ${{ steps.grype-scan.outputs.sarif }}
      - name: Kubescape scanner
        uses: kubescape/github-action@main
        id: kubescape
        with:
          image: ${{ env.IMAGE_NAME }}
          verbose: true
          format: pretty-printer
          # can't whitelist CVE yet: https://github.com/kubescape/kubescape/pull/1568
          severityThreshold: critical
      - name: Dockle Linter
        uses: erzz/dockle-action@v1
        if: ${{ always() }}
        with:
          image: ${{ env.IMAGE_NAME }}
          exit-code: 42
          failure-threshold: high
      - name: Hadolint
        uses: hadolint/hadolint-action@v3.3.0
        id: hadolint
        if: ${{ always() }}
        with:
          dockerfile: .docker/Dockerfile-build
          verbose: true
          format: "json"
          failure-threshold: "error"
      - name: View Hadolint results
        if: ${{ always() }}
        shell: bash
        run: |
          echo "::group::Hadolint Scan Details"
          echo "${HADOLINT_RESULTS}" | jq '.'
          echo "::endgroup::"
 

What changed

7 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow