diff --git a/x-pack/plugins/actions/README.md b/x-pack/plugins/actions/README.md index 1e5f84b022bdccb..4c8cc3aa503e6e2 100644 --- a/x-pack/plugins/actions/README.md +++ b/x-pack/plugins/actions/README.md @@ -64,12 +64,12 @@ Table of Contents - [`config`](#config-6) - [`secrets`](#secrets-6) - [`params`](#params-6) - - [`actionParams (pushToService)`](#actionparams-pushtoservice) + - [`subActionParams (pushToService)`](#subactionparams-pushtoservice) - [Jira](#jira) - [`config`](#config-7) - [`secrets`](#secrets-7) - [`params`](#params-7) - - [`actionParams (pushToService)`](#actionparams-pushtoservice-1) + - [`subActionParams (pushToService)`](#subactionparams-pushtoservice-1) - [Command Line Utility](#command-line-utility) ## Terminology @@ -149,8 +149,8 @@ This is the primary function for an action type. Whenever the action needs to ex | actionId | The action saved object id that the action type is executing for. | | config | The decrypted configuration given to an action. This comes from the action saved object that is partially or fully encrypted within the data store. If you would like to validate the config before being passed to the executor, define `validate.config` within the action type. | | params | Parameters for the execution. These will be given at execution time by either an alert or manually provided when calling the plugin provided execute function. | -| services.callCluster(path, opts) | Use this to do Elasticsearch queries on the cluster Kibana connects to. This function is the same as any other `callCluster` in Kibana but runs in the context of the user who is calling the action when security is enabled.| -| services.getScopedCallCluster | This function scopes an instance of CallCluster by returning a `callCluster(path, opts)` function that runs in the context of the user who is calling the action when security is enabled. This must only be called with instances of CallCluster provided by core.| +| services.callCluster(path, opts) | Use this to do Elasticsearch queries on the cluster Kibana connects to. This function is the same as any other `callCluster` in Kibana but runs in the context of the user who is calling the action when security is enabled. | +| services.getScopedCallCluster | This function scopes an instance of CallCluster by returning a `callCluster(path, opts)` function that runs in the context of the user who is calling the action when security is enabled. This must only be called with instances of CallCluster provided by core. | | services.savedObjectsClient | This is an instance of the saved objects client. This provides the ability to do CRUD on any saved objects within the same space the alert lives in.

The scope of the saved objects client is tied to the user in context calling the execute API or the API key provided to the execute plugin function (only when security isenabled). | | services.log(tags, [data], [timestamp]) | Use this to create server logs. (This is the same function as server.log) | @@ -489,12 +489,12 @@ The ServiceNow action uses the [V2 Table API](https://developer.servicenow.com/a ### `params` -| Property | Description | Type | -| ------------ | -------------------------------------------------------------------------------- | ------ | -| action | The action to perform. It can be `pushToService`, `handshake`, and `getIncident` | string | -| actionParams | The parameters of the action | object | +| Property | Description | Type | +| --------------- | ------------------------------------------------------------------------------------ | ------ | +| subAction | The sub action to perform. It can be `pushToService`, `handshake`, and `getIncident` | string | +| subActionParams | The parameters of the sub action | object | -#### `actionParams (pushToService)` +#### `subActionParams (pushToService)` | Property | Description | Type | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------- | @@ -504,10 +504,9 @@ The ServiceNow action uses the [V2 Table API](https://developer.servicenow.com/a | comments | The comments of the case. A comment is of the form `{ commentId: string, version: string, comment: string }` | object[] _(optional)_ | | externalId | The id of the incident in ServiceNow . If presented the incident will be update. Otherwise a new incident will be created. | string _(optional)_ | - --- -## Jira +## Jira ID: `.jira` @@ -529,12 +528,12 @@ The Jira action uses the [V2 API](https://developer.atlassian.com/cloud/jira/pla ### `params` -| Property | Description | Type | -| ------------ | -------------------------------------------------------------------------------- | ------ | -| action | The action to perform. It can be `pushToService`, `handshake`, and `getIncident` | string | -| actionParams | The parameters of the action | object | +| Property | Description | Type | +| --------------- | ------------------------------------------------------------------------------------ | ------ | +| subAction | The sub action to perform. It can be `pushToService`, `handshake`, and `getIncident` | string | +| subActionParams | The parameters of the sub action | object | -#### `actionParams (pushToService)` +#### `subActionParams (pushToService)` | Property | Description | Type | | ----------- | ------------------------------------------------------------------------------------------------------------------- | --------------------- | diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/schema.ts b/x-pack/plugins/actions/server/builtin_action_types/case/schema.ts index 5a2d4f8f323e3d5..1f23ae6492b631f 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/case/schema.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/case/schema.ts @@ -75,6 +75,6 @@ export const ExecutorActionParams = { export const ExecutorActionParamsSchema = schema.object(ExecutorActionParams); export const ExecutorParamsSchema = schema.object({ - action: ExecutorActionSchema, - actionParams: ExecutorActionParamsSchema, + subAction: ExecutorActionSchema, + subActionParams: ExecutorActionParamsSchema, }); diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/utils.ts b/x-pack/plugins/actions/server/builtin_action_types/case/utils.ts index 5f4b55badbd3460..effd16f7041d58d 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/case/utils.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/case/utils.ts @@ -72,8 +72,8 @@ export const createConnectorExecutor = ({ } = execOptions.config as ConnectorPublicConfigurationType; const params = execOptions.params as ExecutorParams; - const { action, actionParams } = params; - const { comments, externalId, ...restParams } = actionParams; + const { subAction, subActionParams } = params; + const { comments, externalId, ...restParams } = subActionParams; const mapping = buildMap(configurationMapping); const externalCase = mapParams(restParams as ExecutorActionParams, mapping); @@ -89,14 +89,14 @@ export const createConnectorExecutor = ({ secrets: execOptions.secrets, }); - if (!api[action]) { - throw new Error('[Action][Connector] Unsupported action type'); + if (!api[subAction]) { + throw new Error('[Action][Connector] Unsupported subAction type'); } - const data = await api[action]({ + const data = await api[subAction]({ externalService, mapping, - params: { ...actionParams, externalCase }, + params: { ...subActionParams, externalCase }, }); return { diff --git a/x-pack/plugins/siem/public/containers/case/api.test.tsx b/x-pack/plugins/siem/public/containers/case/api.test.tsx index bf1cfc8062bf3e9..174738098fa107b 100644 --- a/x-pack/plugins/siem/public/containers/case/api.test.tsx +++ b/x-pack/plugins/siem/public/containers/case/api.test.tsx @@ -418,7 +418,9 @@ describe('Case Configuration API', () => { await pushToService(connectorId, casePushParams, abortCtrl.signal); expect(fetchMock).toHaveBeenCalledWith(`/api/action/${connectorId}/_execute`, { method: 'POST', - body: JSON.stringify({ params: { action: 'pushToService', actionParams: casePushParams } }), + body: JSON.stringify({ + params: { subAction: 'pushToService', subActionParams: casePushParams }, + }), signal: abortCtrl.signal, }); }); diff --git a/x-pack/plugins/siem/public/containers/case/api.ts b/x-pack/plugins/siem/public/containers/case/api.ts index 72fbf77defab9b9..438eae9d88a4482 100644 --- a/x-pack/plugins/siem/public/containers/case/api.ts +++ b/x-pack/plugins/siem/public/containers/case/api.ts @@ -245,7 +245,9 @@ export const pushToService = async ( `${ACTION_URL}/${connectorId}/_execute`, { method: 'POST', - body: JSON.stringify({ params: { action: 'pushToService', actionParams: casePushParams } }), + body: JSON.stringify({ + params: { subAction: 'pushToService', subActionParams: casePushParams }, + }), signal, } ); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts index 4c501bac568e3b4..c6a6db1ec451a93 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts @@ -48,8 +48,8 @@ export default function jiraTest({ getService }: FtrProviderContext) { email: 'elastic@elastic.co', }, params: { - action: 'pushToService', - actionParams: { + subAction: 'pushToService', + subActionParams: { caseId: '123', title: 'a title', description: 'a description', @@ -326,7 +326,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [action]: expected at least one defined value but got [undefined]', + 'error validating action params: [subAction]: expected at least one defined value but got [undefined]', }); }); }); @@ -336,7 +336,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { .post(`/api/action/${simulatedActionId}/_execute`) .set('kbn-xsrf', 'foo') .send({ - params: { action: 'non-supported' }, + params: { subAction: 'non-supported' }, }) .then((resp: any) => { expect(resp.body).to.eql({ @@ -344,17 +344,17 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [action]: types that failed validation:\n- [action.0]: expected value to equal [getIncident]\n- [action.1]: expected value to equal [pushToService]\n- [action.2]: expected value to equal [handshake]', + 'error validating action params: [subAction]: types that failed validation:\n- [subAction.0]: expected value to equal [getIncident]\n- [subAction.1]: expected value to equal [pushToService]\n- [subAction.2]: expected value to equal [handshake]', }); }); }); - it('should handle failing with a simulated success without actionParams', async () => { + it('should handle failing with a simulated success without subActionParams', async () => { await supertest .post(`/api/action/${simulatedActionId}/_execute`) .set('kbn-xsrf', 'foo') .send({ - params: { action: 'pushToService' }, + params: { subAction: 'pushToService' }, }) .then((resp: any) => { expect(resp.body).to.eql({ @@ -362,7 +362,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.caseId]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.caseId]: expected value of type [string] but got [undefined]', }); }); }); @@ -372,7 +372,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { .post(`/api/action/${simulatedActionId}/_execute`) .set('kbn-xsrf', 'foo') .send({ - params: { action: 'pushToService', actionParams: {} }, + params: { subAction: 'pushToService', subActionParams: {} }, }) .then((resp: any) => { expect(resp.body).to.eql({ @@ -380,7 +380,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.caseId]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.caseId]: expected value of type [string] but got [undefined]', }); }); }); @@ -392,7 +392,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { .send({ params: { ...mockJira.params, - actionParams: { + subActionParams: { caseId: 'success', }, }, @@ -403,7 +403,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.title]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.title]: expected value of type [string] but got [undefined]', }); }); }); @@ -415,7 +415,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { .send({ params: { ...mockJira.params, - actionParams: { + subActionParams: { caseId: 'success', title: 'success', }, @@ -427,7 +427,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.createdAt]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.createdAt]: expected value of type [string] but got [undefined]', }); }); }); @@ -439,8 +439,8 @@ export default function jiraTest({ getService }: FtrProviderContext) { .send({ params: { ...mockJira.params, - actionParams: { - ...mockJira.params.actionParams, + subActionParams: { + ...mockJira.params.subActionParams, caseId: 'success', title: 'success', createdAt: 'success', @@ -455,7 +455,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.comments.0.commentId]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.comments.0.commentId]: expected value of type [string] but got [undefined]', }); }); }); @@ -467,8 +467,8 @@ export default function jiraTest({ getService }: FtrProviderContext) { .send({ params: { ...mockJira.params, - actionParams: { - ...mockJira.params.actionParams, + subActionParams: { + ...mockJira.params.subActionParams, caseId: 'success', title: 'success', createdAt: 'success', @@ -483,7 +483,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.comments.0.comment]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.comments.0.comment]: expected value of type [string] but got [undefined]', }); }); }); @@ -495,8 +495,8 @@ export default function jiraTest({ getService }: FtrProviderContext) { .send({ params: { ...mockJira.params, - actionParams: { - ...mockJira.params.actionParams, + subActionParams: { + ...mockJira.params.subActionParams, caseId: 'success', title: 'success', createdAt: 'success', @@ -511,7 +511,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.comments.0.createdAt]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.comments.0.createdAt]: expected value of type [string] but got [undefined]', }); }); }); @@ -525,8 +525,8 @@ export default function jiraTest({ getService }: FtrProviderContext) { .send({ params: { ...mockJira.params, - actionParams: { - ...mockJira.params.actionParams, + subActionParams: { + ...mockJira.params.subActionParams, comments: [], }, }, diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/servicenow.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/servicenow.ts index 63e09854a93a3f3..e58f46a7e43059a 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/servicenow.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/servicenow.ts @@ -47,8 +47,8 @@ export default function servicenowTest({ getService }: FtrProviderContext) { username: 'changeme', }, params: { - action: 'pushToService', - actionParams: { + subAction: 'pushToService', + subActionParams: { caseId: '123', title: 'a title', description: 'a description', @@ -297,7 +297,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [action]: expected at least one defined value but got [undefined]', + 'error validating action params: [subAction]: expected at least one defined value but got [undefined]', }); }); }); @@ -307,7 +307,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { .post(`/api/action/${simulatedActionId}/_execute`) .set('kbn-xsrf', 'foo') .send({ - params: { action: 'non-supported' }, + params: { subAction: 'non-supported' }, }) .then((resp: any) => { expect(resp.body).to.eql({ @@ -315,17 +315,17 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [action]: types that failed validation:\n- [action.0]: expected value to equal [getIncident]\n- [action.1]: expected value to equal [pushToService]\n- [action.2]: expected value to equal [handshake]', + 'error validating action params: [subAction]: types that failed validation:\n- [subAction.0]: expected value to equal [getIncident]\n- [subAction.1]: expected value to equal [pushToService]\n- [subAction.2]: expected value to equal [handshake]', }); }); }); - it('should handle failing with a simulated success without actionParams', async () => { + it('should handle failing with a simulated success without subActionParams', async () => { await supertest .post(`/api/action/${simulatedActionId}/_execute`) .set('kbn-xsrf', 'foo') .send({ - params: { action: 'pushToService' }, + params: { subAction: 'pushToService' }, }) .then((resp: any) => { expect(resp.body).to.eql({ @@ -333,7 +333,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.caseId]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.caseId]: expected value of type [string] but got [undefined]', }); }); }); @@ -343,7 +343,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { .post(`/api/action/${simulatedActionId}/_execute`) .set('kbn-xsrf', 'foo') .send({ - params: { action: 'pushToService', actionParams: {} }, + params: { subAction: 'pushToService', subActionParams: {} }, }) .then((resp: any) => { expect(resp.body).to.eql({ @@ -351,7 +351,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.caseId]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.caseId]: expected value of type [string] but got [undefined]', }); }); }); @@ -363,7 +363,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { .send({ params: { ...mockServiceNow.params, - actionParams: { + subActionParams: { caseId: 'success', }, }, @@ -374,7 +374,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.title]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.title]: expected value of type [string] but got [undefined]', }); }); }); @@ -386,7 +386,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { .send({ params: { ...mockServiceNow.params, - actionParams: { + subActionParams: { caseId: 'success', title: 'success', }, @@ -398,7 +398,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.createdAt]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.createdAt]: expected value of type [string] but got [undefined]', }); }); }); @@ -410,8 +410,8 @@ export default function servicenowTest({ getService }: FtrProviderContext) { .send({ params: { ...mockServiceNow.params, - actionParams: { - ...mockServiceNow.params.actionParams, + subActionParams: { + ...mockServiceNow.params.subActionParams, caseId: 'success', title: 'success', createdAt: 'success', @@ -426,7 +426,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.comments.0.commentId]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.comments.0.commentId]: expected value of type [string] but got [undefined]', }); }); }); @@ -438,8 +438,8 @@ export default function servicenowTest({ getService }: FtrProviderContext) { .send({ params: { ...mockServiceNow.params, - actionParams: { - ...mockServiceNow.params.actionParams, + subActionParams: { + ...mockServiceNow.params.subActionParams, caseId: 'success', title: 'success', createdAt: 'success', @@ -454,7 +454,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.comments.0.comment]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.comments.0.comment]: expected value of type [string] but got [undefined]', }); }); }); @@ -466,8 +466,8 @@ export default function servicenowTest({ getService }: FtrProviderContext) { .send({ params: { ...mockServiceNow.params, - actionParams: { - ...mockServiceNow.params.actionParams, + subActionParams: { + ...mockServiceNow.params.subActionParams, caseId: 'success', title: 'success', createdAt: 'success', @@ -482,7 +482,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: [actionParams.comments.0.createdAt]: expected value of type [string] but got [undefined]', + 'error validating action params: [subActionParams.comments.0.createdAt]: expected value of type [string] but got [undefined]', }); }); }); @@ -496,8 +496,8 @@ export default function servicenowTest({ getService }: FtrProviderContext) { .send({ params: { ...mockServiceNow.params, - actionParams: { - ...mockServiceNow.params.actionParams, + subActionParams: { + ...mockServiceNow.params.subActionParams, comments: [], }, },