-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cloud Security] [Findings] Adding grouping component #169884
Conversation
packages/kbn-securitysolution-grouping/src/components/group_selector/index.tsx
Show resolved
Hide resolved
return false; | ||
} | ||
// Disable all non selected options when the maxGroupingLevels is reached | ||
return groupsSelected.length === maxGroupingLevels && (key ? !isGroupSelected(key) : true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we keep the behaviour of disabling currently selected option when the max level is 1? Right now to remove grouping, you can either switch to none or "unselect" the option. If we change the behavior to toggle when max level is 1, maybe it makes sense to disable this "unselect" behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great point, I'll adjust it in the code and bring it to discussion with the code owners
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats fine, can you please just add some unit tests? We never get to line 53 in the current tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the unit tests related to the changes introduced in this PR, thanks a lot for reviewing it @stephmilovic!
packages/kbn-securitysolution-grouping/src/hooks/use_get_group_selector.tsx
Show resolved
Hide resolved
...s/cloud_security_posture/public/components/cloud_security_data_table/additional_controls.tsx
Outdated
Show resolved
Hide resolved
...d_security_posture/public/pages/configurations/latest_findings/latest_findings_container.tsx
Outdated
Show resolved
Hide resolved
...d_security_posture/public/pages/configurations/latest_findings/latest_findings_container.tsx
Outdated
Show resolved
Hide resolved
...s/cloud_security_posture/public/components/cloud_security_data_table/additional_controls.tsx
Outdated
Show resolved
Hide resolved
...s/cloud_security_posture/public/components/cloud_security_data_table/additional_controls.tsx
Outdated
Show resolved
Hide resolved
...d_security_posture/public/pages/configurations/latest_findings/latest_findings_container.tsx
Outdated
Show resolved
Hide resolved
...d_security_posture/public/pages/configurations/latest_findings/latest_findings_container.tsx
Outdated
Show resolved
Hide resolved
...d_security_posture/public/pages/configurations/latest_findings/latest_findings_container.tsx
Outdated
Show resolved
Hide resolved
additionalFilters: [query], | ||
groupByField: selectedGroup, | ||
uniqueValue, | ||
from: 'now-1y', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its an unlikely scenario but why this time limit? isnt showing the relevant results the job of the transform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, currently our dashboard shows data without any filter, so to ensure consistency in the eventual case that the transform stops running I kept the time limit high. But I see now that this is going to change with this PR, so I will update the query to consider the retention policy instead, and keep in sync with the same filter used by the Dashboard.
...d_security_posture/public/pages/configurations/latest_findings/latest_findings_container.tsx
Outdated
Show resolved
Hide resolved
...d_security_posture/public/pages/configurations/latest_findings/latest_findings_container.tsx
Outdated
Show resolved
Hide resolved
.../cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx
Outdated
Show resolved
Hide resolved
Does this table use virtualization? it seems like the items disappear when scrolling, and you dont have to scroll a lot in order to get to the not-render zones Screen.Recording.2023-11-06.at.13.18.47.movI would like to suggest to either extend the amount of items we do render, or to test if we can completely remove virtualization from the table for now. we only render a maximum amount of 500 items, 2 tables cannot be opened at once so i believe react can easily handle 500 rows of text. |
Virtualization was implemented on purpose since users can load up to 10k records using the "load more button" when going to the last page, and then without virtualization, the table starts to freeze. I think we can try instead to set additional settings on the virtualization options such as increasing overscanRowCount to improve the experience when scrolling to fewer items and also adding a style for rows that are being loaded while scrolling so we don't show just a blank while scrolling (like on this example), WDYT? |
/* | ||
Hook for managing common table state and methods for the Cloud Posture DataTable | ||
*/ | ||
export const useCloudPostureDataTable = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hook was created from the use_cloud_posture_table
and it will replace it as we aim to remove old code in future PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple of nit comments and a couple of things to check:
- let's check if the non-recoverable error is specific to this pr or is it serverless-specific. If it's introduced in this PR, let's fix it
- I'd add some unit tests to the shared library, at least to cover changes introduced by this PR
setSelectedGroups(['none']); | ||
} else { | ||
setSelectedGroups(groups); | ||
// Simulate a toggle behavior when maxGroupingLevels is 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think kbn-securitysolution-grouping
lib would benefit from having some unit tests. As it didn't have any, I wouldn't block this PR on that, but I'd vote for adding some of the tests which are testing your changes to the lib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
kbn-securitysolution-grouping
lib would benefit from having some unit tests. As it didn't have any...
@maxcold Why do you think there are not unit tests? We do have tests that should have been added to :
packages/kbn-securitysolution-grouping/src/components/group_selector/index.test.tsx
packages/kbn-securitysolution-grouping/src/hooks/use_get_group_selector.test.tsx
Please add unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephmilovic totally my bad, I have no idea where I looked tbh, but I remember checking the codebase in my code editor and not finding the unit test files. Some kind of a blackout from my side I guess :) for sure we need to cover new cases with unit tests
size: pageSize, | ||
}); | ||
|
||
export const useBaseEsQuery = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move it to own hook file? not really a util
}: CloudSecurityGroupingProps) => { | ||
return ( | ||
<div | ||
data-test-subj="cloudSecurityGrouping" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move it to TEST_SUBJECTS constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'm going to address those neats in the next PR
setSelectedGroups(groups); | ||
// Simulate a toggle behavior when maxGroupingLevels is 1 | ||
if (maxGroupingLevels === 1) { | ||
setSelectedGroups([groupSelection]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks to be the only untested condition here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test added 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before merging, please add a few unit tests for the code changes in kbn-securitysolution-grouping
. LGTM other than that. Thanks for the improvements
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Canvas Sharable Runtime
Public APIs missing exports
Page load bundle
Unknown metric groupsmiscellaneous assets size
History
To update your PR or re-run it, just comment with: |
…72256) ## Summary This PR adds custom rendering for each of the default Grouping visualizations: - #168543 - #169043 - #169044 - #169045 **It also adds:** - Fix error handling (follow up from [this comment](#169884 (comment))) - Change the Findings page to have the Misconfiguration tab in the first position. - Added `size` property to the `ComplianceScoreBar` component - Custom message for groups that don't have value (ex. No Cloud accounts) - Changed the sort order of grouping components to be based on the compliance score - Added compliance score for custom renderers ### Screenshot Resource <img width="1492" alt="image" src="https://github.com/elastic/kibana/assets/19270322/596f8bdb-abcc-4325-8512-23c919c727a9"> Rule name <img width="1489" alt="image" src="https://github.com/elastic/kibana/assets/19270322/787138e3-b3b2-4e15-811a-84c583831469"> Cloud account <img width="1490" alt="image" src="https://github.com/elastic/kibana/assets/19270322/9a48145d-dba5-4eda-bd7d-a97ed8f78a2d"> <img width="1492" alt="image" src="https://github.com/elastic/kibana/assets/19270322/399d0be0-4bc0-4090-ac20-e4b016cc4be5"> Kubernetes <img width="1499" alt="image" src="https://github.com/elastic/kibana/assets/19270322/3745498a-969a-4769-b4ae-3c932511a5a9"> Custom field: <img width="1488" alt="image" src="https://github.com/elastic/kibana/assets/19270322/8c75535d-2248-4cf9-b1cb-9b0d318114e9"> --------- Co-authored-by: kibanamachine <[email protected]>
Summary
It closes #168542
This PR introduces a new Grouping feature to the Findings page as described in #168542. It uses the Grouping component from the
@kbn/securitysolution-grouping
package abstracts all common code related to tables across our solutions.Changes included
@kbn/securitysolution-grouping:
Findings page
nonPersistedFilter
to combine the group by filter with the Url Params filtering)Dashboard
Out of scope (not included)
Screenshot
Recordings
Screen.Recording.2023-11-15.at.12.05.31.AM.mov
Screen.Recording.2023-11-15.at.12.06.52.AM.mov