Support Sonatype Guide tokens for OSS Index analyzer#5994
Support Sonatype Guide tokens for OSS Index analyzer#5994nscuro merged 1 commit intoDependencyTrack:masterfrom
Conversation
Sonatype Guide uses bearer tokens, whereas OSS Index expects basic auth using email and token. Note that the OSS Index API does not yet support Guide tokens, but will soon. This change ensures a smooth transition when the time comes. Signed-off-by: nscuro <[email protected]>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 5 |
| Duplication | 4 |
🟢 Coverage 100.00% diff coverage · +0.00% coverage variation
Metric Results Coverage variation ✅ +0.00% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage (70.00%) Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (d3ff4c1) 24774 20111 81.18% Head commit (28d5f7c) 24779 (+5) 20116 (+5) 81.18% (+0.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#5994) 15 15 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
TIP This summary will be updated as you push new changes. Give us feedback
There was a problem hiding this comment.
Pull request overview
Updates the OSS Index analyzer to accept Sonatype Guide-style bearer tokens (in addition to the existing OSS Index basic-auth credentials), with accompanying test coverage.
Changes:
- Allow OSS Index analysis to proceed with only an API token (no username) when the token is identified as a Guide bearer token.
- Send
Authorization: Bearer …for Guide tokens; otherwise continue using basic auth with username + token. - Extend/adjust unit tests to cover bearer-token behavior and the “missing username” scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/main/java/org/dependencytrack/tasks/scanners/OssIndexAnalysisTask.java |
Adds bearer-token detection and conditionally sets the Authorization header as Bearer vs Basic. |
src/test/java/org/dependencytrack/tasks/scanners/OssIndexAnalysisTaskTest.java |
Updates the “missing user” test and adds new tests asserting bearer auth header behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Supports Sonatype Guide tokens for OSS Index analyzer.
Sonatype Guide uses bearer tokens, whereas OSS Index expects basic auth using email and token.
Note that the OSS Index API does not yet support Guide tokens, but will soon. This change ensures a smooth transition when the time comes.
Addressed Issue
Relates to #5977
Additional Details
N/A
Checklist
This PR fixes a defect, and I have provided tests to verify that the fix is effectiveThis PR introduces changes to the database model, and I have added corresponding update logicThis PR introduces new or alters existing behavior, and I have updated the documentation accordingly