Skip to content

Commit 2979e70

Browse files
christinewengniros1
authored andcommitted
[Cases] Add extract observables setting to cases SO mapping (#236028)
## Summary This is part 1 of introducing auto-extract observables in cases. This PR adds mapping and default value of false to a new setting called `extractObservables`. Part 2 that introduces the actual feature is in #233027 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
1 parent 8005434 commit 2979e70

File tree

34 files changed

+246
-33
lines changed

34 files changed

+246
-33
lines changed

packages/kbn-check-saved-objects-cli/current_fields.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
"observables.value",
186186
"owner",
187187
"settings",
188+
"settings.extractObservables",
188189
"settings.syncAlerts",
189190
"severity",
190191
"status",

packages/kbn-check-saved-objects-cli/current_mappings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@
649649
"properties": {
650650
"syncAlerts": {
651651
"type": "boolean"
652+
},
653+
"extractObservables": {
654+
"type": "boolean"
652655
}
653656
}
654657
},

src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
7979
"canvas-element": "288fd8d216eb49cbeb5e8f7491f207ef074b80dd",
8080
"canvas-workpad": "5cd605383a100a27941cca6cbf2d954aa96a16e2",
8181
"canvas-workpad-template": "f9a6ffab76ddfcd8fa3823002aa576c8f1d0e686",
82-
"cases": "9f91e6f385bbc09dc16c63309363822700a1ae53",
82+
"cases": "cd5fa06dcdbe902d3647666a10e16b233810d0e4",
8383
"cases-comments": "235311d14fbba84faf8ce1f32c31ddb3a435bacb",
8484
"cases-configure": "66d4c64d83b464f5166005b8ffa03b721fcaaf8b",
8585
"cases-connector-mappings": "877bb4d52e9821e330622bd75fba799490ec6952",
@@ -406,9 +406,9 @@ describe('checking migration metadata changes on all registered SO types', () =>
406406
"canvas-workpad-template|warning: The SO type owner should ensure these transform functions DO NOT mutate after they are defined.",
407407
"================================================================================================================================",
408408
"cases|global: 58923536ede82aed6c22799b52c4f51f4bf66aba",
409-
"cases|mappings: 2ee9c5f866298b30dbdcfd22d952ebbecb6582fb",
409+
"cases|mappings: 8531977e6b164e1d0072a24c84e390beedb5756f",
410410
"cases|schemas: da39a3ee5e6b4b0d3255bfef95601890afd80709",
411-
"cases|10.5.0: 96204bccc728de96e75fd5cc7d82c5990429fbf6",
411+
"cases|10.5.0: 566d7b907e87be36f8cac8152d2f721bf91bcead",
412412
"cases|10.4.0: 3b1d7eee41677f6b5e78b5d3b6108e6c12ae0222",
413413
"cases|10.3.0: e75b333589e368f47fb160e6dd01200590e3c313",
414414
"cases|10.2.0: bf34bde323a6d193f85d11a9ca87d52263beace6",

x-pack/platform/plugins/shared/cases/common/types/api/case/v1.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const basicCase: Case = {
9999
version: 'WzQ3LDFd',
100100
settings: {
101101
syncAlerts: true,
102+
extractObservables: false,
102103
},
103104
// damaged_raccoon uid
104105
assignees: [{ uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0' }],
@@ -151,6 +152,7 @@ describe('CasePostRequestRt', () => {
151152
},
152153
settings: {
153154
syncAlerts: true,
155+
extractObservables: undefined,
154156
},
155157
owner: 'cases',
156158
severity: CaseSeverity.LOW,

x-pack/platform/plugins/shared/cases/common/types/domain/case/v1.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const basicCase = {
7171
version: 'WzQ3LDFd',
7272
settings: {
7373
syncAlerts: true,
74+
extractObservables: false,
7475
},
7576
// damaged_raccoon uid
7677
assignees: [{ uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0' }],
@@ -146,20 +147,24 @@ describe('RelatedCaseRt', () => {
146147

147148
describe('SettingsRt', () => {
148149
it('has expected attributes in request', () => {
149-
const query = CaseSettingsRt.decode({ syncAlerts: true });
150+
const query = CaseSettingsRt.decode({ syncAlerts: true, extractObservables: true });
150151

151152
expect(query).toStrictEqual({
152153
_tag: 'Right',
153-
right: { syncAlerts: true },
154+
right: { syncAlerts: true, extractObservables: true },
154155
});
155156
});
156157

157158
it('removes foo:bar attributes from request', () => {
158-
const query = CaseSettingsRt.decode({ syncAlerts: false, foo: 'bar' });
159+
const query = CaseSettingsRt.decode({
160+
syncAlerts: false,
161+
extractObservables: false,
162+
foo: 'bar',
163+
});
159164

160165
expect(query).toStrictEqual({
161166
_tag: 'Right',
162-
right: { syncAlerts: false },
167+
right: { syncAlerts: false, extractObservables: false },
163168
});
164169
});
165170
});
@@ -178,6 +183,7 @@ describe('CaseAttributesRt', () => {
178183
},
179184
settings: {
180185
syncAlerts: true,
186+
extractObservables: true,
181187
},
182188
owner: 'cases',
183189
severity: CaseSeverity.LOW,

x-pack/platform/plugins/shared/cases/common/types/domain/case/v1.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ export const CaseSeverityRt = rt.union([
4949
* Case
5050
*/
5151

52-
export const CaseSettingsRt = rt.strict({
53-
syncAlerts: rt.boolean,
54-
});
52+
export const CaseSettingsRt = rt.intersection([
53+
rt.strict({
54+
syncAlerts: rt.boolean,
55+
}),
56+
rt.exact(
57+
rt.partial({
58+
extractObservables: rt.boolean,
59+
})
60+
),
61+
]);
5562

5663
const CaseBaseFields = {
5764
/**

x-pack/platform/plugins/shared/cases/common/types/domain/configure/v1.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ describe('configure', () => {
8282
},
8383
settings: {
8484
syncAlerts: true,
85+
extractObservables: true,
8586
},
8687
},
8788
};

x-pack/platform/plugins/shared/cases/public/components/case_action_bar/index.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ describe('CaseActionBar', () => {
9494
key: 'settings',
9595
value: {
9696
syncAlerts: false,
97+
extractObservables: true,
9798
},
9899
});
99100
});

x-pack/platform/plugins/shared/cases/public/containers/mock.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export const basicCase: CaseUI = {
270270
version: 'WzQ3LDFd',
271271
settings: {
272272
syncAlerts: true,
273+
extractObservables: true,
273274
},
274275
// damaged_raccoon uid
275276
assignees: [{ uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0' }],
@@ -309,6 +310,7 @@ export const caseWithAlertsSyncOff = {
309310
totalAlerts: 2,
310311
settings: {
311312
syncAlerts: false,
313+
extractObservables: false,
312314
},
313315
id: caseWithAlertsSyncOffId,
314316
};
@@ -410,6 +412,7 @@ export const mockCase: CaseUI = {
410412
version: 'WzQ3LDFd',
411413
settings: {
412414
syncAlerts: true,
415+
extractObservables: true,
413416
},
414417
assignees: [],
415418
category: null,
@@ -615,6 +618,7 @@ export const caseWithAlertsSyncOffSnake = {
615618
totalAlerts: 2,
616619
settings: {
617620
syncAlerts: false,
621+
extractObservables: false,
618622
},
619623
id: caseWithAlertsSyncOffId,
620624
};
@@ -742,7 +746,7 @@ export const getUserAction = (
742746
severity: CaseSeverity.LOW,
743747
title: 'a title',
744748
tags: ['a tag'],
745-
settings: { syncAlerts: true },
749+
settings: { syncAlerts: true, extractObservables: true },
746750
owner: SECURITY_SOLUTION_OWNER,
747751
assignees: [],
748752
},
@@ -776,7 +780,7 @@ export const getUserAction = (
776780
return {
777781
...commonProperties,
778782
type: UserActionTypes.settings,
779-
payload: { settings: { syncAlerts: true } },
783+
payload: { settings: { syncAlerts: true, extractObservables: true } },
780784
...overrides,
781785
};
782786
case UserActionTypes.status:

x-pack/platform/plugins/shared/cases/server/client/cases/bulk_create.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('bulkCreate', () => {
4747
type: ConnectorTypes.none,
4848
fields: null,
4949
},
50-
settings: { syncAlerts: true },
50+
settings: { syncAlerts: true, extractObservables: true },
5151
severity: CaseSeverity.LOW,
5252
owner: SECURITY_SOLUTION_OWNER,
5353
assignees: [{ uid: '1' }],
@@ -125,6 +125,7 @@ describe('bulkCreate', () => {
125125
"observables": Array [],
126126
"owner": "securitySolution",
127127
"settings": Object {
128+
"extractObservables": true,
128129
"syncAlerts": true,
129130
},
130131
"severity": "low",
@@ -171,6 +172,7 @@ describe('bulkCreate', () => {
171172
"observables": Array [],
172173
"owner": "securitySolution",
173174
"settings": Object {
175+
"extractObservables": true,
174176
"syncAlerts": true,
175177
},
176178
"severity": "critical",
@@ -253,6 +255,7 @@ describe('bulkCreate', () => {
253255
"observables": Array [],
254256
"owner": "securitySolution",
255257
"settings": Object {
258+
"extractObservables": true,
256259
"syncAlerts": true,
257260
},
258261
"severity": "low",
@@ -293,6 +296,7 @@ describe('bulkCreate', () => {
293296
"observables": Array [],
294297
"owner": "securitySolution",
295298
"settings": Object {
299+
"extractObservables": true,
296300
"syncAlerts": true,
297301
},
298302
"severity": "critical",
@@ -1253,7 +1257,7 @@ describe('bulkCreate', () => {
12531257
customFields: [],
12541258
description: 'This is a brand new case of a bad meanie defacing data',
12551259
owner: 'securitySolution',
1256-
settings: { syncAlerts: true },
1260+
settings: { syncAlerts: true, extractObservables: true },
12571261
severity: 'low',
12581262
tags: ['defacement'],
12591263
title: 'Super Bad Security Issue',
@@ -1287,7 +1291,7 @@ describe('bulkCreate', () => {
12871291
customFields: [],
12881292
description: 'This is a brand new case of a bad meanie defacing data',
12891293
owner: 'securitySolution',
1290-
settings: { syncAlerts: true },
1294+
settings: { syncAlerts: true, extractObservables: true },
12911295
severity: 'low',
12921296
tags: ['defacement'],
12931297
title: 'Super Bad Security Issue',

0 commit comments

Comments
 (0)