From 4376d9becc44c945d79071bdf42a1fe61855c8f6 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 18 Sep 2024 05:28:57 +1000 Subject: [PATCH] [8.x] [Security Solution][Endpoint] Updated Response Console display of Tech. Preview badge (#193182) (#193213) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution][Endpoint] Updated Response Console display of Tech. Preview badge (#193182)](https://github.com/elastic/kibana/pull/193182) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> --- .../agent_type_integration.test.tsx | 14 ++++++++ .../agent_type_integration.tsx | 25 ++++++++++++-- .../isolate_host/header.test.tsx | 18 ++-------- .../document_details/isolate_host/header.tsx | 19 ++--------- .../hooks/use_with_show_responder.tsx | 33 +------------------ 5 files changed, 41 insertions(+), 68 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/endpoint/agents/agent_type_integration/agent_type_integration.test.tsx b/x-pack/plugins/security_solution/public/common/components/endpoint/agents/agent_type_integration/agent_type_integration.test.tsx index 87b144ad51d1c..35fe16fa3a85c 100644 --- a/x-pack/plugins/security_solution/public/common/components/endpoint/agents/agent_type_integration/agent_type_integration.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/endpoint/agents/agent_type_integration/agent_type_integration.test.tsx @@ -51,5 +51,19 @@ describe('AgentTypeIntegration component', () => { expect(getByTestId('test-tooltipAnchor')); }); + + if (agentType === 'sentinel_one' || agentType === 'crowdstrike') { + it('should display tech preview badge', () => { + const { getByTestId } = render(); + + expect(getByTestId('test-betaBadge')).not.toBeNull(); + }); + } else { + it('should NOT display tech preview badge', () => { + const { queryByTestId } = render(); + + expect(queryByTestId('test-betaBadge')).toBeNull(); + }); + } }); }); diff --git a/x-pack/plugins/security_solution/public/common/components/endpoint/agents/agent_type_integration/agent_type_integration.tsx b/x-pack/plugins/security_solution/public/common/components/endpoint/agents/agent_type_integration/agent_type_integration.tsx index e99c91fe05dbb..117605e22c76b 100644 --- a/x-pack/plugins/security_solution/public/common/components/endpoint/agents/agent_type_integration/agent_type_integration.tsx +++ b/x-pack/plugins/security_solution/public/common/components/endpoint/agents/agent_type_integration/agent_type_integration.tsx @@ -5,14 +5,18 @@ * 2.0. */ -import React, { memo } from 'react'; +import React, { memo, useMemo } from 'react'; import type { EuiTextProps } from '@elastic/eui'; -import { EuiFlexGroup, EuiFlexItem, EuiIconTip, EuiText } from '@elastic/eui'; +import { EuiBetaBadge, EuiFlexGroup, EuiFlexItem, EuiIconTip, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { useTestIdGenerator } from '../../../../../management/hooks/use_test_id_generator'; import { AgentTypeVendorLogo } from '../agent_type_vendor_logo'; -import { getAgentTypeName } from '../../../../translations'; +import { + getAgentTypeName, + TECHNICAL_PREVIEW, + TECHNICAL_PREVIEW_TOOLTIP, +} from '../../../../translations'; import type { ResponseActionAgentType } from '../../../../../../common/endpoint/service/response_actions/constants'; export const INTEGRATION_SECTION_LABEL = i18n.translate( @@ -38,6 +42,10 @@ export const AgentTypeIntegration = memo( ({ agentType, textSize = 's', layout = 'vertical', 'data-test-subj': dataTestSubj }) => { const testId = useTestIdGenerator(dataTestSubj); + const isTechPreview = useMemo(() => { + return agentType === 'sentinel_one' || agentType === 'crowdstrike'; + }, [agentType]); + return ( ( {getAgentTypeName(agentType)} + {isTechPreview && ( + + + + )} diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.test.tsx index ba166175640ea..700f4d2f11984 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.test.tsx @@ -14,7 +14,6 @@ import { createAppRootMockRenderer, endpointAlertDataMock } from '../../../commo import type { ResponseActionAgentType } from '../../../../common/endpoint/service/response_actions/constants'; import { RESPONSE_ACTION_AGENT_TYPE } from '../../../../common/endpoint/service/response_actions/constants'; import { ISOLATE_HOST, UNISOLATE_HOST } from '../../../common/components/endpoint/host_isolation'; -import { TECHNICAL_PREVIEW } from '../../../common/translations'; jest.mock('./context'); @@ -58,8 +57,6 @@ describe('Isolation Flyout PanelHeader', () => { action: IsolateHostPanelContext['isolateAction']; agentType: ResponseActionAgentType; title: string; - // if `expectedBadgeText` is `undefined`, then it validates that the badge is not displayed - expectedBadgeText: string | undefined; }> = []; for (const agentType of RESPONSE_ACTION_AGENT_TYPE) { @@ -69,10 +66,6 @@ describe('Isolation Flyout PanelHeader', () => { action, agentType, title: action === 'isolateHost' ? ISOLATE_HOST : UNISOLATE_HOST, - expectedBadgeText: - agentType === 'crowdstrike' || agentType === 'sentinel_one' - ? TECHNICAL_PREVIEW - : undefined, }); } ); @@ -80,22 +73,15 @@ describe('Isolation Flyout PanelHeader', () => { it.each(testConditions)( 'should display correct flyout header title for $action on agentType $agentType', - ({ action, agentType, title, expectedBadgeText }) => { + ({ action, agentType, title }) => { setUseIsolateHostPanelContext({ isolateAction: action, dataFormattedForFieldBrowser: endpointAlertDataMock.generateAlertDetailsItemDataForAgentType(agentType), }); - const { getByTestId, queryByTestId } = render(); + const { getByTestId } = render(); expect(getByTestId('flyoutHostIsolationHeaderTitle')).toHaveTextContent(title); - - if (expectedBadgeText) { - expect(getByTestId('flyoutHostIsolationHeaderBadge')).toHaveTextContent(expectedBadgeText); - } else { - expect(queryByTestId('flyoutHostIsolationHeaderBadge')).toBeNull(); - } - expect(getByTestId('flyoutHostIsolationHeaderIntegration')); } ); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.tsx index 80f75f9808620..d7effaea8016b 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.tsx @@ -5,13 +5,12 @@ * 2.0. */ -import { EuiBetaBadge, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui'; import type { FC } from 'react'; -import React, { useMemo } from 'react'; +import React from 'react'; import { FlyoutHeader } from '@kbn/security-solution-common'; import { AgentTypeIntegration } from '../../../common/components/endpoint/agents/agent_type_integration'; import { useAlertResponseActionsSupport } from '../../../common/hooks/endpoint/use_alert_response_actions_support'; -import { TECHNICAL_PREVIEW, TECHNICAL_PREVIEW_TOOLTIP } from '../../../common/translations'; import { useIsolateHostPanelContext } from './context'; import { FLYOUT_HEADER_TITLE_TEST_ID } from './test_ids'; import { ISOLATE_HOST, UNISOLATE_HOST } from '../../../common/components/endpoint'; @@ -22,14 +21,9 @@ import { ISOLATE_HOST, UNISOLATE_HOST } from '../../../common/components/endpoin export const PanelHeader: FC = () => { const { isolateAction, dataFormattedForFieldBrowser: data } = useIsolateHostPanelContext(); const { - isSupported: supportsResponseActions, details: { agentType }, } = useAlertResponseActionsSupport(data); - const showTechPreviewBadge: boolean = useMemo(() => { - return supportsResponseActions && (agentType === 'sentinel_one' || agentType === 'crowdstrike'); - }, [agentType, supportsResponseActions]); - const title = ( @@ -41,15 +35,6 @@ export const PanelHeader: FC = () => { data-test-subj="flyoutHostIsolationHeaderIntegration" /> - {showTechPreviewBadge && ( - - - - )} ); diff --git a/x-pack/plugins/security_solution/public/management/hooks/use_with_show_responder.tsx b/x-pack/plugins/security_solution/public/management/hooks/use_with_show_responder.tsx index bd348c77fde3e..f7622681112bd 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/use_with_show_responder.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/use_with_show_responder.tsx @@ -6,8 +6,6 @@ */ import React, { useCallback } from 'react'; -import { EuiBetaBadge, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { TECHNICAL_PREVIEW, TECHNICAL_PREVIEW_TOOLTIP } from '../../common/translations'; import { useLicense } from '../../common/hooks/use_license'; import type { MaybeImmutable } from '../../../common/endpoint/types'; import type { EndpointCapabilities } from '../../../common/endpoint/service/response_actions/constants'; @@ -23,7 +21,6 @@ import { import { useConsoleManager } from '../components/console'; import { MissingEncryptionKeyCallout } from '../components/missing_encryption_key_callout'; import { RESPONDER_PAGE_TITLE } from './translations'; -import { useIsExperimentalFeatureEnabled } from '../../common/hooks/use_experimental_features'; type ShowResponseActionsConsole = (props: ResponderInfoProps) => void; @@ -47,19 +44,10 @@ export const useWithShowResponder = (): ShowResponseActionsConsole => { const consoleManager = useConsoleManager(); const endpointPrivileges = useUserPrivileges().endpointPrivileges; const isEnterpriseLicense = useLicense().isEnterprise(); - const isSentinelOneV1Enabled = useIsExperimentalFeatureEnabled( - 'responseActionsSentinelOneV1Enabled' - ); - const responseActionsCrowdstrikeManualHostIsolationEnabled = useIsExperimentalFeatureEnabled( - 'responseActionsCrowdstrikeManualHostIsolationEnabled' - ); return useCallback( (props: ResponderInfoProps) => { const { agentId, agentType, capabilities, hostName, platform } = props; - const isExternalEdr = - (isSentinelOneV1Enabled && agentType === 'sentinel_one') || - (responseActionsCrowdstrikeManualHostIsolationEnabled && agentType === 'crowdstrike'); // If no authz, just exit and log something to the console if (agentType === 'endpoint' && !endpointPrivileges.canAccessResponseConsole) { @@ -109,19 +97,6 @@ export const useWithShowResponder = (): ShowResponseActionsConsole => { }, consoleProps, PageTitleComponent: () => { - if (isExternalEdr) { - return ( - - {RESPONDER_PAGE_TITLE} - - - - - ); - } return <>{RESPONDER_PAGE_TITLE}; }, ActionComponents: endpointPrivileges.canReadActionsLogManagement @@ -141,12 +116,6 @@ export const useWithShowResponder = (): ShowResponseActionsConsole => { .show(); } }, - [ - isSentinelOneV1Enabled, - responseActionsCrowdstrikeManualHostIsolationEnabled, - endpointPrivileges, - isEnterpriseLicense, - consoleManager, - ] + [endpointPrivileges, isEnterpriseLicense, consoleManager] ); };