diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index 05e8fecdcaad1..923f4704aa652 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -22,20 +22,22 @@ import { } from '../constants'; import { - migratePackagePolicyToV7110, - migratePackagePolicyToV7120, - // @ts-expect-error -} from './security_solution'; -import { - migrateAgentToV7100, + migrateAgentActionToV7100, migrateAgentEventToV7100, migrateAgentPolicyToV7100, + migrateAgentToV7100, migrateEnrollmentApiKeysToV7100, migratePackagePolicyToV7100, migrateSettingsToV7100, - migrateAgentActionToV7100, } from './migrations/to_v7_10_0'; -import { migrateAgentToV7120, migrateAgentPolicyToV7120 } from './migrations/to_v7_12_0'; + +import { migratePackagePolicyToV7110 } from './migrations/to_v7_11_0'; + +import { + migrateAgentPolicyToV7120, + migrateAgentToV7120, + migratePackagePolicyToV7120, +} from './migrations/to_v7_12_0'; /* * Saved object types and mappings diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/index.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/index.ts new file mode 100644 index 0000000000000..bbdd3f14fe22f --- /dev/null +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export { migratePackagePolicyToV7110 } from './to_v7_11_0'; +export { migratePackagePolicyToV7120 } from './to_v7_12_0'; diff --git a/x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_11_0.test.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_11_0.test.ts similarity index 98% rename from x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_11_0.test.ts rename to x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_11_0.test.ts index 251539113fee1..71a87793727a8 100644 --- a/x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_11_0.test.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_11_0.test.ts @@ -6,7 +6,9 @@ */ import { SavedObjectMigrationContext, SavedObjectUnsanitizedDoc } from 'kibana/server'; -import { PackagePolicy } from '../../../../../fleet/common'; + +import type { PackagePolicy } from '../../../../common'; + import { migratePackagePolicyToV7110 } from './to_v7_11_0'; describe('7.11.0 Endpoint Package Policy migration', () => { diff --git a/x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_11_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_11_0.ts similarity index 95% rename from x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_11_0.ts rename to x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_11_0.ts index d0dc4f547332a..445b84995353b 100644 --- a/x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_11_0.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_11_0.ts @@ -7,7 +7,8 @@ import { SavedObjectMigrationFn, SavedObjectUnsanitizedDoc } from 'kibana/server'; import { cloneDeep } from 'lodash'; -import { PackagePolicy } from '../../../../../fleet/common'; + +import type { PackagePolicy } from '../../../../common'; export const migratePackagePolicyToV7110: SavedObjectMigrationFn = ( packagePolicyDoc diff --git a/x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_12_0.test.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_12_0.test.ts similarity index 91% rename from x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_12_0.test.ts rename to x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_12_0.test.ts index 936d90cc1aa9c..e2f73270efbca 100644 --- a/x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_12_0.test.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_12_0.test.ts @@ -6,14 +6,15 @@ */ import { SavedObjectMigrationContext, SavedObjectUnsanitizedDoc } from 'kibana/server'; -import { PackagePolicy } from '../../../../../fleet/common'; -import { PolicyData, ProtectionModes } from '../../types'; + +import type { PackagePolicy } from '../../../../common'; + import { migratePackagePolicyToV7120 } from './to_v7_12_0'; describe('7.12.0 Endpoint Package Policy migration', () => { const migration = migratePackagePolicyToV7120; it('adds ransomware option and notification customization', () => { - const doc: SavedObjectUnsanitizedDoc = { + const doc = { id: 'mock-saved-object-id', attributes: { name: 'Some Policy Name', @@ -41,7 +42,6 @@ describe('7.12.0 Endpoint Package Policy migration', () => { policy: { value: { windows: { - // @ts-expect-error popup: { malware: { message: '', @@ -58,9 +58,7 @@ describe('7.12.0 Endpoint Package Policy migration', () => { type: ' nested', }; - expect( - migration(doc, {} as SavedObjectMigrationContext) as SavedObjectUnsanitizedDoc - ).toEqual({ + expect(migration(doc, {} as SavedObjectMigrationContext)).toEqual({ attributes: { name: 'Some Policy Name', package: { @@ -88,7 +86,7 @@ describe('7.12.0 Endpoint Package Policy migration', () => { value: { windows: { ransomware: { - mode: ProtectionModes.off, + mode: 'off', }, popup: { malware: { diff --git a/x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_12_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_12_0.ts similarity index 88% rename from x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_12_0.ts rename to x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_12_0.ts index 06d505a71025f..c10a89fea6b18 100644 --- a/x-pack/plugins/security_solution/common/endpoint/policy/migrations/to_v7_12_0.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_12_0.ts @@ -7,8 +7,8 @@ import { SavedObjectMigrationFn, SavedObjectUnsanitizedDoc } from 'kibana/server'; import { cloneDeep } from 'lodash'; -import { PackagePolicy } from '../../../../../fleet/common'; -import { ProtectionModes } from '../../types'; + +import type { PackagePolicy } from '../../../../common'; export const migratePackagePolicyToV7120: SavedObjectMigrationFn = ( packagePolicyDoc @@ -19,7 +19,7 @@ export const migratePackagePolicyToV7120: SavedObjectMigrationFn = ( agentDoc ) => { diff --git a/x-pack/plugins/security_solution/common/shared_exports.ts b/x-pack/plugins/security_solution/common/shared_exports.ts index f10aaf45dcac3..bf740ddce9fd6 100644 --- a/x-pack/plugins/security_solution/common/shared_exports.ts +++ b/x-pack/plugins/security_solution/common/shared_exports.ts @@ -17,6 +17,4 @@ export { exactCheck } from './exact_check'; export { getPaths, foldLeftRight, removeExternalLinkText } from './test_utils'; export { validate, validateEither } from './validate'; export { formatErrors } from './format_errors'; -export { migratePackagePolicyToV7110 } from './endpoint/policy/migrations/to_v7_11_0'; -export { migratePackagePolicyToV7120 } from './endpoint/policy/migrations/to_v7_12_0'; export { addIdToItem, removeIdFromItem } from './add_remove_id_to_item';