You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
golang: infer main-module version from image tag when build info is (devel) (#3)
* golang: infer main-module version from image tag when build info is (devel)
A Go binary built from a checkout carries no comparable main-module
version: build info reports "(devel)". A project like k3s sets its
version through `-ldflags -X pkg.Version=...`, which writes a separate
variable that never reaches buildinfo.Main.Version. The scanner sent
"(devel)" to OSV, which cannot range-match it, so OSV returned advisories
already fixed in the running version and the main module's always-present
pclntab symbols made every one of them land as a false positive.
In image mode, when a binary's main-module version is non-comparable,
recover a version from the image reference tag. The mapping is kept honest
so it can never silently under-report a real vulnerability:
- Main module only: dependencies keep their real build-info versions.
- Semver gated: the tag is used only when it normalizes to a full
MAJOR.MINOR.PATCH semver. latest, digests and date-stamps infer nothing.
- k3s/rke2 aware: Docker tags cannot contain '+', so v1.36.3+k3s1 ships as
v1.36.3-k3s1. A trailing -k3sN / -rke2rN is converted back to +k3sN /
+rke2rN so it matches the versions those advisories are filed under.
- Provenance: any finding whose version was inferred carries an
image-tag-version evidence note in both text and JSON output, so an
inferred version is never mistaken for one read from the artifact.
When no plausible tag exists the original "(devel)" is kept, which
over-reports rather than guessing a version that could hide a real finding.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* golang: sharpen inferred-version provenance wording and pin the semver gate
Lead the provenance note with "version not in build info" so a reader of
text or JSON output cannot mistake an inferred version for one read from
the binary. For a generic image a clean-semver tag is a real guess that
could read too high, and this label is what keeps such a finding honest.
Add a test asserting golang.org/x/mod/semver.IsValid accepts the
normalized "+k3sN" build-metadata form, so the gate can never regress into
rejecting the very case the fallback exists to enable.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: cwayne18 <cwayne18@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
0 commit comments