Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
animehart committed Aug 20, 2024
1 parent 6b3eab0 commit 9f1cc37
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 41 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/test/security_solution_cypress/cypress/screens/common @elastic/security-detections-response @elastic/security-threat-hunting
/x-pack/test/security_solution_cypress/cypress/support @elastic/security-detections-response @elastic/security-threat-hunting
/x-pack/test/security_solution_cypress/cypress/urls @elastic/security-threat-hunting-investigations @elastic/security-detection-engine
/x-pack/test/security_solution_cypress/cypress/e2e/cloud_security_posture @elastic/kibana-cloud-security-posture

/x-pack/plugins/security_solution/common/ecs @elastic/security-threat-hunting-investigations
/x-pack/plugins/security_solution/common/test @elastic/security-detections-response @elastic/security-threat-hunting
Expand Down
2 changes: 1 addition & 1 deletion x-pack/packages/kbn-cloud-security-posture/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export { useCspSetupStatusApi } from './src/hooks/use_csp_setup_status_api';
export {
getAggregationCount,
getFindingsCountAggQuery,
isAllIndicesEmpty,
isIndexWithDocsAvailable,
} from './src/utils/utils';
5 changes: 2 additions & 3 deletions x-pack/packages/kbn-cloud-security-posture/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const getMisconfigurationAggregationCount = (
};
};

export const isAllIndicesEmpty = (indices: Array<IndexDetails | undefined>) => {
const notEmptyIndices = indices.find((indice) => indice?.status !== 'empty');
return notEmptyIndices ? false : true;
export const isIndexWithDocsAvailable = (indices: Array<IndexDetails | undefined>) => {
return indices.some((indice) => indice?.status !== 'empty');
};
2 changes: 0 additions & 2 deletions x-pack/packages/kbn-cloud-security-posture/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export interface FindingsBaseEsQuery {
}

export interface CspClientPluginStartDeps {
// required
data: DataPublicPluginStart;
dataViews: DataViewsServicePublic;
dataViewFieldEditor: IndexPatternFieldEditorStart;
Expand All @@ -44,6 +43,5 @@ export interface CspClientPluginStartDeps {
share: SharePluginStart;
storage: Storage;

// optional
usageCollection?: UsageCollectionStart;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import React from 'react';
import React, { useMemo } from 'react';
import { EuiHorizontalRule } from '@elastic/eui';
import { useCspSetupStatusApi, isAllIndicesEmpty } from '@kbn/cloud-security-posture';
import { useCspSetupStatusApi, isIndexWithDocsAvailable } from '@kbn/cloud-security-posture';
import { AssetCriticalityAccordion } from '../../../entity_analytics/components/asset_criticality/asset_criticality_selector';
import { FlyoutRiskSummary } from '../../../entity_analytics/components/risk_summary_flyout/risk_summary';
import type { RiskScoreState } from '../../../entity_analytics/api/hooks/use_risk_score';
Expand Down Expand Up @@ -49,7 +49,9 @@ export const HostPanelContent = ({
const getSetupStatus = useCspSetupStatusApi({
refetchInterval: 10000,
});
const cspAllIndicesEmpty = isAllIndicesEmpty(getSetupStatus.data?.indicesDetails || []);
const notEmptyIndices = useMemo(() => {
return isIndexWithDocsAvailable(getSetupStatus.data?.indicesDetails || []);
}, [getSetupStatus.data?.indicesDetails]);
return (
<FlyoutBody>
{riskScoreState.isModuleEnabled && riskScoreState.data?.length !== 0 && (
Expand Down Expand Up @@ -77,7 +79,7 @@ export const HostPanelContent = ({
queryId={HOST_PANEL_OBSERVED_HOST_QUERY_ID}
/>
<EuiHorizontalRule />
{!cspAllIndicesEmpty && <InsightEntity hostName={hostName} />}
{notEmptyIndices && <InsightEntity hostName={hostName} />}
</FlyoutBody>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { getDataTestSubjectSelector } from '../../../helpers/common';
import { expandFirstAlertHostFlyout } from '../../../tasks/asset_criticality/common';
import { deleteAlertsAndRules } from '../../../tasks/api_calls/common';
import { login } from '../../../tasks/login';
import { visit } from '../../../tasks/navigation';
import { createRule } from '../../../tasks/api_calls/rules';
import { getNewRule } from '../../../objects/rule';
import { ALERTS_URL } from '../../../urls/navigation';
import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule';

import {
HOST_INSIGHT_MISCONFIGURATION,
HOST_INSIGHT_MISCONFIGURATION_TITLE,
} from '../../../../screens/hosts/flyout_host_panel';
import { expandFirstAlertHostFlyout } from '../../../../tasks/asset_criticality/common';
import { deleteAlertsAndRules } from '../../../../tasks/api_calls/common';
import { login } from '../../../../tasks/login';
import { visit } from '../../../../tasks/navigation';
import { createRule } from '../../../../tasks/api_calls/rules';
import { getNewRule } from '../../../../objects/rule';
import { ALERTS_URL } from '../../../../urls/navigation';
import { waitForAlertsToPopulate } from '../../../../tasks/create_new_rule';
const HOST_INSIGHT_MISCONFIGURATION = getDataTestSubjectSelector(
'securitySolutionFlyoutInsightsMisconfigurationsLeftSection'
);
const HOST_INSIGHT_MISCONFIGURATION_TITLE = getDataTestSubjectSelector(
'securitySolutionFlyoutInsightsMisconfigurationsTitleText'
);

describe('Alert Host details expandable flyout', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@ import { getDataTestSubjectSelector } from '../../helpers/common';
export const HOST_PANEL_HEADER = getDataTestSubjectSelector('host-panel-header');
export const HOST_PREVIEW_PANEL_FOOTER = getDataTestSubjectSelector('host-preview-footer');
export const OPEN_HOST_FLYOUT_LINK = getDataTestSubjectSelector('open-host-flyout');
export const HOST_INSIGHT_MISCONFIGURATION = getDataTestSubjectSelector(
'securitySolutionFlyoutInsightsMisconfigurationsLeftSection'
);
export const HOST_INSIGHT_MISCONFIGURATION_TITLE = getDataTestSubjectSelector(
'securitySolutionFlyoutInsightsMisconfigurationsTitleText'
);
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,3 @@ export const enableRules = ({ names, ids }: EnableRulesParameters): Cypress.Chai
failOnStatusCode: false,
});
};

export const createFindings = (
rule: RuleCreateProps
): Cypress.Chainable<Cypress.Response<RuleResponse>> => {
return cy.currentSpace().then((spaceId) =>
rootRequest<RuleResponse>({
method: 'POST',
url: spaceId ? getSpaceUrl(spaceId, DETECTION_ENGINE_RULES_URL) : DETECTION_ENGINE_RULES_URL,
body: rule,
failOnStatusCode: false,
})
);
};

0 comments on commit 9f1cc37

Please sign in to comment.