[Cloud Security] Refactor Contextual Flyout#200291
Conversation
|
/ci |
|
/ci |
|
/ci |
1 similar comment
|
/ci |
|
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security) |
tiansivive
left a comment
There was a problem hiding this comment.
LGTM from Entity Analytics
albertoblaz
left a comment
There was a problem hiding this comment.
Very nice work encapsulating a lot of repititions into these hooks. I'm still not familiar with the code and how these hooks work, but I added some comments. Feel free to disregard if they don't make sense
| signalIndexName, | ||
| queryId: `${DETECTION_RESPONSE_ALERTS_BY_STATUS_ID}HOST_NAME_RIGHT`, | ||
| const { hasNonClosedAlerts } = useNonClosedAlerts({ | ||
| fieldName: 'host.name', |
There was a problem hiding this comment.
I'd put host.name in a constant because this literal is passed down to all these hooks
| (isRiskScoreExist || | ||
| hasMisconfigurationFindings || | ||
| hasVulnerabilitiesFindings || | ||
| hasNonClosedAlerts) |
There was a problem hiding this comment.
Why are you adding hasNonClosedAlerts here? Is it fixing a bug? We should try not to mix changes of functionality in refactor PRs
There was a problem hiding this comment.
Hi !, yes this is to fix a small bug that I found when refactoring the code
There was a problem hiding this comment.
I have created a separate PR for this small fix as this PR is too big and risky to be included before FF, but this fix should be small enough and safe
There was a problem hiding this comment.
Awesome! I just approved that PR. I'd ship it separately and remove hasNonClosedAlerts from here. That way, we'll have a clean refactor-only change-set on this PR
| const { data } = useVulnerabilitiesPreview({ | ||
| query: buildEntityFlyoutPreviewQuery(fieldName, name), | ||
| sort: [], | ||
| enabled: true, | ||
| pageSize: 1, | ||
| }); |
There was a problem hiding this comment.
it seems we didn't use ignore_unavailable here, but we'll do so now with the hook. How will that affect the behavior?
There was a problem hiding this comment.
useVulnerabilitiesPreview doesnt use the ignore_unavailable field so it should have no effect
There was a problem hiding this comment.
Sorry, wrong line. I meant the other useMisconfigurationsPreview.
I saw you removed ignore_unavailable from the hook, so 👍
| const { data: dataMisconfiguration } = useMisconfigurationPreview({ | ||
| query: buildEntityFlyoutPreviewQuery('host.name', name), | ||
| sort: [], | ||
| enabled: true, | ||
| pageSize: 1, | ||
| }); |
There was a problem hiding this comment.
it seems we didn't use ignore_unavailable here, but we'll do so now with the hook. How will that affect the behavior?
There was a problem hiding this comment.
good catch, I left this one when debugging an issue, will remove it
|
You might want to add a |
x-pack/packages/kbn-cloud-security-posture/public/src/hooks/use_has_misconfigurations.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/cloud_security_posture/hooks/use_entity_insight.ts
Outdated
Show resolved
Hide resolved
...plugins/security_solution/public/cloud_security_posture/components/alerts/alerts_preview.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/cloud_security_posture/hooks/use_entity_insight.ts
Outdated
Show resolved
Hide resolved
...plugins/security_solution/public/cloud_security_posture/components/alerts/alerts_preview.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/cloud_security_posture/components/entity_insight.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/cloud_security_posture/components/entity_insight.tsx
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/cloud_security_posture/components/entity_insight.tsx
Outdated
Show resolved
Hide resolved
...olution/public/cloud_security_posture/components/vulnerabilities/vulnerabilities_preview.tsx
Outdated
Show resolved
Hide resolved
|
@albertoblaz @animehart I suggest we wait till 8.17 is branched out to have this refactoring in 8.18 to be on the safe side. Not sure if merging it in 8.17 on the day of the FF is a good idea |
maxcold
left a comment
There was a problem hiding this comment.
blocking until the 8.17 is branched out, just to be in the safe side
|
Unblocking as 8.17 has been branched out and 8.x now pointing to 8.18 |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
History
|
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/11961194600 |
## Summary This PR is for reducing code duplication by Encapsulating Hooks, Functions, constants that are used multiple times in a same manner accross multiple files --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Maxim Kholod <maxim.kholod@elastic.co> (cherry picked from commit c842db5)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `8.x`: - [[Cloud Security] Refactor Contextual Flyout (#200291)](#200291) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Rickyanto Ang","email":"rickyangwyn@gmail.com"},"sourceCommit":{"committedDate":"2024-11-21T20:33:30Z","message":"[Cloud Security] Refactor Contextual Flyout (#200291)\n\n## Summary\r\n\r\nThis PR is for reducing code duplication by Encapsulating Hooks,\r\nFunctions, constants that are used multiple times in a same manner\r\naccross multiple files\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Maxim Kholod <maxim.kholod@elastic.co>","sha":"c842db549ac55238499d63033f046d744ee18ba1","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud Security","backport:prev-minor","v8.18.0"],"title":"[Cloud Security] Refactor Contextual Flyout","number":200291,"url":"https://github.com/elastic/kibana/pull/200291","mergeCommit":{"message":"[Cloud Security] Refactor Contextual Flyout (#200291)\n\n## Summary\r\n\r\nThis PR is for reducing code duplication by Encapsulating Hooks,\r\nFunctions, constants that are used multiple times in a same manner\r\naccross multiple files\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Maxim Kholod <maxim.kholod@elastic.co>","sha":"c842db549ac55238499d63033f046d744ee18ba1"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200291","number":200291,"mergeCommit":{"message":"[Cloud Security] Refactor Contextual Flyout (#200291)\n\n## Summary\r\n\r\nThis PR is for reducing code duplication by Encapsulating Hooks,\r\nFunctions, constants that are used multiple times in a same manner\r\naccross multiple files\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Maxim Kholod <maxim.kholod@elastic.co>","sha":"c842db549ac55238499d63033f046d744ee18ba1"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Rickyanto Ang <rickyangwyn@gmail.com>
## Summary This PR is for reducing code duplication by Encapsulating Hooks, Functions, constants that are used multiple times in a same manner accross multiple files --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Maxim Kholod <maxim.kholod@elastic.co>
## Summary This PR is for reducing code duplication by Encapsulating Hooks, Functions, constants that are used multiple times in a same manner accross multiple files --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Maxim Kholod <maxim.kholod@elastic.co>
Summary
This PR is for reducing code duplication by Encapsulating Hooks, Functions, constants that are used multiple times in a same manner accross multiple files