Repository navigation
Download advisories via an authenticated GitLab client - #122
Merged
Merged
Conversation
The advisory download did a plain http.Get on the release's advisory web URL, which fails with 404 because the GitLab API requires authentication and a URL-encoded API URL. Add a GitLab client that reads GITLAB_TOKEN lazily on first use (like the other sub-clients), converts the web URL to the repository files API URL with URL-encoded project and file path, and authenticates with an Authorization: Bearer header. Errors distinguish an invalid or expired token (401) from a missing or inaccessible file (404). Co-Authored-By: Claude Code <noreply@anthropic.com>
tommartensen
force-pushed
the
gitlab-advisory-download
branch
from
December 3, 2026 15:51
f14c513 to
e0a4722
Compare
kurlov
approved these changes
Dec 3, 2026
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.
Summary
The advisory download in
GetAdvisoryFromReleasedid a plainhttp.Geton the release's advisory web URL, which fails with404: the raw web API on gitlab.cee.redhat.com is private, and the release status only exposes the GitLab web URL, not the API URL.This adds a GitLab client (
pkg/client/gitlab) that:GITLAB_TOKENlazily on first use, following the sub-client pattern from Scope credentials to the commands that need them #119 — only commands that download advisory content require the token, and the error surfaces at that point/releng/advisories/-/raw/main/data/...) to the repository files API URL with URL-encoded project and file path (slashes →%2F)Authorization: Bearer <token>(preferred over GitLab'sPRIVATE-TOKEN)GITLAB_TOKENis a personal access token with theread_apiscope, created at https://gitlab.cee.redhat.com/-/user_settings/personal_access_tokens; it is now documented in the README.Testing
tests/gitlabsuite: success path (verifies the web→API conversion, URL encoding via an escaped-path matcher, and the Bearer header), 401/404 errors, missing token, invalid URLs — all green; fullgo test ./...,go vet,golangci-lintpass.GITLAB_TOKENthe command now fails with a clearGITLAB_TOKEN environment variable is requiredinstead of a downstream parse error; with a token, the raw advisory downloads (endpoint validated via curl).🤖 Generated with Claude Code
Triggered by https://redhat-internal.slack.com/archives/C0BV9SM5PJ4/p1796308868260249