Skip to content

Support multiple configurable OSV data sources - #7113

Open
sahibamittal wants to merge 8 commits into
DependencyTrack:mainfrom
sahibamittal:issue-6331-Support-Multiple-OSV-Sources
Open

sahibamittal wants to merge 8 commits into
DependencyTrack:mainfrom
sahibamittal:issue-6331-Support-Multiple-OSV-Sources

Conversation

@sahibamittal

@sahibamittal sahibamittal commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

  1. Replace the flat OSV runtime config with a list of independently configurable sources.
  2. Compose one OsvVulnDataSource per enabled source, namespace watermark keys per source name.
  3. Migrate legacy OSV configs and watermarks to a default source.

Addressed Issue

Closes #6331

Additional Details

Frontend: DependencyTrack/frontend#1783
Docs update: DependencyTrack/docs#237

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have updated the migration changelog accordingly
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly
  • This PR is a substantial change (per the ADR criteria), and I have added an ADR under docs/adr/

Signed-off-by: Sahiba Mittal <sahiba.mittal@citi.com>
@owasp-dt-bot

owasp-dt-bot commented Aug 25, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codacy-production

codacy-production Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 24 complexity

Metric Results
Complexity 24

View in Codacy

🟢 Coverage 89.33% diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation (-1.00%)
Diff coverage ✅ 89.33% diff coverage (70.00%)

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8e0f33f) 44902 39270 87.46%
Head commit (501058f) 44956 (+54) 39319 (+49) 87.46% (+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 (#7113) 75 67 89.33%

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%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sahibamittal
sahibamittal marked this pull request as ready for review August 27, 2026 14:37

@nscuro nscuro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly looks good with a few issues to fix and tweaks to make.

But this also introduces a new hazard where multiple feeds can contribute information for the same vulnerability. They'd override each other's data because our data model (i.e. VULNERABILITY.SOURCE column) is not granular enough to discern "OSV" from "OSV, feed XYZ". Should be documented.

Separately, so you know of any public OSV feed that this could be tested with? I checked Chainguard but they appear to use a different feed format that OSV? https://packages.cgr.dev/chainguard/osv/all.json

if (currentDataSource == null) {
throw new IllegalStateException("No current data source to mark processed");
}
currentDataSource.markProcessed(bom);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

MirrorVulnDataSourceActivity buffers up to 25 BOVs before marking them as processed. If during this buffering currentDataSource has transitioned from source A to source B, all BOVs are attributed to source B.

Comment on lines +95 to +107
for (final var source : config.getSources()) {
if (source.getName() == null || source.getName().isBlank()) {
throw new InvalidRuntimeConfigException("No data source name provided");
}
if (!source.isEnabled()) {
continue;
}
if (source.getDataUrl() == null) {
throw new InvalidRuntimeConfigException("No data URL provided");
}
if (source.getEcosystems() == null || source.getEcosystems().isEmpty()) {
throw new InvalidRuntimeConfigException("At least one ecosystem must be specified");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a validation that no duplicate source names can exist, so sources can't corrupt each other's watermarks etc.

try {
dataSource.close();
} catch (final Exception e) {
LOGGER.warn("Failed to close data source: {}", dataSource, e);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OsvVulnDataSource doesn't implement toString so this will log something like OsvVulnDataSource@1a2b3c. Did you mean to call dataSource.getDataSourceName()?

Comment on lines +19 to +24
"name": {
"type": "string",
"title": "Name",
"description": "The name of the OSV data source.",
"minLength": 1
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a free-text string that is used in watermark keys and other places. We should restrict this to a certain length and characters.

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

@WireMockTest

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

WireMock isn't used here.

/**
* @since 5.0.0
*/
final class OsvCompositeVulnDataSource implements VulnDataSource {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider adding the name of the current source to SLF4J's MDC so log statements show what source is currently being processed. Must be cautious though that the new MDC field doesn't leak, so probably best to only set it around calls to currentDataSource.

"format": "uri"
},
"ecosystems": {
"sources": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: consider using the term "feed" for this instead, i.e. users would be consuming from the default and the Chainguard feeds using the OSV data source.

"source" is a bit overloaded since the overarching thing is already a source, vulnerabilities also have a source field.

@sahibamittal

sahibamittal commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

But this also introduces a new hazard where multiple feeds can contribute information for the same vulnerability. They'd override each other's data because our data model (i.e. VULNERABILITY.SOURCE column) is not granular enough to discern "OSV" from "OSV, feed XYZ". Should be documented.

Docs updated DependencyTrack/docs#237

Separately, so you know of any public OSV feed that this could be tested with? I checked Chainguard but they appear to use a different feed format that OSV? https://packages.cgr.dev/chainguard/osv/all.json

Not likely public, they provide OSV feed via API which is auth protected (via token).

Signed-off-by: Sahiba Mittal <sahiba.mittal@citi.com>
Signed-off-by: Sahiba Mittal <sahiba.mittal@citi.com>
Signed-off-by: Sahiba Mittal <sahiba.mittal@citi.com>
Signed-off-by: Sahiba Mittal <sahiba.mittal@citi.com>
@sahibamittal
sahibamittal requested a review from nscuro September 18, 2026 10:13

This branch has not been deployed

No deployments
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.

Support Multiple OSV Sources with sub tabs and ecosystem scoping

3 participants