deps: remove gosnmp via contrib/snmp2cpe submodule isolation#2468
Open
deps: remove gosnmp via contrib/snmp2cpe submodule isolation#2468
Conversation
Create contrib/snmp2cpe/go.mod as a separate Go module so gosnmp is no longer a dependency of the main vuls binary. Replace config.Version/Revision import in version.go with local ldflags-settable variables to break circular dependency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Why (motivation for removing this dependency)
gosnmp/gosnmpis an SNMP protocol library used exclusively incontrib/snmp2cpe/— a standalone CLI tool for converting SNMP device info to CPE formatvulsbinary at all, but was pulled in because snmp2cpe shared the rootgo.modWhat (replacement details)
contrib/snmp2cpe/go.modas a separate Go module (github.com/future-architect/vuls/contrib/snmp2cpe)config.Version/config.Revisionimport inversion.gowith local variables settable via-ldflagsat build time (breaks the only import from snmp2cpe into the main module)go mod tidyautomatically removed gosnmp and its transitive depsChanged files
contrib/snmp2cpe/go.modcontrib/snmp2cpe/go.sumcontrib/snmp2cpe/pkg/cmd/version/version.goconfig.Version/config.Revisionimport with local ldflags varsgo.modgo.sumSafety (why this is safe)
github.com/future-architect/vuls/contrib/snmp2cpe/...), which naturally becomes the new module pathconfig.Version/Revision) is replaced with equivalent local variablespkg/cpe/cpe_test.go) passes in the new moduleTest plan
cd contrib/snmp2cpe && go build ./...— submodule buildscd contrib/snmp2cpe && go test ./...—cpe_test.gopassesgo build ./cmd/...— root module builds (without gosnmp)go test ./...— root module all tests passGOEXPERIMENT=jsonv2 golangci-lint run ./...— 0 issuesgrep gosnmp go.mod— confirms gosnmp is not in root go.modReview hint (how to review efficiently)
contrib/snmp2cpe/go.mod— verify the module path and dependencies look correctcontrib/snmp2cpe/pkg/cmd/version/version.go— the only code change: localVersion/Revisionvars replacing theconfigimportgo.moddiff — confirm gosnmp and related deps are removedgo test ./...from root, which will skip snmp2cpe packages (they're in a separate module). A follow-up CI change may be needed to also test the submodule.🤖 Generated with Claude Code