mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Cloud Security][BugFix] Fix for loading issue when loading Dashboard (#153908)
## Summary This is a fix for issue where: - the dashboard is stuck on loading state after user installed either KSPM or CSPM - Installation Prompt for integration thats not been installed yet is not rendered - Regression on Findings page caused by Status PR Added a test to cover rendering test for CSPM or KSPM installation prompt on Dashboard page (depending on which one is not installed yet) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
dfbf21f289
commit
107f4d82f3
13 changed files with 247 additions and 111 deletions
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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 { CspSetupStatus } from '../../../common/types';
|
||||
|
||||
// Cloud Posture Management Status
|
||||
export const getCpmStatus = (cpmStatusData: CspSetupStatus | undefined) => {
|
||||
// if has findings in any of the integrations.
|
||||
const hasFindings =
|
||||
cpmStatusData?.indicesDetails[0].status === 'not-empty' ||
|
||||
cpmStatusData?.kspm.status === 'indexed' ||
|
||||
cpmStatusData?.cspm.status === 'indexed';
|
||||
|
||||
// kspm
|
||||
const hasKspmFindings =
|
||||
cpmStatusData?.kspm?.status === 'indexed' ||
|
||||
cpmStatusData?.indicesDetails[0].status === 'not-empty';
|
||||
|
||||
// cspm
|
||||
const hasCspmFindings =
|
||||
cpmStatusData?.cspm?.status === 'indexed' ||
|
||||
cpmStatusData?.indicesDetails[0].status === 'not-empty';
|
||||
|
||||
const isKspmInstalled = cpmStatusData?.kspm?.status !== 'not-installed';
|
||||
const isCspmInstalled = cpmStatusData?.cspm?.status !== 'not-installed';
|
||||
const isKspmPrivileged = cpmStatusData?.kspm?.status !== 'unprivileged';
|
||||
const isCspmPrivileged = cpmStatusData?.cspm?.status !== 'unprivileged';
|
||||
|
||||
const isCspmIntegrationInstalled = isCspmInstalled && isCspmPrivileged;
|
||||
const isKspmIntegrationInstalled = isKspmInstalled && isKspmPrivileged;
|
||||
|
||||
const isEmptyData =
|
||||
cpmStatusData?.kspm?.status === 'not-installed' &&
|
||||
cpmStatusData?.cspm?.status === 'not-installed' &&
|
||||
cpmStatusData?.indicesDetails[0].status === 'empty';
|
||||
|
||||
return {
|
||||
hasFindings,
|
||||
hasKspmFindings,
|
||||
hasCspmFindings,
|
||||
isCspmInstalled,
|
||||
isKspmInstalled,
|
||||
isKspmPrivileged,
|
||||
isCspmPrivileged,
|
||||
isCspmIntegrationInstalled,
|
||||
isKspmIntegrationInstalled,
|
||||
isEmptyData,
|
||||
};
|
||||
};
|
|
@ -38,7 +38,14 @@ describe('<CloudPosturePage />', () => {
|
|||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
status: 'success',
|
||||
data: { status: 'indexed' },
|
||||
data: {
|
||||
cspm: { status: 'indexed' },
|
||||
kspm: { status: 'indexed' },
|
||||
indicesDetails: [
|
||||
{ index: 'logs-cloud_security_posture.findings_latest-default', status: 'not-empty' },
|
||||
{ index: 'logs-cloud_security_posture.findings-default*', status: 'not-empty' },
|
||||
],
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import { useCspIntegrationLink } from '../common/navigation/use_csp_integration_
|
|||
|
||||
import noDataIllustration from '../assets/illustrations/no_data_illustration.svg';
|
||||
import { cspIntegrationDocsNavigation } from '../common/navigation/constants';
|
||||
import { getCpmStatus } from '../common/utils/get_cpm_status';
|
||||
|
||||
export const LOADING_STATE_TEST_SUBJECT = 'cloud_posture_page_loading';
|
||||
export const ERROR_STATE_TEST_SUBJECT = 'cloud_posture_page_error';
|
||||
|
@ -250,9 +251,10 @@ export const CloudPosturePage = <TData, TError>({
|
|||
noDataRenderer = defaultNoDataRenderer,
|
||||
}: CloudPosturePageProps<TData, TError>) => {
|
||||
const subscriptionStatus = useSubscriptionStatus();
|
||||
const getSetupStatus = useCspSetupStatusApi();
|
||||
const { data: getSetupStatus, isLoading, isError, error } = useCspSetupStatusApi();
|
||||
const kspmIntegrationLink = useCspIntegrationLink(KSPM_POLICY_TEMPLATE);
|
||||
const cspmIntegrationLink = useCspIntegrationLink(CSPM_POLICY_TEMPLATE);
|
||||
const { isEmptyData, hasFindings } = getCpmStatus(getSetupStatus);
|
||||
|
||||
const render = () => {
|
||||
if (subscriptionStatus.isError) {
|
||||
|
@ -267,23 +269,23 @@ export const CloudPosturePage = <TData, TError>({
|
|||
return subscriptionNotAllowedRenderer();
|
||||
}
|
||||
|
||||
if (getSetupStatus.isError) {
|
||||
return defaultErrorRenderer(getSetupStatus.error);
|
||||
if (isError) {
|
||||
return defaultErrorRenderer(error);
|
||||
}
|
||||
|
||||
if (getSetupStatus.isLoading) {
|
||||
if (isLoading) {
|
||||
return defaultLoadingRenderer();
|
||||
}
|
||||
|
||||
/* Checks if its a completely new user which means no integration has been installed and no latest findings default index has been found */
|
||||
if (
|
||||
getSetupStatus.data?.kspm?.status === 'not-installed' &&
|
||||
getSetupStatus.data?.cspm?.status === 'not-installed' &&
|
||||
getSetupStatus.data?.indicesDetails[0].status === 'empty'
|
||||
) {
|
||||
if (isEmptyData) {
|
||||
return packageNotInstalledRenderer({ kspmIntegrationLink, cspmIntegrationLink });
|
||||
}
|
||||
|
||||
if (!hasFindings) {
|
||||
return children;
|
||||
}
|
||||
|
||||
if (!query) {
|
||||
return children;
|
||||
}
|
||||
|
|
|
@ -23,14 +23,10 @@ import { useCISIntegrationPoliciesLink } from '../common/navigation/use_navigate
|
|||
import { NO_FINDINGS_STATUS_TEST_SUBJ } from './test_subjects';
|
||||
import { CloudPosturePage } from './cloud_posture_page';
|
||||
import { useCspSetupStatusApi } from '../common/api/use_setup_status_api';
|
||||
import type { CloudSecurityPolicyTemplate, IndexDetails } from '../../common/types';
|
||||
import type { IndexDetails, PostureTypes } from '../../common/types';
|
||||
|
||||
const REFETCH_INTERVAL_MS = 20000;
|
||||
|
||||
interface PostureTypes {
|
||||
posturetype: CloudSecurityPolicyTemplate;
|
||||
}
|
||||
|
||||
const NotDeployed = () => {
|
||||
// using an existing hook to get agent id and package policy id
|
||||
const benchmarks = useCspBenchmarkIntegrations({
|
||||
|
@ -180,14 +176,14 @@ const Unprivileged = ({ unprivilegedIndices }: { unprivilegedIndices: string[] }
|
|||
* This component will return the render states based on cloud posture setup status API
|
||||
* since 'not-installed' is being checked globally by CloudPosturePage and 'indexed' is the pass condition, those states won't be handled here
|
||||
* */
|
||||
export const NoFindingsStates = (posturetype?: PostureTypes) => {
|
||||
export const NoFindingsStates = ({ posturetype }: { posturetype: PostureTypes }) => {
|
||||
const getSetupStatus = useCspSetupStatusApi({
|
||||
options: { refetchInterval: REFETCH_INTERVAL_MS },
|
||||
});
|
||||
const statusKspm = getSetupStatus.data?.kspm?.status;
|
||||
const statusCspm = getSetupStatus.data?.cspm?.status;
|
||||
const indicesStatus = getSetupStatus.data?.indicesDetails;
|
||||
const status = posturetype?.posturetype === 'cspm' ? statusCspm : statusKspm;
|
||||
const status = posturetype === 'cspm' ? statusCspm : statusKspm;
|
||||
const unprivilegedIndices =
|
||||
indicesStatus &&
|
||||
indicesStatus
|
||||
|
|
|
@ -31,7 +31,14 @@ describe('<Benchmarks />', () => {
|
|||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
status: 'success',
|
||||
data: { status: 'indexed' },
|
||||
data: {
|
||||
cspm: { status: 'indexed' },
|
||||
kspm: { status: 'indexed' },
|
||||
indicesDetails: [
|
||||
{ index: 'logs-cloud_security_posture.findings_latest-default', status: 'not-empty' },
|
||||
{ index: 'logs-cloud_security_posture.findings-default*', status: 'not-empty' },
|
||||
],
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import React from 'react';
|
||||
|
||||
import { coreMock } from '@kbn/core/public/mocks';
|
||||
import { render } from '@testing-library/react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { TestProvider } from '../../test/test_provider';
|
||||
import { ComplianceDashboard } from '.';
|
||||
import { useCspSetupStatusApi } from '../../common/api/use_setup_status_api';
|
||||
|
@ -18,11 +18,17 @@ import {
|
|||
CLOUD_DASHBOARD_CONTAINER,
|
||||
DASHBOARD_CONTAINER,
|
||||
KUBERNETES_DASHBOARD_CONTAINER,
|
||||
KUBERNETES_DASHBOARD_TAB,
|
||||
CLOUD_DASHBOARD_TAB,
|
||||
} from './test_subjects';
|
||||
import { mockDashboardData } from './mock';
|
||||
import { createReactQueryResponse } from '../../test/fixtures/react_query';
|
||||
import { NO_FINDINGS_STATUS_TEST_SUBJ } from '../../components/test_subjects';
|
||||
import { expectIdsInDoc } from '../../test/utils';
|
||||
import {
|
||||
CSPM_INTEGRATION_NOT_INSTALLED_TEST_SUBJECT,
|
||||
KSPM_INTEGRATION_NOT_INSTALLED_TEST_SUBJECT,
|
||||
} from '../../components/cloud_posture_page';
|
||||
|
||||
jest.mock('../../common/api/use_setup_status_api');
|
||||
jest.mock('../../common/api/use_stats_api');
|
||||
|
@ -498,4 +504,86 @@ describe('<ComplianceDashboard />', () => {
|
|||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('Show CSPM installation prompt if CSPM is not installed and KSPM is installed ,NO AGENT', () => {
|
||||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
status: 'success',
|
||||
data: {
|
||||
kspm: { status: 'not-deployed', healthyAgents: 0, installedPackagePolicies: 1 },
|
||||
cspm: { status: 'not-installed' },
|
||||
indicesDetails: [
|
||||
{ index: 'logs-cloud_security_posture.findings_latest-default', status: 'empty' },
|
||||
{ index: 'logs-cloud_security_posture.findings-default*', status: 'empty' },
|
||||
],
|
||||
},
|
||||
})
|
||||
);
|
||||
(useKspmStatsApi as jest.Mock).mockImplementation(() => ({
|
||||
isSuccess: true,
|
||||
isLoading: false,
|
||||
data: { stats: { totalFindings: 0 } },
|
||||
}));
|
||||
(useCspmStatsApi as jest.Mock).mockImplementation(() => ({
|
||||
isSuccess: true,
|
||||
isLoading: false,
|
||||
data: undefined,
|
||||
}));
|
||||
|
||||
renderComplianceDashboardPage();
|
||||
|
||||
screen.getByTestId(CLOUD_DASHBOARD_TAB).click();
|
||||
|
||||
expectIdsInDoc({
|
||||
be: [CSPM_INTEGRATION_NOT_INSTALLED_TEST_SUBJECT],
|
||||
notToBe: [
|
||||
KUBERNETES_DASHBOARD_CONTAINER,
|
||||
NO_FINDINGS_STATUS_TEST_SUBJ.INDEX_TIMEOUT,
|
||||
NO_FINDINGS_STATUS_TEST_SUBJ.NO_AGENTS_DEPLOYED,
|
||||
NO_FINDINGS_STATUS_TEST_SUBJ.INDEXING,
|
||||
NO_FINDINGS_STATUS_TEST_SUBJ.UNPRIVILEGED,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('Show KSPM installation prompt if KSPM is not installed and CSPM is installed , NO AGENT', () => {
|
||||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
status: 'success',
|
||||
data: {
|
||||
cspm: { status: 'not-deployed' },
|
||||
kspm: { status: 'not-installed' },
|
||||
indicesDetails: [
|
||||
{ index: 'logs-cloud_security_posture.findings_latest-default', status: 'empty' },
|
||||
{ index: 'logs-cloud_security_posture.findings-default*', status: 'empty' },
|
||||
],
|
||||
},
|
||||
})
|
||||
);
|
||||
(useCspmStatsApi as jest.Mock).mockImplementation(() => ({
|
||||
isSuccess: true,
|
||||
isLoading: false,
|
||||
data: { stats: { totalFindings: 0 } },
|
||||
}));
|
||||
(useKspmStatsApi as jest.Mock).mockImplementation(() => ({
|
||||
isSuccess: true,
|
||||
isLoading: false,
|
||||
data: undefined,
|
||||
}));
|
||||
|
||||
renderComplianceDashboardPage();
|
||||
|
||||
screen.getByTestId(KUBERNETES_DASHBOARD_TAB).click();
|
||||
|
||||
expectIdsInDoc({
|
||||
be: [KSPM_INTEGRATION_NOT_INSTALLED_TEST_SUBJECT],
|
||||
notToBe: [
|
||||
CLOUD_DASHBOARD_CONTAINER,
|
||||
NO_FINDINGS_STATUS_TEST_SUBJ.INDEX_TIMEOUT,
|
||||
NO_FINDINGS_STATUS_TEST_SUBJ.NO_AGENTS_DEPLOYED,
|
||||
NO_FINDINGS_STATUS_TEST_SUBJ.INDEXING,
|
||||
NO_FINDINGS_STATUS_TEST_SUBJ.UNPRIVILEGED,
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,6 +25,8 @@ import {
|
|||
CLOUD_DASHBOARD_CONTAINER,
|
||||
DASHBOARD_CONTAINER,
|
||||
KUBERNETES_DASHBOARD_CONTAINER,
|
||||
KUBERNETES_DASHBOARD_TAB,
|
||||
CLOUD_DASHBOARD_TAB,
|
||||
} from './test_subjects';
|
||||
import { useCspmStatsApi, useKspmStatsApi } from '../../common/api/use_stats_api';
|
||||
import { useCspSetupStatusApi } from '../../common/api/use_setup_status_api';
|
||||
|
@ -33,6 +35,7 @@ import { SummarySection } from './dashboard_sections/summary_section';
|
|||
import { BenchmarksSection } from './dashboard_sections/benchmarks_section';
|
||||
import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../../common/constants';
|
||||
import { cspIntegrationDocsNavigation } from '../../common/navigation/constants';
|
||||
import { getCpmStatus } from '../../common/utils/get_cpm_status';
|
||||
|
||||
const noDataOptions: Record<
|
||||
PosturePolicyTemplate,
|
||||
|
@ -176,61 +179,62 @@ const IntegrationPostureDashboard = ({
|
|||
|
||||
export const ComplianceDashboard = () => {
|
||||
const [selectedTab, setSelectedTab] = useState(CSPM_POLICY_TEMPLATE);
|
||||
const getSetupStatus = useCspSetupStatusApi();
|
||||
const hasFindingsKspm =
|
||||
getSetupStatus.data?.kspm?.status === 'indexed' ||
|
||||
getSetupStatus.data?.indicesDetails[0].status === 'not-empty';
|
||||
const hasFindingsCspm =
|
||||
getSetupStatus.data?.cspm?.status === 'indexed' ||
|
||||
getSetupStatus.data?.indicesDetails[0].status === 'not-empty';
|
||||
const { data: getSetupStatus } = useCspSetupStatusApi();
|
||||
|
||||
const {
|
||||
hasKspmFindings,
|
||||
hasCspmFindings,
|
||||
isKspmInstalled,
|
||||
isCspmInstalled,
|
||||
isCspmIntegrationInstalled,
|
||||
isKspmIntegrationInstalled,
|
||||
} = getCpmStatus(getSetupStatus);
|
||||
|
||||
const cspmIntegrationLink = useCspIntegrationLink(CSPM_POLICY_TEMPLATE);
|
||||
const kspmIntegrationLink = useCspIntegrationLink(KSPM_POLICY_TEMPLATE);
|
||||
|
||||
const getCspmDashboardData = useCspmStatsApi({
|
||||
enabled: hasFindingsCspm,
|
||||
enabled: hasCspmFindings,
|
||||
});
|
||||
const getKspmDashboardData = useKspmStatsApi({
|
||||
enabled: hasFindingsKspm,
|
||||
enabled: hasKspmFindings,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const selectInitialTab = () => {
|
||||
const cspmTotalFindings = getCspmDashboardData.data?.stats.totalFindings;
|
||||
const kspmTotalFindings = getKspmDashboardData.data?.stats.totalFindings;
|
||||
const installedPolicyTemplatesCspm = getSetupStatus.data?.cspm?.status;
|
||||
const installedPolicyTemplatesKspm = getSetupStatus.data?.kspm?.status;
|
||||
let preferredDashboard = CSPM_POLICY_TEMPLATE;
|
||||
const cspmTotalFindings = getCspmDashboardData.data?.stats.totalFindings;
|
||||
const kspmTotalFindings = getKspmDashboardData.data?.stats.totalFindings;
|
||||
const installedPolicyTemplatesCspm = getSetupStatus?.cspm?.status;
|
||||
const installedPolicyTemplatesKspm = getSetupStatus?.kspm?.status;
|
||||
let preferredDashboard = CSPM_POLICY_TEMPLATE;
|
||||
|
||||
// cspm has findings
|
||||
if (!!cspmTotalFindings) {
|
||||
preferredDashboard = CSPM_POLICY_TEMPLATE;
|
||||
}
|
||||
// kspm has findings
|
||||
else if (!!kspmTotalFindings) {
|
||||
preferredDashboard = KSPM_POLICY_TEMPLATE;
|
||||
}
|
||||
// cspm is installed
|
||||
else if (
|
||||
installedPolicyTemplatesCspm !== 'unprivileged' &&
|
||||
installedPolicyTemplatesCspm !== 'not-installed'
|
||||
) {
|
||||
preferredDashboard = CSPM_POLICY_TEMPLATE;
|
||||
}
|
||||
// kspm is installed
|
||||
else if (
|
||||
installedPolicyTemplatesKspm !== 'unprivileged' &&
|
||||
installedPolicyTemplatesKspm !== 'not-installed'
|
||||
) {
|
||||
preferredDashboard = KSPM_POLICY_TEMPLATE;
|
||||
}
|
||||
setSelectedTab(preferredDashboard);
|
||||
};
|
||||
selectInitialTab();
|
||||
// cspm has findings
|
||||
if (!!cspmTotalFindings) {
|
||||
preferredDashboard = CSPM_POLICY_TEMPLATE;
|
||||
}
|
||||
// kspm has findings
|
||||
else if (!!kspmTotalFindings) {
|
||||
preferredDashboard = KSPM_POLICY_TEMPLATE;
|
||||
}
|
||||
// cspm is installed
|
||||
else if (
|
||||
installedPolicyTemplatesCspm !== 'unprivileged' &&
|
||||
installedPolicyTemplatesCspm !== 'not-installed'
|
||||
) {
|
||||
preferredDashboard = CSPM_POLICY_TEMPLATE;
|
||||
}
|
||||
// kspm is installed
|
||||
else if (
|
||||
installedPolicyTemplatesKspm !== 'unprivileged' &&
|
||||
installedPolicyTemplatesKspm !== 'not-installed'
|
||||
) {
|
||||
preferredDashboard = KSPM_POLICY_TEMPLATE;
|
||||
}
|
||||
setSelectedTab(preferredDashboard);
|
||||
}, [
|
||||
getCspmDashboardData.data?.stats.totalFindings,
|
||||
getKspmDashboardData.data?.stats.totalFindings,
|
||||
getSetupStatus.data?.cspm?.status,
|
||||
getSetupStatus.data?.kspm?.status,
|
||||
getSetupStatus?.cspm?.status,
|
||||
getSetupStatus?.kspm?.status,
|
||||
]);
|
||||
|
||||
const tabs = useMemo(
|
||||
|
@ -239,11 +243,12 @@ export const ComplianceDashboard = () => {
|
|||
label: i18n.translate('xpack.csp.dashboardTabs.cloudTab.tabTitle', {
|
||||
defaultMessage: 'Cloud',
|
||||
}),
|
||||
'data-test-subj': CLOUD_DASHBOARD_TAB,
|
||||
isSelected: selectedTab === CSPM_POLICY_TEMPLATE,
|
||||
onClick: () => setSelectedTab(CSPM_POLICY_TEMPLATE),
|
||||
content: (
|
||||
<>
|
||||
{hasFindingsCspm ? (
|
||||
{hasCspmFindings || !isCspmInstalled ? (
|
||||
<CloudPosturePage query={getCspmDashboardData}>
|
||||
<div data-test-subj={CLOUD_DASHBOARD_CONTAINER}>
|
||||
<IntegrationPostureDashboard
|
||||
|
@ -253,10 +258,7 @@ export const ComplianceDashboard = () => {
|
|||
CSPM_POLICY_TEMPLATE,
|
||||
cspmIntegrationLink
|
||||
)}
|
||||
isIntegrationInstalled={
|
||||
getSetupStatus.data?.cspm?.status !== 'unprivileged' &&
|
||||
getSetupStatus.data?.cspm?.status !== 'not-installed'
|
||||
}
|
||||
isIntegrationInstalled={isCspmIntegrationInstalled}
|
||||
/>
|
||||
</div>
|
||||
</CloudPosturePage>
|
||||
|
@ -270,11 +272,12 @@ export const ComplianceDashboard = () => {
|
|||
label: i18n.translate('xpack.csp.dashboardTabs.kubernetesTab.tabTitle', {
|
||||
defaultMessage: 'Kubernetes',
|
||||
}),
|
||||
'data-test-subj': KUBERNETES_DASHBOARD_TAB,
|
||||
isSelected: selectedTab === KSPM_POLICY_TEMPLATE,
|
||||
onClick: () => setSelectedTab(KSPM_POLICY_TEMPLATE),
|
||||
content: (
|
||||
<>
|
||||
{hasFindingsKspm ? (
|
||||
{hasKspmFindings || !isKspmInstalled ? (
|
||||
<CloudPosturePage query={getKspmDashboardData}>
|
||||
<div data-test-subj={KUBERNETES_DASHBOARD_CONTAINER}>
|
||||
<IntegrationPostureDashboard
|
||||
|
@ -284,10 +287,7 @@ export const ComplianceDashboard = () => {
|
|||
KSPM_POLICY_TEMPLATE,
|
||||
kspmIntegrationLink
|
||||
)}
|
||||
isIntegrationInstalled={
|
||||
getSetupStatus.data?.kspm?.status !== 'unprivileged' &&
|
||||
getSetupStatus.data?.kspm?.status !== 'not-installed'
|
||||
}
|
||||
isIntegrationInstalled={isKspmIntegrationInstalled}
|
||||
/>
|
||||
</div>
|
||||
</CloudPosturePage>
|
||||
|
@ -302,12 +302,14 @@ export const ComplianceDashboard = () => {
|
|||
cspmIntegrationLink,
|
||||
getCspmDashboardData,
|
||||
getKspmDashboardData,
|
||||
getSetupStatus.data?.kspm?.status,
|
||||
getSetupStatus.data?.cspm?.status,
|
||||
kspmIntegrationLink,
|
||||
selectedTab,
|
||||
hasFindingsKspm,
|
||||
hasFindingsCspm,
|
||||
hasCspmFindings,
|
||||
hasKspmFindings,
|
||||
isKspmIntegrationInstalled,
|
||||
isCspmIntegrationInstalled,
|
||||
isCspmInstalled,
|
||||
isKspmInstalled,
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -16,3 +16,5 @@ export const DASHBOARD_COUNTER_CARDS = {
|
|||
};
|
||||
export const DASHBOARD_TABLE_HEADER_SCORE_TEST_ID = 'csp:dashboard-sections-table-header-score';
|
||||
export const DASHBOARD_TABLE_COLUMN_SCORE_TEST_ID = 'csp:dashboard-sections-table-column-score';
|
||||
export const KUBERNETES_DASHBOARD_TAB = 'kubernetes-dashboard-tab';
|
||||
export const CLOUD_DASHBOARD_TAB = 'cloud-dashboard-tab';
|
||||
|
|
|
@ -15,16 +15,17 @@ import { useLatestFindingsDataView } from '../../common/api/use_latest_findings_
|
|||
import { cloudPosturePages, findingsNavigation } from '../../common/navigation/constants';
|
||||
import { FindingsByResourceContainer } from './latest_findings_by_resource/findings_by_resource_container';
|
||||
import { LatestFindingsContainer } from './latest_findings/latest_findings_container';
|
||||
import { getCpmStatus } from '../../common/utils/get_cpm_status';
|
||||
|
||||
export const Configurations = () => {
|
||||
const location = useLocation();
|
||||
const dataViewQuery = useLatestFindingsDataView();
|
||||
const getSetupStatus = useCspSetupStatusApi();
|
||||
const hasFindings =
|
||||
getSetupStatus.data?.indicesDetails[0].status === 'not-empty' ||
|
||||
getSetupStatus.data?.kspm.status === 'indexed' ||
|
||||
getSetupStatus.data?.cspm.status === 'indexed';
|
||||
if (!hasFindings) return <NoFindingsStates posturetype={'cspm'} />;
|
||||
const { data: getSetupStatus } = useCspSetupStatusApi();
|
||||
const { hasFindings, isCspmInstalled } = getCpmStatus(getSetupStatus);
|
||||
|
||||
const noFindingsForPostureType = isCspmInstalled ? 'cspm' : 'kspm';
|
||||
|
||||
if (!hasFindings) return <NoFindingsStates posturetype={noFindingsForPostureType} />;
|
||||
|
||||
return (
|
||||
<CloudPosturePage query={dataViewQuery}>
|
||||
|
|
|
@ -18,8 +18,6 @@ import { FormattedMessage } from '@kbn/i18n-react';
|
|||
import { css } from '@emotion/react';
|
||||
import { Redirect, Switch, useHistory, useLocation } from 'react-router-dom';
|
||||
import { Route } from '@kbn/shared-ux-router';
|
||||
import { NoFindingsStates } from '../../components/no_findings_states';
|
||||
import { useCspSetupStatusApi } from '../../common/api/use_setup_status_api';
|
||||
import { Configurations } from '../configurations';
|
||||
import { cloudPosturePages, findingsNavigation } from '../../common/navigation/constants';
|
||||
import { Vulnerabilities } from '../vulnerabilities';
|
||||
|
@ -27,13 +25,6 @@ import { Vulnerabilities } from '../vulnerabilities';
|
|||
export const Findings = () => {
|
||||
const history = useHistory();
|
||||
const location = useLocation();
|
||||
const getSetupStatus = useCspSetupStatusApi();
|
||||
|
||||
const hasFindings =
|
||||
getSetupStatus.data?.indicesDetails[0].status === 'not-empty' ||
|
||||
getSetupStatus.data?.kspm.status === 'indexed' ||
|
||||
getSetupStatus.data?.cspm.status === 'indexed';
|
||||
if (!hasFindings) return <NoFindingsStates posturetype={'cspm'} />;
|
||||
|
||||
const navigateToVulnerabilitiesTab = () => {
|
||||
history.push({ pathname: findingsNavigation.vulnerabilities.path });
|
||||
|
|
|
@ -68,7 +68,14 @@ describe('<Rules />', () => {
|
|||
(useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
|
||||
createReactQueryResponse({
|
||||
status: 'success',
|
||||
data: { status: 'indexed' },
|
||||
data: {
|
||||
cspm: { status: 'indexed' },
|
||||
kspm: { status: 'indexed' },
|
||||
indicesDetails: [
|
||||
{ index: 'logs-cloud_security_posture.findings_latest-default', status: 'not-empty' },
|
||||
{ index: 'logs-cloud_security_posture.findings-default*', status: 'not-empty' },
|
||||
],
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ describe('calculateCspStatusCode for cspm', () => {
|
|||
},
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
['cspm']
|
||||
);
|
||||
|
||||
|
@ -36,7 +35,6 @@ describe('calculateCspStatusCode for cspm', () => {
|
|||
},
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
[]
|
||||
);
|
||||
|
||||
|
@ -51,7 +49,6 @@ describe('calculateCspStatusCode for cspm', () => {
|
|||
findings: 'not-empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
['cspm']
|
||||
|
@ -69,7 +66,6 @@ describe('calculateCspStatusCode for cspm', () => {
|
|||
score: 'not-empty',
|
||||
},
|
||||
1,
|
||||
1,
|
||||
10,
|
||||
['cspm']
|
||||
);
|
||||
|
@ -85,7 +81,6 @@ describe('calculateCspStatusCode for cspm', () => {
|
|||
findings: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
['cspm']
|
||||
|
@ -103,7 +98,6 @@ describe('calculateCspStatusCode for cspm', () => {
|
|||
score: 'empty',
|
||||
},
|
||||
1,
|
||||
1,
|
||||
9,
|
||||
['cspm']
|
||||
);
|
||||
|
@ -120,7 +114,6 @@ describe('calculateCspStatusCode for cspm', () => {
|
|||
score: 'empty',
|
||||
},
|
||||
1,
|
||||
1,
|
||||
11,
|
||||
['cspm']
|
||||
);
|
||||
|
@ -137,7 +130,6 @@ describe('calculateCspStatusCode for cspm', () => {
|
|||
score: 'not-empty',
|
||||
},
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
['cspm']
|
||||
);
|
||||
|
@ -157,7 +149,6 @@ describe('calculateCspStatusCode for vul_mgmt', () => {
|
|||
},
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
['cspm']
|
||||
);
|
||||
|
||||
|
@ -174,7 +165,6 @@ describe('calculateCspStatusCode for vul_mgmt', () => {
|
|||
},
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
[]
|
||||
);
|
||||
|
||||
|
@ -189,7 +179,6 @@ describe('calculateCspStatusCode for vul_mgmt', () => {
|
|||
findings: 'not-empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
@ -207,7 +196,6 @@ describe('calculateCspStatusCode for vul_mgmt', () => {
|
|||
score: 'not-empty',
|
||||
},
|
||||
1,
|
||||
1,
|
||||
10,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
);
|
||||
|
@ -223,7 +211,6 @@ describe('calculateCspStatusCode for vul_mgmt', () => {
|
|||
findings: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
@ -241,7 +228,6 @@ describe('calculateCspStatusCode for vul_mgmt', () => {
|
|||
score: 'empty',
|
||||
},
|
||||
1,
|
||||
1,
|
||||
9,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
);
|
||||
|
@ -258,7 +244,6 @@ describe('calculateCspStatusCode for vul_mgmt', () => {
|
|||
score: 'empty',
|
||||
},
|
||||
1,
|
||||
1,
|
||||
11,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
);
|
||||
|
@ -275,7 +260,6 @@ describe('calculateCspStatusCode for vul_mgmt', () => {
|
|||
score: 'not-empty',
|
||||
},
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
);
|
||||
|
|
|
@ -94,7 +94,6 @@ export const calculateCspStatusCode = (
|
|||
findings: IndexStatus;
|
||||
score?: IndexStatus;
|
||||
},
|
||||
installedCspPackagePolicies: number,
|
||||
healthyAgents: number,
|
||||
timeSinceInstallationInMinutes: number,
|
||||
installedPolicyTemplates: string[]
|
||||
|
@ -269,7 +268,6 @@ export const getCspStatus = async ({
|
|||
findings: findingsIndexStatusCspm,
|
||||
score: scoreIndexStatusCspm,
|
||||
},
|
||||
installedPackagePoliciesTotalCspm,
|
||||
healthyAgentsCspm,
|
||||
calculateDiffFromNowInMinutes(installation?.install_started_at || MIN_DATE),
|
||||
installedPolicyTemplates
|
||||
|
@ -282,7 +280,6 @@ export const getCspStatus = async ({
|
|||
findings: findingsIndexStatusKspm,
|
||||
score: scoreIndexStatusKspm,
|
||||
},
|
||||
installedPackagePoliciesTotalKspm,
|
||||
healthyAgentsKspm,
|
||||
calculateDiffFromNowInMinutes(installation?.install_started_at || MIN_DATE),
|
||||
installedPolicyTemplates
|
||||
|
@ -294,7 +291,6 @@ export const getCspStatus = async ({
|
|||
findingsLatest: vulnerabilitiesLatestIndexStatus,
|
||||
findings: vulnerabilitiesIndexStatus,
|
||||
},
|
||||
installedPackagePoliciesTotalVulnMgmt,
|
||||
healthyAgentsVulMgmt,
|
||||
calculateDiffFromNowInMinutes(installation?.install_started_at || MIN_DATE),
|
||||
installedPolicyTemplates
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue