Skip to content

Commit

Permalink
[8.x] [Security Solution][Endpoint] Show tooltip icon on `proces…
Browse files Browse the repository at this point in the history
…ses` response console command for SentinelOne Windows hosts (elastic#201030) (elastic#202595)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution][Endpoint] Show tooltip icon on
`processes` response console command for SentinelOne Windows
hosts (elastic#201030)](elastic#201030)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Paul
Tavares","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-02T21:59:35Z","message":"[Security
Solution][Endpoint] Show tooltip icon on `processes` response console
command for SentinelOne Windows hosts (elastic#201030)\n\n## Summary\r\n\r\n-
Displays a tooltip icon for the `processes` command on the
Response\r\nConsole for SentinelOne Windows hosts indicating that
`processes` is not\r\nsupported on those types of
hosts","sha":"40905c14ad7383cc9abf046b0fb44e98da1e448e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Defend
Workflows","backport:prev-minor","v8.17.0"],"title":"[Security
Solution][Endpoint] Show tooltip icon on `processes` response console
command for SentinelOne Windows
hosts","number":201030,"url":"https://github.com/elastic/kibana/pull/201030","mergeCommit":{"message":"[Security
Solution][Endpoint] Show tooltip icon on `processes` response console
command for SentinelOne Windows hosts (elastic#201030)\n\n## Summary\r\n\r\n-
Displays a tooltip icon for the `processes` command on the
Response\r\nConsole for SentinelOne Windows hosts indicating that
`processes` is not\r\nsupported on those types of
hosts","sha":"40905c14ad7383cc9abf046b0fb44e98da1e448e"}},"sourceBranch":"main","suggestedTargetBranches":["8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201030","number":201030,"mergeCommit":{"message":"[Security
Solution][Endpoint] Show tooltip icon on `processes` response console
command for SentinelOne Windows hosts (elastic#201030)\n\n## Summary\r\n\r\n-
Displays a tooltip icon for the `processes` command on the
Response\r\nConsole for SentinelOne Windows hosts indicating that
`processes` is not\r\nsupported on those types of
hosts","sha":"40905c14ad7383cc9abf046b0fb44e98da1e448e"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Paul Tavares <[email protected]>
  • Loading branch information
kibanamachine and paul-tavares authored Dec 2, 2024
1 parent 53e01df commit 8e40ae2
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe('When using execute action from response actions console', () => {
endpointAgentId: 'a.b.c',
endpointCapabilities: [...capabilities],
endpointPrivileges,
platform: 'linux',
}),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe('When using get-file action from response actions console', () => {
endpointAgentId: 'a.b.c',
endpointCapabilities: [...ENDPOINT_CAPABILITIES],
endpointPrivileges,
platform: 'linux',
};

render = async (capabilities: EndpointCapabilities[] = [...ENDPOINT_CAPABILITIES]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('When using processes action from response actions console', () => {
canSuspendProcess: true,
canGetRunningProcesses: true,
},
platform: 'linux',
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('When using isolate action from response actions console', () => {
loading: false,
canIsolateHost: true,
},
platform: 'linux',
}),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe.skip('When using the kill-process action from response actions console'
canSuspendProcess: true,
canGetRunningProcesses: true,
},
platform: 'linux',
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const prepareTest = () => {
canUnIsolateHost: true,
loading: false,
},
platform: 'linux',
}),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('When using scan action from response actions console', () => {
endpointAgentId: 'agent-a',
endpointCapabilities: [...ENDPOINT_CAPABILITIES],
endpointPrivileges,
platform: 'linux',
};

render = async (capabilities: EndpointCapabilities[] = [...ENDPOINT_CAPABILITIES]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ describe.skip('When using processes action from response actions console', () =>
...getEndpointAuthzInitialState(),
loading: false,
},
platform: 'linux',
}),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe('When using the suspend-process action from response actions console',
canSuspendProcess: true,
canGetRunningProcesses: true,
},
platform: 'linux',
}),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe.skip('When using `upload` response action', () => {
endpointAgentId: 'a.b.c',
endpointCapabilities,
endpointPrivileges,
platform: 'linux',
}),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,16 @@ export interface GetEndpointConsoleCommandsOptions {
/** Applicable only for Endpoint Agents */
endpointCapabilities: ImmutableArray<string>;
endpointPrivileges: EndpointPrivileges;
/** Host's platform: windows, linux, macos */
platform: string;
}

export const getEndpointConsoleCommands = ({
endpointAgentId,
agentType,
endpointCapabilities,
endpointPrivileges,
platform,
}: GetEndpointConsoleCommandsOptions): CommandDefinition[] => {
const featureFlags = ExperimentalFeaturesService.get();

Expand Down Expand Up @@ -523,7 +526,7 @@ export const getEndpointConsoleCommands = ({

switch (agentType) {
case 'sentinel_one':
return adjustCommandsForSentinelOne({ commandList: consoleCommands });
return adjustCommandsForSentinelOne({ commandList: consoleCommands, platform });
case 'crowdstrike':
return adjustCommandsForCrowdstrike({ commandList: consoleCommands });
default:
Expand All @@ -543,8 +546,10 @@ const disableCommand = (command: CommandDefinition, agentType: ResponseActionAge
/** @private */
const adjustCommandsForSentinelOne = ({
commandList,
platform,
}: {
commandList: CommandDefinition[];
platform: string;
}): CommandDefinition[] => {
const featureFlags = ExperimentalFeaturesService.get();
const isKillProcessEnabled = featureFlags.responseActionsSentinelOneKillProcessEnabled;
Expand Down Expand Up @@ -580,6 +585,28 @@ const adjustCommandsForSentinelOne = ({
)
) {
disableCommand(command, 'sentinel_one');
} else {
// processes is not currently supported for Windows hosts
if (command.name === 'processes' && platform.toLowerCase() === 'windows') {
const message = i18n.translate(
'xpack.securitySolution.consoleCommandsDefinition.sentineloneProcessesWindowRestriction',
{
defaultMessage:
'Processes command is not currently supported for SentinelOne hosts running on Windows',
}
);

command.helpDisabled = true;
command.about = getCommandAboutInfo({
aboutInfo: command.about,
isSupported: false,
dataTestSubj: 'sentineloneProcessesWindowsWarningTooltip',
tooltipContent: message,
});
command.validate = () => {
return message;
};
}
}

return command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import React from 'react';
import type { EuiToolTipProps } from '@elastic/eui';
import { EuiIconTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

Expand All @@ -17,23 +18,28 @@ const UNSUPPORTED_COMMAND_INFO = i18n.translate(
}
);

const DisabledTooltip = React.memo(() => {
return <EuiIconTip content={UNSUPPORTED_COMMAND_INFO} type="warning" color="danger" />;
});
DisabledTooltip.displayName = 'DisabledTooltip';

export const getCommandAboutInfo = ({
aboutInfo,
isSupported,
tooltipContent = UNSUPPORTED_COMMAND_INFO,
dataTestSubj,
}: {
aboutInfo: string;
aboutInfo: React.ReactNode;
isSupported: boolean;
tooltipContent?: EuiToolTipProps['content'];
dataTestSubj?: string;
}) => {
return isSupported ? (
aboutInfo
) : (
<>
{aboutInfo} <DisabledTooltip />
{aboutInfo}{' '}
<EuiIconTip
anchorProps={{ 'data-test-subj': dataTestSubj }}
content={tooltipContent}
type="warning"
color="danger"
/>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('When displaying Endpoint Response Actions', () => {
endpointAgentId: '123',
endpointCapabilities: endpointMetadata.Endpoint.capabilities ?? [],
endpointPrivileges: getEndpointPrivilegesInitialStateMock(),
platform: 'linux',
});
});

Expand Down Expand Up @@ -89,13 +90,16 @@ describe('When displaying Endpoint Response Actions', () => {
responseActionsCrowdstrikeManualHostIsolationEnabled: true,
responseActionsSentinelOneV1Enabled: true,
responseActionsSentinelOneGetFileEnabled: true,
responseActionsSentinelOneKillProcessEnabled: true,
responseActionsSentinelOneProcessesEnabled: true,
});

commands = getEndpointConsoleCommands({
agentType: 'sentinel_one',
endpointAgentId: '123',
endpointCapabilities: endpointMetadata.Endpoint.capabilities ?? [],
endpointPrivileges: getEndpointPrivilegesInitialStateMock(),
platform: 'linux',
});
});

Expand All @@ -110,13 +114,34 @@ describe('When displaying Endpoint Response Actions', () => {
});

it('should display response action commands in the help panel in expected order', () => {
render({ commands });
const { queryByTestId } = render({ commands });
consoleSelectors.openHelpPanel();
const commandsInPanel = helpPanelSelectors.getHelpCommandNames(
HELP_GROUPS.responseActions.label
);

expect(commandsInPanel).toEqual(['isolate', 'release', 'get-file --path']);
expect(commandsInPanel).toEqual([
'isolate',
'release',
'processes',
'kill-process --processName',
'get-file --path',
]);
expect(queryByTestId('sentineloneProcessesWindowsWarningTooltip')).toBeNull();
});

it('should display warning icon on processes command if host is running on windows', () => {
commands = getEndpointConsoleCommands({
agentType: 'sentinel_one',
endpointAgentId: '123',
endpointCapabilities: endpointMetadata.Endpoint.capabilities ?? [],
endpointPrivileges: getEndpointPrivilegesInitialStateMock(),
platform: 'windows',
});
const { getByTestId } = render({ commands });
consoleSelectors.openHelpPanel();

expect(getByTestId('sentineloneProcessesWindowsWarningTooltip')).not.toBeNull();
});
});

Expand All @@ -130,6 +155,7 @@ describe('When displaying Endpoint Response Actions', () => {
endpointAgentId: '123',
endpointCapabilities: endpointMetadata.Endpoint.capabilities ?? [],
endpointPrivileges: getEndpointPrivilegesInitialStateMock(),
platform: 'linux',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const useWithShowResponder = (): ShowResponseActionsConsole => {
endpointAgentId: agentId,
endpointCapabilities: capabilities,
endpointPrivileges,
platform,
}),
'data-test-subj': `${agentType}ResponseActionsConsole`,
storagePrefix: 'xpack.securitySolution.Responder',
Expand Down

0 comments on commit 8e40ae2

Please sign in to comment.