Skip to content

feat: add user-agent header#10

Merged
alexanderbsingh merged 6 commits into
mainfrom
user-agent-header
Jul 6, 2026
Merged

feat: add user-agent header#10
alexanderbsingh merged 6 commits into
mainfrom
user-agent-header

Conversation

@alexanderbsingh

@alexanderbsingh alexanderbsingh commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Adds a User-Agent header to the SBOM upload request. The User-Agent is bifrost-cli/<version>, where the version is the latest version tag plus the current commit, number of commits off from the release and -dirty if built with uncomited changes. A clean example bifrost-cli/v0.1.4 and a "dirty" example bifrsot-cli/v0.1.4-4-g82f64fd-dirty

@alexanderbsingh alexanderbsingh changed the title feat: add CLI user-agent header feat: add user-agent header Jul 1, 2026
# Conflicts:
#	.github/workflows/build.yaml
#	internal/bifrost/api_test.go

Copilot AI left a comment

Copy link
Copy Markdown

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 a User-Agent header to SBOM upload HTTP requests, intending to identify the CLI as bifrost-cli/<version> where the version is derived from Git metadata and/or release inputs.

Changes:

  • Thread the CLI version from CLI(...)NewSBOMUploadTask(...)NewAPI(...) and set User-Agent on upload requests.
  • Update tests to assert the new User-Agent header is present.
  • Adjust build plumbing (Makefile + GitHub Actions) to pass version/commit information into the build.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Makefile Makes VERSION/GIT_COMMIT overridable and embeds them via -ldflags for runtime version reporting.
internal/bifrost/sbom_upload.go Passes the CLI version into API construction for request header population.
internal/bifrost/cli.go Updates SBOM upload task construction to include the CLI version.
internal/bifrost/cli_test.go Adds assertion that the CLI-driven upload includes User-Agent.
internal/bifrost/api.go Adds userAgent handling and sets User-Agent on the upload request.
internal/bifrost/api_test.go Adds User-Agent assertions and updates most NewAPI call sites for the new signature.
.github/workflows/build.yaml Updates version derivation and propagates version/commit through environment into make build-all.
Comments suppressed due to low confidence (1)

internal/bifrost/api.go:45

  • NewAPI now requires an extra version argument, but there is still at least one call site using the old signature (e.g. internal/bifrost/api_test.go:85 in TestAPI_UploadSBOM_EscapesServiceAndVersionPathSegments), which will cause compilation failures. Update the remaining call(s) to pass a version string (or "" to omit the /version suffix in the User-Agent).
func NewAPI(serverURL string, token string, retryAttempts int, retryDelay time.Duration, gitBranch string, gitCommitSHA string, gitOrigin string, version string) API {
	if retryAttempts < 0 {
		retryAttempts = 0
	}
	if retryDelay < 0 {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile Outdated
Comment thread .github/workflows/build.yaml Outdated
@alexanderbsingh alexanderbsingh self-assigned this Jul 2, 2026
@alexanderbsingh alexanderbsingh marked this pull request as ready for review July 2, 2026 08:18
@alexanderbsingh alexanderbsingh merged commit d64050a into main Jul 6, 2026
1 check passed
@alexanderbsingh alexanderbsingh deleted the user-agent-header branch July 6, 2026 09:29
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.

3 participants