mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[8.16] [Cloud Security] Clicking on Contextual Flyout popout Icon now opens page in new tab (#196763) (#197934)
# Backport This will backport the following commits from `main` to `8.16`: - [[Cloud Security] Clicking on Contextual Flyout popout Icon now opens page in new tab (#196763)](https://github.com/elastic/kibana/pull/196763) <!--- 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-10-27T16:47:01Z","message":"[Cloud Security] Clicking on Contextual Flyout popout Icon now opens page in new tab (#196763)\n\n## Summary\r\n\r\nCurrently when user clicks on Popout icon on Misconfiguration or\r\nVulnerabilities Contextual flyout, user gets redirected to Findings page\r\nbut in the same tab. Popout Icon implies that it should navigate user to\r\nother page on separate Tabs as such the current behaviour is not right.\r\n\r\nThis PR addresses that issue\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"37a4691ab6b33886b20126b54120f37002f26125","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"],"title":"[Cloud Security] Clicking on Contextual Flyout popout Icon now opens page in new tab","number":196763,"url":"https://github.com/elastic/kibana/pull/196763","mergeCommit":{"message":"[Cloud Security] Clicking on Contextual Flyout popout Icon now opens page in new tab (#196763)\n\n## Summary\r\n\r\nCurrently when user clicks on Popout icon on Misconfiguration or\r\nVulnerabilities Contextual flyout, user gets redirected to Findings page\r\nbut in the same tab. Popout Icon implies that it should navigate user to\r\nother page on separate Tabs as such the current behaviour is not right.\r\n\r\nThis PR addresses that issue\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"37a4691ab6b33886b20126b54120f37002f26125"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196763","number":196763,"mergeCommit":{"message":"[Cloud Security] Clicking on Contextual Flyout popout Icon now opens page in new tab (#196763)\n\n## Summary\r\n\r\nCurrently when user clicks on Popout icon on Misconfiguration or\r\nVulnerabilities Contextual flyout, user gets redirected to Findings page\r\nbut in the same tab. Popout Icon implies that it should navigate user to\r\nother page on separate Tabs as such the current behaviour is not right.\r\n\r\nThis PR addresses that issue\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"37a4691ab6b33886b20126b54120f37002f26125"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Rickyanto Ang <rickyangwyn@gmail.com>
This commit is contained in:
parent
bfc8ec8ea7
commit
7f52ae8d6a
11 changed files with 280 additions and 96 deletions
|
@ -8,7 +8,7 @@
|
|||
export * from './src/types';
|
||||
export * from './src/constants/component_constants';
|
||||
export * from './src/constants/navigation';
|
||||
export type { NavFilter } from './src/hooks/use_navigate_findings';
|
||||
export type { NavFilter } from './src/utils/query_utils';
|
||||
export { showErrorToast } from './src/utils/show_error_toast';
|
||||
export { encodeQuery, decodeQuery } from './src/utils/query_utils';
|
||||
export { CspEvaluationBadge } from './src/components/csp_evaluation_badge';
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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 { CoreStart } from '@kbn/core-lifecycle-browser';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { useCallback } from 'react';
|
||||
import { CspClientPluginStartDeps } from '../types';
|
||||
import { NavFilter, encodeQueryUrl, composeQueryFilters } from '../utils/query_utils';
|
||||
|
||||
export const useGetNavigationUrlParams = () => {
|
||||
const { services } = useKibana<CoreStart & CspClientPluginStartDeps>();
|
||||
|
||||
const getNavUrlParams = useCallback(
|
||||
(
|
||||
filterParams: NavFilter = {},
|
||||
findingsType?: 'configurations' | 'vulnerabilities',
|
||||
groupBy?: string[]
|
||||
) => {
|
||||
const filters = composeQueryFilters(filterParams);
|
||||
|
||||
const searchParams = new URLSearchParams(encodeQueryUrl(services.data, filters, groupBy));
|
||||
|
||||
return `${findingsType ? findingsType : ''}?${searchParams.toString()}`;
|
||||
},
|
||||
[services.data]
|
||||
);
|
||||
|
||||
return getNavUrlParams;
|
||||
};
|
|
@ -7,74 +7,28 @@
|
|||
|
||||
import { useCallback } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { Filter } from '@kbn/es-query';
|
||||
import {
|
||||
SECURITY_DEFAULT_DATA_VIEW_ID,
|
||||
CDR_MISCONFIGURATIONS_DATA_VIEW_ID_PREFIX,
|
||||
} from '@kbn/cloud-security-posture-common';
|
||||
import { CDR_MISCONFIGURATIONS_DATA_VIEW_ID_PREFIX } from '@kbn/cloud-security-posture-common';
|
||||
import type { CoreStart } from '@kbn/core/public';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { findingsNavigation } from '../constants/navigation';
|
||||
import { useDataView } from './use_data_view';
|
||||
import { CspClientPluginStartDeps } from '../..';
|
||||
import { encodeQuery } from '../utils/query_utils';
|
||||
import { NavFilter, encodeQueryUrl, composeQueryFilters } from '../utils/query_utils';
|
||||
|
||||
interface NegatedValue {
|
||||
value: string | number;
|
||||
negate: boolean;
|
||||
}
|
||||
|
||||
type FilterValue = string | number | NegatedValue;
|
||||
|
||||
export type NavFilter = Record<string, FilterValue>;
|
||||
|
||||
const createFilter = (key: string, filterValue: FilterValue, dataViewId: string): Filter => {
|
||||
let negate = false;
|
||||
let value = filterValue;
|
||||
if (typeof filterValue === 'object') {
|
||||
negate = filterValue.negate;
|
||||
value = filterValue.value;
|
||||
}
|
||||
// If the value is '*', we want to create an exists filter
|
||||
if (value === '*') {
|
||||
return {
|
||||
query: { exists: { field: key } },
|
||||
meta: { type: 'exists', index: dataViewId },
|
||||
};
|
||||
}
|
||||
return {
|
||||
meta: {
|
||||
alias: null,
|
||||
negate,
|
||||
disabled: false,
|
||||
type: 'phrase',
|
||||
key,
|
||||
index: dataViewId,
|
||||
},
|
||||
query: { match_phrase: { [key]: value } },
|
||||
};
|
||||
};
|
||||
const useNavigate = (pathname: string, dataViewId = SECURITY_DEFAULT_DATA_VIEW_ID) => {
|
||||
const useNavigate = (pathname: string, dataViewId?: string) => {
|
||||
const history = useHistory();
|
||||
const { services } = useKibana<CoreStart & CspClientPluginStartDeps>();
|
||||
|
||||
const { services } = useKibana<CoreStart & CspClientPluginStartDeps>();
|
||||
return useCallback(
|
||||
(filterParams: NavFilter = {}, groupBy?: string[]) => {
|
||||
const filters = Object.entries(filterParams).map(([key, filterValue]) =>
|
||||
createFilter(key, filterValue, dataViewId)
|
||||
);
|
||||
const filters = composeQueryFilters(filterParams, dataViewId);
|
||||
|
||||
history.push({
|
||||
pathname,
|
||||
search: encodeQuery({
|
||||
// Set query language from user's preference
|
||||
query: services.data.query.queryString.getDefaultQuery(),
|
||||
filters,
|
||||
...(groupBy && { groupBy }),
|
||||
}),
|
||||
search: encodeQueryUrl(services.data, filters, groupBy),
|
||||
});
|
||||
},
|
||||
[history, pathname, services.data.query.queryString, dataViewId]
|
||||
[dataViewId, history, pathname, services.data]
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* 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 { encodeQueryUrl, composeQueryFilters } from './query_utils';
|
||||
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
|
||||
|
||||
const DEFAULT_DATA_VIEW_ID = 'security-solution-default';
|
||||
|
||||
describe('composeQueryFilters', () => {
|
||||
it('Should return correct filters given some filterParams', () => {
|
||||
const testFilterParams = {
|
||||
test_field: 'test_value',
|
||||
};
|
||||
const testResult = [
|
||||
{
|
||||
meta: {
|
||||
alias: null,
|
||||
negate: false,
|
||||
disabled: false,
|
||||
type: 'phrase',
|
||||
key: 'test_field',
|
||||
index: DEFAULT_DATA_VIEW_ID,
|
||||
},
|
||||
query: { match_phrase: { test_field: 'test_value' } },
|
||||
},
|
||||
];
|
||||
expect(composeQueryFilters(testFilterParams)).toEqual(testResult);
|
||||
});
|
||||
|
||||
it('Should return empty filters given empty filterParams', () => {
|
||||
expect(composeQueryFilters({})).toEqual([]);
|
||||
});
|
||||
|
||||
it('Should return correct filters given some filterParams and dataviewId', () => {
|
||||
const testFilterParams = {
|
||||
test_field: 'test_value',
|
||||
};
|
||||
const testResult = [
|
||||
{
|
||||
meta: {
|
||||
alias: null,
|
||||
negate: false,
|
||||
disabled: false,
|
||||
type: 'phrase',
|
||||
key: 'test_field',
|
||||
index: 'test-data-view',
|
||||
},
|
||||
query: { match_phrase: { test_field: 'test_value' } },
|
||||
},
|
||||
];
|
||||
expect(composeQueryFilters(testFilterParams, 'test-data-view')).toEqual(testResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe('encodeQueryUrl', () => {
|
||||
const getServicesMock = () => ({
|
||||
data: dataPluginMock.createStartContract(),
|
||||
});
|
||||
|
||||
it('Should return correct URL given empty filters', () => {
|
||||
const result = 'cspq=(filters:!())';
|
||||
expect(encodeQueryUrl(getServicesMock().data, [])).toEqual(result);
|
||||
});
|
||||
|
||||
it('should return correct URL given filters', () => {
|
||||
const filter = [
|
||||
{
|
||||
meta: {
|
||||
alias: null,
|
||||
negate: false,
|
||||
disabled: false,
|
||||
type: 'phrase',
|
||||
key: 'test_field',
|
||||
index: DEFAULT_DATA_VIEW_ID,
|
||||
},
|
||||
query: { match_phrase: { test_field: 'test_value' } },
|
||||
},
|
||||
];
|
||||
const result =
|
||||
'cspq=(filters:!((meta:(alias:!n,disabled:!f,index:security-solution-default,key:test_field,negate:!f,type:phrase),query:(match_phrase:(test_field:test_value)))))';
|
||||
expect(encodeQueryUrl(getServicesMock().data, filter)).toEqual(result);
|
||||
});
|
||||
|
||||
it('should return correct URL given filters and group by', () => {
|
||||
const filter = [
|
||||
{
|
||||
meta: {
|
||||
alias: null,
|
||||
negate: false,
|
||||
disabled: false,
|
||||
type: 'phrase',
|
||||
key: 'test_field',
|
||||
index: DEFAULT_DATA_VIEW_ID,
|
||||
},
|
||||
query: { match_phrase: { test_field: 'test_value' } },
|
||||
},
|
||||
];
|
||||
const groupByFilter = ['filterA'];
|
||||
const result =
|
||||
'cspq=(filters:!((meta:(alias:!n,disabled:!f,index:security-solution-default,key:test_field,negate:!f,type:phrase),query:(match_phrase:(test_field:test_value)))),groupBy:!(filterA))';
|
||||
expect(encodeQueryUrl(getServicesMock().data, filter, groupByFilter)).toEqual(result);
|
||||
});
|
||||
});
|
|
@ -4,8 +4,21 @@
|
|||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { encode, decode } from '@kbn/rison';
|
||||
import type { LocationDescriptorObject } from 'history';
|
||||
import { Filter } from '@kbn/es-query';
|
||||
import { SECURITY_DEFAULT_DATA_VIEW_ID } from '@kbn/cloud-security-posture-common';
|
||||
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
|
||||
interface NegatedValue {
|
||||
value: string | number;
|
||||
negate: boolean;
|
||||
}
|
||||
|
||||
type FilterValue = string | number | NegatedValue;
|
||||
|
||||
export type NavFilter = Record<string, FilterValue>;
|
||||
|
||||
const encodeRison = (v: any): string | undefined => {
|
||||
try {
|
||||
|
@ -38,3 +51,52 @@ export const decodeQuery = <T extends unknown>(search?: string): Partial<T> | un
|
|||
if (!risonQuery) return;
|
||||
return decodeRison<T>(risonQuery);
|
||||
};
|
||||
|
||||
export const encodeQueryUrl = (
|
||||
servicesStart: DataPublicPluginStart,
|
||||
filters: Filter[],
|
||||
groupBy?: string[]
|
||||
): any => {
|
||||
return encodeQuery({
|
||||
query: servicesStart.query.queryString.getDefaultQuery(),
|
||||
filters,
|
||||
...(groupBy && { groupBy }),
|
||||
});
|
||||
};
|
||||
|
||||
// dataViewId is used to prevent FilterManager from falling back to the default in the sorcerer (logs-*)
|
||||
export const composeQueryFilters = (
|
||||
filterParams: NavFilter = {},
|
||||
dataViewId = SECURITY_DEFAULT_DATA_VIEW_ID
|
||||
): Filter[] => {
|
||||
return Object.entries(filterParams).map(([key, filterValue]) =>
|
||||
createFilter(key, filterValue, dataViewId)
|
||||
);
|
||||
};
|
||||
|
||||
export const createFilter = (key: string, filterValue: FilterValue, dataViewId: string): Filter => {
|
||||
let negate = false;
|
||||
let value = filterValue;
|
||||
if (typeof filterValue === 'object') {
|
||||
negate = filterValue.negate;
|
||||
value = filterValue.value;
|
||||
}
|
||||
// If the value is '*', we want to create an exists filter
|
||||
if (value === '*') {
|
||||
return {
|
||||
query: { exists: { field: key } },
|
||||
meta: { type: 'exists', index: dataViewId },
|
||||
};
|
||||
}
|
||||
return {
|
||||
meta: {
|
||||
alias: null,
|
||||
negate,
|
||||
disabled: false,
|
||||
type: 'phrase',
|
||||
key,
|
||||
index: dataViewId,
|
||||
},
|
||||
query: { match_phrase: { [key]: value } },
|
||||
};
|
||||
};
|
||||
|
|
|
@ -35,5 +35,6 @@
|
|||
"@kbn/ui-theme",
|
||||
"@kbn/i18n-react",
|
||||
"@kbn/rison",
|
||||
"@kbn/core-lifecycle-browser",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
|
|||
import { css } from '@emotion/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { useNavigateFindings } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
|
||||
import type { NavFilter } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
|
||||
import type { NavFilter } from '@kbn/cloud-security-posture/src/utils/query_utils';
|
||||
import type {
|
||||
BenchmarkData,
|
||||
ComplianceDashboardDataV2,
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { css } from '@emotion/react';
|
||||
import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common';
|
||||
import type { NavFilter } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
|
||||
import type { NavFilter } from '@kbn/cloud-security-posture/src/utils/query_utils';
|
||||
import { useNavigateFindings } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
|
||||
import { useCspIntegrationLink } from '../../../common/navigation/use_csp_integration_link';
|
||||
import { DASHBOARD_COUNTER_CARDS, DASHBOARD_SUMMARY_CONTAINER } from '../test_subjects';
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
useEuiTheme,
|
||||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { NavFilter } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
|
||||
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 type { VulnSeverity } from '@kbn/cloud-security-posture-common';
|
||||
import { CVSScoreBadge, SeverityStatusBadge } from '@kbn/cloud-security-posture';
|
||||
|
|
|
@ -7,14 +7,13 @@
|
|||
|
||||
import React, { memo, useEffect, useState } from 'react';
|
||||
import type { Criteria, EuiBasicTableColumn } from '@elastic/eui';
|
||||
import { EuiSpacer, EuiIcon, EuiPanel, EuiLink, EuiText, EuiBasicTable } from '@elastic/eui';
|
||||
import { EuiSpacer, EuiPanel, EuiText, EuiBasicTable, EuiIcon } from '@elastic/eui';
|
||||
import { useMisconfigurationFindings } from '@kbn/cloud-security-posture/src/hooks/use_misconfiguration_findings';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { CspFinding, CspFindingResult } from '@kbn/cloud-security-posture-common';
|
||||
import { buildEntityFlyoutPreviewQuery } from '@kbn/cloud-security-posture-common';
|
||||
import { euiThemeVars } from '@kbn/ui-theme';
|
||||
import { DistributionBar } from '@kbn/security-solution-distribution-bar';
|
||||
import { useNavigateFindings } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
|
||||
import type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common/schema/rules/latest';
|
||||
import { CspEvaluationBadge } from '@kbn/cloud-security-posture';
|
||||
import {
|
||||
|
@ -24,6 +23,9 @@ import {
|
|||
uiMetricService,
|
||||
} from '@kbn/cloud-security-posture-common/utils/ui_metrics';
|
||||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
import { useGetNavigationUrlParams } from '@kbn/cloud-security-posture/src/hooks/use_get_navigation_url_params';
|
||||
import { SecurityPageName } from '@kbn/deeplinks-security';
|
||||
import { SecuritySolutionLinkAnchor } from '../../../common/components/links';
|
||||
|
||||
type MisconfigurationFindingDetailFields = Pick<CspFinding, 'result' | 'rule' | 'resource'>;
|
||||
|
||||
|
@ -114,18 +116,14 @@ export const MisconfigurationFindingsDetailsTable = memo(
|
|||
}
|
||||
};
|
||||
|
||||
const navToFindings = useNavigateFindings();
|
||||
const getNavUrlParams = useGetNavigationUrlParams();
|
||||
|
||||
const navToFindingsByRuleAndResourceId = (ruleId: string, resourceId: string) => {
|
||||
navToFindings({ 'rule.id': ruleId, 'resource.id': resourceId });
|
||||
const getFindingsPageUrlFilteredByRuleAndResourceId = (ruleId: string, resourceId: string) => {
|
||||
return getNavUrlParams({ 'rule.id': ruleId, 'resource.id': resourceId }, 'configurations');
|
||||
};
|
||||
|
||||
const navToFindingsByName = (name: string, queryField: 'host.name' | 'user.name') => {
|
||||
uiMetricService.trackUiMetric(
|
||||
METRIC_TYPE.CLICK,
|
||||
NAV_TO_FINDINGS_BY_RULE_NAME_FRPOM_ENTITY_FLYOUT
|
||||
);
|
||||
navToFindings({ [queryField]: name }, ['rule.name']);
|
||||
const getFindingsPageUrl = (name: string, queryField: 'host.name' | 'user.name') => {
|
||||
return getNavUrlParams({ [queryField]: name }, 'configurations', ['rule.name']);
|
||||
};
|
||||
|
||||
const columns: Array<EuiBasicTableColumn<MisconfigurationFindingDetailFields>> = [
|
||||
|
@ -134,13 +132,23 @@ export const MisconfigurationFindingsDetailsTable = memo(
|
|||
name: '',
|
||||
width: '5%',
|
||||
render: (rule: CspBenchmarkRuleMetadata, finding: MisconfigurationFindingDetailFields) => (
|
||||
<EuiLink
|
||||
<SecuritySolutionLinkAnchor
|
||||
deepLinkId={SecurityPageName.cloudSecurityPostureFindings}
|
||||
path={`${getFindingsPageUrlFilteredByRuleAndResourceId(
|
||||
rule?.id,
|
||||
finding?.resource?.id
|
||||
)}`}
|
||||
target={'_blank'}
|
||||
external={false}
|
||||
onClick={() => {
|
||||
navToFindingsByRuleAndResourceId(rule?.id, finding?.resource?.id);
|
||||
uiMetricService.trackUiMetric(
|
||||
METRIC_TYPE.CLICK,
|
||||
NAV_TO_FINDINGS_BY_RULE_NAME_FRPOM_ENTITY_FLYOUT
|
||||
);
|
||||
}}
|
||||
>
|
||||
<EuiIcon type={'popout'} />
|
||||
</EuiLink>
|
||||
</SecuritySolutionLinkAnchor>
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -170,13 +178,16 @@ export const MisconfigurationFindingsDetailsTable = memo(
|
|||
return (
|
||||
<>
|
||||
<EuiPanel hasShadow={false}>
|
||||
<EuiLink
|
||||
<SecuritySolutionLinkAnchor
|
||||
deepLinkId={SecurityPageName.cloudSecurityPostureFindings}
|
||||
path={`${getFindingsPageUrl(queryName, fieldName)}`}
|
||||
target={'_blank'}
|
||||
external={false}
|
||||
onClick={() => {
|
||||
uiMetricService.trackUiMetric(
|
||||
METRIC_TYPE.CLICK,
|
||||
NAV_TO_FINDINGS_BY_HOST_NAME_FRPOM_ENTITY_FLYOUT
|
||||
);
|
||||
navToFindingsByName(queryName, fieldName);
|
||||
}}
|
||||
>
|
||||
{i18n.translate(
|
||||
|
@ -186,7 +197,7 @@ export const MisconfigurationFindingsDetailsTable = memo(
|
|||
}
|
||||
)}
|
||||
<EuiIcon type={'popout'} />
|
||||
</EuiLink>
|
||||
</SecuritySolutionLinkAnchor>
|
||||
<EuiSpacer size="xl" />
|
||||
<DistributionBar stats={getFindingsStats(passedFindings, failedFindings)} />
|
||||
<EuiSpacer size="l" />
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
|
||||
import React, { memo, useEffect, useState } from 'react';
|
||||
import type { Criteria, EuiBasicTableColumn } from '@elastic/eui';
|
||||
import { EuiSpacer, EuiIcon, EuiPanel, EuiLink, EuiText, EuiBasicTable } from '@elastic/eui';
|
||||
import { EuiSpacer, EuiPanel, EuiText, EuiBasicTable, EuiIcon } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { VulnSeverity } from '@kbn/cloud-security-posture-common';
|
||||
import { buildEntityFlyoutPreviewQuery } from '@kbn/cloud-security-posture-common';
|
||||
import { DistributionBar } from '@kbn/security-solution-distribution-bar';
|
||||
import { useNavigateVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
|
||||
import { useVulnerabilitiesFindings } from '@kbn/cloud-security-posture/src/hooks/use_vulnerabilities_findings';
|
||||
import type {
|
||||
CspVulnerabilityFinding,
|
||||
|
@ -29,6 +28,9 @@ import {
|
|||
uiMetricService,
|
||||
} from '@kbn/cloud-security-posture-common/utils/ui_metrics';
|
||||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
import { SecurityPageName } from '@kbn/deeplinks-security';
|
||||
import { useGetNavigationUrlParams } from '@kbn/cloud-security-posture/src/hooks/use_get_navigation_url_params';
|
||||
import { SecuritySolutionLinkAnchor } from '../../../common/components/links';
|
||||
|
||||
type VulnerabilitiesFindingDetailFields = Pick<
|
||||
CspVulnerabilityFinding,
|
||||
|
@ -38,6 +40,7 @@ type VulnerabilitiesFindingDetailFields = Pick<
|
|||
interface VulnerabilitiesPackage extends Vulnerability {
|
||||
package: {
|
||||
name: string;
|
||||
version: string;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -94,20 +97,27 @@ export const VulnerabilitiesFindingsDetailsTable = memo(({ queryName }: { queryN
|
|||
}
|
||||
};
|
||||
|
||||
const navToVulnerabilities = useNavigateVulnerabilities();
|
||||
const getNavUrlParams = useGetNavigationUrlParams();
|
||||
|
||||
const navToVulnerabilitiesByName = (name: string, queryField: 'host.name' | 'user.name') => {
|
||||
navToVulnerabilities({ [queryField]: name });
|
||||
const getVulnerabilityUrl = (name: string, queryField: 'host.name' | 'user.name') => {
|
||||
return getNavUrlParams({ [queryField]: name }, 'vulnerabilities');
|
||||
};
|
||||
|
||||
const navToVulnerabilityByVulnerabilityAndResourceId = (
|
||||
const getVulnerabilityUrlFilteredByVulnerabilityAndResourceId = (
|
||||
vulnerabilityId: string,
|
||||
resourceId: string
|
||||
resourceId: string,
|
||||
vulnerabilityPackageName: string,
|
||||
vulnerabilityPackageVersion: string
|
||||
) => {
|
||||
navToVulnerabilities({
|
||||
'vulnerability.id': vulnerabilityId,
|
||||
'resource.id': resourceId,
|
||||
});
|
||||
return getNavUrlParams(
|
||||
{
|
||||
'vulnerability.id': vulnerabilityId,
|
||||
'resource.id': resourceId,
|
||||
'vulnerability.package.name': vulnerabilityPackageName,
|
||||
'vulnerability.package.version': vulnerabilityPackageVersion,
|
||||
},
|
||||
'vulnerabilities'
|
||||
);
|
||||
};
|
||||
|
||||
const columns: Array<EuiBasicTableColumn<VulnerabilitiesFindingDetailFields>> = [
|
||||
|
@ -119,16 +129,19 @@ export const VulnerabilitiesFindingsDetailsTable = memo(({ queryName }: { queryN
|
|||
vulnerability: VulnerabilitiesPackage,
|
||||
finding: VulnerabilitiesFindingDetailFields
|
||||
) => (
|
||||
<EuiLink
|
||||
onClick={() => {
|
||||
navToVulnerabilityByVulnerabilityAndResourceId(
|
||||
vulnerability?.id,
|
||||
finding?.resource?.id || ''
|
||||
);
|
||||
}}
|
||||
<SecuritySolutionLinkAnchor
|
||||
deepLinkId={SecurityPageName.cloudSecurityPostureFindings}
|
||||
path={`${getVulnerabilityUrlFilteredByVulnerabilityAndResourceId(
|
||||
vulnerability?.id,
|
||||
finding?.resource?.id || '',
|
||||
vulnerability?.package?.name,
|
||||
vulnerability?.package?.version
|
||||
)}`}
|
||||
target={'_blank'}
|
||||
external={false}
|
||||
>
|
||||
<EuiIcon type={'popout'} />
|
||||
</EuiLink>
|
||||
</SecuritySolutionLinkAnchor>
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -189,20 +202,23 @@ export const VulnerabilitiesFindingsDetailsTable = memo(({ queryName }: { queryN
|
|||
return (
|
||||
<>
|
||||
<EuiPanel hasShadow={false}>
|
||||
<EuiLink
|
||||
<SecuritySolutionLinkAnchor
|
||||
deepLinkId={SecurityPageName.cloudSecurityPostureFindings}
|
||||
path={`${getVulnerabilityUrl(queryName, 'host.name')}`}
|
||||
target={'_blank'}
|
||||
external={false}
|
||||
onClick={() => {
|
||||
uiMetricService.trackUiMetric(
|
||||
METRIC_TYPE.CLICK,
|
||||
NAV_TO_FINDINGS_BY_HOST_NAME_FRPOM_ENTITY_FLYOUT
|
||||
);
|
||||
navToVulnerabilitiesByName(queryName, 'host.name');
|
||||
}}
|
||||
>
|
||||
{i18n.translate('xpack.securitySolution.flyout.left.insights.vulnerability.tableTitle', {
|
||||
defaultMessage: 'Vulnerability ',
|
||||
})}
|
||||
<EuiIcon type={'popout'} />
|
||||
</EuiLink>
|
||||
</SecuritySolutionLinkAnchor>
|
||||
<EuiSpacer size="xl" />
|
||||
<DistributionBar
|
||||
stats={getVulnerabilityStats({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue