Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/actions/image-scan/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ outputs:
runs:
using: composite
steps:
# The cache directory has the name of the category, so scans that run at the same time in one
# job do not share it: the file cache of Trivy serves one process (#7236).
#
# The runner starts the image with the workspace as its working directory and the Docker
# socket mounted, so Trivy reads an image that the job loaded. dockerd retries each layer
# pull. Renovate moves the tag and the digest of both steps.
- name: Scan the image
uses: docker://ghcr.io/aquasecurity/trivy:0.76.2@sha256:8f6bb947dbc528902e11f2f5be52f7b519f6a39d5d148f41166f2040499768fb
with:
args: >-
image --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed --timeout 3m
image --cache-dir /github/home/.cache/trivy-${{ inputs.category }}
--scanners vuln --severity HIGH,CRITICAL --ignore-unfixed --timeout 3m
--ignorefile ${{ inputs.ignore-file }} --exit-code ${{ inputs.exit-code }}
--format sarif --output ${{ inputs.category }}.sarif ${{ inputs.image-ref }}

Expand All @@ -64,7 +68,8 @@ runs:
uses: docker://ghcr.io/aquasecurity/trivy:0.76.2@sha256:8f6bb947dbc528902e11f2f5be52f7b519f6a39d5d148f41166f2040499768fb
with:
args: >-
image --quiet --skip-db-update --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed
image --cache-dir /github/home/.cache/trivy-${{ inputs.category }}
--quiet --skip-db-update --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed
--timeout 30s --ignorefile ${{ inputs.ignore-file }} --format table --table-mode detailed
${{ inputs.image-ref }}

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,11 @@ jobs:
size=$(docker image inspect "$IMAGE" --format '{{.Size}}')
if [ "$size" -gt 3000000000 ]; then echo "The mcp-server image is $size bytes, over the bound of 3000000000."; exit 1; fi

# The three scans run in the background: each one overlaps the steps after it (#7236). A
# failed gate scan fails the job at the wait step at the end of the job.
- name: Scan MCP Server Image for Vulnerabilities
id: scan_mcp_server
background: true
if: steps.image_changes.outputs.changed == 'true'
timeout-minutes: 4
uses: ./.github/actions/image-scan
Expand All @@ -687,6 +691,8 @@ jobs:
docker run --rm --read-only --tmpfs /tmp --tmpfs /home/devops:mode=1777,exec,size=3g -v "$PWD:/checkout:ro" --cap-drop ALL --security-opt no-new-privileges --entrypoint sh "$IMAGE" -c 'mkdir /home/devops/project && tar -C /checkout --exclude=./.git --exclude=./.venv --exclude=./node_modules -cf - . | tar -C /home/devops/project -xf - && cd /home/devops/project && python -m devops_cli.roadmap.runner_tools /home/devops/project && uv run ruff --version && uv run pytest --version && uv run mypy --version'

- name: Scan Runner Image for Vulnerabilities
id: scan_runner
background: true
if: steps.image_changes.outputs.changed == 'true'
timeout-minutes: 4
uses: ./.github/actions/image-scan
Expand Down Expand Up @@ -724,13 +730,18 @@ jobs:
'

- name: Scan UV Seed Image for Vulnerabilities
id: scan_uv_seed
background: true
if: steps.image_changes.outputs.changed == 'true'
timeout-minutes: 4
uses: ./.github/actions/image-scan
with:
image-ref: devops-cli-uv-seed:local
category: trivy-image-uv-seed

- name: Wait for the Image Scans
wait-all:

# Advisory only: reports newer upstream releases without gating any merge. Scheduled so
# the PyPI round-trip never sits on the pull request critical path.
dependency-freshness:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-25
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Design

## Decisions
- Background steps keep the step list flat, so the tests that read the steps of `ci.yml` still see each one.
- The scans start where they ran before, after the smoke test of their image, so a broken image still fails before its scan.
- One Trivy cache directory for each category: the file cache of Trivy serves one process.

## Rejected alternatives
- One job for each image: each job builds its image again, and #4649 removed such jobs.
- `--cache-backend memory` with one shared directory: the pass that prints the findings reads the cache of the scan, and would read the image again.
- No scan of the runner image in pull requests: it removes coverage, and only the owner can decide that.
- A stored Java database: the restore of about 1 GB takes about as long as the download.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Proposal: #7236

## Why
The `Runner Image` check ran its three image scans and its smoke tests one after the other. In 4 runs on 2026-11-25 it took 274 to 365 s, against a limit of 360 s, and the scans took 90 to 146 s of that.

## What Changes
- The three scan steps of the `Runner Image` job run as background steps, and the job waits for all of them at its end.
- `.github/actions/image-scan` gives each category its own Trivy cache directory.

## Capabilities
- `ci-image-scan`: new requirement for scans that run at the same time.

## Impact
The images, severities, exit codes, ignore file and SARIF categories do not change. A failed gate scan now fails the job at the wait step, and the later steps still run. Each scan downloads the vulnerability database for itself (about 138 MiB).

## Feasibility
- GitHub runs steps of one job in parallel since 2026-06-25, and a composite action can be a background step.
- `actionlint` 1.17.1, the pinned version, accepts `background`, `wait` and `wait-all`.

## Existing Tool Considered
GitHub parallel steps do this. No shell job control and no new job is necessary.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## ADDED Requirements

### Requirement: The scans of the Runner Image job run at the same time
The `Runner Image` job of `ci.yml` SHALL run each image scan as a background step and SHALL wait for all of them before it ends, so a failed gate scan fails the job. `.github/actions/image-scan` SHALL give each `category` its own Trivy cache directory.

#### Scenario: The scans overlap and pass
- **WHEN** a person reads the `Runner Image` job of a pull request that changes image content
- **THEN** the scans start before the earlier scans end, no log holds a cache lock error, and each category uploads its SARIF
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Tasks

## 1. Behavior

- [x] 1.1 Give each category of the scan action its own Trivy cache directory
- Verification: `$ uv run devops ci --check --only actionlint,zizmor`
- [x] 1.2 Run the three scans of the `Runner Image` job as background steps and wait for them
- Verification: `$ uv run devops ci --check --only actionlint,zizmor`
- [x] 1.3 Keep the tests of the workflows green
- Verification: `$ uv run devops ci test tests/commands/test_ci.py`
7 changes: 7 additions & 0 deletions openspec/specs/ci-image-scan/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ The workflow `.github/workflows/image-rescan.yml` SHALL run daily at 04:45 UTC o
#### Scenario: Rescan workflow lint
- **WHEN** a developer runs `uv run devops ci --check --only actionlint,zizmor`
- **THEN** the command exits 0 and reports no finding for `.github/workflows/image-rescan.yml`

### Requirement: The scans of the Runner Image job run at the same time
The `Runner Image` job of `ci.yml` SHALL run each image scan as a background step and SHALL wait for all of them before it ends, so a failed gate scan fails the job. `.github/actions/image-scan` SHALL give each `category` its own Trivy cache directory.

#### Scenario: The scans overlap and pass
- **WHEN** a person reads the `Runner Image` job of a pull request that changes image content
- **THEN** the scans start before the earlier scans end, no log holds a cache lock error, and each category uploads its SARIF