Skip to content

Conversation

@Alan-TheGentleman
Copy link
Contributor

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/severity that returns failed findings count grouped by provider type and severity level.

Changes:

  • Add OverviewProviderSeveritySerializer for the response format
  • Add the endpoint with support for provider_id__in and provider_type__in filters
  • Add OpenAPI documentation for the endpoint
  • Add 2 unit tests covering basic functionality and filtering
  • Update API CHANGELOG
  • Ignore xmltodict vulnerability 79408 in pre-commit (needs upgrade to >=0.15.1)

Response example:

{
  "data": [
    {
      "type": "provider-severity-overview",
      "id": "aws",
      "attributes": {
        "critical": 150,
        "high": 995,
        "medium": 1648,
        "low": 500,
        "informational": 200
      }
    }
  ]
}

Steps to review

  1. Review the serializer in api/src/backend/api/v1/serializers.py
  2. Review the endpoint implementation in api/src/backend/api/v1/views.py
  3. Run the tests: cd api && poetry run pytest src/backend/api/tests/test_views.py::TestOverviewViewSet -v
  4. Optionally test the endpoint manually with filters

Checklist

  • Are there new checks included in this PR? No
  • Review if the code is being covered by tests.
  • Review if code is being documented following this specification
  • Review if backport is needed.
  • Review if is needed to change the Readme.md - Not needed
  • Ensure new entries are added to CHANGELOG.md, if applicable.

API

  • Verify if API specs need to be regenerated. - Auto-generated via drf-spectacular
  • Check if version updates are required (e.g., specs, Poetry, etc.).
  • Ensure new entries are added to CHANGELOG.md, if applicable.

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.

- Add OverviewProviderSeveritySerializer for severity breakdown by provider type
- Add GET /api/v1/overviews/providers/severity endpoint
- Return failed findings count grouped by provider type and severity level
- Support provider_id and provider_type filters via ScanSummaryFilter
- Add OpenAPI documentation for the new endpoint
- Add unit tests for the endpoint with and without filters
- Update CHANGELOG
- Ignore xmltodict vulnerability 79408 in pre-commit (needs upgrade to >=0.15.1)
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

✅ All necessary CHANGELOG.md files have been updated.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Conflict Markers Resolved

All conflict markers have been successfully resolved in this pull request.

@Alan-TheGentleman Alan-TheGentleman self-assigned this Dec 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

🔒 Container Security Scan

Image: prowler:8a8fbdc
Last scan: 2025-12-02 17:00:45 UTC

📊 Vulnerability Summary

Severity Count
🔴 Critical 2
Total 2

2 package(s) affected

⚠️ Action Required

Critical severity vulnerabilities detected. These should be addressed before merging:

  • Review the detailed scan results
  • Update affected packages to patched versions
  • Consider using a different base image if updates are unavailable

📋 Resources:

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

🔒 Container Security Scan

Image: prowler-api:8a8fbdc
Last scan: 2025-12-02 17:02:44 UTC

📊 Vulnerability Summary

Severity Count
🔴 Critical 4
Total 4

3 package(s) affected

⚠️ Action Required

Critical severity vulnerabilities detected. These should be addressed before merging:

  • Review the detailed scan results
  • Update affected packages to patched versions
  • Consider using a different base image if updates are unavailable

📋 Resources:

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.74%. Comparing base (07e82bd) to head (fc17123).
⚠️ Report is 43 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9415      +/-   ##
==========================================
+ Coverage   92.72%   92.74%   +0.02%     
==========================================
  Files         155      155              
  Lines       21544    21610      +66     
==========================================
+ Hits        19976    20043      +67     
+ Misses       1568     1567       -1     
Flag Coverage Δ
api 92.74% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
prowler ∅ <ø> (∅)
api 92.74% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Alan-TheGentleman
Copy link
Contributor Author

No need for this endpoint :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants