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
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ FROM ghcr.io/astral-sh/uv:0.13.7@sha256:96f40d3904aad8d0bd010539001d36c8e2188b98
# The Node runtime of the pinned OpenSpec. Its major version is the one of `.node-version`.
FROM node:24-trixie-slim@sha256:af02d57b57719b9657a45199a79264a9437940cd55b3c7b3fc99615654f124a0 AS node

# The maintained actionlint fork that knows current runner labels, pinned by digest (#1501,
# #3108). Its 1.17.1 release holds a fixed Go toolchain, so the image scan accepts it.
FROM docker.io/kjanat/actionlint:1.17.1@sha256:c0a63b3e5c974c2466ead39404b70e448176beaff8c5ec7af0b2e96191aea661 AS actionlint

# The requirements of `uv.lock`, with their hashes and without the project (#4550). A release
# changes the project version in `pyproject.toml` and `uv.lock`, but not these two files, and BuildKit
# keys the cache of a `COPY --from` on the content of the files that it copies. So the dependency
Expand Down Expand Up @@ -84,15 +88,16 @@ RUN DEVOPS_CLI_USER_DATA_ROOT=/opt/devops-tools /app/.venv/bin/devops install-to
FROM builder AS runner-tools
RUN DEVOPS_CLI_USER_DATA_ROOT=/opt/devops-tools /app/.venv/bin/devops install-tools \
--tool promtool --target-dir /opt/devops-tools/bin && \
DEVOPS_CLI_USER_DATA_ROOT=/opt/devops-tools /app/.venv/bin/devops install-tools \
--tool trivy --target-dir /opt/devops-tools/bin && \
chmod -R a+rX /opt/devops-tools

# The runner: the pod of a cluster Job in which `devops roadmap implement` runs its steps (#2667).
# `runner-deps` adds to the venv of `deps` the dev requirements that the steps' tests and checks
# run (pytest, ruff, mypy, pre-commit and the rest of the dev group), and git, which a step and
# the job need. `deps` holds uv and gh. The stage adds the tools that the gate and the hooks need
# (#3072): curl and jq from apt, the Node runtime, and OpenSpec and promtool at their pins in
# `tools.lock`. actionlint, shellcheck and Trivy are not here: the image scan fails on the newest
# release of each (see `NOT_IN_RUNNER`). The list of the tools is `RUNNER_TOOLS` in
# (#3072): curl, jq and shellcheck from apt, the Node runtime, and actionlint, OpenSpec, promtool
# and Trivy at their pins. The list of the tools is `RUNNER_TOOLS` in
# `src/devops_cli/roadmap/runner_tools.py`, and the last step of the `runner` stage checks every
# one of them. A Job installs no tool, so the image holds no npm, and pip goes (it vendors
# `certifi`, `urllib3` and `msgpack`), as in the service stage: the scan of the image reports them.
Expand All @@ -103,6 +108,7 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-reco
ca-certificates \
curl \
jq \
shellcheck \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /usr/local/lib/python3.14/site-packages/pip* /usr/local/bin/pip*

Expand All @@ -115,6 +121,7 @@ RUN git config --system credential.https://githubproxy.fjygbaifeng.eu.org.helper '!gh auth git-crede
git config --system credential.https://gist.github.com.helper '!gh auth git-credential'

COPY --from=runner-tools /opt/devops-tools /opt/devops-tools
COPY --from=actionlint /usr/local/bin/actionlint /usr/local/bin/actionlint

COPY --from=lock /lock/dev.txt /lock/dev.txt
RUN --mount=type=cache,target=/root/.cache/uv \
Expand Down
4 changes: 2 additions & 2 deletions docs/CLUSTER.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ROADMAP_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ The programs that the shell refuses, and what to run instead:

A verification command of a plan starts with a program of the first table other than `git`, with `openspec` or `devops`, or with the `!` of the negative search. The step runs git in a verification command only as the negative search `! git grep`: it runs the command in the checkout, where git reads the configuration that the agent can write, and the negative search reaches no remote and gets no token. The step, the stage gate, the plan reader and the amendments read the same rule (`read_verification`).

The runner image holds the tools that the gate and the hooks need, listed in `RUNNER_TOOLS` in `src/devops_cli/roadmap/runner_tools.py`. The image leaves out `actionlint`, `shellcheck` and Trivy, because the image scan fails on the newest release of each (#3108), and it leaves out npm, so a Job cannot run the `audit` row, the `actionlint` row or the IaC scan of Trivy. The pull request runs them. The shell can start only the programs above. The checks of a group run them through `uv run`.
The runner image holds the tools that the gate and the hooks need, listed in `RUNNER_TOOLS` in `src/devops_cli/roadmap/runner_tools.py`. It holds `actionlint`, `shellcheck` and Trivy since their releases passed the image scan (#3108). It leaves out npm, so a Job cannot run the `audit` row; the pull request runs it. The shell can start only the programs above. The checks of a group run them through `uv run`.

## The open plans in the stage context

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-14
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Design

## Decisions

**actionlint comes from the digest-pinned devcontainer image.** The fork is already pinned by digest in `.devcontainer/Dockerfile`, and its 1.17.1 binary scans clean, so the runner copies that same binary. A source build would add a Go toolchain and a stage to the runner image.

**shellcheck comes from apt.** actionlint runs shellcheck when it is on PATH, and Debian gives the package. It has no pin, like `git`, `curl` and `jq`, because a pin would fail the build on each security update.

**Trivy comes from `tools.lock`.** The image already links the lock's tools in `/opt/devops-tools/bin`, which is on PATH, so the `runner-tools` stage installs `trivy` beside `promtool`. This keeps one pin and one checksum.

**The image scan stays the gate.** No `.trivyignore` entry is added: the scan of `ci.yml` and `release.yml` must pass on the built image, and the Runner Image check runs it on the pull request.

**`HOOK_PROGRAMS` stays, with no entry.** The mechanism that leaves out a hook for a missing program remains for a future tool, but no hook needs it while the image holds actionlint.

## Rejected alternatives

- **Build actionlint from source.** It adds a Go toolchain and a build step to the runner image.
- **Download the actionlint release binary in the Dockerfile.** The Dockerfile would hold a second pin and checksum.
- **Install Trivy from apt.** Debian gives no pinned Trivy version.
- **Add a `.trivyignore` entry.** The scan is the gate that keeps the finding out, and the owner alone may lower it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Proposal: #3108

## Why

The runner image leaves out `actionlint`, `shellcheck` and Trivy, because the image scan fails on a fixed HIGH finding in the newest release of each. The blockers are gone: the maintained actionlint fork `kjanat/actionlint` 1.17.1 updates its Go toolchain and its local binary scans with 0 HIGH or CRITICAL findings, and Trivy 0.76.2 holds go-jose 4.1.6 (CVE-2026-116587 fixed). The image now holds the three tools, so a Job runs the `actionlint` row of `devops ci` and the IaC scan that the pull request checks. Closes #3108.

## What Changes

- Move `actionlint`, `shellcheck` and `trivy` from `NOT_IN_RUNNER` to `RUNNER_TOOLS`, with their sources: the pinned `kjanat/actionlint` image, apt, and `tools.lock`.
- Add the `actionlint` image stage to the `Dockerfile`, copy its binary to the runner, install shellcheck from apt, and install Trivy with `devops install-tools` in the `runner-tools` stage.
- Update the test that held the three out, and the two documents that said the image lacks them.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-implement-runner`: The runner image passes the image scan.

## Impact

- Code: `src/devops_cli/roadmap/runner_tools.py`, `Dockerfile`
- Documents: `docs/CLUSTER.md`, `docs/ROADMAP_WORKFLOW.md`
- Tests: `tests/roadmap/test_roadmap_runner_tools.py`

## Feasibility

Read on 2026-11-14 against `origin/main` at `04107728d`.

- `actionlint` 1.17.1 of `kjanat/actionlint` (2026-11-09) says it "updates the Go toolchain and container packages to address the vulnerabilities reported in #356". `trivy rootfs --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 /usr/local/bin/actionlint` reports 0 findings on the binary of the pinned image.
- Trivy 0.76.2 (2026-11-05) says "`github.com/go-jose/go-jose/v4` is bumped to v4.1.6, fixing GHSA-mgcc-cww5-fp2q" and `golang.org/x/net` to v0.62.0; `src/devops_cli/tools_lock/tools.lock:228:version = "0.76.2"` is the pin.
- The devcontainer already pins the actionlint image by digest: `.devcontainer/Dockerfile:3:FROM docker.io/kjanat/actionlint:1.17.1@sha256:c0a63b3e...`.
- The runner image links `/opt/devops-tools/bin` on PATH: `Dockerfile:142:PATH=/app/.venv/bin:/opt/devops-tools/bin:$PATH`.
- The tests of the table pass on the branch: `uv run devops ci test tests/roadmap/test_roadmap_runner_tools.py`.

## Existing Tool Considered

The three tools are existing open tools, and the change adds no new tool and no new dependency. The image scan, `devops install-tools` and the table checks are the project's own tools. The alternative of building actionlint from source would add a Go toolchain and a build stage.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## MODIFIED Requirements

### Requirement: The runner image passes the image scan
The runner image SHALL pass the scan of `ci.yml` and `release.yml` (Trivy, `HIGH,CRITICAL`, fixed findings only) with no `.trivyignore` entry. A tool whose newest release fails the scan SHALL be in `NOT_IN_RUNNER`, with the finding as the reason. A tool whose newest release passes the scan SHALL be in `RUNNER_TOOLS`, and the `runner` stage SHALL install it.

#### Scenario: A tool fails the scan
- **WHEN** the newest release of a tool that the gate needs holds a fixed HIGH finding
- **THEN** the table `NOT_IN_RUNNER` names the tool with the image scan as the reason, and the `runner` stage installs neither it nor a tool that only serves it

#### Scenario: The scanned tools return
- **WHEN** the newest releases of actionlint and Trivy pass the scan
- **THEN** `RUNNER_TOOLS` holds `actionlint`, `shellcheck` and `trivy`, and the `runner` stage installs all three

#### Scenario: The image is scanned
- **WHEN** `trivy image --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1` runs on the built `runner` target
- **THEN** it exits 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Tasks

## 1. Hold the three tools in the runner image

Kind: behavior. Reads: `src/devops_cli/roadmap/runner_tools.py`, `Dockerfile`. Changes: `src/devops_cli/roadmap/runner_tools.py`, `Dockerfile`, `tests/roadmap/test_roadmap_runner_tools.py`.

- [x] 1.1 Move `actionlint`, `shellcheck` and `trivy` into `RUNNER_TOOLS` with the source of each, remove them from `NOT_IN_RUNNER`, and set `HOOK_PROGRAMS` empty
- Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_runner_tools.py` passes
- [x] 1.2 Add the pinned actionlint image stage, copy its binary, install shellcheck from apt, and install Trivy in the `runner-tools` stage
- Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_runner_tools.py` passes
- [x] 1.3 Replace the test that held the tools out with a test that they are held at the pins of their sources
- Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_runner_tools.py` passes

## 2. Name the tools in the documents

Kind: other. Reads: `docs/CLUSTER.md`, `docs/ROADMAP_WORKFLOW.md`. Changes: `docs/CLUSTER.md`, `docs/ROADMAP_WORKFLOW.md`.

- [x] 2.1 Say that the runner image holds actionlint, shellcheck and Trivy since their releases passed the scan
- Verification: `$ uv run devops ci docs` passes

## 3. Run the gates

Kind: other. Reads: `tests/roadmap/`. Changes: none.

- [x] 3.1 Run the whole gate of the branch
- Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_runner_tools.py tests/roadmap/implement/test_roadmap_implement_hooks.py` passes
- Verification: `$ uv run devops ci --check --only lint,format,typecheck` passes
- [x] 3.2 The Runner Image check of the pull request builds the image and scans it
- Verification: `$ uv run devops pr checks` shows `Runner Image` pass
10 changes: 7 additions & 3 deletions openspec/specs/roadmap-implement-runner/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,15 @@ The smoke test of the runner image in `ci.yml` and in `release.yml` SHALL be the
- **THEN** the two texts are equal, they run the check module and the size bound, and no line runs `--entrypoint <tool> "$IMAGE" --version`

### Requirement: The runner image passes the image scan
The runner image SHALL pass the scan of `ci.yml` and `release.yml` (Trivy, `HIGH,CRITICAL`, fixed findings only) with no `.trivyignore` entry. A tool whose newest release fails the scan SHALL be in `NOT_IN_RUNNER`, with the finding as the reason.
The runner image SHALL pass the scan of `ci.yml` and `release.yml` (Trivy, `HIGH,CRITICAL`, fixed findings only) with no `.trivyignore` entry. A tool whose newest release fails the scan SHALL be in `NOT_IN_RUNNER`, with the finding as the reason. A tool whose newest release passes the scan SHALL be in `RUNNER_TOOLS`, and the `runner` stage SHALL install it.

#### Scenario: A tool fails the scan
- **WHEN** the newest release of `actionlint` (Go 1.27.0) and of Trivy (go-jose 4.1.5) hold a fixed HIGH finding
- **THEN** the table `NOT_IN_RUNNER` names `actionlint`, `shellcheck` and `trivy` with the image scan as the reason, and the `runner` stage installs none of them
- **WHEN** the newest release of a tool that the gate needs holds a fixed HIGH finding
- **THEN** the table `NOT_IN_RUNNER` names the tool with the image scan as the reason, and the `runner` stage installs neither it nor a tool that only serves it

#### Scenario: The scanned tools return
- **WHEN** the newest releases of actionlint and Trivy pass the scan
- **THEN** `RUNNER_TOOLS` holds `actionlint`, `shellcheck` and `trivy`, and the `runner` stage installs all three

#### Scenario: The image is scanned
- **WHEN** `trivy image --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1` runs on the built `runner` target
Expand Down
39 changes: 16 additions & 23 deletions src/devops_cli/roadmap/runner_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
UV_VERSION = "0.13.7"
GH_VERSION = "2.103.3"
NODE_MAJOR = "24"
ACTIONLINT_VERSION = "1.17.1"


class ToolSource(StrEnum):
Expand Down Expand Up @@ -141,6 +142,15 @@ def _base(name: str, *needed_by: str) -> RunnerTool:
_apt("curl", "test:live"),
_apt("jq", "test:live"),
_locked("promtool", "gate:test"),
RunnerTool(
"actionlint",
ToolSource.IMAGE_PIN,
("ci:actionlint", "gate:static", "hook:devops-ci-workflows-pre-push"),
("actionlint", "--version"),
pin=ACTIONLINT_VERSION,
),
_apt("shellcheck", "ci:actionlint"),
_locked("trivy", "gate:static"),
_base("nice", "ci:security"),
_base(
"timeout",
Expand Down Expand Up @@ -170,18 +180,12 @@ def _base(name: str, *needed_by: str) -> RunnerTool:
"gate (#2165). The runner does the same as the gate."
)
_NO_GATE_STEP = "No step of a required job of `ci.yml` runs it."
_IMAGE_SCAN = (
"The image scan of `ci.yml` and `release.yml` fails on the HIGH findings that the newest "
"release holds: {finding}. The scan stays as it is, so the image waits for a release without "
"them (#3108). A Job cannot run the {rows}, so the pull request checks it."
)
# A hook of `.pre-commit-config.yaml` that runs a program from `NOT_IN_RUNNER`, with the programs
# it runs. The Job leaves the hook out of the configuration it gives `pre-commit` when one of its
# programs is not on PATH, because no agent can repair a missing program. The checks of the pull
# request run the hook (#3134). A test holds that each program is in `NOT_IN_RUNNER`.
HOOK_PROGRAMS: dict[str, tuple[str, ...]] = {
"devops-ci-workflows-pre-push": ("actionlint",),
}
# A hook of `.pre-commit-config.yaml` that runs a program that the image does not hold, with the
# programs it runs. The Job leaves the hook out of the configuration it gives `pre-commit` when one
# of its programs is not on PATH, because no agent can repair a missing program. The checks of the
# pull request run the hook (#3134). The image holds actionlint since 1.17.1 (#3108), so no hook
# needs this table today; a test holds that each program here is in `NOT_IN_RUNNER`.
HOOK_PROGRAMS: dict[str, tuple[str, ...]] = {}


def hooks_without_programs(search_path: str | None = None) -> tuple[str, ...]:
Expand Down Expand Up @@ -222,17 +226,6 @@ def hooks_without_programs(search_path: str | None = None) -> tuple[str, ...]:
"ansible-core": (
"No gate row, hook or job starts Ansible. Only `devops infra` starts it, on a workstation."
),
"actionlint": _IMAGE_SCAN.format(
finding="Go standard library 1.27.0 (four CVEs) in actionlint 1.17.0",
rows="`actionlint` row",
),
"shellcheck": (
"Only actionlint runs it, and the image scan keeps actionlint out (see `actionlint`)."
),
"trivy": _IMAGE_SCAN.format(
finding="go-jose 4.1.5 (CVE-2026-116587, fixed in 4.1.6) in Trivy 0.76.1",
rows="IaC scan of the Security Scan step",
),
"gh-dash": _NO_GATE_STEP,
"tuicr": _NO_GATE_STEP,
"devcontainers-cli": _NO_GATE_STEP,
Expand Down
26 changes: 16 additions & 10 deletions tests/roadmap/test_roadmap_runner_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from devops_cli.commands.ci import get_check_specs
from devops_cli.config.defaults import DEFAULT_PYTHON_VERSION
from devops_cli.roadmap.runner_tools import (
ACTIONLINT_VERSION,
GH_VERSION,
HOOK_PROGRAMS,
NODE_MAJOR,
Expand Down Expand Up @@ -257,18 +258,23 @@ def test_the_pins_of_the_table_are_the_pins_of_the_dockerfile() -> None:
) == (True, True, True, True, NODE_MAJOR, True, True)


def test_a_tool_whose_release_fails_the_scan_of_the_image_is_left_out_with_the_reason() -> None:
"""The scan of the image fails on a fixed HIGH finding in a Go binary, and the owner alone may
lower it. Trivy, actionlint and shellcheck (which only actionlint uses) wait for a release
that the scan accepts."""
held = set(tool_names())
scan = ("trivy", "actionlint", "shellcheck")
def test_the_scanned_tools_are_in_the_runner_with_the_pins_of_their_images() -> None:
"""actionlint 1.17.1 holds a fixed Go toolchain and Trivy 0.76.2 holds go-jose 4.1.6, so the
scan accepts both and the runner image holds actionlint, shellcheck and Trivy (#3108)."""
tools = {tool.name: tool for tool in RUNNER_TOOLS}
dockerfile = _text("Dockerfile")
actionlint = f"docker.io/kjanat/actionlint:{ACTIONLINT_VERSION}@sha256:"

assert (
held.isdisjoint(scan),
all("image scan" in NOT_IN_RUNNER[name] for name in scan),
"FROM docker.io/kjanat/actionlint" in _text("Dockerfile"),
) == (True, True, False)
not {"trivy", "actionlint", "shellcheck"} & set(NOT_IN_RUNNER),
tools["actionlint"].source is ToolSource.IMAGE_PIN,
tools["trivy"].source is ToolSource.TOOLS_LOCK,
tools["shellcheck"].source is ToolSource.APT,
actionlint in dockerfile,
actionlint in _text(".devcontainer/Dockerfile"),
"--tool trivy" in dockerfile,
"shellcheck" in dockerfile,
) == (True, True, True, True, True, True, True, True)


def test_the_apt_packages_of_the_runner_are_the_apt_tools_of_the_table() -> None:
Expand Down