feat(packages): PURL-based vulnerability lifecycle for packages#4131
Open
Aman-Cool wants to merge 1 commit intoeclipse-sw360:mainfrom
Open
feat(packages): PURL-based vulnerability lifecycle for packages#4131Aman-Cool wants to merge 1 commit intoeclipse-sw360:mainfrom
Aman-Cool wants to merge 1 commit intoeclipse-sw360:mainfrom
Conversation
- Add PackageVulnerabilityRelation Thrift struct and CouchDB repository
- Extend VulnerabilityService with package CVE CRUD methods
- Add GET/PATCH /api/packages/{id}/vulnerabilities endpoints
- Fix getVulnerabilitiesByProjectId to include package vulnerabilities
- Wire PURL decomposition into existing CVE search heuristic
- Add REST docs tests for new package vulnerability endpoints
Contributor
Author
|
@GMishx, Would love to get some eyes on this when you get a chance. |
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.
So here's the thing that's been quietly bothering me while exploring the codebase; packages have been first-class citizens in SW360 since the Siemens Healthineers contribution, but if you went to check vulnerabilities for a project that used packages instead of releases, you'd get back nothing. Not "no vulnerabilities found", just silence. The
getVulnerabilitiesByProjectIdcall simply skipped overproject.packageIdsentirely and only walkedreleaseIdToUsage. Issue #2093 has been open on this for a while.The fix is conceptually simple: every package already carries a PURL (e.g.
pkg:npm/angular-sanitize@1.8.2). We decompose that PURL into name / namespace / version, build a syntheticReleaseobject from those parts, and feed it straight into the existing CVE search heuristic, the same CPE-matching and fuzzy vendor/product/version search that already works for releases. No new external API, no new infrastructure, just reusing what's already there. The matched CVEs get stored asPackageVulnerabilityRelationdocuments in CouchDB (a parallel to the existingReleaseVulnerabilityRelation), and two new endpoints;GET /api/packages/{id}/vulnerabilitiesandPATCH /api/packages/{id}/vulnerabilities; expose them over REST, following the exact same pattern as the release equivalents.The project-level fix is in the backend service layer (
VulnerabilityHandler.getVulnerabilitiesByProjectId), so every caller; not just the REST endpoint, now gets package CVEs automatically.On the Thrift removal work:
This PR intentionally stays shallow with respect to Thrift. The four new service methods (
getVulnerabilitiesByPackageId,addPackageVulnerabilityRelation,updatePackageVulnerabilityRelation,deletePackageVulnerabilityRelation) follow the exact same structural pattern as the existing methods sitting next to them inVulnerabilityService.thriftandVulnerabilityHandler.java. There are no new Thrift services, no new client stubs, no new inter-service wiring, it's purely additive inside an already-targeted service. When the removal work reachesVulnerabilityService, these four methods migrate identically to the rest; same effort, same pattern, nothing special to untangle. The REST layer code (PackageController,Sw360VulnerabilityService) is already pure Spring, exactly where the migration is heading anyway. This PR doesn't push Thrift deeper into the stack; if anything, the REST endpoints here are already in the post-Thrift shape.Issue: #2093
Suggest Reviewer
@GMishx
Checklist
Must: