ROX-34153: Don't return compliance profiles if filter matches nothing#20048
Open
ROX-34153: Don't return compliance profiles if filter matches nothing#20048
Conversation
|
Skipping CI for Draft Pull Request. |
4 tasks
Contributor
🚀 Build Images ReadyImages are ready for commit 63b7ca9. To use with deploy scripts: export MAIN_IMAGE_TAG=4.11.x-688-g63b7ca9a70 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #20048 +/- ##
=======================================
Coverage 49.67% 49.67%
=======================================
Files 2765 2765
Lines 209049 209052 +3
=======================================
+ Hits 103847 103850 +3
Misses 97523 97523
Partials 7679 7679
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…hes nothing When GetProfilesNames returns nil (filter matches no profiles), the caller was passing nil into AddExactMatches which is a no-op, producing a query with no WHERE clause — causing SearchProfiles to return every profile in the database instead of an empty list. Fix: early-return before building the second query when the name list is empty. AI-assisted change.
The previous test sent a request with no filter, so GetProfilesNames returning nil simulated "cluster has no profiles", not "filter matches nothing". Add a Compliance Profile Name:nonexistent filter so the test exercises the intended scenario. AI-assisted change.
5593dd7 to
63b7ca9
Compare
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.
Description
Before this PR, a filter matching 0 profiles in
GET /v2/compliance/profiles/summaryresulted in querying the database without aWHEREclause, so the API returned every profile in the database instead of none. MeanwhiletotalCountwas computed correctly as 0, contradicting the returned data.This PR fixes the logic by adding an early return when a filter does not match.
A similar issue exists in
/v2/compliance/scan/configurations/, addressed in #20044.User-facing documentation
Testing and quality
Automated testing
How I validated my change
By running in a live cluster and querying with a filter that matches nothing: