[8.15] [SecuritySolution][Endpoint] Update Responder command definition test so that it fails when new commands are added (#187491) (#187689)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[SecuritySolution][Endpoint] Update Responder command definition test
so that it fails when new commands are added
(#187491)](https://github.com/elastic/kibana/pull/187491)

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

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

<!--BACKPORT
[{"author":{"name":"Ash","email":"1849116+ashokaditya@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-07-05T14:51:39Z","message":"[SecuritySolution][Endpoint]
Update Responder command definition test so that it fails when new
commands are added (#187491)\n\n## Summary\r\n\r\nUpdates test so that
it fails whenever we add a introduce a new\r\nresponder
command.\r\n\r\n### Checklist\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"fffc684d4e489490ede9726ffe0792206a14be34","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Defend
Workflows","OLM
Sprint","v8.15.0","v8.16.0"],"title":"[SecuritySolution][Endpoint]
Update Responder command definition test so that it fails when new
commands are
added","number":187491,"url":"https://github.com/elastic/kibana/pull/187491","mergeCommit":{"message":"[SecuritySolution][Endpoint]
Update Responder command definition test so that it fails when new
commands are added (#187491)\n\n## Summary\r\n\r\nUpdates test so that
it fails whenever we add a introduce a new\r\nresponder
command.\r\n\r\n### Checklist\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"fffc684d4e489490ede9726ffe0792206a14be34"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/187491","number":187491,"mergeCommit":{"message":"[SecuritySolution][Endpoint]
Update Responder command definition test so that it fails when new
commands are added (#187491)\n\n## Summary\r\n\r\nUpdates test so that
it fails whenever we add a introduce a new\r\nresponder
command.\r\n\r\n### Checklist\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"fffc684d4e489490ede9726ffe0792206a14be34"}}]}]
BACKPORT-->

Co-authored-by: Ash <1849116+ashokaditya@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2024-07-10 11:53:06 +02:00 committed by GitHub
parent a98ac324f2
commit e9f1ada196
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 14 deletions

View file

@ -134,6 +134,11 @@ export class EndpointMetadataGenerator extends BaseDataGenerator {
capabilities.push('upload_file');
}
// v8.15 introduced `scan` capability
if (gte(agentVersion, '8.15.0')) {
capabilities.push('scan');
}
const hostMetadataDoc: HostMetadataInterface = {
'@timestamp': ts,
event: {

View file

@ -65,9 +65,9 @@ export type EndpointCapabilities = typeof ENDPOINT_CAPABILITIES[number];
export const CONSOLE_RESPONSE_ACTION_COMMANDS = [
'isolate',
'release',
'processes',
'kill-process',
'suspend-process',
'processes',
'get-file',
'execute',
'upload',

View file

@ -18,6 +18,7 @@ import { HELP_GROUPS } from '../console_commands_definition';
import { ExperimentalFeaturesService } from '../../../../../common/experimental_features_service';
import type { CommandDefinition } from '../../../console';
import type { HostMetadataInterface } from '../../../../../../common/endpoint/types';
import { CONSOLE_RESPONSE_ACTION_COMMANDS } from '../../../../../../common/endpoint/service/response_actions/constants';
jest.mock('../../../../../common/experimental_features_service');
@ -43,8 +44,9 @@ describe('When displaying Endpoint Response Actions', () => {
describe('for agent type endpoint', () => {
beforeEach(() => {
(ExperimentalFeaturesService.get as jest.Mock).mockReturnValueOnce({
(ExperimentalFeaturesService.get as jest.Mock).mockReturnValue({
responseActionUploadEnabled: true,
responseActionScanEnabled: true,
});
commands = getEndpointConsoleCommands({
agentType: 'endpoint',
@ -71,17 +73,14 @@ describe('When displaying Endpoint Response Actions', () => {
HELP_GROUPS.responseActions.label
);
expect(commandsInPanel).toEqual([
'isolate',
'release',
'status',
'processes',
'kill-process --pid',
'suspend-process --pid',
'get-file --path',
'execute --command',
'upload --file',
]);
const expectedCommands: string[] = [...CONSOLE_RESPONSE_ACTION_COMMANDS];
// add status to the list of expected commands in that order
expectedCommands.splice(2, 0, 'status');
const helpCommandsString = commandsInPanel.map((command) => command.split(' ')[0]).join(',');
// verify that the help commands map to the command list in the same order
expect(helpCommandsString).toEqual(expectedCommands.join(','));
});
});

View file

@ -12,7 +12,10 @@ import { getDefaultConfigSettings } from '../common/config_settings';
import type { ConfigType } from './config';
export const createMockConfig = (): ConfigType => {
const enableExperimental: Array<keyof ExperimentalFeatures> = ['responseActionUploadEnabled'];
const enableExperimental: Array<keyof ExperimentalFeatures> = [
'responseActionUploadEnabled',
'responseActionScanEnabled',
];
return {
[SIGNALS_INDEX_KEY]: DEFAULT_SIGNALS_INDEX,