feat(api): add providers/severity endpoint for sankey chart #9415
+249
−2
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.
Context
This PR adds a new API endpoint needed by the UI Sankey chart (Risk Pipeline) to display severity breakdown per provider type with accurate data.
Previously, the frontend had to make 2 API calls and calculate proportional severity distribution using
Math.round(), which caused rounding errors (e.g., showing 1,638 instead of 1,648).Description
Add a new endpoint
GET /api/v1/overviews/providers/severitythat returns failed findings count grouped by provider type and severity level.Changes:
OverviewProviderSeveritySerializerfor the response formatprovider_id__inandprovider_type__infiltersResponse example:
{ "data": [ { "type": "provider-severity-overview", "id": "aws", "attributes": { "critical": 150, "high": 995, "medium": 1648, "low": 500, "informational": 200 } } ] }Steps to review
api/src/backend/api/v1/serializers.pyapi/src/backend/api/v1/views.pycd api && poetry run pytest src/backend/api/tests/test_views.py::TestOverviewViewSet -vChecklist
API
Note
The pre-commit config was updated to ignore vulnerability 79408 (xmltodict < 0.15.1). Consider upgrading xmltodict to fix this properly.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.