-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
# 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]>
- Loading branch information
1 parent
b42ac29
commit 4175ab6
Showing
21 changed files
with
360 additions
and
463 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
x-pack/packages/kbn-cloud-security-posture/public/src/hooks/use_has_misconfigurations.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { buildEntityFlyoutPreviewQuery } from '@kbn/cloud-security-posture-common'; | ||
import { useMisconfigurationPreview } from './use_misconfiguration_preview'; | ||
|
||
export const useHasMisconfigurations = (field: 'host.name' | 'user.name', value: string) => { | ||
const { data } = useMisconfigurationPreview({ | ||
query: buildEntityFlyoutPreviewQuery(field, value), | ||
sort: [], | ||
enabled: true, | ||
pageSize: 1, | ||
}); | ||
|
||
const passedFindings = data?.count.passed || 0; | ||
const failedFindings = data?.count.failed || 0; | ||
|
||
const hasMisconfigurationFindings = passedFindings > 0 || failedFindings > 0; | ||
|
||
return { | ||
passedFindings, | ||
failedFindings, | ||
hasMisconfigurationFindings, | ||
}; | ||
}; |
39 changes: 39 additions & 0 deletions
39
x-pack/packages/kbn-cloud-security-posture/public/src/hooks/use_has_vulnerabilities.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { buildEntityFlyoutPreviewQuery } from '@kbn/cloud-security-posture-common'; | ||
import { useVulnerabilitiesPreview } from './use_vulnerabilities_preview'; | ||
import { hasVulnerabilitiesData } from '../utils/vulnerability_helpers'; | ||
|
||
export const useHasVulnerabilities = (field: 'host.name' | 'user.name', value: string) => { | ||
const { data: vulnerabilitiesData } = useVulnerabilitiesPreview({ | ||
query: buildEntityFlyoutPreviewQuery(field, value), | ||
sort: [], | ||
enabled: true, | ||
pageSize: 1, | ||
}); | ||
|
||
const { | ||
CRITICAL = 0, | ||
HIGH = 0, | ||
MEDIUM = 0, | ||
LOW = 0, | ||
NONE = 0, | ||
} = vulnerabilitiesData?.count || {}; | ||
|
||
const counts = { | ||
critical: CRITICAL, | ||
high: HIGH, | ||
medium: MEDIUM, | ||
low: LOW, | ||
none: NONE, | ||
}; | ||
|
||
const hasVulnerabilitiesFindings = hasVulnerabilitiesData(counts); | ||
|
||
return { counts, hasVulnerabilitiesFindings }; | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.