Skip to content

ci(security): scan each image with one Trivy action and SARIF #6405

Closed

Description

@dan-petty

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

  1. 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.yaml and --format sarif --output.
    • Then it runs github/codeql-action/upload-sarif (the SHA already pinned at ci.yml:112) with if: always() and category trivy-image-<target>. The gate does not change.
  2. Use it in place of the 6 scan blocks. This deletes 'Set up uv toolchain', 'Install Trivy', skip-setup-trivy and the version: inputs. Give those jobs security-events: write.
  3. third-party-image-scan.yml uses it with its documented exit-code 0.
  4. Move every image entry into the vulnerabilities: section of .trivyignore.yaml. Write one entry per finding and binary, with id, paths (the exact Trivy Target), purls, a statement that names the issue, and expired_at. Then delete .trivyignore, .trivyignore-mcp-server and .trivyignore-tofu, and put .trivyignore.yaml in their place in the 3 IMAGE_CONTENT_PATHS lists.
  5. 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.
  6. 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 the config_reads.toml counts 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.yaml on 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-runner and trivy-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.yml or .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.yaml on each, then changes one paths value 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,zizmor and git 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 docs and npx --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 pytest and uv 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.yaml with one entry per finding and binary under vulnerabilities:. Each entry names id, paths (the exact Trivy target), purls (the purl Trivy reports), a statement that names the tracking issue, and expired_at. Keep the existing misconfigurations: entries and delete .trivyignore, .trivyignore-mcp-server and .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 a run step that invokes docker run on the digest-pinned image, not a uses: docker:// step; .github/actions/devcontainer-smoke/action.yml:41 already 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 --output and uploads it with github/codeql-action/upload-sarif under category trivy-image-${{ inputs.target }} with if: 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, target and exit-code inputs. image-ref is the image to scan, target is the SARIF category suffix such as service, runner, mcp-server or crawl4ai, and exit-code defaults to 1. Each of the six jobs passes its image and target; third-party-image-scan.yml passes target: crawl4ai and exit-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-action inputs in tests/invariants/test_mcp_server_image.py:53-65 and tests/invariants/test_runner_image.py:105-111, and the service release assertion in tests/commands/test_ci.py:914-922. The range tests/invariants/test_service_image.py:111-141 in 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 at tests/invariants/test_service_image.py:144-180, the stale-entry test at tests/invariants/test_service_image.py:130-142, the parity test at tests/invariants/test_mcp_server_image.py:76-83, the release input test at tests/invariants/test_runner_image.py:101-111, the three image-job Install Trivy allowlist entries at tests/commands/test_ci.py:1896-1920, and the service release input assertion at tests/commands/test_ci.py:914-922. Keep the kubectl and helm pin test but remove its .trivyignore-mcp-server read at tests/invariants/test_mcp_server_image.py:100-103. Update the permission expectations at tests/commands/test_ci.py:821-826, tests/commands/test_ci.py:856-873 and tests/invariants/test_runner_image.py:122-135 to include security-events: write. Lower tests/gate/tree_checks/config_reads.toml to 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-server read 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.
  • 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, the Dockerfile:8 comment, .github/renovate/base.json:142 and .github/renovate.json:229-233 name the legacy files or the trivy-action version inputs. Update them. The Trivy pin in src/devops_cli/tools_lock/tools.lock:228-253 stays 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

  1. added
    type/infra
    scope/security
    source/agent
    status/new
    value/medium
    effort/high
    on Nov 19, 2026
  2. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  7. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 19, 2026
  8. added a commit that references this issue on Nov 20, 2026
  9. added
    status/in-review
    and removed
    status/in-progress
    on Nov 20, 2026
  10. removed
    status/in-review
    owner/agent
    on Nov 20, 2026
  11. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor
  12. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-20 01:51 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p2-mediumscope/securitysource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions