DevelopVulnerabilities
@holtkeeper/vuln-go
A Fixer for Go modules. Given findings for a go.mod, it upgrades the vulnerable modules with go get and tidies the module.
Public API
Section titled “Public API”goFixer(options?: { runner?: CommandRunner }): Fixer— fixer namedgo.supports(source)is true for any file namedgo.mod. Commands run throughrunner(default:localRunnerfrom@holtkeeper/exec).planGoUpgrades(findings): GoUpgradePlan— pure planning step: findings in,{ upgrades, notes }out.
Planning rules
Section titled “Planning rules”- Only findings with ecosystem
Goare handled; others are skipped with a note. - The target for a finding is
fixedVersions[0]. Without one, the finding is skipped with a note. - Several findings for one module are merged into one upgrade to the highest target; all their ids count as fixed once
go getsucceeds. - A target at or below the version in use is never applied (no downgrades).
- Versions are accepted with or without
v(osv-scanner reports0.3.0);go getalways getsv0.3.8. stdlibandtoolchainfindings change nothing. They produce one note per pseudo-package, such asstdlib: upgrade the Go toolchain to go1.22.7 or later (GO-...).
Commands
Section titled “Commands”In the directory of the go.mod:
go get <module>@v<version>for each planned upgrade, one at a time. A failure becomes a note and the module is not reported as fixed.go mod tidy, only if at least onego getsucceeded. A failure throwsCommandError.
changedFiles lists go.mod and go.sum (relative to the project) when their contents changed.
Environment
Section titled “Environment”GOTOOLCHAIN=local— never download a toolchain. If a new dependency version needs a newer Go than the one installed,go getfails and the failure is reported as a note.GOWORK=off— ignore anygo.workabove the module.GOFLAGS=-mod=mod— allow updatinggo.modeven when avendor/directory exists. This replaces anyGOFLAGSfrom the caller’s environment.
GOPROXY, GOPRIVATE and credentials come from the caller’s environment.
Limitations
Section titled “Limitations”- Standard library and toolchain advisories need a Go upgrade, which this fixer does not do. osv-scanner 2.7 did not report
stdlibfindings forgo.modsources in our tests, but other scanners (and older osv-scanner versions) do. go getmay raise thegodirective or upgrade other modules when the new version requires it.replacedirectives win overrequire: if the vulnerable module is replaced,go getupdatesrequirebut the build still uses the replacement. Such findings will reappear on rescan.- Workspaces (
go.work) are not updated; each module is fixed on its own withGOWORK=off. vendor/directories are not refreshed (go mod vendoris not run).