Skip to content
This repository was archived by the owner on May 30, 2026. It is now read-only.

feat: add UNKNOWN enum value to Vulnerability sources#1948

Closed
fahedouch wants to merge 1 commit into
DependencyTrack:mainfrom
fahedouch:add-unknown-to-enum
Closed

feat: add UNKNOWN enum value to Vulnerability sources#1948
fahedouch wants to merge 1 commit into
DependencyTrack:mainfrom
fahedouch:add-unknown-to-enum

Conversation

@fahedouch
Copy link
Copy Markdown
Contributor

@fahedouch fahedouch commented Mar 27, 2026

Description

When the system encountered vulnerability sources not defined in the enum, it threw an IllegalArgumentException: No enum constant org.dependencytrack.model.Vulnerability.Source.UNKNOWN and failed to process the vulnerability. Adding the UNKNOWN enum value allows the system to gracefully handle unrecognized vulnerability sources instead of crashing.

I discovered this issue when testing this PR

Addressed Issue

Additional Details

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

Copilot AI review requested due to automatic review settings March 27, 2026 23:10
Copy link
Copy Markdown
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

Adds an UNKNOWN value to Vulnerability.Source so code paths that parse "UNKNOWN" via Vulnerability.Source.valueOf(...) no longer throw IllegalArgumentException, improving resilience when encountering placeholder/unrecognized vulnerability sources.

Changes:

  • Add UNKNOWN enum value to Vulnerability.Source.
  • Update enum constant list formatting to accommodate the new value.
Comments suppressed due to low confidence (1)

apiserver/src/main/java/org/dependencytrack/model/Vulnerability.java:139

  • isKnownSource() currently returns true for UNKNOWN (since it’s now part of values()). Callers like CycloneDXVexImporter use this check to reject unsupported sources, so treating UNKNOWN as "known" may let placeholder/invalid sources through. Consider explicitly excluding UNKNOWN from this predicate (or renaming the method to reflect the new semantics).
        public static boolean isKnownSource(String source) {
            return Arrays.stream(values()).anyMatch(enumSource -> enumSource.name().equalsIgnoreCase(source));
        }

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

Comment on lines +134 to +135
CSAF, // CSAF Vulnerability sources
UNKNOWN; // Unknown or unrecognized vulnerability source
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

Source enum now includes UNKNOWN, but the enum-level documentation says it defines sources "supported" by Dependency-Track. Consider updating the wording to explicitly mention that UNKNOWN is a fallback placeholder (i.e., not an authoritative/supported feed) to avoid misleading future readers and API users.

Copilot uses AI. Check for mistakes.
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 12, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 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%)

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8bd646c) 41913 35824 85.47%
Head commit (55f0451) 41914 (+1) 35825 (+1) 85.47% (+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 (#1948) 2 2 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%

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.

Signed-off-by: Fahed Dorgaa <fahed.dorgaa@gmail.com>
@fahedouch fahedouch force-pushed the add-unknown-to-enum branch from 8e552c3 to 55f0451 Compare May 20, 2026 15:26
@nscuro nscuro mentioned this pull request May 27, 2026
2 tasks
@nscuro
Copy link
Copy Markdown
Member

nscuro commented May 27, 2026

Superseded by #2214

@nscuro nscuro closed this May 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants