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: 0 additions & 9 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
# Trivy vulnerability ignore file.
# Pinned findings that cannot be remediated immediately must record a reason and expiration date (exp: YYYY-MM-DD).

# gh v2.102.0 (Dockerfile), the newest GitHub CLI release, is built with Go 1.27.1 and
# golang.org/x/net v0.58.0. All three are denial-of-service fixes: two in the Go standard library,
# fixed in Go 1.27.2 (net/http and crypto/tls), and one in net/http and x/net's HTTP/2, fixed in
# Go 1.27.2 and x/net v0.60.0. gh is a client. cli/cli's trunk builds with Go 1.27.2 and x/net
# v0.60.0 since 2026-10-09; bump gh and drop these entries in #1492.
CVE-2026-78667 exp:2026-10-23
CVE-2026-97031 exp:2026-10-23
CVE-2026-78669 exp:2026-10-23
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-10-28
skip_specs: true
21 changes: 21 additions & 0 deletions openspec/changes/1492-drop-gh-go-trivy-ignores/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Design

## What is left of the item

The item has two parts: a gh build with Go 1.27.2 or later, and no ignore for the Go findings. The fix of #1800 did the first part with gh v2.102.1. This change does the second part.

## Why the tests check a floor and a list

The floor is gh v2.102.1, the first release built with Go 1.27.2 or later. A later bump only has to stay at or above it, so the test does not force every bump to edit it. The test also requires one release for the two tarballs, so a bump of one architecture alone fails.

Trivy reads an ignore that matches no finding and says nothing. That is how the three ignores stayed after #1800. The second test fails when `.trivyignore` ignores one of the three findings again.

Both tests read only committed files. They read no network and start no scanner. The second test fails on `origin/main` and passes after the change. The first test passes on both, because `origin/main` already pins v2.102.1.

## Rejected alternatives

- **Bump gh to v2.103.3, the newest release.** Rejected: v2.103.3 has the same `toolchain go1.27.3` and `golang.org/x/net v0.60.0` as v2.102.1, and Trivy finds no HIGH or CRITICAL finding in either binary. No cli/cli security advisory names v2.102.1 as vulnerable. v2.103.0 adds features, such as expiring OAuth tokens, so the bump is a dependency update and not a part of this security fix.
- **Return the item to `New`, because #1800 already moved the pin.** Rejected: the acceptance criterion for `.trivyignore` is not met on `origin/main`, and the work is small and clear.
- **Move the expiry of the ignores to a later date.** Rejected: the pinned build does not have the findings, so the ignores protect nothing. A later expiry only hides the findings if an older gh comes back.
- **A test that fails when an ignore of `.trivyignore` has expired.** Rejected: the result changes with the date and not with the tree, so the test fails on an unchanged `main`.
- **A Renovate rule for the gh tarballs of the Dockerfile.** Rejected: `.github/renovate.json` has no rule for them today, and a new rule changes how many pull requests the repository gets. That needs a decision of its own, and it does not remove the three ignores.
43 changes: 43 additions & 0 deletions openspec/changes/1492-drop-gh-go-trivy-ignores/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Proposal

## Why

Issue #1492: the Service image installed gh v2.102.0, which cli/cli builds with Go 1.27.1 and `golang.org/x/net` v0.58.0. Trivy failed the image on HIGH denial-of-service findings in that build. `.trivyignore` ignored three of them until 2026-10-23: CVE-2026-78667, CVE-2026-97031 and CVE-2026-78669.

The fix of #1800 moved the Dockerfile to gh v2.102.1, which cli/cli builds with Go 1.27.3 and `golang.org/x/net` v0.60.0. That build does not have the three findings. The three ignores stayed in `.trivyignore`, and their reason still names gh v2.102.0 and Go 1.27.1. No check stops an ignore from staying after the pin that needs it moves.

## What Changes

- Delete the three ignores and their reason from `.trivyignore`. The file keeps its header.
- Keep the gh pin at v2.102.1. It already is a release built with Go 1.27.2 or later, with the SHA-256 of each tarball.
- Add two invariant tests in `tests/test_service_image_gh.py`. One fails when the Dockerfile fetches gh from more than one release, or from a release below v2.102.1. The other fails when `.trivyignore` ignores one of the three findings again.
- The change has no spec delta and sets `skip_specs: true`. The three ignores expired on 2026-10-23, so Trivy already applies none of them. The image, its scan result and every `devops` command stay the same.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

None.

## Impact

- Scanner configuration: `.trivyignore`. The CI job `Service Image` watches this file, so the pull request builds and scans the Service image.
- Tests: `tests/test_service_image_gh.py`.

## Feasibility

- `Dockerfile` on `origin/main` (bb46660c) fetches `gh_2.102.1_linux_amd64.tar.gz` and `gh_2.102.1_linux_arm64.tar.gz` from the release `v2.102.1`. `.trivyignore` lists the three findings with `exp:2026-10-23`.
- The `go.mod` of cli/cli at the tag `v2.102.1` has `toolchain go1.27.3` and `golang.org/x/net v0.60.0` (`devops gh api repos/cli/cli/contents/go.mod?ref=v2.102.1`). The release notes of v2.102.1 say that the release only moves Go from 1.27.1 to 1.27.3 and `golang.org/x/net` from 0.58.0 to 0.60.0.
- The `linux_amd64` binary of v2.102.1 holds the build information `go1.27.3` and `golang.org/x/net v0.60.0`. Its tarball matches the `--checksum` of the Dockerfile.
- Trivy 0.75.0, with the vulnerability database of 2026-10-28, scans the gh binaries with `--severity HIGH,CRITICAL --ignore-unfixed` and no ignore file. The v2.102.0 binary gives CVE-2026-78667, CVE-2026-97031 and CVE-2026-78669 (Go 1.27.1, `golang.org/x/net` v0.58.0), and CVE-2026-111943. The v2.102.1 binary gives no finding.
- The release run 40626081164 of v0.8.2, on 2026-10-28, passed the step "Scan Service Image for Vulnerabilities". The ignores had expired at that time, so the image needs none of them.
- The newest gh release is v2.103.3. Its `go.mod` has the same toolchain and the same `golang.org/x/net`, and its Trivy scan also gives no finding. No cli/cli security advisory names v2.102.1 as vulnerable.

## Existing Tool Considered

Trivy is the open tool that finds the vulnerabilities, and `.trivyignore` is its own ignore format. The change uses both as they are. Trivy does not report an ignore that matches no finding, so the second test holds this item. The change builds no code. It deletes the three ignores and their reason.
11 changes: 11 additions & 0 deletions openspec/changes/1492-drop-gh-go-trivy-ignores/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Tasks

## 1. No ignore stays for the Go findings that the pinned gh fixes

- [x] 1.1 Write the tests `test_service_image_installs_a_gh_release_built_with_go_1_27_2_or_later` and `test_trivyignore_ignores_no_go_finding_that_the_pinned_gh_fixes` in `tests/test_service_image_gh.py`, and see the second test fail on the three ignores with `uv run devops ci test tests/test_service_image_gh.py`
- [x] 1.2 Delete CVE-2026-78667, CVE-2026-97031, CVE-2026-78669 and their reason from `.trivyignore`; verify with `uv run devops ci test tests/test_service_image_gh.py tests/test_architectural_invariants.py`
- [x] 1.3 Regenerate the documentation; no command, option or message changes, so nothing changes; verify with `uv run devops docs generate --sync-readme` and `uv run devops docs check`

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).
58 changes: 58 additions & 0 deletions tests/test_service_image_gh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""Invariant tests for the gh build that the Service image installs, and its Trivy ignores (#1492).

They read only committed files, so they need no network, no image build and no scanner.
"""

from __future__ import annotations

from pathlib import PurePosixPath
from urllib.parse import urlsplit

from packaging.version import Version

from tests.support.paths import REPO_ROOT

GH_RELEASE_DOWNLOAD_URL = "https://github.com/cli/cli/releases/download/"

# gh v2.102.1 is the first GitHub CLI release that cli/cli builds with Go 1.27.2 or later
# (`toolchain go1.27.3` in its go.mod) and with golang.org/x/net v0.60.0 (#1492).
GH_FIRST_SAFE_VERSION = Version("2.102.1")

# The HIGH Go findings that Trivy reports in gh v2.102.0 (Go 1.27.1, golang.org/x/net v0.58.0).
# Go 1.27.2 and golang.org/x/net v0.60.0 fix them, so the pinned gh build does not have them.
GH_GO_FINDINGS_FIXED_IN_THE_PIN = frozenset({"CVE-2026-78667", "CVE-2026-97031", "CVE-2026-78669"})


def test_service_image_installs_a_gh_release_built_with_go_1_27_2_or_later() -> None:
"""Verify that the Service image fetches one gh release, at or above the first safe release.

Regression test (#1492): gh v2.102.0 is built with Go 1.27.1, and Trivy fails the image on
its HIGH denial-of-service findings in `net/http`, `crypto/tls` and HTTP/2.
"""
dockerfile = (REPO_ROOT / "Dockerfile").read_text(encoding="utf-8")
urls = [token for token in dockerfile.split() if token.startswith(GH_RELEASE_DOWNLOAD_URL)]
tags_and_assets = [PurePosixPath(urlsplit(url).path).parts[-2:] for url in urls]

tags = {tag for tag, _ in tags_and_assets}
assert len(tags) == 1, f"the Dockerfile fetches gh from more than one release: {sorted(tags)}"
version = tags.pop().removeprefix("v")
assert sorted(asset for _, asset in tags_and_assets) == [
f"gh_{version}_linux_amd64.tar.gz",
f"gh_{version}_linux_arm64.tar.gz",
]
assert Version(version) >= GH_FIRST_SAFE_VERSION


def test_trivyignore_ignores_no_go_finding_that_the_pinned_gh_fixes() -> None:
"""Verify that `.trivyignore` holds no ignore for a Go finding that the pinned gh build fixes.

Regression test (#1492): the three ignores stayed after the Dockerfile moved to gh v2.102.1,
and their reason still named gh v2.102.0 and Go 1.27.1. An ignore that no finding needs only
hides that finding when a later change brings it back.
"""
lines = (REPO_ROOT / ".trivyignore").read_text(encoding="utf-8").splitlines()
ignored = {
line.split()[0] for line in lines if line.strip() and not line.lstrip().startswith("#")
}

assert ignored & GH_GO_FINDINGS_FIXED_IN_THE_PIN == set()
Loading