feat: add UNKNOWN enum value to Vulnerability sources#1948
feat: add UNKNOWN enum value to Vulnerability sources#1948fahedouch wants to merge 1 commit intoDependencyTrack:mainfrom
Conversation
Signed-off-by: Fahed Dorgaa <fahed.dorgaa@gmail.com>
There was a problem hiding this comment.
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
UNKNOWNenum value toVulnerability.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 forUNKNOWN(since it’s now part ofvalues()). Callers likeCycloneDXVexImporteruse this check to reject unsupported sources, so treatingUNKNOWNas "known" may let placeholder/invalid sources through. Consider explicitly excludingUNKNOWNfrom 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.
| CSAF, // CSAF Vulnerability sources | ||
| UNKNOWN; // Unknown or unrecognized vulnerability source |
There was a problem hiding this comment.
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.
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
Description
When the system encountered vulnerability sources not defined in the enum, it threw an
IllegalArgumentException: No enum constant org.dependencytrack.model.Vulnerability.Source.UNKNOWNand failed to process the vulnerability. Adding theUNKNOWNenum 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