[FEATURE] Harden the third-party license tree: a PR check, per-OS package sets, and Go's own license

Open
#2,569 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
github-actions, go

Research direction

Start with the Makefile target third-party-licenses, .goreleaser.yaml, and TestThirdPartyLicensesCoverEveryShippedBuild; compare the shipped GOOS/GOARCH pairs and mains with the proposed per-pair passes. Then inspect docs/security/verifying-releases.md and pkg/foreman/agent/tools/run_gate_job_ci_sync_test.go for the related wording and exemption. Done means the license tree includes Go's license, generation uses isolated staging and exact module exclusion, and the coverage test verifies every shipped build; the lint.yml check and gate exemption require a maintainer edit.

Written by the indexing model from the issue text.

Description

ci enhancement kind/feature priority/medium size/medium

Feature Description

Follow-ups from the code review of #2568 (#2564), which made every release archive and image ship third_party_licenses/. The tree is correct today. This makes it hard to break, and closes one gap in what it covers.

Problem Statement

  1. License problems surface only at release time. make third-party-licenses runs in goreleaser's before hook and in hack/scan-images.sh, and release-scan.yml runs the real scan only on the release-please PR or a manual run (startsWith(github.head_ref, 'release-please--branches--main')). Ordinary pull requests run only scripts/scan-images_test.sh. A dependency bump that go-licenses cannot classify, or that breaks a package load, merges green and then blocks the next release. The gate exemption #2568 added in pkg/foreman/agent/tools/run_gate_job_ci_sync_test.go says the tree "carries no per-branch signal", which is not true: every go.mod change is one.
  2. Each pass loads every binary under every GOOS. The target runs go-licenses save over all six mains for linux, darwin and windows, at the host's GOARCH and default cgo setting. goreleaser builds cmd/metal-agent for darwin only; the controller, foreman-operator and router-proxy for linux only; the cli for windows on amd64 only; all with CGO_ENABLED=0. A package whose files are all limited to another OS fails to load ("build constraints exclude all Go files"), so a future darwin-only import in the Mac agent would fail the linux and windows passes and block every release, although goreleaser would build fine. The module sets match today (109 module paths), so nothing is missing now.
  3. Go's own license is not in the tree. go-licenses skips the standard library by design, but every shipped binary statically links the Go runtime and standard library, and Go's BSD-3-Clause license asks binary redistributions to reproduce its notice.
  4. --ignore $(go list -m) is a prefix match. go-licenses v2.0.1 compares with strings.HasPrefix(p.PkgPath, i) (licenses/library.go:134), so a future dependency such as github.com/defilantech/llmkube-runtimes would be dropped from the tree without a warning. With a go.work in scope, go list -m also prints more than one module.
  5. Staging directories can be left in the repo root. The target stages in third_party_licenses.tmp and third_party_licenses.tmp.<os> at the repo root, which the /third_party_licenses/ gitignore entry does not cover. A run killed by SIGKILL or the OOM killer skips the EXIT trap, and the leftovers make a later non-snapshot goreleaser release fail its dirty-tree check.

As a maintainer, I want a dependency change that breaks the license tree to fail its own pull request, not the next release.

Proposed Solution

Decisions, so this can be built without a round trip:

  1. PR check. A new make check-third-party-licenses target generates the tree into a temporary directory exactly as the release does, and discards it; it fails when generation fails. It runs on every pull request as a step in lint.yml, next to check-docs-reference, with no paths filter (lint.yml already notes that GitHub ignores paths filters for merge_group).
    • The lint.yml step, and the gateExemptCIChecks entry it needs in run_gate_job_ci_sync_test.go (same reasoning as #2568's), are a maintainer edit: the bot cannot push workflow files. Write the exact step in the PR body and leave both to a maintainer commit, as in #2568.
    • Correct the existing third-party-licenses exemption reason in run_gate_job_ci_sync_test.go: drop "carries no per-branch signal" and say the pull-request check covers it.
  2. Per-target passes. One go-licenses save pass per (GOOS, GOARCH) pair that .goreleaser.yaml ships (today linux/amd64, linux/arm64, darwin/amd64, darwin/arm64 and windows/amd64), each with CGO_ENABLED=0 and only the mains goreleaser builds for that pair. The trees merge as they do today. The per-pair lists stay in the Makefile, and TestThirdPartyLicensesCoverEveryShippedBuild checks them against .goreleaser.yaml in both directions, honoring each build's ignore: every shipped build is covered, and no pass loads a main goreleaser does not build for that pair.
  3. Go's license. The target copies $(go env GOROOT)/LICENSE to third_party_licenses/go/LICENSE, so the notice comes from the toolchain that built the release. The sentence in docs/security/verifying-releases.md says the tree includes it.
  4. Exact ignore. --ignore "$(GOWORK=off go list -m)/", with the trailing slash, so only the main module's packages are excluded (the repo has no package at the module root).
  5. Staging. Stage in mktemp -d outside the repo and move the result into place, so a killed run leaves nothing in the working tree.
  6. Nothing else changes. The archives and images keep shipping third_party_licenses/ and /licenses/ as #2568 made them.

How to verify:

  • make third-party-licenses passes, and the tree has the 13 NOTICE files from #2564 plus go/LICENSE.
  • make check-third-party-licenses passes on the branch, and fails on a scratch change that makes a pass fail to load (for example a darwin-only import added to a linux-only main).
  • TestThirdPartyLicensesCoverEveryShippedBuild fails when a (GOOS, GOARCH) pair or a main is added to .goreleaser.yaml without the Makefile, and when a Makefile pass loads a main that goreleaser does not build for that pair.
  • A goreleaser snapshot build still shows third_party_licenses/ in every archive.
  • make gate passes.

Alternatives Considered

  • Run the PR check only when go.mod or go.sum change: cheaper, but it needs a paths filter or a changed-files step, and merge_group ignores paths filters.
  • Generate the per-pair lists from .goreleaser.yaml: removes the duplication, but needs a YAML parser in the Makefile or a helper binary; a two-way test keeps the lists honest more simply.
  • Leave Go's license out: common in Go projects, but it is cheap to include and it answers a question a license review would ask.

Additional Context

  • Related issues: #2564 (the tree) and its PR #2568; #2565 (the copyright holder). All are ahead of the CNCF Sandbox application.
  • Found by a code review of #2568 on 2026-11-16. Each item was checked against release-scan.yml, .goreleaser.yaml and the go-licenses v2.0.1 source.
  • Out of scope: the Foreman scan Job reporting a setup failure as a CVE finding with no logs (it predates #2568, and the Job moves to Meitheal), and test cleanups in internal/machoplist/release_licenses_test.go.

Priority

  • Critical - Blocking my use case
  • High - Would significantly improve my workflow
  • Medium - Nice to have
  • Low - Minor improvement

Willingness to Contribute

  • Yes, I can submit a PR
  • Yes, I can help test
  • No, but I can provide feedback
  • No, just requesting
Dominant language
Go
Stars
232
Forks
37
Avg merge
21h 42m
Merged PRs (30d)
244

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from defilantech/LLMKube

All issues in defilantech/LLMKube

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.