Skip to content

Commit 0bc3a79

Browse files
cnasikasXavierMstephmilovickibanamachine
authored
[7.x] [Security Solutions][Case] Settings per case per connector (#77327) (#79716)
Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com> Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 570f2d2 commit 0bc3a79

File tree

154 files changed

+8612
-959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+8612
-959
lines changed

x-pack/plugins/actions/server/builtin_action_types/jira/api.test.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ describe('api', () => {
7474

7575
expect(externalService.createIncident).toHaveBeenCalledWith({
7676
incident: {
77+
labels: ['kibana', 'elastic'],
78+
priority: 'High',
79+
issueType: '10006',
80+
parent: null,
7781
description:
7882
'Incident description (created at 2020-04-27T10:59:46.202Z by Elastic User)',
7983
summary: 'Incident title (created at 2020-04-27T10:59:46.202Z by Elastic User)',
@@ -233,6 +237,10 @@ describe('api', () => {
233237
expect(externalService.updateIncident).toHaveBeenCalledWith({
234238
incidentId: 'incident-3',
235239
incident: {
240+
labels: ['kibana', 'elastic'],
241+
priority: 'High',
242+
issueType: '10006',
243+
parent: null,
236244
description:
237245
'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
238246
summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
@@ -443,6 +451,10 @@ describe('api', () => {
443451
expect(externalService.updateIncident).toHaveBeenCalledWith({
444452
incidentId: 'incident-3',
445453
incident: {
454+
labels: ['kibana', 'elastic'],
455+
priority: 'High',
456+
issueType: '10006',
457+
parent: null,
446458
summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
447459
description:
448460
'description from jira \r\nIncident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
@@ -480,6 +492,10 @@ describe('api', () => {
480492
expect(externalService.updateIncident).toHaveBeenCalledWith({
481493
incidentId: 'incident-3',
482494
incident: {
495+
labels: ['kibana', 'elastic'],
496+
priority: 'High',
497+
issueType: '10006',
498+
parent: null,
483499
description:
484500
'description from jira \r\nIncident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
485501
},
@@ -516,6 +532,10 @@ describe('api', () => {
516532
expect(externalService.updateIncident).toHaveBeenCalledWith({
517533
incidentId: 'incident-3',
518534
incident: {
535+
labels: ['kibana', 'elastic'],
536+
priority: 'High',
537+
issueType: '10006',
538+
parent: null,
519539
summary:
520540
'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
521541
description:
@@ -553,7 +573,12 @@ describe('api', () => {
553573
});
554574
expect(externalService.updateIncident).toHaveBeenCalledWith({
555575
incidentId: 'incident-3',
556-
incident: {},
576+
incident: {
577+
labels: ['kibana', 'elastic'],
578+
priority: 'High',
579+
issueType: '10006',
580+
parent: null,
581+
},
557582
});
558583
});
559584

@@ -587,6 +612,10 @@ describe('api', () => {
587612
expect(externalService.updateIncident).toHaveBeenCalledWith({
588613
incidentId: 'incident-3',
589614
incident: {
615+
labels: ['kibana', 'elastic'],
616+
priority: 'High',
617+
issueType: '10006',
618+
parent: null,
590619
summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
591620
},
592621
});
@@ -622,6 +651,10 @@ describe('api', () => {
622651
expect(externalService.updateIncident).toHaveBeenCalledWith({
623652
incidentId: 'incident-3',
624653
incident: {
654+
labels: ['kibana', 'elastic'],
655+
priority: 'High',
656+
issueType: '10006',
657+
parent: null,
625658
summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
626659
description:
627660
'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
@@ -659,6 +692,10 @@ describe('api', () => {
659692
expect(externalService.updateIncident).toHaveBeenCalledWith({
660693
incidentId: 'incident-3',
661694
incident: {
695+
labels: ['kibana', 'elastic'],
696+
priority: 'High',
697+
issueType: '10006',
698+
parent: null,
662699
description:
663700
'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
664701
},
@@ -695,6 +732,10 @@ describe('api', () => {
695732
expect(externalService.updateIncident).toHaveBeenCalledWith({
696733
incidentId: 'incident-3',
697734
incident: {
735+
labels: ['kibana', 'elastic'],
736+
priority: 'High',
737+
issueType: '10006',
738+
parent: null,
698739
summary:
699740
'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
700741
description:
@@ -733,6 +774,10 @@ describe('api', () => {
733774
expect(externalService.updateIncident).toHaveBeenCalledWith({
734775
incidentId: 'incident-3',
735776
incident: {
777+
labels: ['kibana', 'elastic'],
778+
priority: 'High',
779+
issueType: '10006',
780+
parent: null,
736781
summary:
737782
'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
738783
},

x-pack/plugins/actions/server/builtin_action_types/jira/api.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,25 @@ const pushToServiceHandler = async ({
9191
defaultPipes,
9292
});
9393

94-
incident = transformFields<PushToServiceApiParams, ExternalServiceParams, Incident>({
94+
const transformedFields = transformFields<
95+
PushToServiceApiParams,
96+
ExternalServiceParams,
97+
Incident
98+
>({
9599
params,
96100
fields,
97101
currentIncident,
98102
});
103+
104+
const { priority, labels, issueType, parent } = params;
105+
incident = {
106+
summary: transformedFields.summary,
107+
description: transformedFields.description,
108+
priority,
109+
labels,
110+
issueType,
111+
parent,
112+
};
99113
} else {
100114
const { title, description, priority, labels, issueType, parent } = params;
101115
incident = { summary: title, description, priority, labels, issueType, parent };

x-pack/plugins/actions/server/builtin_action_types/jira/service.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,21 @@ export const createExternalService = (
9999
return fields;
100100
};
101101

102-
const createErrorMessage = (errors: ResponseError) => {
102+
const createErrorMessage = (errorResponse: ResponseError | null | undefined): string => {
103+
if (errorResponse == null) {
104+
return '';
105+
}
106+
107+
const { errorMessages, errors } = errorResponse;
108+
109+
if (errors == null) {
110+
return '';
111+
}
112+
113+
if (Array.isArray(errorMessages) && errorMessages.length > 0) {
114+
return `${errorMessages.join(', ')}`;
115+
}
116+
103117
return Object.entries(errors).reduce((errorMessage, [, value]) => {
104118
const msg = errorMessage.length > 0 ? `${errorMessage} ${value}` : value;
105119
return msg;
@@ -154,7 +168,7 @@ export const createExternalService = (
154168
i18n.NAME,
155169
`Unable to get incident with id ${id}. Error: ${
156170
error.message
157-
} Reason: ${createErrorMessage(error.response?.data?.errors ?? {})}`
171+
} Reason: ${createErrorMessage(error.response?.data)}`
158172
)
159173
);
160174
}
@@ -207,7 +221,7 @@ export const createExternalService = (
207221
getErrorMessage(
208222
i18n.NAME,
209223
`Unable to create incident. Error: ${error.message}. Reason: ${createErrorMessage(
210-
error.response?.data?.errors ?? {}
224+
error.response?.data
211225
)}`
212226
)
213227
);
@@ -249,7 +263,7 @@ export const createExternalService = (
249263
i18n.NAME,
250264
`Unable to update incident with id ${incidentId}. Error: ${
251265
error.message
252-
}. Reason: ${createErrorMessage(error.response?.data?.errors ?? {})}`
266+
}. Reason: ${createErrorMessage(error.response?.data)}`
253267
)
254268
);
255269
}
@@ -280,7 +294,7 @@ export const createExternalService = (
280294
i18n.NAME,
281295
`Unable to create comment at incident with id ${incidentId}. Error: ${
282296
error.message
283-
}. Reason: ${createErrorMessage(error.response?.data?.errors ?? {})}`
297+
}. Reason: ${createErrorMessage(error.response?.data)}`
284298
)
285299
);
286300
}
@@ -302,7 +316,7 @@ export const createExternalService = (
302316
getErrorMessage(
303317
i18n.NAME,
304318
`Unable to get capabilities. Error: ${error.message}. Reason: ${createErrorMessage(
305-
error.response?.data?.errors ?? {}
319+
error.response?.data
306320
)}`
307321
)
308322
);
@@ -342,7 +356,7 @@ export const createExternalService = (
342356
getErrorMessage(
343357
i18n.NAME,
344358
`Unable to get issue types. Error: ${error.message}. Reason: ${createErrorMessage(
345-
error.response?.data?.errors ?? {}
359+
error.response?.data
346360
)}`
347361
)
348362
);
@@ -388,7 +402,7 @@ export const createExternalService = (
388402
getErrorMessage(
389403
i18n.NAME,
390404
`Unable to get fields. Error: ${error.message}. Reason: ${createErrorMessage(
391-
error.response?.data?.errors ?? {}
405+
error.response?.data
392406
)}`
393407
)
394408
);
@@ -415,7 +429,7 @@ export const createExternalService = (
415429
getErrorMessage(
416430
i18n.NAME,
417431
`Unable to get issues. Error: ${error.message}. Reason: ${createErrorMessage(
418-
error.response?.data?.errors ?? {}
432+
error.response?.data
419433
)}`
420434
)
421435
);
@@ -439,7 +453,7 @@ export const createExternalService = (
439453
getErrorMessage(
440454
i18n.NAME,
441455
`Unable to get issue with id ${id}. Error: ${error.message}. Reason: ${createErrorMessage(
442-
error.response?.data?.errors ?? {}
456+
error.response?.data
443457
)}`
444458
)
445459
);

x-pack/plugins/actions/server/builtin_action_types/jira/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,6 @@ export interface Fields {
199199
[key: string]: string | string[] | { name: string } | { key: string } | { id: string };
200200
}
201201
export interface ResponseError {
202-
[k: string]: string;
202+
errorMessages: string[] | null | undefined;
203+
errors: { [k: string]: string } | null | undefined;
203204
}

x-pack/plugins/actions/server/builtin_action_types/resilient/api.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ describe('api', () => {
7474

7575
expect(externalService.createIncident).toHaveBeenCalledWith({
7676
incident: {
77+
incidentTypes: [1001],
78+
severityCode: 6,
7779
description:
7880
'Incident description (created at 2020-06-03T15:09:13.606Z by Elastic User)',
7981
name: 'Incident title (created at 2020-06-03T15:09:13.606Z by Elastic User)',
@@ -175,6 +177,8 @@ describe('api', () => {
175177
expect(externalService.updateIncident).toHaveBeenCalledWith({
176178
incidentId: 'incident-3',
177179
incident: {
180+
incidentTypes: [1001],
181+
severityCode: 6,
178182
description:
179183
'Incident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
180184
name: 'Incident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
@@ -298,6 +302,8 @@ describe('api', () => {
298302
expect(externalService.updateIncident).toHaveBeenCalledWith({
299303
incidentId: 'incident-3',
300304
incident: {
305+
incidentTypes: [1001],
306+
severityCode: 6,
301307
name: 'Incident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
302308
description:
303309
'description from ibm resilient \r\nIncident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
@@ -335,6 +341,8 @@ describe('api', () => {
335341
expect(externalService.updateIncident).toHaveBeenCalledWith({
336342
incidentId: 'incident-3',
337343
incident: {
344+
incidentTypes: [1001],
345+
severityCode: 6,
338346
description:
339347
'description from ibm resilient \r\nIncident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
340348
},
@@ -371,6 +379,8 @@ describe('api', () => {
371379
expect(externalService.updateIncident).toHaveBeenCalledWith({
372380
incidentId: 'incident-3',
373381
incident: {
382+
incidentTypes: [1001],
383+
severityCode: 6,
374384
name:
375385
'title from ibm resilient \r\nIncident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
376386
description:
@@ -408,7 +418,10 @@ describe('api', () => {
408418
});
409419
expect(externalService.updateIncident).toHaveBeenCalledWith({
410420
incidentId: 'incident-3',
411-
incident: {},
421+
incident: {
422+
incidentTypes: [1001],
423+
severityCode: 6,
424+
},
412425
});
413426
});
414427

@@ -442,6 +455,8 @@ describe('api', () => {
442455
expect(externalService.updateIncident).toHaveBeenCalledWith({
443456
incidentId: 'incident-3',
444457
incident: {
458+
incidentTypes: [1001],
459+
severityCode: 6,
445460
name: 'Incident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
446461
},
447462
});
@@ -477,6 +492,8 @@ describe('api', () => {
477492
expect(externalService.updateIncident).toHaveBeenCalledWith({
478493
incidentId: 'incident-3',
479494
incident: {
495+
incidentTypes: [1001],
496+
severityCode: 6,
480497
name: 'Incident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
481498
description:
482499
'Incident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
@@ -514,6 +531,8 @@ describe('api', () => {
514531
expect(externalService.updateIncident).toHaveBeenCalledWith({
515532
incidentId: 'incident-3',
516533
incident: {
534+
incidentTypes: [1001],
535+
severityCode: 6,
517536
description:
518537
'Incident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
519538
},
@@ -550,6 +569,8 @@ describe('api', () => {
550569
expect(externalService.updateIncident).toHaveBeenCalledWith({
551570
incidentId: 'incident-3',
552571
incident: {
572+
incidentTypes: [1001],
573+
severityCode: 6,
553574
name:
554575
'title from ibm resilient \r\nIncident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
555576
description:
@@ -588,6 +609,8 @@ describe('api', () => {
588609
expect(externalService.updateIncident).toHaveBeenCalledWith({
589610
incidentId: 'incident-3',
590611
incident: {
612+
incidentTypes: [1001],
613+
severityCode: 6,
591614
name:
592615
'title from ibm resilient \r\nIncident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
593616
},

x-pack/plugins/actions/server/builtin_action_types/resilient/api.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,23 @@ const pushToServiceHandler = async ({
7373
defaultPipes,
7474
});
7575

76-
incident = transformFields<PushToServiceApiParams, ExternalServiceParams, Incident>({
76+
const transformedFields = transformFields<
77+
PushToServiceApiParams,
78+
ExternalServiceParams,
79+
Incident
80+
>({
7781
params,
7882
fields,
7983
currentIncident,
8084
});
85+
86+
const { incidentTypes, severityCode } = params;
87+
incident = {
88+
name: transformedFields.name,
89+
description: transformedFields.description,
90+
incidentTypes,
91+
severityCode,
92+
};
8193
} else {
8294
const { title, description, incidentTypes, severityCode } = params;
8395
incident = { name: title, description, incidentTypes, severityCode };

0 commit comments

Comments
 (0)