fix: self-install govulncheck and gosec via go run#53
Merged
Conversation
Both tools were relying on whatever was on $PATH:
govulncheck ./... # snap-installed v0.0.0 on admin1 (Go 1.22 typechecker)
gosec ./... # snap-installed v2.26.1, but sudo flips GOPATH
The snap govulncheck on admin1 fails with "package golang.org/x/sys/unix
without types was imported from github.com/mattn/go-isatty" — its
typechecker is older than our go.mod's go directive (1.25.10), so it
cannot resolve types for the module it is asked to scan.
The snap gosec under sudo -i fails with "No packages found" — sudo
swaps GOPATH to /root/go, leaving go/packages with an empty module
cache to load from.
Switch both targets to "go run pkg@version", which:
- downloads the toolchain pinned in our go.mod via GOTOOLCHAIN=auto,
so the typechecker always matches what wifimgr declares;
- resolves modules through the invoking user's normal GOPATH, so the
sudo-cache-swap footgun goes away;
- uses pinned explicit semver tags.
GOVULNCHECK_VERSION = v1.3.0
GOSEC_VERSION = v2.26.1
95c1de7 to
2939df3
Compare
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.
Summary
The
securitytarget was callinggovulncheckandgosecfrom$PATH, which broke onadmin1.prod.core.scale.internal:govulncheck ./...(as user) → snap-installedv0.0.0-...20240415, built against Go 1.22. Its typechecker is older than ourgo.mod'sgo 1.25.10, so it bails with:gosec ./...(undersudo -i) →sudoswapsGOPATHto/root/go.gosec'sgo/packagesloader has no module cache to read from, so:Fix
Switch both invocations to
go run pkg@version:Properties:
GOTOOLCHAIN=auto(default),go rundownloads the toolchain pinned ingo.modif the local Go is older. The tool's typechecker always matches the module it's scanning.gosec/govulncheckhappens to be on PATH (snap, brew, system) is ignored.go runresolves modules through the invoking user's normalGOPATH.Test plan
make vulnon darwin/arm64 (Go 1.26.2): downloadsgovulncheck@v1.3.0, runs, reports findings normally (no internal error).make securityrunsgosecthengovulncheck, both self-installed.make installon admin1 (Go 1.22.2, snap tools): toolchain auto-downloadsgo1.25.10; gosec + govulncheck build with that and complete cleanly.