fix: add lazy Go installation for cdxgen Go module scanning#96
Merged
vpetersson merged 1 commit intomasterfrom Jan 8, 2026
Merged
fix: add lazy Go installation for cdxgen Go module scanning#96vpetersson merged 1 commit intomasterfrom
vpetersson merged 1 commit intomasterfrom
Conversation
cdxgen requires Go to be installed to run `go list -deps` for proper dependency resolution. Without it, the --fail-on-error flag causes cdxgen to exit with status 1 when scanning go.mod files. This adds on-demand Go installation following the existing pattern used for Java/Maven: - Thread-safe installation with double-check locking - Skips if Go is already available in PATH - Installs golang package via apt-get with --no-install-recommends - Caches installation state to avoid repeated checks This keeps the base Docker image lean while supporting Go projects that need full dependency resolution.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds lazy Go installation for cdxgen to properly scan Go modules, preventing failures when the --fail-on-error flag is used on projects with go.mod files. The implementation follows the existing Java/Maven installation pattern.
Key Changes
- Added thread-safe on-demand Go installation with double-check locking pattern
- Integrated Go installation check into cdxgen generator before scanning Go projects
- Cached installation state to avoid repeated system checks
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sbomify_action/_generation/utils.py | Implements ensure_go_installed() function with thread-safe installation logic and state tracking |
| sbomify_action/_generation/generators/cdxgen.py | Triggers Go installation before processing Go ecosystem projects |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
cdxgen requires Go to be installed to run
go list -depsfor proper dependency resolution. Without it, the --fail-on-error flag causes cdxgen to exit with status 1 when scanning go.mod files.This adds on-demand Go installation following the existing pattern used for Java/Maven:
This keeps the base Docker image lean while supporting Go projects that need full dependency resolution.