Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Endpoint] Hide agent types on Types filter when on a flyout and other UI changes #176280

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const UNSAVED_TIMELINE_SAVE_PROMPT_TITLE = i18n.translate(
export const getAgentTypeName = (agentType: ResponseActionAgentType) => {
switch (agentType) {
case 'endpoint':
return 'Endpoint';
return 'Elastic Defend';
case 'sentinel_one':
return 'SentinelOne';
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const getThirdPartyAgentInfo = (
) as ResponseActionAgentType,
},
host: {
name: getFieldValue({ category: 'host', field: 'host.os.name' }, eventData),
name: getFieldValue({ category: 'host', field: 'host.name' }, eventData),
os: {
name: getFieldValue({ category: 'host', field: 'host.os.name' }, eventData),
family: getFieldValue({ category: 'host', field: 'host.os.family' }, eventData),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import React, { memo, useMemo } from 'react';
import { EuiCodeBlock, EuiDescriptionList, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { css, euiStyled } from '@kbn/kibana-react-plugin/common';
import { map } from 'lodash';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { getAgentTypeName } from '../../../../common/translations';
import { RESPONSE_ACTION_API_COMMAND_TO_CONSOLE_COMMAND_MAP } from '../../../../../common/endpoint/service/response_actions/constants';
import {
isExecuteAction,
Expand Down Expand Up @@ -178,7 +180,19 @@ export const ActionsLogExpandedTray = memo<{
}>(({ action, 'data-test-subj': dataTestSubj }) => {
const getTestId = useTestIdGenerator(dataTestSubj);

const { hosts, startedAt, completedAt, command: _command, comment, parameters } = action;
const isSentinelOneV1Enabled = useIsExperimentalFeatureEnabled(
'responseActionsSentinelOneV1Enabled'
);

const {
hosts,
startedAt,
completedAt,
command: _command,
comment,
parameters,
agentType,
} = action;

const parametersList = useMemo(
() =>
Expand All @@ -192,45 +206,61 @@ export const ActionsLogExpandedTray = memo<{

const command = RESPONSE_ACTION_API_COMMAND_TO_CONSOLE_COMMAND_MAP[_command];

const dataList = useMemo(
() =>
[
{
title: OUTPUT_MESSAGES.expandSection.placedAt,
description: `${startedAt}`,
},
{
title: OUTPUT_MESSAGES.expandSection.startedAt,
description: `${startedAt}`,
},
{
title: OUTPUT_MESSAGES.expandSection.completedAt,
description: `${completedAt ?? emptyValue}`,
},
{
title: OUTPUT_MESSAGES.expandSection.input,
description: `${command}`,
},
{
title: OUTPUT_MESSAGES.expandSection.parameters,
description: parametersList ? parametersList.join(', ') : emptyValue,
},
{
title: OUTPUT_MESSAGES.expandSection.comment,
description: comment ? comment : emptyValue,
},
{
title: OUTPUT_MESSAGES.expandSection.hostname,
description: map(hosts, (host) => host.name).join(', ') || emptyValue,
},
].map(({ title, description }) => {
return {
title: <StyledEuiCodeBlock>{title}</StyledEuiCodeBlock>,
description: <StyledEuiCodeBlock>{description}</StyledEuiCodeBlock>,
};
}),
[command, comment, completedAt, hosts, parametersList, startedAt]
);
const dataList = useMemo(() => {
const list = [
{
title: OUTPUT_MESSAGES.expandSection.placedAt,
description: `${startedAt}`,
},
{
title: OUTPUT_MESSAGES.expandSection.startedAt,
description: `${startedAt}`,
},
{
title: OUTPUT_MESSAGES.expandSection.completedAt,
description: `${completedAt ?? emptyValue}`,
},
{
title: OUTPUT_MESSAGES.expandSection.input,
description: `${command}`,
},
{
title: OUTPUT_MESSAGES.expandSection.parameters,
description: parametersList ? parametersList.join(', ') : emptyValue,
},
{
title: OUTPUT_MESSAGES.expandSection.comment,
description: comment ? comment : emptyValue,
},
{
title: OUTPUT_MESSAGES.expandSection.hostname,
description: map(hosts, (host) => host.name).join(', ') || emptyValue,
},
];

if (isSentinelOneV1Enabled) {
list.push({
title: OUTPUT_MESSAGES.expandSection.agentType,
description: getAgentTypeName(agentType) || emptyValue,
});
}

return list.map(({ title, description }) => {
return {
title: <StyledEuiCodeBlock>{title}</StyledEuiCodeBlock>,
description: <StyledEuiCodeBlock>{description}</StyledEuiCodeBlock>,
};
});
}, [
agentType,
command,
comment,
completedAt,
hosts,
isSentinelOneV1Enabled,
parametersList,
startedAt,
]);

const outputList = useMemo(
() => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,28 @@ const getTypesFilterInitialState = (
// v8.13 onwards
// for showing agent types and action types in the same filter
if (isSentinelOneV1Enabled) {
if (!isFlyout) {
return [
{
label: FILTER_NAMES.agentTypes,
isGroupLabel: true,
},
...RESPONSE_ACTION_AGENT_TYPE.map((type) =>
getFilterOptions({
key: type,
label: getAgentTypeName(type),
checked: !isFlyout && agentTypes?.includes(type) ? 'on' : undefined,
})
),
{
label: FILTER_NAMES.actionTypes,
isGroupLabel: true,
},
...defaultFilterOptions,
];
}

return [
{
label: FILTER_NAMES.agentTypes,
isGroupLabel: true,
},
...RESPONSE_ACTION_AGENT_TYPE.map((type) =>
getFilterOptions({
key: type,
label: getAgentTypeName(type),
checked: !isFlyout && agentTypes?.includes(type) ? 'on' : undefined,
})
),
{
label: FILTER_NAMES.actionTypes,
isGroupLabel: true,
Expand Down Expand Up @@ -336,7 +346,10 @@ export const useActionsLogFilter = ({
() => items.filter((item) => item.checked === 'on').length,
[items]
);
const numFilters = useMemo(() => items.filter((item) => item.checked !== 'on').length, [items]);
const numFilters = useMemo(
() => items.filter((item) => item.key && item.checked !== 'on').length,
[items]
Comment on lines +349 to +351
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

);

return {
areHostsSelectedOnMount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export const OUTPUT_MESSAGES = Object.freeze({
defaultMessage: 'Hostname',
}
),
agentType: i18n.translate(
'xpack.securitySolution.responseActionsList.list.item.expandSection.agentType',
{
defaultMessage: 'Agent type',
}
),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ describe('Response actions history page', () => {
}, []);

expect(selectedFilterOptions.length).toEqual(1);
expect(selectedFilterOptions).toEqual(['Endpoint. Checked option.']);
expect(selectedFilterOptions).toEqual(['Elastic Defend. Checked option.']);
expect(history.location.search).toEqual('?agentTypes=endpoint');
});
});
Expand Down