Repository navigation
feat: build settings by allow-list, node architecture, go_build payload (ADR 0019) - #45
Merged
Merged
Conversation
…ad (ADR 0019) The scanner read every binary's build-settings block and kept one bit of it (the PGO boolean), discarding the facts that decide whether a Go workload can be advised at all: microarchitecture level, CGO, race builds, and the commit a binary was built from. Keep an allow-listed subset on the node, before the channel: CGO_ENABLED, GOARCH, GOAMD64, GOARM64, GOARM, -race, -trimpath and vcs.*. Allow-list rather than deny-list because build settings are the one place where operator-written strings enter the agent — a real -ldflags carries build-machine paths and internal hostnames, -pgo carries a path — and because the toolchain owns the key set and may grow it in any release. An over-long value is dropped whole rather than truncated. Rename the ADR 0017 payload go_dependencies -> go_build, with settings alongside modules: it already carried go_version and main_module, so it was facts about a build from the day it shipped. No backend consumes it yet, so the rename costs a golden file now instead of a migration later. Add node_metadata.nodes[].architecture, read from an object already watched. GOARCH is not a finding on its own — it is one half of a comparison, and the other half did not exist anywhere in the agent's data. Verified in kind: the sample build ships CGO_ENABLED=0, GOARCH=arm64, GOARM64=v8.0 and no vcs.* — its build context holds no .git, which ADR 0019 documents as the common case for containerized builds. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice: the build-settings allow-list,
node_metadata.architecture, and thego_dependencies→go_buildrename. ADR 0019 in this PR.What was wrong
internal/nodescanread the whole build-settings block of every kept binary and threw all but one bit of it away —hasPGOreturned a boolean, everything else was discarded. What was discarded is what decides whether a Go workload can be advised:GOAMD64(a v1 binary on a v3 fleet leaves instructions unused),CGO_ENABLED,-race(multiples of CPU and memory in production), andvcs.*(which commit, and whether the tree was dirty).Allow-list, not deny-list
Build settings are the one place where strings a person typed into a CI pipeline enter the agent. This repository's own image carries:
And the key set belongs to the Go toolchain, which may grow it in any release. A deny-list protects only against the keys we thought to name. The filter lives in the scanner, so nothing outside the list crosses the node→controller channel (invariant 4).
Kept:
CGO_ENABLED,GOARCH,GOAMD64,GOARM64,GOARM,-race,-trimpath,vcs,vcs.revision,vcs.time,vcs.modified. A value beyond 128 chars is dropped whole, never truncated — a prefix of an unexpected string is still an unexpected string, and would ship looking legitimate.Rename
go_dependenciesalready carriedgo_versionandmain_module; it was facts about a build from the day it shipped, and settings made the name plainly wrong. No backend consumes it yet, so this costs a golden file now instead of a protocol migration later.inventory.BuildDependencies→BuildFacts, spool filego-build-<digest>.json.ADR 0018 names the old method names and is not edited — accepted ADRs are immutable; ADR 0019 carries the forwarding address.
vcs.*and why its absence is normalThe toolchain stamps it only when three conditions hold in a container build:
.gitin the build context,gitin the builder image, and matching ownership. The last fails loudly —COPY . .thenUSER nonrootmakesgo builderror out, not skip silently, and the usual response (-buildvcs=false) removes the stamp permanently. ADR 0019 records this, andbackend-requirements.mdrequires the backend not to treat a missingvcs.*as a coverage gap.Verified against real images from this repo: the agent image carries
vcs.revisionandvcs.modified=true; the e2e sample (contexttest/e2e/sample/, no.git) carries novcs.*at all.Node architecture
GOARCHis not a finding on its own — it is one half of a comparison, and the other half existed nowhere in the agent's data. One field from an object already watched: no new informer, no new RBAC.Verification
make test(incl.go vet -tags e2e ./...) andmake lintgreen.make inventory-e2ein kind: PASS, 122.78s, with the settings assertion from a real cluster:vcs.*(as documented), no-ldflags, no-pgo, no-buildmode. The e2e restates the allow-list independently, so widening it in the scanner alone cannot silently widen what leaves a cluster.Docs updated in the same PR per CLAUDE.md:
security.md§8 enumerates the allow-list in full and names what is dropped;backend-requirements.mdgets thego_buildingest rules, the optional-keys rule, and the architecture join.🤖 Generated with Claude Code