Skip to content

Commit

Permalink
[8.x] [Cloud Security] add vulnerabilties data set to filter for link…
Browse files Browse the repository at this point in the history
…s from CNVM dashboard (#197648) (#198140)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Cloud Security] add vulnerabilties data set to filter for links from
CNVM dashboard (#197648)](#197648)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Maxim
Kholod","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-29T10:53:23Z","message":"[Cloud
Security] add vulnerabilties data set to filter for links from CNVM
dashboard (#197648)\n\n## Summary\r\n\r\n- fixes
https://github.com/elastic/security-team/issues/10915","sha":"b4ed7a1945f5ea5b76be36833cdf11e28641cf8f","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud
Security","backport:prev-minor","v8.16.0","backport:version","v8.17.0"],"title":"[Cloud
Security] add vulnerabilties data set to filter for links from CNVM
dashboard","number":197648,"url":"https://github.com/elastic/kibana/pull/197648","mergeCommit":{"message":"[Cloud
Security] add vulnerabilties data set to filter for links from CNVM
dashboard (#197648)\n\n## Summary\r\n\r\n- fixes
https://github.com/elastic/security-team/issues/10915","sha":"b4ed7a1945f5ea5b76be36833cdf11e28641cf8f"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197648","number":197648,"mergeCommit":{"message":"[Cloud
Security] add vulnerabilties data set to filter for links from CNVM
dashboard (#197648)\n\n## Summary\r\n\r\n- fixes
https://github.com/elastic/security-team/issues/10915","sha":"b4ed7a1945f5ea5b76be36833cdf11e28641cf8f"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Maxim Kholod <[email protected]>
  • Loading branch information
kibanamachine and maxcold authored Oct 30, 2024
1 parent e26e003 commit 43626cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,17 @@ export const useNavigateFindings = () => {

export const useNavigateVulnerabilities = () =>
useNavigate(findingsNavigation.vulnerabilities.path);

export const useNavigateNativeVulnerabilities = () => {
const navToVulnerabilities = useNavigateVulnerabilities();

return useCallback(
(filterParams: NavFilter = {}, groupBy?: string[]) => {
navToVulnerabilities(
{ ...filterParams, 'data_stream.dataset': 'cloud_security_posture.vulnerabilities' },
groupBy
);
},
[navToVulnerabilities]
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import React, { useMemo } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiHealth } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useNavigateVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { useNavigateNativeVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { VULNERABILITIES_SEVERITY } from '@kbn/cloud-security-posture-common';
import { getSeverityStatusColor } from '@kbn/cloud-security-posture';
import { VulnCounterCard, type VulnCounterCardProps } from '../../components/vuln_counter_card';
import { useVulnerabilityDashboardApi } from '../../common/api/use_vulnerability_dashboard_api';
import { CompactFormattedNumber } from '../../components/compact_formatted_number';

export const VulnerabilityStatistics = () => {
const navToVulnerabilities = useNavigateVulnerabilities();
const navToVulnerabilities = useNavigateNativeVulnerabilities();
const getVulnerabilityDashboard = useVulnerabilityDashboardApi();

const stats: VulnCounterCardProps[] = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { NavFilter } from '@kbn/cloud-security-posture/src/utils/query_utils';
import { useNavigateVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { useNavigateNativeVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import type { VulnSeverity } from '@kbn/cloud-security-posture-common';
import { CVSScoreBadge, SeverityStatusBadge } from '@kbn/cloud-security-posture';
import {
Expand All @@ -33,7 +33,7 @@ import { VULNERABILITY_GROUPING_OPTIONS, VULNERABILITY_FIELDS } from '../../comm
export const VulnerabilityTablePanelSection = () => {
const getVulnerabilityDashboard = useVulnerabilityDashboardApi();
const { euiTheme } = useEuiTheme();
const navToVulnerabilities = useNavigateVulnerabilities();
const navToVulnerabilities = useNavigateNativeVulnerabilities();

const onCellClick = useCallback(
(filters: NavFilter) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { EuiButton, EuiComboBox } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';

import { useNavigateVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { useNavigateNativeVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import type { VulnSeverity } from '@kbn/cloud-security-posture-common';
import { VULNERABILITIES_SEVERITY } from '@kbn/cloud-security-posture-common';
import { getSeverityStatusColor } from '@kbn/cloud-security-posture';
Expand Down Expand Up @@ -50,7 +50,7 @@ const theme: PartialTheme = {
};

const ViewAllButton = () => {
const navToVulnerabilities = useNavigateVulnerabilities();
const navToVulnerabilities = useNavigateNativeVulnerabilities();

return (
<EuiButton onClick={() => navToVulnerabilities()} size="s">
Expand Down

0 comments on commit 43626cf

Please sign in to comment.