-
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] Refactor Contextual Flyout #200291
[Cloud Security] Refactor Contextual Flyout #200291
Conversation
/ci |
/ci |
/ci |
1 similar comment
/ci |
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 from Entity Analytics
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi !, yes this is to fix a small bug that I found when refactoring the code
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useVulnerabilitiesPreview doesnt use the ignore_unavailable field so it should have no effect
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
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 |
## 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 <[email protected]> Co-authored-by: Maxim Kholod <[email protected]> (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":"[email protected]"},"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 <[email protected]>\r\nCo-authored-by: Maxim Kholod <[email protected]>","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 <[email protected]>\r\nCo-authored-by: Maxim Kholod <[email protected]>","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 <[email protected]>\r\nCo-authored-by: Maxim Kholod <[email protected]>","sha":"c842db549ac55238499d63033f046d744ee18ba1"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Rickyanto Ang <[email protected]>
## 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 <[email protected]> Co-authored-by: Maxim Kholod <[email protected]>
## 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 <[email protected]> Co-authored-by: Maxim Kholod <[email protected]>
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