From 15daa0fca3996ed3ca2cf96f5ce6fcf7d2b7e59a Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Tue, 18 Apr 2023 17:20:09 -0400 Subject: [PATCH 01/10] [Security Solution] Remove index false from artifact saved objects mappings --- .../endpoint/lib/artifacts/saved_object_mappings.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts index 9ce550859da4d..a72d90250d0f5 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts @@ -14,36 +14,31 @@ export const exceptionsArtifactSavedObjectType = ArtifactConstants.SAVED_OBJECT_ export const manifestSavedObjectType = ManifestConstants.SAVED_OBJECT_TYPE; export const exceptionsArtifactSavedObjectMappings: SavedObjectsType['mappings'] = { + dynamic: false, properties: { identifier: { type: 'keyword', }, compressionAlgorithm: { type: 'keyword', - index: false, }, encryptionAlgorithm: { type: 'keyword', - index: false, }, encodedSha256: { type: 'keyword', }, encodedSize: { type: 'long', - index: false, }, decodedSha256: { type: 'keyword', - index: false, }, decodedSize: { type: 'long', - index: false, }, created: { type: 'date', - index: false, }, body: { type: 'binary', @@ -52,28 +47,25 @@ export const exceptionsArtifactSavedObjectMappings: SavedObjectsType['mappings'] }; export const manifestSavedObjectMappings: SavedObjectsType['mappings'] = { + dynamic: false, properties: { created: { type: 'date', - index: false, }, schemaVersion: { type: 'keyword', }, semanticVersion: { type: 'keyword', - index: false, }, artifacts: { type: 'nested', properties: { policyId: { type: 'keyword', - index: false, }, artifactId: { type: 'keyword', - index: false, }, }, }, From 891b39f7593d45dcb67a2f9716fda3dbafe994e2 Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Tue, 18 Apr 2023 18:11:18 -0400 Subject: [PATCH 02/10] update snapshot --- .../migrations/group2/check_registered_types.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts b/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts index 09977e1c272ab..b585f8fc06a91 100644 --- a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts +++ b/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts @@ -81,8 +81,8 @@ describe('checking migration metadata changes on all registered SO types', () => "core-usage-stats": "b3c04da317c957741ebcdedfea4524049fdc79ff", "csp-rule-template": "099c229bf97578d9ca72b3a672d397559b84ee0b", "dashboard": "71e3f8dfcffeb5fbd410dec81ce46f5691763c43", - "endpoint:user-artifact": "a5b154962fb6cdf5d9e7452e58690054c95cc72a", - "endpoint:user-artifact-manifest": "5989989c0f84dd2d02da1eb46b6254e334bd2ccd", + "endpoint:user-artifact": "1bc8f4ab74f9bb0d90239a431d435c16f31cc32e", + "endpoint:user-artifact-manifest": "17d17827606db55e7499b1dab259263ffee3bb09", "enterprise_search_telemetry": "4b41830e3b28a16eb92dee0736b44ae6276ced9b", "epm-packages": "83235af7c95fd9bfb1d70996a5511e05b3fcc9ef", "epm-packages-assets": "00c8b5e5bf059627ffc9fbde920e1ac75926c5f6", From 19d06c7c3ee1ad8db562d8e5702ba57738f72597 Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Wed, 19 Apr 2023 15:16:38 -0400 Subject: [PATCH 03/10] delete unused SO --- .../src/core/unused_types.ts | 2 + .../group2/check_registered_types.test.ts | 1 - .../migrate_artifacts_to_fleet.test.ts | 144 ------------------ .../artifacts/migrate_artifacts_to_fleet.ts | 96 ------------ .../lib/artifacts/saved_object_mappings.ts | 40 ----- .../security_solution/server/plugin.ts | 21 ++- .../security_solution/server/saved_objects.ts | 2 - 7 files changed, 11 insertions(+), 295 deletions(-) delete mode 100644 x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts delete mode 100644 x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.ts diff --git a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/core/unused_types.ts b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/core/unused_types.ts index 46ddd23251217..2f9dd57afa294 100644 --- a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/core/unused_types.ts +++ b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/core/unused_types.ts @@ -47,6 +47,8 @@ export const REMOVED_TYPES: string[] = [ 'csp_rule', // Removed in 8.8 https://github.com/elastic/kibana/pull/151116 'upgrade-assistant-telemetry', + // Removed in 8.8 https://github.com/elastic/kibana/pull/155204 + 'endpoint:user-artifact', ].sort(); export const excludeUnusedTypesQuery: QueryDslQueryContainer = { diff --git a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts b/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts index b585f8fc06a91..e3a54b835f008 100644 --- a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts +++ b/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts @@ -81,7 +81,6 @@ describe('checking migration metadata changes on all registered SO types', () => "core-usage-stats": "b3c04da317c957741ebcdedfea4524049fdc79ff", "csp-rule-template": "099c229bf97578d9ca72b3a672d397559b84ee0b", "dashboard": "71e3f8dfcffeb5fbd410dec81ce46f5691763c43", - "endpoint:user-artifact": "1bc8f4ab74f9bb0d90239a431d435c16f31cc32e", "endpoint:user-artifact-manifest": "17d17827606db55e7499b1dab259263ffee3bb09", "enterprise_search_telemetry": "4b41830e3b28a16eb92dee0736b44ae6276ced9b", "epm-packages": "83235af7c95fd9bfb1d70996a5511e05b3fcc9ef", diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts deleted file mode 100644 index 277772253b92e..0000000000000 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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. - */ - -import { - loggingSystemMock, - savedObjectsClientMock, - elasticsearchServiceMock, -} from '@kbn/core/server/mocks'; -import type { - SavedObjectsClient, - Logger, - SavedObjectsFindResponse, - SavedObjectsFindResult, -} from '@kbn/core/server'; -import { migrateArtifactsToFleet } from './migrate_artifacts_to_fleet'; -import { createEndpointArtifactClientMock } from '../../services/artifacts/mocks'; -import type { InternalArtifactCompleteSchema } from '../../schemas'; -import { generateArtifactEsGetSingleHitMock } from '@kbn/fleet-plugin/server/services/artifacts/mocks'; -import type { NewArtifact } from '@kbn/fleet-plugin/server/services'; -import type { CreateRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; - -describe('When migrating artifacts to fleet', () => { - let soClient: jest.Mocked; - let logger: jest.Mocked; - let artifactClient: ReturnType; - /** An artifact that was created prior to 7.14 */ - let soArtifactEntry: InternalArtifactCompleteSchema; - - const createSoFindResult = ( - soHits: SavedObjectsFindResult[] = [], - total: number = 15, - page: number = 1 - ): SavedObjectsFindResponse => { - return { - total, - page, - per_page: 10, - saved_objects: soHits, - }; - }; - - beforeEach(async () => { - soClient = savedObjectsClientMock.create() as unknown as jest.Mocked; - logger = loggingSystemMock.create().get() as jest.Mocked; - artifactClient = createEndpointArtifactClientMock(); - // pre-v7.14 artifact, which is compressed - soArtifactEntry = { - identifier: 'endpoint-exceptionlist-macos-v1', - compressionAlgorithm: 'zlib', - encryptionAlgorithm: 'none', - decodedSha256: 'd801aa1fb7ddcc330a5e3173372ea6af4a3d08ec58074478e85aa5603e926658', - encodedSha256: 'f8e6afa1d5662f5b37f83337af774b5785b5b7f1daee08b7b00c2d6813874cda', - decodedSize: 14, - encodedSize: 22, - body: 'eJyrVkrNKynKTC1WsoqOrQUAJxkFKQ==', - }; - - // Mock the esClient create response to include the artifact properties that were provide - // to it by fleet artifact client - artifactClient._esClient.create.mockImplementation((props: CreateRequest) => { - return elasticsearchServiceMock.createSuccessTransportRequestPromise({ - ...generateArtifactEsGetSingleHitMock({ - ...((props?.body ?? {}) as NewArtifact), - }), - _index: '.fleet-artifacts-7', - _id: `endpoint:endpoint-exceptionlist-macos-v1-${ - // @ts-expect-error TS2339 - props?.body?.decodedSha256 ?? 'UNKNOWN?' - }`, - _version: 1, - result: 'created', - _shards: { - total: 1, - successful: 1, - failed: 0, - }, - _seq_no: 0, - _primary_term: 1, - }); - }); - - soClient.find.mockResolvedValue(createSoFindResult([], 0)).mockResolvedValueOnce( - createSoFindResult([ - { - score: 1, - type: '', - id: 'abc123', - references: [], - attributes: soArtifactEntry, - }, - ]) - ); - }); - - it('should do nothing if there are no artifacts', async () => { - soClient.find.mockReset(); - soClient.find.mockResolvedValue(createSoFindResult([], 0)); - await migrateArtifactsToFleet(soClient, artifactClient, logger); - expect(soClient.find).toHaveBeenCalled(); - expect(artifactClient.createArtifact).not.toHaveBeenCalled(); - expect(soClient.delete).not.toHaveBeenCalled(); - }); - - it('should create new artifact via fleet client and delete prior SO one', async () => { - await migrateArtifactsToFleet(soClient, artifactClient, logger); - expect(artifactClient.createArtifact).toHaveBeenCalled(); - expect(soClient.delete).toHaveBeenCalled(); - }); - - it('should create artifact in fleet with attributes that match the SO version', async () => { - await migrateArtifactsToFleet(soClient, artifactClient, logger); - - await expect(artifactClient.createArtifact.mock.results[0].value).resolves.toEqual( - expect.objectContaining({ - ...soArtifactEntry, - compressionAlgorithm: 'zlib', - }) - ); - }); - - it('should ignore 404 responses for SO delete (multi-node kibana setup)', async () => { - const notFoundError: Error & { output?: { statusCode: number } } = new Error('not found'); - notFoundError.output = { statusCode: 404 }; - soClient.delete.mockRejectedValue(notFoundError); - await expect(migrateArtifactsToFleet(soClient, artifactClient, logger)).resolves.toEqual( - undefined - ); - expect(logger.debug).toHaveBeenCalledWith( - 'Artifact Migration: Attempt to delete Artifact SO [abc123] returned 404' - ); - }); - - it('should Throw() and log error if migration fails', async () => { - const error = new Error('test: delete failed'); - soClient.delete.mockRejectedValue(error); - await expect(migrateArtifactsToFleet(soClient, artifactClient, logger)).rejects.toThrow( - 'Artifact SO migration failed' - ); - }); -}); diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.ts deleted file mode 100644 index e015019fa8a5d..0000000000000 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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. - */ - -import { inflate as _inflate } from 'zlib'; -import { promisify } from 'util'; -import type { SavedObjectsClient, Logger } from '@kbn/core/server'; -import type { EndpointArtifactClientInterface } from '../../services'; -import type { InternalArtifactCompleteSchema, InternalArtifactSchema } from '../../schemas'; -import { ArtifactConstants } from './common'; - -class ArtifactMigrationError extends Error { - constructor(message: string, public readonly meta?: unknown) { - super(message); - } -} - -const inflateAsync = promisify(_inflate); - -function isCompressed(artifact: InternalArtifactSchema) { - return artifact.compressionAlgorithm === 'zlib'; -} - -/** - * With v7.13, artifact storage was moved from a security_solution saved object to a fleet index - * in order to support Fleet Server. - */ -export const migrateArtifactsToFleet = async ( - soClient: SavedObjectsClient, - endpointArtifactClient: EndpointArtifactClientInterface, - logger: Logger -): Promise => { - let totalArtifactsMigrated = -1; - let hasMore = true; - - try { - while (hasMore) { - // Retrieve list of artifact records - const { saved_objects: artifactList, total } = - await soClient.find({ - type: ArtifactConstants.SAVED_OBJECT_TYPE, - page: 1, - perPage: 10, - }); - - if (totalArtifactsMigrated === -1) { - totalArtifactsMigrated = total; - if (total > 0) { - logger.info(`Migrating artifacts from SavedObject`); - } - } - - // If nothing else to process, then exit out - if (total === 0) { - hasMore = false; - if (totalArtifactsMigrated > 0) { - logger.info(`Total Artifacts migrated: ${totalArtifactsMigrated}`); - } - return; - } - - for (const artifact of artifactList) { - if (isCompressed(artifact.attributes)) { - artifact.attributes = { - ...artifact.attributes, - body: (await inflateAsync(Buffer.from(artifact.attributes.body, 'base64'))).toString( - 'base64' - ), - }; - } - - // Create new artifact in fleet index - await endpointArtifactClient.createArtifact(artifact.attributes); - // Delete old artifact from SO and if there are errors here, then ignore 404's - // since multiple kibana instances could be going at this - try { - await soClient.delete(ArtifactConstants.SAVED_OBJECT_TYPE, artifact.id); - } catch (e) { - if (e?.output?.statusCode !== 404) { - throw e; - } - logger.debug( - `Artifact Migration: Attempt to delete Artifact SO [${artifact.id}] returned 404` - ); - } - } - } - } catch (e) { - const error = new ArtifactMigrationError('Artifact SO migration failed', e); - logger.error(error); - throw error; - } -}; diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts index a72d90250d0f5..efd6ef7ab719a 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts @@ -13,39 +13,6 @@ import { migrations } from './migrations'; export const exceptionsArtifactSavedObjectType = ArtifactConstants.SAVED_OBJECT_TYPE; export const manifestSavedObjectType = ManifestConstants.SAVED_OBJECT_TYPE; -export const exceptionsArtifactSavedObjectMappings: SavedObjectsType['mappings'] = { - dynamic: false, - properties: { - identifier: { - type: 'keyword', - }, - compressionAlgorithm: { - type: 'keyword', - }, - encryptionAlgorithm: { - type: 'keyword', - }, - encodedSha256: { - type: 'keyword', - }, - encodedSize: { - type: 'long', - }, - decodedSha256: { - type: 'keyword', - }, - decodedSize: { - type: 'long', - }, - created: { - type: 'date', - }, - body: { - type: 'binary', - }, - }, -}; - export const manifestSavedObjectMappings: SavedObjectsType['mappings'] = { dynamic: false, properties: { @@ -72,13 +39,6 @@ export const manifestSavedObjectMappings: SavedObjectsType['mappings'] = { }, }; -export const exceptionsArtifactType: SavedObjectsType = { - name: exceptionsArtifactSavedObjectType, - hidden: false, - namespaceType: 'agnostic', - mappings: exceptionsArtifactSavedObjectMappings, -}; - export const manifestType: SavedObjectsType = { name: manifestSavedObjectType, hidden: false, diff --git a/x-pack/plugins/security_solution/server/plugin.ts b/x-pack/plugins/security_solution/server/plugin.ts index 2b6048c122f27..fce56379f1b2e 100644 --- a/x-pack/plugins/security_solution/server/plugin.ts +++ b/x-pack/plugins/security_solution/server/plugin.ts @@ -69,7 +69,6 @@ import type { ITelemetryReceiver } from './lib/telemetry/receiver'; import { TelemetryReceiver } from './lib/telemetry/receiver'; import { licenseService } from './lib/license'; import { PolicyWatcher } from './endpoint/lib/policy/license_watch'; -import { migrateArtifactsToFleet } from './endpoint/lib/artifacts/migrate_artifacts_to_fleet'; import previewPolicy from './lib/detection_engine/routes/index/preview_policy.json'; import { createRuleExecutionLogService } from './lib/detection_engine/rule_monitoring'; import { getKibanaPrivilegesFeaturePrivileges, getCasesKibanaFeature } from './features'; @@ -448,17 +447,15 @@ export class Plugin implements ISecuritySolutionPlugin { // Migrate artifacts to fleet and then start the minifest task after that is done plugins.fleet.fleetSetupCompleted().then(() => { - migrateArtifactsToFleet(savedObjectsClient, artifactClient, logger).finally(() => { - logger.info('Dependent plugin setup complete - Starting ManifestTask'); - - if (this.manifestTask) { - this.manifestTask.start({ - taskManager, - }); - } else { - logger.error(new Error('User artifacts task not available.')); - } - }); + logger.info('Dependent plugin setup complete - Starting ManifestTask'); + + if (this.manifestTask) { + this.manifestTask.start({ + taskManager, + }); + } else { + logger.error(new Error('User artifacts task not available.')); + } }); // License related start diff --git a/x-pack/plugins/security_solution/server/saved_objects.ts b/x-pack/plugins/security_solution/server/saved_objects.ts index 394cab7f52455..d29e560ec64d1 100644 --- a/x-pack/plugins/security_solution/server/saved_objects.ts +++ b/x-pack/plugins/security_solution/server/saved_objects.ts @@ -13,7 +13,6 @@ import { legacyType as legacyRuleActionsType } from './lib/detection_engine/rule import { prebuiltRuleAssetType } from './lib/detection_engine/prebuilt_rules'; import { type as signalsMigrationType } from './lib/detection_engine/migrations/saved_objects'; import { - exceptionsArtifactType, manifestType, } from './endpoint/lib/artifacts/saved_object_mappings'; @@ -23,7 +22,6 @@ const types = [ legacyRuleActionsType, prebuiltRuleAssetType, timelineType, - exceptionsArtifactType, manifestType, signalsMigrationType, ]; From 3af7d62f57025fbeae6dcac084c9ec2bfef853e8 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 19 Apr 2023 19:22:57 +0000 Subject: [PATCH 04/10] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- x-pack/plugins/security_solution/server/saved_objects.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x-pack/plugins/security_solution/server/saved_objects.ts b/x-pack/plugins/security_solution/server/saved_objects.ts index d29e560ec64d1..bd6c21a4d489a 100644 --- a/x-pack/plugins/security_solution/server/saved_objects.ts +++ b/x-pack/plugins/security_solution/server/saved_objects.ts @@ -12,9 +12,7 @@ import { noteType, pinnedEventType, timelineType } from './lib/timeline/saved_ob import { legacyType as legacyRuleActionsType } from './lib/detection_engine/rule_actions_legacy'; import { prebuiltRuleAssetType } from './lib/detection_engine/prebuilt_rules'; import { type as signalsMigrationType } from './lib/detection_engine/migrations/saved_objects'; -import { - manifestType, -} from './endpoint/lib/artifacts/saved_object_mappings'; +import { manifestType } from './endpoint/lib/artifacts/saved_object_mappings'; const types = [ noteType, From 13edaf325559ed1962a2f6698d3b1e151725a6dd Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Wed, 19 Apr 2023 16:03:39 -0400 Subject: [PATCH 05/10] remove fields that were not indexed --- .../endpoint/lib/artifacts/saved_object_mappings.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts index efd6ef7ab719a..4be7aa053b25c 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts @@ -22,19 +22,8 @@ export const manifestSavedObjectMappings: SavedObjectsType['mappings'] = { schemaVersion: { type: 'keyword', }, - semanticVersion: { - type: 'keyword', - }, artifacts: { type: 'nested', - properties: { - policyId: { - type: 'keyword', - }, - artifactId: { - type: 'keyword', - }, - }, }, }, }; From 0ea2a73eb4b52ec3f72eaf647ac7b4a9c4c6d0ae Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Wed, 19 Apr 2023 16:06:18 -0400 Subject: [PATCH 06/10] remove last field --- .../server/endpoint/lib/artifacts/saved_object_mappings.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts index 4be7aa053b25c..a425b4f9966ca 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/saved_object_mappings.ts @@ -16,9 +16,6 @@ export const manifestSavedObjectType = ManifestConstants.SAVED_OBJECT_TYPE; export const manifestSavedObjectMappings: SavedObjectsType['mappings'] = { dynamic: false, properties: { - created: { - type: 'date', - }, schemaVersion: { type: 'keyword', }, From efdd7b1294c7b887ec2bcb7ded737ec96b3da3ea Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Wed, 19 Apr 2023 16:49:20 -0400 Subject: [PATCH 07/10] fix test --- .../migrations/group2/check_registered_types.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts b/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts index e3a54b835f008..14c13bb179448 100644 --- a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts +++ b/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts @@ -81,7 +81,7 @@ describe('checking migration metadata changes on all registered SO types', () => "core-usage-stats": "b3c04da317c957741ebcdedfea4524049fdc79ff", "csp-rule-template": "099c229bf97578d9ca72b3a672d397559b84ee0b", "dashboard": "71e3f8dfcffeb5fbd410dec81ce46f5691763c43", - "endpoint:user-artifact-manifest": "17d17827606db55e7499b1dab259263ffee3bb09", + "endpoint:user-artifact-manifest": "8ad9bd235dcfdc18b567aef0dc36ac686193dc89", "enterprise_search_telemetry": "4b41830e3b28a16eb92dee0736b44ae6276ced9b", "epm-packages": "83235af7c95fd9bfb1d70996a5511e05b3fcc9ef", "epm-packages-assets": "00c8b5e5bf059627ffc9fbde920e1ac75926c5f6", From e95a49f65561e8d9f0600a7193e96c9998924e63 Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Wed, 19 Apr 2023 17:49:32 -0400 Subject: [PATCH 08/10] fix tests --- ...grations_state_action_machine.test.ts.snap | 30 +++++++++++++++++++ .../src/initial_state.test.ts | 5 ++++ 2 files changed, 35 insertions(+) diff --git a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap index cd2b218d58dd4..e5d9fde9f6c73 100644 --- a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap +++ b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap @@ -134,6 +134,11 @@ Object { "type": "upgrade-assistant-telemetry", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, ], }, }, @@ -321,6 +326,11 @@ Object { "type": "upgrade-assistant-telemetry", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, ], }, }, @@ -512,6 +522,11 @@ Object { "type": "upgrade-assistant-telemetry", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, ], }, }, @@ -707,6 +722,11 @@ Object { "type": "upgrade-assistant-telemetry", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, ], }, }, @@ -950,6 +970,11 @@ Object { "type": "upgrade-assistant-telemetry", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, ], }, }, @@ -1148,6 +1173,11 @@ Object { "type": "upgrade-assistant-telemetry", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, ], }, }, diff --git a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/initial_state.test.ts b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/initial_state.test.ts index 2dcadc9ab0210..e97cc69ac08b5 100644 --- a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/initial_state.test.ts +++ b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/initial_state.test.ts @@ -168,6 +168,11 @@ describe('createInitialState', () => { "type": "upgrade-assistant-telemetry", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, ], }, }, From 8230f87cf36d2d788a5882e8dabd39347850df49 Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Thu, 20 Apr 2023 07:29:24 -0400 Subject: [PATCH 09/10] actually fix tests --- ...grations_state_action_machine.test.ts.snap | 60 +++++++++---------- .../src/initial_state.test.ts | 10 ++-- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap index e5d9fde9f6c73..e23d6e857802a 100644 --- a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap +++ b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap @@ -54,6 +54,11 @@ Object { "type": "csp_rule", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, Object { "term": Object { "type": "file-upload-telemetry", @@ -134,11 +139,6 @@ Object { "type": "upgrade-assistant-telemetry", }, }, - Object { - "term": Object { - "type": "endpoint:user-artifact", - }, - }, ], }, }, @@ -246,6 +246,11 @@ Object { "type": "csp_rule", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, Object { "term": Object { "type": "file-upload-telemetry", @@ -326,11 +331,6 @@ Object { "type": "upgrade-assistant-telemetry", }, }, - Object { - "term": Object { - "type": "endpoint:user-artifact", - }, - }, ], }, }, @@ -442,6 +442,11 @@ Object { "type": "csp_rule", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, Object { "term": Object { "type": "file-upload-telemetry", @@ -522,11 +527,6 @@ Object { "type": "upgrade-assistant-telemetry", }, }, - Object { - "term": Object { - "type": "endpoint:user-artifact", - }, - }, ], }, }, @@ -642,6 +642,11 @@ Object { "type": "csp_rule", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, Object { "term": Object { "type": "file-upload-telemetry", @@ -722,11 +727,6 @@ Object { "type": "upgrade-assistant-telemetry", }, }, - Object { - "term": Object { - "type": "endpoint:user-artifact", - }, - }, ], }, }, @@ -890,6 +890,11 @@ Object { "type": "csp_rule", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, Object { "term": Object { "type": "file-upload-telemetry", @@ -970,11 +975,6 @@ Object { "type": "upgrade-assistant-telemetry", }, }, - Object { - "term": Object { - "type": "endpoint:user-artifact", - }, - }, ], }, }, @@ -1093,6 +1093,11 @@ Object { "type": "csp_rule", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, Object { "term": Object { "type": "file-upload-telemetry", @@ -1173,11 +1178,6 @@ Object { "type": "upgrade-assistant-telemetry", }, }, - Object { - "term": Object { - "type": "endpoint:user-artifact", - }, - }, ], }, }, diff --git a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/initial_state.test.ts b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/initial_state.test.ts index e97cc69ac08b5..ae7c47850dfd6 100644 --- a/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/initial_state.test.ts +++ b/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/initial_state.test.ts @@ -88,6 +88,11 @@ describe('createInitialState', () => { "type": "csp_rule", }, }, + Object { + "term": Object { + "type": "endpoint:user-artifact", + }, + }, Object { "term": Object { "type": "file-upload-telemetry", @@ -168,11 +173,6 @@ describe('createInitialState', () => { "type": "upgrade-assistant-telemetry", }, }, - Object { - "term": Object { - "type": "endpoint:user-artifact", - }, - }, ], }, }, From 85395d589b7ad726d0afe95b00b24edb849df432 Mon Sep 17 00:00:00 2001 From: Kevin Logan Date: Tue, 25 Apr 2023 07:32:02 -0400 Subject: [PATCH 10/10] update after kibana index split --- .../saved_objects/migrations/group3/split_kibana_index.test.ts | 1 - .../saved_objects/delete_unknown_types/mappings.json | 2 -- .../fixtures/es_archiver/deprecations_service/mappings.json | 1 - .../saved_objects_management/export_transform/mappings.json | 1 - .../saved_objects_management/hidden_saved_objects/mappings.json | 1 - .../nested_export_transform/mappings.json | 1 - .../visible_in_management/mappings.json | 2 -- .../fixtures/es_archiver/saved_objects/spaces/mappings.json | 2 -- .../fixtures/es_archiver/saved_objects/spaces/mappings.json | 2 -- 9 files changed, 13 deletions(-) diff --git a/src/core/server/integration_tests/saved_objects/migrations/group3/split_kibana_index.test.ts b/src/core/server/integration_tests/saved_objects/migrations/group3/split_kibana_index.test.ts index 8c5f78a574db1..06b8c169cc396 100644 --- a/src/core/server/integration_tests/saved_objects/migrations/group3/split_kibana_index.test.ts +++ b/src/core/server/integration_tests/saved_objects/migrations/group3/split_kibana_index.test.ts @@ -188,7 +188,6 @@ describe('split .kibana index into multiple system indices', () => { "connector_token", "core-usage-stats", "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "enterprise_search_telemetry", "epm-packages", diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/delete_unknown_types/mappings.json b/test/api_integration/fixtures/es_archiver/saved_objects/delete_unknown_types/mappings.json index 4468d6849f6ca..885a64189a059 100644 --- a/test/api_integration/fixtures/es_archiver/saved_objects/delete_unknown_types/mappings.json +++ b/test/api_integration/fixtures/es_archiver/saved_objects/delete_unknown_types/mappings.json @@ -102,7 +102,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", @@ -750,7 +749,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", diff --git a/test/functional/fixtures/es_archiver/deprecations_service/mappings.json b/test/functional/fixtures/es_archiver/deprecations_service/mappings.json index f9bec7fdca4d5..33968127fe42c 100644 --- a/test/functional/fixtures/es_archiver/deprecations_service/mappings.json +++ b/test/functional/fixtures/es_archiver/deprecations_service/mappings.json @@ -101,7 +101,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/mappings.json b/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/mappings.json index 963eaa9d47892..63842481820ee 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/mappings.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/mappings.json @@ -101,7 +101,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/mappings.json b/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/mappings.json index 4cb716253a8a3..dbb70af6b6233 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/mappings.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/mappings.json @@ -101,7 +101,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/mappings.json b/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/mappings.json index 963eaa9d47892..63842481820ee 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/mappings.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/mappings.json @@ -101,7 +101,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/visible_in_management/mappings.json b/test/functional/fixtures/es_archiver/saved_objects_management/visible_in_management/mappings.json index 924b2b070ff4d..6ccba0243793d 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/visible_in_management/mappings.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/visible_in_management/mappings.json @@ -101,7 +101,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", @@ -696,7 +695,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", diff --git a/x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces/mappings.json b/x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces/mappings.json index f1722d291fc1b..407f0fd182fe7 100644 --- a/x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces/mappings.json +++ b/x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces/mappings.json @@ -73,7 +73,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", @@ -226,7 +225,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", diff --git a/x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces/mappings.json b/x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces/mappings.json index a787729a16c35..340a1003d50a9 100644 --- a/x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces/mappings.json +++ b/x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces/mappings.json @@ -73,7 +73,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic", @@ -213,7 +212,6 @@ ], ".kibana_security_solution": [ "csp-rule-template", - "endpoint:user-artifact", "endpoint:user-artifact-manifest", "exception-list", "exception-list-agnostic",