feat(api): add provider group filters#11573
Conversation
- Add provider group filters alongside provider type filters - Support exact and comma-separated provider group filtering - Cover provider group filtering across API views and overviews
📝 WalkthroughWalkthroughThis PR extends the Prowler API to support filtering by provider groups across multiple endpoints. Filter classes are updated with ChangesProvider Group Filtering Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
✅ Conflict Markers Resolved All conflict markers have been successfully resolved in this pull request. |
|
✅ All necessary |
🔒 Container Security ScanImage: 📊 Vulnerability Summary
16 package(s) affected
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
api/src/backend/api/tests/test_views.py (1)
1414-18238:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRun ruff formatter to fix code style.
The pipeline indicates this file needs reformatting.
Run the following command to fix:
uv run ruff format src/backend/api/tests/test_views.py🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/src/backend/api/tests/test_views.py` around lines 1414 - 18238, Summary: The test file src/backend/api/tests/test_views.py is not formatted to project style (ruff) causing CI failures. Fix: run the project formatter (ruff) over the file and commit the changes; e.g. execute the ruff format command the reviewer suggested to automatically reformat the whole file including tests like test_providers_filter_provider_groups, TestProviderGroupViewSet, and other test_* functions; verify no functional changes and then add/commit the formatted file and push. Ensure you run the same command in CI/pre-commit locally (uv run ruff format src/backend/api/tests/test_views.py) so lint/format passes.Source: Pipeline failures
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@api/src/backend/api/tests/test_views.py`:
- Around line 1414-18238: Summary: The test file
src/backend/api/tests/test_views.py is not formatted to project style (ruff)
causing CI failures. Fix: run the project formatter (ruff) over the file and
commit the changes; e.g. execute the ruff format command the reviewer suggested
to automatically reformat the whole file including tests like
test_providers_filter_provider_groups, TestProviderGroupViewSet, and other
test_* functions; verify no functional changes and then add/commit the formatted
file and push. Ensure you run the same command in CI/pre-commit locally (uv run
ruff format src/backend/api/tests/test_views.py) so lint/format passes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 43caf620-81dd-49e3-a170-f580de34e505
📒 Files selected for processing (4)
api/CHANGELOG.mdapi/src/backend/api/filters.pyapi/src/backend/api/tests/test_views.pyapi/src/backend/api/v1/views.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11573 +/- ##
==========================================
+ Coverage 94.02% 94.05% +0.02%
==========================================
Files 241 241
Lines 35705 35872 +167
==========================================
+ Hits 33573 33740 +167
Misses 2132 2132
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Context
Provider group filtering should be available wherever API consumers can already filter cloud-scoped data by provider type, so provider group based workflows can query the same API surfaces without expanding groups client-side.
Description
This PR adds
provider_groupsandprovider_groups__infilters across the API filtersets and overview paths that already support cloud provider filtering.The change covers exact provider group matching, comma-separated
__inmatching, distinct result handling for providers that belong to multiple groups, and OpenAPI filter documentation for the affected routes. Lighthouse endpoints are intentionally excluded because theirprovider_typeparameter refers to LLM providers such asopenaiandbedrock, not Prowler cloud providers.The API changelog includes the new provider group filters entry for this PR.
Steps to review
api/src/backend/api/filters.pyand confirmprovider_groups/provider_groups__inare added alongside cloud provider type filters.api/src/backend/api/v1/views.pyand confirm overview/manual filter handling includes provider groups, includingoverviews/threatscorequery parameters.api/src/backend/api/tests/test_views.pyfor exact and__incoverage across providers, scans, resources, findings, finding groups, and overviews.uv run pytest src/backend/api/tests/test_views.py -k provider_groups -qfromapi/.uv run ruff check src/backend/api/filters.py src/backend/api/tests/test_views.py src/backend/api/v1/views.pyfromapi/.local_scripts/provider_groups_filter_e2e.pyagainst the dev API to recreate provider groups and compare provider group filters against equivalent provider ID filters.Checklist
Community Checklist
SDK/CLI
UI
API
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Summary by CodeRabbit
Release Notes
New Features
Documentation