From b32e62e3fe9739ae289a7e58e01677c1687eacae Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Tue, 15 Sep 2020 17:11:38 +0100 Subject: [PATCH] migrate siem consumer --- .../server/saved_objects/migrations.test.ts | 17 +++++++++++++++++ .../alerts/server/saved_objects/migrations.ts | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/x-pack/plugins/alerts/server/saved_objects/migrations.test.ts b/x-pack/plugins/alerts/server/saved_objects/migrations.test.ts index 84af646a6e2ee..1c1261ae3fa08 100644 --- a/x-pack/plugins/alerts/server/saved_objects/migrations.test.ts +++ b/x-pack/plugins/alerts/server/saved_objects/migrations.test.ts @@ -52,6 +52,23 @@ describe('7.10.0', () => { }); }); + test('migrates the consumer for siem', () => { + const migration710 = getMigrations(encryptedSavedObjectsSetup)['7.10.0']; + const alert = getMockData({ + consumer: 'securitySolution', + }); + expect(migration710(alert, { log })).toMatchObject({ + ...alert, + attributes: { + ...alert.attributes, + consumer: 'siem', + meta: { + versionApiKeyLastmodified: 'pre-7.10.0', + }, + }, + }); + }); + test('migrates the consumer for alerting', () => { const migration710 = getMigrations(encryptedSavedObjectsSetup)['7.10.0']; const alert = getMockData({ diff --git a/x-pack/plugins/alerts/server/saved_objects/migrations.ts b/x-pack/plugins/alerts/server/saved_objects/migrations.ts index c877f955468c3..c88f4d786c212 100644 --- a/x-pack/plugins/alerts/server/saved_objects/migrations.ts +++ b/x-pack/plugins/alerts/server/saved_objects/migrations.ts @@ -11,6 +11,10 @@ import { } from '../../../../../src/core/server'; import { RawAlert } from '../types'; import { EncryptedSavedObjectsPluginSetup } from '../../../encrypted_saved_objects/server'; +import { + APP_ID as SIEM_APP_ID, + SERVER_APP_ID as SIEM_SERVER_APP_ID, +} from '../../../security_solution/common/constants'; export const LEGACY_LAST_MODIFIED_VERSION = 'pre-7.10.0'; @@ -45,6 +49,7 @@ const consumersToChange: Map = new Map( Object.entries({ alerting: 'alerts', metrics: 'infrastructure', + [SIEM_APP_ID]: SIEM_SERVER_APP_ID, }) ); function markAsLegacyAndChangeConsumer(