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
{{ message }}
Repository navigation
Enhancement: keep Go 1.24 tool directive modules as development dependencies in vg scan #567
Go 1.24 added the tool directive to go.mod (go get -tool golang.org/x/tools/cmd/stringer). The tool's module is added to require, usually marked // indirect because no package in the main module imports it:
parseGoMod in src/core-open/scanners/go-scanner.ts doesn't read tool lines, and scanOneGoProject drops every // indirect require before building rows (allDeps.filter(d => !d.indirect)). So build tools pinned this way disappear from vg scan entirely, even though they're real, version-pinned development dependencies that drift like anything else.
What to do
Parse tool directives in both forms (tool path and tool ( … )) and collect the tool package paths.
Map each tool package to the required module that provides it (the longest require module path that is a prefix of the tool path).
Keep those modules in the scan even when they're // indirect, and record them in the devDependencies section rather than dependencies.
Add tool to the looksLikeGoModule keyword list so a bare tool token is never treated as a module.
Add unit tests for the single-line and block forms, a tool whose module is also a direct import (it should stay in dependencies), and a tool path nested under its module path.
Acceptance
The example go.mod above produces a golang.org/x/tools row under development dependencies in vg scan.
Indirect requires that aren't providing a tool are still filtered out as today.
A module that is both imported directly and used as a tool stays a production dependency.
Good catch, Go 1.24 tool pins are easy to miss. Some pointers from the current code:
parseGoMod in src/core-open/scanners/go-scanner.ts only looks at require lines; a tool … line or a tool ( … ) block body goes straight to continue. Collect tool paths with the same single-line vs block handling used for require (including the one-line tool ( … ) edge case the require parser already handles).
The drop happens at const directDeps = allDeps.filter(d => !d.indirect); in scanOneGoProject. After mapping each tool path to its providing module (longest require path that equals the tool path or is a prefix followed by /), keep those modules even when indirect, and carry a flag so the row is pushed with section: 'devDependencies' instead of the hardcoded 'dependencies'.
Watch the prefix match: golang.org/x/tool must not match golang.org/x/tools/cmd/stringer, so compare on a / boundary.
Precedence: a module that's a non-indirect require stays in dependencies even if it also provides a tool.
Add 'tool' to the keyword list in looksLikeGoModule alongside toolchain.
Framework detection (KNOWN_GO_FRAMEWORKS) should keep working for these rows; it's harmless either way, but don't skip it by accident.
Tests can call an exported parseGoMod directly, or go through scanGoProjects with a stubbed GoCache so nothing hits the network.
Activity
vibgrate-team commentedon Nov 3, 2026
Good catch, Go 1.24 tool pins are easy to miss. Some pointers from the current code:
parseGoModinsrc/core-open/scanners/go-scanner.tsonly looks atrequirelines; atool …line or atool ( … )block body goes straight tocontinue. Collect tool paths with the same single-line vs block handling used forrequire(including the one-linetool ( … )edge case the require parser already handles).const directDeps = allDeps.filter(d => !d.indirect);inscanOneGoProject. After mapping each tool path to its providing module (longestrequirepath that equals the tool path or is a prefix followed by/), keep those modules even whenindirect, and carry a flag so the row is pushed withsection: 'devDependencies'instead of the hardcoded'dependencies'.golang.org/x/toolmust not matchgolang.org/x/tools/cmd/stringer, so compare on a/boundary.dependencieseven if it also provides a tool.'tool'to the keyword list inlooksLikeGoModulealongsidetoolchain.KNOWN_GO_FRAMEWORKS) should keep working for these rows; it's harmless either way, but don't skip it by accident.Tests can call an exported
parseGoModdirectly, or go throughscanGoProjectswith a stubbedGoCacheso nothing hits the network.