-
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] fix incorrect number of groups when there is a null group #207360
Conversation
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security) |
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.
LGTM, worth adding a test case before merging
@JordanSh yes, ill add, just wanted to let the CI pipeline start running to see if there are any issues. |
Next time you can open the PR in draft, a gh bot will allow you to run the pipeline by ticking some boxes. |
b6a42d6
to
fb2fec0
Compare
@alexreal1314 do we have the same issue with Vulnerabilities in |
thanks, I'll check it. |
fb2fec0
to
c7e47b5
Compare
@maxcold added same logic for vulnerabilities page as well. |
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.
Left a comment, the rest LGTM! 🙂
@@ -103,13 +103,10 @@ const GroupingComponent = <T,>({ | |||
|
|||
const groupCount = useMemo(() => data?.groupsCount?.value ?? 0, [data?.groupsCount?.value]); | |||
const groupCountText = useMemo(() => { | |||
const hasNullGroup = | |||
data?.groupByFields?.buckets?.some( |
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.
@alexreal1314 do you mind if we keep this old condition ||
'ed with the new one? We're currently not using it in the printed text, but it feels wrong to only take into account nullGroupItems
since other grouping users rely on this condition to detect null groups
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.
@umbopepato fixed. also added more test cases to check it
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.
Awesome, thanks! 😊
Hi @alexreal1314, I noticed the fix works only for pre-defined groups, such as Cloud Account ID, Resource ID, Rule name and Kubernetes cluster ID. Would it be possible to include the fix for the custom field option as well? Screen.Recording.2025-01-23.at.1.01.43.AM.movfeel free to address that in a separate PR in case the fix is not straightforward |
Hi @opauloh thanks for letting me know, I see that when grouping custom fields it uses the totalCount instead of calculated groupsCounted, this is your change as far as I see, is there any reason for that? |
thanks for spotting this, my only guess is that was a product requirement from the beginning that the "null group" also count as a "group" for custom fields groupings. cc @smriti0321 could you confirm what should be the correct behavior for counting custom fields? |
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.
lgtm!
@opauloh The grouping behaviour including counting for custom and pre defined grouping fields should be consistent. |
a253aec
to
c7746fe
Compare
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
|
Starting backport for target branches: 8.x |
…group (elastic#207360) ## Summary This PR fixes group by logic regarding calculation of groups count when there is a null group. ## Video Recording with the fix https://github.com/user-attachments/assets/14e82bf3-b8d3-4287-8f90-04372be23cf2 ## BUG description The checking of null group is scoped to the findings on a specific page, for example if we have two pages and the null group appears on the second page the number of groups will not be correct on the first page because the null group of was subtracted from the total number of groups. On the second page the number is correct because the null group was fetched in the second page. ### Closes - elastic#188138 ### Definition of done - [x] number of groups should be correct across all pages ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) (cherry picked from commit a5051b4)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
… null group (#207360) (#208070) # Backport This will backport the following commits from `main` to `8.x`: - [[Cloud Security] fix incorrect number of groups when there is a null group (#207360)](#207360) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Alex Prozorov","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-23T14:47:05Z","message":"[Cloud Security] fix incorrect number of groups when there is a null group (#207360)\n\n## Summary\r\nThis PR fixes group by logic regarding calculation of groups count when\r\nthere is a null group.\r\n\r\n## Video Recording with the fix\r\n\r\nhttps://github.com/user-attachments/assets/14e82bf3-b8d3-4287-8f90-04372be23cf2\r\n\r\n## BUG description\r\nThe checking of null group is scoped to the findings on a specific page,\r\nfor example if we have two pages and the null group appears on the\r\nsecond page the number of groups will not be correct on the first page\r\nbecause the null group of was subtracted from the total number of\r\ngroups. On the second page the number is correct because the null group\r\nwas fetched in the second page.\r\n\r\n### Closes\r\n- https://github.com/elastic/kibana/issues/188138\r\n\r\n### Definition of done\r\n- [x] number of groups should be correct across all pages\r\n\r\n### Checklist\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct release_note:* label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"a5051b48a9d1af6f2caae747a2ee2af0e5ccf0df","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","good first issue","release_note:skip","v9.0.0","Team:Cloud Security","backport:prev-minor"],"title":"[Cloud Security] fix incorrect number of groups when there is a null group","number":207360,"url":"https://github.com/elastic/kibana/pull/207360","mergeCommit":{"message":"[Cloud Security] fix incorrect number of groups when there is a null group (#207360)\n\n## Summary\r\nThis PR fixes group by logic regarding calculation of groups count when\r\nthere is a null group.\r\n\r\n## Video Recording with the fix\r\n\r\nhttps://github.com/user-attachments/assets/14e82bf3-b8d3-4287-8f90-04372be23cf2\r\n\r\n## BUG description\r\nThe checking of null group is scoped to the findings on a specific page,\r\nfor example if we have two pages and the null group appears on the\r\nsecond page the number of groups will not be correct on the first page\r\nbecause the null group of was subtracted from the total number of\r\ngroups. On the second page the number is correct because the null group\r\nwas fetched in the second page.\r\n\r\n### Closes\r\n- https://github.com/elastic/kibana/issues/188138\r\n\r\n### Definition of done\r\n- [x] number of groups should be correct across all pages\r\n\r\n### Checklist\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct release_note:* label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"a5051b48a9d1af6f2caae747a2ee2af0e5ccf0df"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/207360","number":207360,"mergeCommit":{"message":"[Cloud Security] fix incorrect number of groups when there is a null group (#207360)\n\n## Summary\r\nThis PR fixes group by logic regarding calculation of groups count when\r\nthere is a null group.\r\n\r\n## Video Recording with the fix\r\n\r\nhttps://github.com/user-attachments/assets/14e82bf3-b8d3-4287-8f90-04372be23cf2\r\n\r\n## BUG description\r\nThe checking of null group is scoped to the findings on a specific page,\r\nfor example if we have two pages and the null group appears on the\r\nsecond page the number of groups will not be correct on the first page\r\nbecause the null group of was subtracted from the total number of\r\ngroups. On the second page the number is correct because the null group\r\nwas fetched in the second page.\r\n\r\n### Closes\r\n- https://github.com/elastic/kibana/issues/188138\r\n\r\n### Definition of done\r\n- [x] number of groups should be correct across all pages\r\n\r\n### Checklist\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct release_note:* label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"a5051b48a9d1af6f2caae747a2ee2af0e5ccf0df"}}]}] BACKPORT--> Co-authored-by: Alex Prozorov <[email protected]>
…group (elastic#207360) ## Summary This PR fixes group by logic regarding calculation of groups count when there is a null group. ## Video Recording with the fix https://github.com/user-attachments/assets/14e82bf3-b8d3-4287-8f90-04372be23cf2 ## BUG description The checking of null group is scoped to the findings on a specific page, for example if we have two pages and the null group appears on the second page the number of groups will not be correct on the first page because the null group of was subtracted from the total number of groups. On the second page the number is correct because the null group was fetched in the second page. ### Closes - elastic#188138 ### Definition of done - [x] number of groups should be correct across all pages ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
…group (elastic#207360) ## Summary This PR fixes group by logic regarding calculation of groups count when there is a null group. ## Video Recording with the fix https://github.com/user-attachments/assets/14e82bf3-b8d3-4287-8f90-04372be23cf2 ## BUG description The checking of null group is scoped to the findings on a specific page, for example if we have two pages and the null group appears on the second page the number of groups will not be correct on the first page because the null group of was subtracted from the total number of groups. On the second page the number is correct because the null group was fetched in the second page. ### Closes - elastic#188138 ### Definition of done - [x] number of groups should be correct across all pages ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
…group (elastic#207360) ## Summary This PR fixes group by logic regarding calculation of groups count when there is a null group. ## Video Recording with the fix https://github.com/user-attachments/assets/14e82bf3-b8d3-4287-8f90-04372be23cf2 ## BUG description The checking of null group is scoped to the findings on a specific page, for example if we have two pages and the null group appears on the second page the number of groups will not be correct on the first page because the null group of was subtracted from the total number of groups. On the second page the number is correct because the null group was fetched in the second page. ### Closes - elastic#188138 ### Definition of done - [x] number of groups should be correct across all pages ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Summary
This PR fixes group by logic regarding calculation of groups count when there is a null group.
Video Recording with the fix
Screen.Recording.2025-01-21.at.18.06.49.mov
BUG description
The checking of null group is scoped to the findings on a specific page, for example if we have two pages and the null group appears on the second page the number of groups will not be correct on the first page because the null group of was subtracted from the total number of groups. On the second page the number is correct because the null group was fetched in the second page.
Closes
Definition of done
Checklist