mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[Cloud Security] Fix for status returning incorrect state + Empty Dashboard (#155927)
## Summary This PR is to address issue where Findings and Dashboard page is not loading correctly due cloudbeat is running in the background without cloud_security_package being installed. This is because on how we determine status state on status API. To fix this we will return not-installed in this case, no matter if there are findings or not
This commit is contained in:
parent
28261af7dc
commit
521811e0a1
2 changed files with 58 additions and 1 deletions
|
@ -7,8 +7,43 @@
|
|||
|
||||
import { calculateIntegrationStatus } from './status';
|
||||
import { CSPM_POLICY_TEMPLATE, VULN_MGMT_POLICY_TEMPLATE } from '../../../common/constants';
|
||||
import { Installation } from '@kbn/fleet-plugin/common';
|
||||
|
||||
const mockInstallation: Installation = {
|
||||
installed_kibana: [],
|
||||
installed_es: [],
|
||||
package_assets: [],
|
||||
es_index_patterns: { findings: 'logs-cloud_security_posture.findings-*' },
|
||||
name: 'cloud_security_posture',
|
||||
version: '1.2.13',
|
||||
install_version: '1.2.13',
|
||||
install_status: 'installed',
|
||||
install_started_at: '2023-04-25T20:31:21.784Z',
|
||||
install_source: 'registry',
|
||||
install_format_schema_version: '1.0.0',
|
||||
keep_policies_up_to_date: true,
|
||||
verification_status: 'verified',
|
||||
verification_key_id: 'blablabla',
|
||||
};
|
||||
|
||||
describe('calculateIntegrationStatus for cspm', () => {
|
||||
it('Verify status when CSP package is not installed', async () => {
|
||||
const statusCode = calculateIntegrationStatus(
|
||||
CSPM_POLICY_TEMPLATE,
|
||||
{
|
||||
latest: 'not-empty',
|
||||
stream: 'not-empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
undefined,
|
||||
1,
|
||||
1,
|
||||
['cspm']
|
||||
);
|
||||
|
||||
expect(statusCode).toMatch('not-installed');
|
||||
});
|
||||
|
||||
it('Verify status when there are no permission for cspm', async () => {
|
||||
const statusCode = calculateIntegrationStatus(
|
||||
CSPM_POLICY_TEMPLATE,
|
||||
|
@ -17,6 +52,7 @@ describe('calculateIntegrationStatus for cspm', () => {
|
|||
stream: 'unprivileged',
|
||||
score: 'unprivileged',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
1,
|
||||
['cspm']
|
||||
|
@ -33,6 +69,7 @@ describe('calculateIntegrationStatus for cspm', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
0,
|
||||
0,
|
||||
[]
|
||||
|
@ -49,6 +86,7 @@ describe('calculateIntegrationStatus for cspm', () => {
|
|||
stream: 'empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
mockInstallation,
|
||||
0,
|
||||
10,
|
||||
['cspm']
|
||||
|
@ -65,6 +103,7 @@ describe('calculateIntegrationStatus for cspm', () => {
|
|||
stream: 'not-empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
10,
|
||||
['cspm']
|
||||
|
@ -81,6 +120,7 @@ describe('calculateIntegrationStatus for cspm', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
0,
|
||||
10,
|
||||
['cspm']
|
||||
|
@ -97,6 +137,7 @@ describe('calculateIntegrationStatus for cspm', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
9,
|
||||
['cspm']
|
||||
|
@ -113,6 +154,7 @@ describe('calculateIntegrationStatus for cspm', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
11,
|
||||
['cspm']
|
||||
|
@ -129,6 +171,7 @@ describe('calculateIntegrationStatus for cspm', () => {
|
|||
stream: 'not-empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
0,
|
||||
['cspm']
|
||||
|
@ -147,6 +190,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'unprivileged',
|
||||
score: 'unprivileged',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
1,
|
||||
['cspm']
|
||||
|
@ -163,6 +207,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
0,
|
||||
0,
|
||||
[]
|
||||
|
@ -179,6 +224,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
mockInstallation,
|
||||
0,
|
||||
10,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
@ -195,6 +241,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'not-empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
10,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
@ -211,6 +258,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
0,
|
||||
10,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
@ -227,6 +275,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
9,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
@ -243,6 +292,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
11,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
@ -259,6 +309,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'empty',
|
||||
score: 'empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
61,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
@ -275,6 +326,7 @@ describe('calculateIntegrationStatus for vul_mgmt', () => {
|
|||
stream: 'not-empty',
|
||||
score: 'not-empty',
|
||||
},
|
||||
mockInstallation,
|
||||
1,
|
||||
0,
|
||||
[VULN_MGMT_POLICY_TEMPLATE]
|
||||
|
|
|
@ -14,7 +14,7 @@ import type {
|
|||
PackageService,
|
||||
} from '@kbn/fleet-plugin/server';
|
||||
import moment from 'moment';
|
||||
import { PackagePolicy } from '@kbn/fleet-plugin/common';
|
||||
import { Installation, PackagePolicy } from '@kbn/fleet-plugin/common';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import {
|
||||
CLOUD_SECURITY_POSTURE_PACKAGE_NAME,
|
||||
|
@ -95,6 +95,7 @@ export const calculateIntegrationStatus = (
|
|||
stream: IndexStatus;
|
||||
score?: IndexStatus;
|
||||
},
|
||||
installation: Installation | undefined,
|
||||
healthyAgents: number,
|
||||
timeSinceInstallationInMinutes: number,
|
||||
installedPolicyTemplates: string[]
|
||||
|
@ -104,6 +105,7 @@ export const calculateIntegrationStatus = (
|
|||
|
||||
if (indicesStatus.latest === 'unprivileged' || indicesStatus.score === 'unprivileged')
|
||||
return 'unprivileged';
|
||||
if (!installation) return 'not-installed';
|
||||
if (indicesStatus.latest === 'not-empty') return 'indexed';
|
||||
if (indicesStatus.stream === 'not-empty' && indicesStatus.latest === 'empty') return 'indexing';
|
||||
|
||||
|
@ -263,6 +265,7 @@ export const getCspStatus = async ({
|
|||
stream: findingsIndexStatusCspm,
|
||||
score: scoreIndexStatusCspm,
|
||||
},
|
||||
installation,
|
||||
healthyAgentsCspm,
|
||||
calculateDiffFromNowInMinutes(installation?.install_started_at || MIN_DATE),
|
||||
installedPolicyTemplates
|
||||
|
@ -275,6 +278,7 @@ export const getCspStatus = async ({
|
|||
stream: findingsIndexStatusKspm,
|
||||
score: scoreIndexStatusKspm,
|
||||
},
|
||||
installation,
|
||||
healthyAgentsKspm,
|
||||
calculateDiffFromNowInMinutes(installation?.install_started_at || MIN_DATE),
|
||||
installedPolicyTemplates
|
||||
|
@ -286,6 +290,7 @@ export const getCspStatus = async ({
|
|||
latest: vulnerabilitiesLatestIndexStatus,
|
||||
stream: vulnerabilitiesIndexStatus,
|
||||
},
|
||||
installation,
|
||||
healthyAgentsVulMgmt,
|
||||
calculateDiffFromNowInMinutes(installation?.install_started_at || MIN_DATE),
|
||||
installedPolicyTemplates
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue