Repository navigation
feat(dependencies): declare the Go standard library of a Go module - #140
Merged
Merged
Conversation
Every Go binary links the standard library, and most Go vulnerabilities land there, but a Go root listed only its required modules. A go.mod now declares pkg:golang/stdlib at the toolchain it builds with: the toolchain directive when set, else the go directive. Both the go command resolver (go mod edit -json, falling back to go list's GoVersion) and the flat go.mod parser emit it. It is named stdlib, as the Go vulnerability database and Syft name it: Grype matches nothing on cyclonedx-gomod's "std". Refs #138
Merged
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.
Section 3 of #138.
Every Go binary links the standard library, and most Go vulnerabilities land there, but a Go root listed only its required modules. Now every
go.moddeclarespkg:golang/stdlib@<version>as a direct runtime dependency:toolchaindirective when set (go1.26.11), since that is the toolchain the go command switches to; otherwise thegodirective (1.26.11→go1.26.11). Ago 1.26without a patch release is kept as is: it is the oldest release the module allows.go mod edit -json(no network); if that fails, theGoVersiongo listalready reports stands in.Name:
stdlib, notstd. #138 suggested cyclonedx-gomod'spkg:golang/std, but Grype v0.121.2 matches nothing on it.stdlibis the module name the Go vulnerability database files standard library advisories under, and the one Syft uses. Same component, Grype matches:Tests: directive cases for the parser (go, toolchain over go, no patch, none) and
GoStdVersion; a newtoolchain-directivegolden for the resolver (go 1.22+toolchain go1.22.12→stdlib@go1.22.12); the existing goldens now carrystdlib@go1.22.Checked on a real project (scanoss.api v0.41.3,
dependencies . --extract-local --format cyclonedx, then Grype): the root getspkg:golang/stdlib@go1.26.11with 0 matches, which agrees withgovulncheckon that build; the nestedsdk/gomodule getsstdlib@go1.23with 73. That nested module is not in the shipped binary: scoping to what ships is section 2.