diff --git a/x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/upload_action.tsx b/x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/upload_action.tsx new file mode 100644 index 0000000000000..8e18ff89b6f6d --- /dev/null +++ b/x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/upload_action.tsx @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { memo } from 'react'; +import type { ActionRequestComponentProps } from '../types'; + +export const UploadActionResult = memo< + ActionRequestComponentProps<{ + file: File; + overwrite?: boolean; + }> +>((props) => { + return
{'UploadActionResult placeholder'}
; +}); +UploadActionResult.displayName = 'UploadActionResult'; diff --git a/x-pack/plugins/security_solution/public/management/components/endpoint_responder/lib/console_commands_definition.ts b/x-pack/plugins/security_solution/public/management/components/endpoint_responder/lib/console_commands_definition.ts index 4aa8c99e8a1bd..ce714bb6c3541 100644 --- a/x-pack/plugins/security_solution/public/management/components/endpoint_responder/lib/console_commands_definition.ts +++ b/x-pack/plugins/security_solution/public/management/components/endpoint_responder/lib/console_commands_definition.ts @@ -6,6 +6,8 @@ */ import { i18n } from '@kbn/i18n'; +import { UploadActionResult } from '../command_render_components/upload_action'; +import { ArgumentFileSelector } from '../../console_argument_selectors'; import type { ParsedArgData } from '../../console/service/types'; import { ExperimentalFeaturesService } from '../../../../common/experimental_features_service'; import type { @@ -139,8 +141,11 @@ export const getEndpointConsoleCommands = ({ endpointCapabilities: ImmutableArray; endpointPrivileges: EndpointPrivileges; }): CommandDefinition[] => { - const isGetFileEnabled = ExperimentalFeaturesService.get().responseActionGetFileEnabled; - const isExecuteEnabled = ExperimentalFeaturesService.get().responseActionExecuteEnabled; + const featureFlags = ExperimentalFeaturesService.get(); + + const isGetFileEnabled = featureFlags.responseActionGetFileEnabled; + const isExecuteEnabled = featureFlags.responseActionExecuteEnabled; + const isUploadEnabled = featureFlags.responseActionUploadEnabled; const doesEndpointSupportCommand = (commandName: ConsoleResponseActionCommands) => { const responderCapability = @@ -484,5 +489,69 @@ export const getEndpointConsoleCommands = ({ }), }); } + + // `upload` command + // planned for 8.9 + if (isUploadEnabled) { + consoleCommands.push({ + name: 'upload', + about: getCommandAboutInfo({ + aboutInfo: i18n.translate('xpack.securitySolution.endpointConsoleCommands.upload.about', { + defaultMessage: 'Upload a file to the host', + }), + isSupported: doesEndpointSupportCommand('upload'), + }), + RenderComponent: UploadActionResult, + meta: { + endpointId: endpointAgentId, + capabilities: endpointCapabilities, + privileges: endpointPrivileges, + }, + exampleUsage: 'upload --file --overwrite --comment "script to fix registry"', + exampleInstruction: ENTER_OR_ADD_COMMENT_ARG_INSTRUCTION, + validate: capabilitiesAndPrivilegesValidator, + mustHaveArgs: true, + args: { + file: { + required: true, + allowMultiples: false, + about: i18n.translate( + 'xpack.securitySolution.endpointConsoleCommands.upload.args.file.about', + { + defaultMessage: 'The file that will be sent to the host', + } + ), + mustHaveValue: true, + SelectorComponent: ArgumentFileSelector, + }, + overwrite: { + required: false, + allowMultiples: false, + about: i18n.translate( + 'xpack.securitySolution.endpointConsoleCommands.upload.args.overwrite.about', + { + defaultMessage: 'Overwrite the file on the host if it already exists', + } + ), + mustHaveValue: false, + }, + comment: { + required: false, + allowMultiples: false, + mustHaveValue: 'non-empty-string', + about: COMMENT_ARG_ABOUT, + }, + }, + helpGroupLabel: HELP_GROUPS.responseActions.label, + helpGroupPosition: HELP_GROUPS.responseActions.position, + helpCommandPosition: 7, + helpDisabled: !doesEndpointSupportCommand('upload'), + helpHidden: !getRbacControl({ + commandName: 'upload', + privileges: endpointPrivileges, + }), + }); + } + return consoleCommands; };