diff --git a/x-pack/plugins/security_solution/common/entity_analytics/entity_store/constants.ts b/x-pack/plugins/security_solution/common/entity_analytics/entity_store/constants.ts index 7b46a0a766e2e..b6834422c8cfc 100644 --- a/x-pack/plugins/security_solution/common/entity_analytics/entity_store/constants.ts +++ b/x-pack/plugins/security_solution/common/entity_analytics/entity_store/constants.ts @@ -23,17 +23,3 @@ export const ENTITY_STORE_REQUIRED_ES_CLUSTER_PRIVILEGES = [ // The index pattern for the entity store has to support '.entities.v1.latest.noop' index export const ENTITY_STORE_INDEX_PATTERN = '.entities.v1.latest.*'; - -export const EntityStoreResource = { - ENTITY_ENGINE: 'entity_engine', - ENTITY_DEFINITION: 'entity_definition', - INDEX: 'index', - COMPONENT_TEMPLATE: 'component_template', - INDEX_TEMPLATE: 'index_template', - INGEST_PIPELINE: 'ingest_pipeline', - ENRICH_POLICY: 'enrich_policy', - TASK: 'task', - TRANSFORM: 'transform', -} as const; - -export type EntityStoreResource = (typeof EntityStoreResource)[keyof typeof EntityStoreResource]; diff --git a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/component_template.ts b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/component_template.ts index f8e2de5a10749..a1352594ff47d 100644 --- a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/component_template.ts +++ b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/component_template.ts @@ -6,8 +6,10 @@ */ import type { ElasticsearchClient } from '@kbn/core/server'; -import type { EngineComponentStatus } from '../../../../../common/api/entity_analytics'; -import { EntityStoreResource } from '../../../../../common/entity_analytics/entity_store/constants'; +import { + EngineComponentResourceEnum, + type EngineComponentStatus, +} from '../../../../../common/api/entity_analytics'; import type { UnitedEntityDefinition } from '../united_entity_definitions'; const getComponentTemplateName = (definitionId: string) => `${definitionId}-latest@platform`; @@ -61,6 +63,6 @@ export const getEntityIndexComponentTemplateStatus = async ({ return { id: name, installed: componentTemplate?.component_templates?.length > 0, - resource: EntityStoreResource.COMPONENT_TEMPLATE, + resource: EngineComponentResourceEnum.component_template, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/enrich_policy.ts b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/enrich_policy.ts index edf21219007e4..7064a4dd98851 100644 --- a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/enrich_policy.ts +++ b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/enrich_policy.ts @@ -7,7 +7,7 @@ import type { ElasticsearchClient, Logger } from '@kbn/core/server'; import type { EnrichPutPolicyRequest } from '@elastic/elasticsearch/lib/api/types'; -import { EntityStoreResource } from '../../../../../common/entity_analytics/entity_store/constants'; +import { EngineComponentResourceEnum } from '../../../../../common/api/entity_analytics'; import { getEntitiesIndexName } from '../utils'; import type { UnitedEntityDefinition } from '../united_entity_definitions'; @@ -121,6 +121,6 @@ export const getFieldRetentionEnrichPolicyStatus = async ({ return { installed: policies.length > 0, id: name, - resource: EntityStoreResource.ENRICH_POLICY, + resource: EngineComponentResourceEnum.enrich_policy, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/entity_index.ts b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/entity_index.ts index f000fc16d6639..0de8fe20050ce 100644 --- a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/entity_index.ts +++ b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/entity_index.ts @@ -6,8 +6,11 @@ */ import type { ElasticsearchClient, Logger } from '@kbn/core/server'; -import { EntityStoreResource } from '../../../../../common/entity_analytics/entity_store/constants'; -import type { EngineComponentStatus, EntityType } from '../../../../../common/api/entity_analytics'; +import { + EngineComponentResourceEnum, + type EngineComponentStatus, + type EntityType, +} from '../../../../../common/api/entity_analytics'; import { getEntitiesIndexName } from '../utils'; import { createOrUpdateIndex } from '../../utils/create_or_update_index'; @@ -53,5 +56,5 @@ export const getEntityIndexStatus = async ({ } ); - return { id: index, installed: exists, resource: EntityStoreResource.INDEX }; + return { id: index, installed: exists, resource: EngineComponentResourceEnum.index }; }; diff --git a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/ingest_pipeline.ts b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/ingest_pipeline.ts index da96b672d2f5a..f57102fd13f14 100644 --- a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/ingest_pipeline.ts +++ b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/elasticsearch_assets/ingest_pipeline.ts @@ -8,7 +8,7 @@ import type { ElasticsearchClient, Logger } from '@kbn/core/server'; import type { IngestProcessorContainer } from '@elastic/elasticsearch/lib/api/types'; import type { EntityDefinition } from '@kbn/entities-schema'; -import { EntityStoreResource } from '../../../../../common/entity_analytics/entity_store/constants'; +import { EngineComponentResourceEnum } from '../../../../../common/api/entity_analytics'; import { type FieldRetentionDefinition } from '../field_retention_definition'; import { debugDeepCopyContextStep, @@ -183,6 +183,6 @@ export const getPlatformPipelineStatus = async ({ return { id: pipelineId, installed: !!pipeline[pipelineId], - resource: EntityStoreResource.INGEST_PIPELINE, + resource: EngineComponentResourceEnum.ingest_pipeline, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/entity_store_data_client.ts b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/entity_store_data_client.ts index 2d3e3017a07d9..c5c730eab700c 100644 --- a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/entity_store_data_client.ts +++ b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/entity_store_data_client.ts @@ -31,9 +31,8 @@ import type { InitEntityStoreRequestBody, InitEntityStoreResponse, } from '../../../../common/api/entity_analytics/entity_store/enable.gen'; -import { EntityStoreResource } from '../../../../common/entity_analytics/entity_store/constants'; import type { AppClient } from '../../..'; -import { EntityType } from '../../../../common/api/entity_analytics'; +import { EngineComponentResourceEnum, EntityType } from '../../../../common/api/entity_analytics'; import type { Entity, EngineDataviewUpdateResult, @@ -42,6 +41,7 @@ import type { InspectQuery, ListEntityEnginesResponse, EngineComponentStatus, + EngineComponentResource, } from '../../../../common/api/entity_analytics'; import { EngineDescriptorClient } from './saved_object/engine_descriptor'; import { ENGINE_STATUS, ENTITY_STORE_STATUS, MAX_SEARCH_RESPONSE_SIZE } from './constants'; @@ -299,7 +299,7 @@ export class EntityStoreDataClient { this.log('info', entityType, `Initializing entity store`); this.audit( EntityEngineActions.INIT, - EntityStoreResource.ENTITY_ENGINE, + EngineComponentResourceEnum.entity_engine, entityType, 'Initializing entity engine' ); @@ -428,7 +428,7 @@ export class EntityStoreDataClient { this.audit( EntityEngineActions.INIT, - EntityStoreResource.ENTITY_ENGINE, + EngineComponentResourceEnum.entity_engine, entityType, 'Failed to initialize entity engine resources', err @@ -460,7 +460,7 @@ export class EntityStoreDataClient { { id, installed: false, - resource: EntityStoreResource.ENTITY_DEFINITION, + resource: EngineComponentResourceEnum.entity_definition, }, ]; } @@ -470,11 +470,11 @@ export class EntityStoreDataClient { { id: definition.id, installed: definition.state.installed, - resource: EntityStoreResource.ENTITY_DEFINITION, + resource: EngineComponentResourceEnum.entity_definition, }, ...definition.state.components.transforms.map(({ installed, running, stats }) => ({ id, - resource: EntityStoreResource.TRANSFORM, + resource: EngineComponentResourceEnum.transform, installed, errors: (stats?.health as TransformHealth)?.issues?.map(({ issue, details }) => ({ title: issue, @@ -482,13 +482,13 @@ export class EntityStoreDataClient { })), })), ...definition.state.components.ingestPipelines.map((pipeline) => ({ - resource: EntityStoreResource.INGEST_PIPELINE, + resource: EngineComponentResourceEnum.ingest_pipeline, ...pipeline, })), ...definition.state.components.indexTemplates.map(({ installed }) => ({ id, installed, - resource: EntityStoreResource.INDEX_TEMPLATE, + resource: EngineComponentResourceEnum.index_template, })), ]; } @@ -527,7 +527,7 @@ export class EntityStoreDataClient { const fullEntityDefinition = await this.getExistingEntityDefinition(entityType); this.audit( EntityEngineActions.START, - EntityStoreResource.ENTITY_DEFINITION, + EngineComponentResourceEnum.entity_definition, entityType, 'Starting entity definition' ); @@ -554,7 +554,7 @@ export class EntityStoreDataClient { const fullEntityDefinition = await this.getExistingEntityDefinition(entityType); this.audit( EntityEngineActions.STOP, - EntityStoreResource.ENTITY_DEFINITION, + EngineComponentResourceEnum.entity_definition, entityType, 'Stopping entity definition' ); @@ -597,7 +597,7 @@ export class EntityStoreDataClient { this.log('info', entityType, `Deleting entity store`); this.audit( EntityEngineActions.DELETE, - EntityStoreResource.ENTITY_ENGINE, + EngineComponentResourceEnum.entity_engine, entityType, 'Deleting entity engine' ); @@ -665,7 +665,7 @@ export class EntityStoreDataClient { this.audit( EntityEngineActions.DELETE, - EntityStoreResource.ENTITY_ENGINE, + EngineComponentResourceEnum.entity_engine, entityType, 'Failed to delete entity engine', err @@ -812,7 +812,7 @@ export class EntityStoreDataClient { private audit( action: EntityEngineActions, - resource: EntityStoreResource, + resource: EngineComponentResource, entityType: EntityType, msg: string, error?: Error diff --git a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/task/field_retention_enrichment_task.ts b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/task/field_retention_enrichment_task.ts index 7b79901bac482..3d103ea2af467 100644 --- a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/task/field_retention_enrichment_task.ts +++ b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/task/field_retention_enrichment_task.ts @@ -13,8 +13,10 @@ import type { TaskManagerSetupContract, TaskManagerStartContract, } from '@kbn/task-manager-plugin/server'; -import { EntityStoreResource } from '../../../../../common/entity_analytics/entity_store/constants'; -import type { EntityType } from '../../../../../common/api/entity_analytics/entity_store'; +import { + EngineComponentResourceEnum, + type EntityType, +} from '../../../../../common/api/entity_analytics/entity_store'; import { defaultState, stateSchemaByVersion, @@ -290,7 +292,7 @@ export const getEntityStoreFieldRetentionEnrichTaskState = async ({ return { id: taskState.id, - resource: EntityStoreResource.TASK, + resource: EngineComponentResourceEnum.task, installed: true, enabled: taskState.enabled, status: taskState.status, @@ -304,7 +306,7 @@ export const getEntityStoreFieldRetentionEnrichTaskState = async ({ return { id: taskId, installed: false, - resource: EntityStoreResource.TASK, + resource: EngineComponentResourceEnum.task, }; } throw e;