ROX-34163: Prevent showing all profiles in UI when no scans are configured#20044
Draft
ROX-34163: Prevent showing all profiles in UI when no scans are configured#20044
Conversation
|
Skipping CI for Draft Pull Request. |
Contributor
Author
|
/test ocp-4-21-compliance-e2e-tests |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #20044 +/- ##
==========================================
+ Coverage 49.61% 49.64% +0.02%
==========================================
Files 2765 2765
Lines 208640 208820 +180
==========================================
+ Hits 103517 103663 +146
- Misses 97467 97493 +26
- Partials 7656 7664 +8
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:
|
Contributor
🚀 Build Images ReadyImages are ready for commit 42bfc54. To use with deploy scripts: export MAIN_IMAGE_TAG=4.11.x-664-g42bfc54eb2 |
f5c7e5a to
44fcb2b
Compare
…an configs When GetProfilesNames returns nil (filter matches no scan configurations, or no scan configurations exist), 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 none. Meanwhile totalCount came from a separate countQuery and was correctly 0, contradicting the returned data. Fix: early-return (nil, 0, nil) in getProfiles before building the second query when the name list is empty. Covers both ListComplianceScanConfigProfiles and ListComplianceScanConfigClusterProfiles. Also fixes pre-existing style issues in touched files: replace deprecated k8s.io/utils/strings/slices with stdlib slices, and deduplicate the generated/api/v2 import alias in the test file. AI-assisted change.
44fcb2b to
668b647
Compare
…an configs When GetProfilesNames returns nil (filter matches no scan configurations, or no scan configurations exist), 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 none. Meanwhile totalCount came from a separate countQuery and was correctly 0, contradicting the returned data. Fix: early-return (nil, 0, nil) in getProfiles before building the second query when the name list is empty. Covers both ListComplianceScanConfigProfiles and ListComplianceScanConfigClusterProfiles. AI-assisted change.
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 scan configurations (or no scan configurations existing at all) resulted in querying the profiles database without a
WHEREclause, so the API returned every profile in the database instead of none. MeanwhiletotalCountwas computed correctly as 0, contradicting the returned data.GetProfilesNamesqueries thecompliance_operator_scan_configuration_v2table for distinct profile names. When no rows match, it returns nil. The caller was passing nil intoAddExactMatches— a no-op — producing a query with noWHEREclause.Fix: early-return
(nil, 0, nil)ingetProfilesbefore building the second query when the name list is empty.Affected endpoints:
GET /v2/compliance/scan/configurations/profiles/collection(ListComplianceScanConfigProfiles)GET /v2/compliance/scan/configurations/clusters/{cluster_id}/profiles/collection(ListComplianceScanConfigClusterProfiles)See also: companion fix for
/v2/compliance/profiles/summary(#20048).User-facing documentation
Testing and quality
Automated testing
How I validated my change
By running in a live cluster and querying with an empty query against the profiles collection endpoint (no scan configurations defined):