Skip to content

fix: add lazy Go installation for cdxgen Go module scanning#96

Merged
vpetersson merged 1 commit intomasterfrom
lazy-load-go
Jan 8, 2026
Merged

fix: add lazy Go installation for cdxgen Go module scanning#96
vpetersson merged 1 commit intomasterfrom
lazy-load-go

Conversation

@vpetersson
Copy link
Contributor

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.

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.
Copilot AI review requested due to automatic review settings January 7, 2026 13:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vpetersson vpetersson merged commit 61626f4 into master Jan 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant