Repository navigation
Description
Problem
Six image scan blocks hold the same Trivy step (ci.yml:509-534, 627-652, 737-762; release.yml:393-413, 535-556, 671-692). Each block sets up the uv toolchain and runs devops install-tools --tool trivy (25-28 s per job). It passes skip-setup-trivy and a version: input that has no effect, and it writes a table only, with no SARIF. Three ignore files (.trivyignore, .trivyignore-mcp-server, .trivyignore-tofu) hold entries with no path scope. Today the MCP scan masks kubectl CVE-2026-78669 and CVE-2026-78661 through .trivyignore-tofu:20,27 until 2026-11-21. Tests compare the copies (release equals CI) and the trivy-action input values.
Change
- Add the composite action
.github/actions/image-scan:- It runs Trivy from
docker://ghcr.io/aquasecurity/trivy:<version>@sha256:<digest>with--scanners vuln,--severity HIGH,CRITICAL,--ignore-unfixed,--exit-code 1,--ignorefile .trivyignore.yamland--format sarif --output. - Then it runs
github/codeql-action/upload-sarif(the SHA already pinned at ci.yml:112) withif: always()and categorytrivy-image-<target>. The gate does not change.
- It runs Trivy from
- Use it in place of the 6 scan blocks. This deletes 'Set up uv toolchain', 'Install Trivy',
skip-setup-trivyand theversion:inputs. Give those jobssecurity-events: write. third-party-image-scan.ymluses it with its documented exit-code 0.- Move every image entry into the
vulnerabilities:section of.trivyignore.yaml. Write one entry per finding and binary, withid,paths(the exact Trivy Target),purls, astatementthat names the issue, andexpired_at. Then delete.trivyignore,.trivyignore-mcp-serverand.trivyignore-tofu, and put.trivyignore.yamlin their place in the 3IMAGE_CONTENT_PATHSlists. - Update SECURITY.md:81, docs/ROUTINE_TASKS.md:46,192, the trivy-action note at tools.lock:14-15 and the coupled trivy group at renovate.json:247-249.
- Tests: delete
tests/support/trivyignore.py, its unit tests (test_service_image.py:144-180), the stale-entry test (:130) and the release-equals-CI parity assertions (test_mcp_server_image.py:78-85, test_runner_image.py:103-113). Owner decision of 2026-11-19: also delete the trivy-action input assertions (severity, ignore-unfixed, exit-code: test_mcp_server_image.py:49-67, test_runner_image.py:103-113, test_service_image.py:111-141). They are config-value tests under the owner rule of 2026-11-16, and the one composite action is then the single place to review the threshold (comment on test(k8s): Drop the tests that repeat third-party version pins #6060). Lower theconfig_reads.tomlcounts to match.
The Trivy entry of tools.lock and the trivy config install of the static job (ci.yml:85-86) stay for #4361 and #4363. #4361 changes the entry paths to the new tool paths.
Renovate. The built-in github-actions manager bumps the tag and digest of the docker:// Trivy image and the upload-sarif SHA. No custom manager. The coupled trivy group goes.
Risk. A path or purl that does not match matches nothing, so the scan fails, which is safe. Check in the PR that a composite action can run a docker:// step. If it cannot, use a job-level step. dockerd tries each layer pull 5 times; #4229 removed setup-trivy because its download had no retry. The image digest also keeps a locked checksum in the repository. With SARIF output the log has no table; add a table pass from the cached database if needed. With no Actions cache, the Trivy database downloads on each run; if ghcr.io limits the rate, set TRIVY_DB_REPOSITORY.
Proof
- In the PR, run
trivy image --ignorefile .trivyignore.yamlon each built image: the ignored lines name only the scoped binary. Change one path and run it again: the finding comes back. - After the merge, the code-scanning analyses API lists
trivy-image-service,trivy-image-runnerandtrivy-image-mcp-server. - Each job loses the 25-28 s of toolchain setup and install. The PR reports the measured pull time of the Trivy image.
Depends on: none (#6381 merged)
Alternatives check of 2026-11-19: not-applicable.
Class: ci, no search.
Tool: none found.
Proposed design
Problem statement
Six image scan jobs repeat the same Trivy step and a 25-28 s uv toolchain install. They pass skip-setup-trivy and an ineffective version: input, write only a table, and use three ignore files with no path scope; the MCP scan masks kubectl CVE-2026-78669 and CVE-2026-78661 through .trivyignore-tofu:20,27 until 2026-11-21. The change adds one composite action that runs the digest-pinned Trivy image with docker run, uploads SARIF, replaces the six blocks, moves image entries to scoped .trivyignore.yaml entries, and updates the tests and docs. The Trivy pin in src/devops_cli/tools_lock/tools.lock and the trivy config install of the static job stay for #4361 and #4363.
Acceptance criteria
Requirement: One image scan action
The repository SHALL provide .github/actions/image-scan/action.yml with image-ref, target and exit-code inputs, run the digest-pinned ghcr.io/aquasecurity/trivy image through a docker run step, and upload SARIF with github/codeql-action/upload-sarif under if: always() and category trivy-image-${{ inputs.target }}.
Scenario: Composite action validation
- WHEN A developer runs
uv run devops ci --check --only actionlint,zizmor. - THEN The command exits 0 and reports no finding in
.github/actions/image-scan/action.yml.
Requirement: Six scan jobs use the action
Each of the six image scan jobs in .github/workflows/ci.yml and .github/workflows/release.yml SHALL call .github/actions/image-scan with its image ref and target and SHALL grant security-events: write.
Scenario: Image workflow validation
- WHEN A developer runs
uv run devops ci --check --only actionlint,zizmor. - THEN The command exits 0 and reports no finding in
.github/workflows/ci.ymlor.github/workflows/release.yml.
Requirement: Third-party image scan
.github/workflows/third-party-image-scan.yml SHALL call .github/actions/image-scan with exit-code: 0, SHALL grant security-events: write, and SHALL run when the action changes.
Scenario: Third-party workflow validation
- WHEN A developer runs
uv run devops ci --check --only actionlint,zizmor. - THEN The command exits 0 and reports no finding in
.github/workflows/third-party-image-scan.yml.
Requirement: Scoped image ignore entries
.trivyignore.yaml SHALL hold each image finding under vulnerabilities: with one entry per finding and binary, and each entry SHALL name id, paths (the exact Trivy target), purls (the purl Trivy reports), a statement that names the tracking issue, and expired_at.
Scenario: Scoped ignore live check
- WHEN A developer builds the service, runner and MCP server images and runs
trivy image --ignorefile .trivyignore.yamlon each, then changes onepathsvalue and reruns. - THEN Each ignored finding names only its scoped binary, and the changed path makes the finding appear again.
Requirement: Legacy ignore files removed
The files .trivyignore, .trivyignore-mcp-server and .trivyignore-tofu SHALL be absent from the repository.
Scenario: Legacy ignore files absent
- WHEN A developer runs
git ls-files .trivyignore .trivyignore-mcp-server .trivyignore-tofu. - THEN The command prints no path and exits 0.
Requirement: Image content paths
Each IMAGE_CONTENT_PATHS list in .github/workflows/ci.yml SHALL name .trivyignore.yaml in place of the three legacy ignore files.
Scenario: Image workflow paths validation
- WHEN A developer runs
uv run devops ci --check --only actionlint,zizmorandgit grep -n 'trivyignore' .github/workflows/ci.yml. - THEN The first command exits 0 and reports no finding in
.github/workflows/ci.yml; the second prints only.trivyignore.yaml.
Requirement: Documentation and Renovate config
SECURITY.md, docs/ROUTINE_TASKS.md, docs/CLUSTER.md, docs/ROADMAP_WORKFLOW.md, the Dockerfile comment, .github/renovate/base.json and .github/renovate.json SHALL name .trivyignore.yaml and the single image scan action, and .github/renovate.json SHALL hold no coupled trivy group.
Scenario: Docs and Renovate validation
- WHEN A developer runs
uv run devops ci --check --only docsandnpx --yes renovate-config-validator .github/renovate.json. - THEN Both commands exit 0 and report no finding.
Requirement: Test suite after removals
The test suite SHALL pass after the trivy-action input assertions, the legacy ignore parser and its unit tests, the stale-entry test, the release-equals-CI parity assertions, and the image-job Install Trivy allowlist entries are removed, and tests/gate/tree_checks/config_reads.toml SHALL hold 3 reads for each of tests/invariants/test_mcp_server_image.py, tests/invariants/test_runner_image.py and tests/invariants/test_service_image.py.
Scenario: Test suite and ratchet pass
- WHEN A developer runs
uv run pytestanduv run devops ci --check --only test-tree. - THEN Both commands exit 0 and report no failure.
Existing Tool Considered
The alternatives check of 2026-11-19 records not-applicable and names no new tool. Trivy's official GHCR image ghcr.io/aquasecurity/trivy at the src/devops_cli/tools_lock/tools.lock:228-253 pin (0.76.2) covers image vulnerability scanning and SARIF output (https://trivy.dev/docs/latest/getting-started/installation/). Trivy does not upload SARIF to code scanning; github/codeql-action/upload-sarif at .github/workflows/ci.yml:112 covers that upload. The composite action only wires these tools and builds no scanner code.
Key questions
- Which ignore file format should hold image entries?: Use
.trivyignore.yamlwith one entry per finding and binary undervulnerabilities:. Each entry namesid,paths(the exact Trivy target),purls(the purl Trivy reports), astatementthat names the tracking issue, andexpired_at. Keep the existingmisconfigurations:entries and delete.trivyignore,.trivyignore-mcp-serverand.trivyignore-tofu. Use each finding's effective legacy date: the OpenTofu entries keep 2026-11-21, the kubectl CVE-2026-78669 and CVE-2026-78661 entries keep 2026-11-21 (the date the tofu entry currently supplies), the kubectl CVE-2026-56851 entry keeps 2026-11-20, and the CVE-2026-97054 entries keep 2026-11-22. (best practice) [sources: .trivyignore.yaml:1-36, openspec/changes/archive/2026-11-07-3881-time-limited-gh-cve-ignore/design.md:9]- Chosen: YAML ignore file. It scopes a finding by path and purl and holds an expiry; the legacy text format has no path field.
- Rejected: Legacy text ignore files. They hold no path scope, so the MCP scan masks kubectl findings with tofu entries.
- Should the image scan use a composite action or a job-level step?: Use the composite action
.github/actions/image-scan. Its Trivy step is arunstep that invokesdocker runon the digest-pinned image, not auses: docker://step;.github/actions/devcontainer-smoke/action.yml:41already runs a container this way in a composite action. (best practice) [sources: .github/actions/devcontainer-smoke/action.yml:41, https://docs.github.com/en/actions/reference/workflows-and-actions/metadata-syntax, .github/workflows/ci.yml:509-534, .github/workflows/release.yml:393-413]- Chosen: Composite action with a docker run step. It removes six copies of the Trivy step and uses a documented composite-action run step.
- Rejected: Composite action with uses: docker://. Composite support for a docker:// step is not settled; the run step avoids that risk.
- Rejected: Job-level step in each job. It keeps six copies and the drift that the issue removes.
- Should the scan write SARIF and upload it to code scanning?: Yes. The action writes SARIF with
--format sarif --outputand uploads it withgithub/codeql-action/upload-sarifunder categorytrivy-image-${{ inputs.target }}withif: always(). The Trivy exit code stays the gate. (best practice) [sources: .github/workflows/ci.yml:112, .github/workflows/ci.yml:509-534]- Chosen: SARIF upload. Code scanning lists the result and the per-target category keeps the table out of the log.
- Rejected: Table output only. It gives no code-scanning record and no per-target category.
- How should the action receive the image, target and exit code?: Add
image-ref,targetandexit-codeinputs.image-refis the image to scan,targetis the SARIF category suffix such asservice,runner,mcp-serverorcrawl4ai, andexit-codedefaults to1. Each of the six jobs passes its image and target;third-party-image-scan.ymlpassestarget: crawl4aiandexit-code: 0. (best practice) [sources: .github/workflows/ci.yml:509-534, .github/workflows/release.yml:393-413, .github/workflows/third-party-image-scan.yml:49-57]- Chosen: Separate image-ref, target and exit-code inputs. The six jobs need different image refs and SARIF categories, and the third-party scan needs exit code 0.
- Rejected: Hardcoded values. A hardcoded image or category cannot serve the six jobs and the third-party scan.
- Should the trivy-action input assertions remain?: No. Delete the assertions that read
aquasecurity/trivy-actioninputs intests/invariants/test_mcp_server_image.py:53-65andtests/invariants/test_runner_image.py:105-111, and the service release assertion intests/commands/test_ci.py:914-922. The rangetests/invariants/test_service_image.py:111-141in the issue body is the gh release pin test, not a trivy-action input assertion, so it stays. The owner decision of 2026-11-19 and the owner rule of 2026-11-16 remove the config-value assertions; the one composite action is then the single review point. (best practice) [sources: tests/invariants/test_mcp_server_image.py:53-65, tests/invariants/test_runner_image.py:105-111, tests/commands/test_ci.py:914-922, tests/invariants/test_service_image.py:111-127, docs/TESTING.md:62, openspec/changes/archive/2026-11-16-6060-drop-config-value-tests/proposal.md:4, openspec/changes/archive/2026-11-19-6381-delete-clock-trivyignore-tests/proposal.md:15]- Chosen: Delete the input assertions. They are config-value tests and the composite action is the single review point.
- Rejected: Keep the input assertions. They duplicate the action definition and keep the drift the issue removes.
- Rejected: Also delete the gh release pin test. It is not a trivy-action input assertion; the issue's line range names it by mistake.
- Which tests and ratchet counts must change when the legacy ignore files go?: Delete
tests/support/trivyignore.py, its unit tests attests/invariants/test_service_image.py:144-180, the stale-entry test attests/invariants/test_service_image.py:130-142, the parity test attests/invariants/test_mcp_server_image.py:76-83, the release input test attests/invariants/test_runner_image.py:101-111, the three image-jobInstall Trivyallowlist entries attests/commands/test_ci.py:1896-1920, and the service release input assertion attests/commands/test_ci.py:914-922. Keep the kubectl and helm pin test but remove its.trivyignore-mcp-serverread attests/invariants/test_mcp_server_image.py:100-103. Update the permission expectations attests/commands/test_ci.py:821-826,tests/commands/test_ci.py:856-873andtests/invariants/test_runner_image.py:122-135to includesecurity-events: write. Lowertests/gate/tree_checks/config_reads.tomlto 3 for each of the three image test modules. (best practice) [sources: tests/invariants/test_service_image.py:130-180, tests/invariants/test_mcp_server_image.py:76-103, tests/invariants/test_runner_image.py:101-135, tests/commands/test_ci.py:821-826, tests/commands/test_ci.py:856-922, tests/commands/test_ci.py:1896-1920, tests/gate/tree_checks/config_reads.toml:37-39]- Chosen: Keep the tool-pin assertions and drop the ignore-file read. The pin floors are a safety rule; the deleted
.trivyignore-mcp-serverread would otherwise break the test. - Rejected: Delete the whole tool-pin test. It would drop the kubectl and helm floor checks that the image scan relies on.
- Rejected: Rewrite the tool-pin test against
.trivyignore.yaml. It would keep a config-value read that the owner rule of 2026-11-16 removes.
- Chosen: Keep the tool-pin assertions and drop the ignore-file read. The pin floors are a safety rule; the deleted
- Which docs and Renovate files name the legacy ignore files or the coupled Trivy group?:
SECURITY.md:81,docs/ROUTINE_TASKS.md:46,192,docs/CLUSTER.md:68,docs/ROADMAP_WORKFLOW.md:357, theDockerfile:8comment,.github/renovate/base.json:142and.github/renovate.json:229-233name the legacy files or the trivy-action version inputs. Update them. The Trivy pin insrc/devops_cli/tools_lock/tools.lock:228-253stays for build(docker): build the runner image FROM devtools with no tool install #4361 and chore(tools): remove devops install-tools and tools.lock #4363. [sources: SECURITY.md:81, docs/ROUTINE_TASKS.md:46, docs/ROUTINE_TASKS.md:192, docs/CLUSTER.md:68, docs/ROADMAP_WORKFLOW.md:357, .github/renovate/base.json:142, .github/renovate.json:229-233, src/devops_cli/tools_lock/tools.lock:228-253] - Should the image scan also write a table?: No. The SARIF upload is the required code-scanning record and the Trivy exit code is the gate. A table pass would run a second scan from the cache and add time without changing the gate. The PR reports the measured Trivy image pull time. (best practice) [sources: .github/workflows/ci.yml:509-534, .github/workflows/ci.yml:112]
- Chosen: SARIF only. The code-scanning record is the required output and the exit code is the gate; no second scan.
- Rejected: SARIF and a table pass. It duplicates the scan and adds run time without changing the gate.
- Should the Trivy database use an Actions cache or TRIVY_DB_REPOSITORY?: No database cache in this change. The action downloads the database on each run, as the issue says. If ghcr.io rate-limits the database pull, set
TRIVY_DB_REPOSITORY; the PR reports the measured pull time. A cache is separate work. (best practice) [sources: .github/workflows/ci.yml:509-534, .github/workflows/release.yml:393-413]- Chosen: No database cache. The issue leaves it out and the PR measures the pull time; a cache is separate work.
- Rejected: Actions cache for the database. It adds cache scope and key work that this issue does not need.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 19, 2026
Both work on the same six Trivy scan blocks in ci.yml and release.yml, but #4229 added retry logic while the candidate replaces the blocks with one composite action and SARIF upload.devops-cli-service commentedon Nov 19, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 19, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
docs(openspec): archive #6405 image-scan-action-sarif
devops-cli-service commentedon Nov 20, 2026
Released in v0.182.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.182.1
devops-cli-service commentedon Nov 20, 2026
Live since 2026-11-20 01:51 UTC