From a8b96d8e7b5809d805b122f98283970d7349555f Mon Sep 17 00:00:00 2001 From: machadoum Date: Tue, 17 Sep 2024 16:40:48 +0200 Subject: [PATCH] Fix build --- .../entity_store/definition.ts | 90 ++++++++++--------- .../entity_store/utils/utils.ts | 6 +- 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/definition.ts b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/definition.ts index d3869446b79dd..391e8b16dd32d 100644 --- a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/definition.ts +++ b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/definition.ts @@ -9,48 +9,50 @@ import { entityDefinitionSchema, type EntityDefinition } from '@kbn/entities-sch import { ENTITY_STORE_DEFAULT_SOURCE_INDICES } from './constants'; import { getEntityDefinitionId } from './utils/utils'; -export const HOST_ENTITY_DEFINITION: EntityDefinition = entityDefinitionSchema.parse({ - id: getEntityDefinitionId('host'), - name: 'EA Host Store', - type: 'host', - indexPatterns: ENTITY_STORE_DEFAULT_SOURCE_INDICES, - identityFields: ['host.name'], - displayNameTemplate: '{{host.name}}', - metadata: [ - 'host.domain', - 'host.hostname', - 'host.id', - 'host.ip', - 'host.mac', - 'host.name', - 'host.type', - 'host.architecture', - ], - history: { - timestampField: '@timestamp', - interval: '1m', - }, - version: '1.0.0', -}); +export const buildHostEntityDefinition = (): EntityDefinition => + entityDefinitionSchema.parse({ + id: getEntityDefinitionId('host'), + name: 'EA Host Store', + type: 'host', + indexPatterns: ENTITY_STORE_DEFAULT_SOURCE_INDICES, + identityFields: ['host.name'], + displayNameTemplate: '{{host.name}}', + metadata: [ + 'host.domain', + 'host.hostname', + 'host.id', + 'host.ip', + 'host.mac', + 'host.name', + 'host.type', + 'host.architecture', + ], + history: { + timestampField: '@timestamp', + interval: '1m', + }, + version: '1.0.0', + }); -export const USER_ENTITY_DEFINITION: EntityDefinition = entityDefinitionSchema.parse({ - id: getEntityDefinitionId('user'), - name: 'EA User Store', - indexPatterns: ENTITY_STORE_DEFAULT_SOURCE_INDICES, - identityFields: ['user.name'], - displayNameTemplate: '{{user.name}}', - metadata: [ - 'user.domain', - 'user.email', - 'user.full_name', - 'user.hash', - 'user.id', - 'user.name', - 'user.roles', - ], - history: { - timestampField: '@timestamp', - interval: '1m', - }, - version: '1.0.0', -}); +export const buildUserEntityDefinition = (): EntityDefinition => + entityDefinitionSchema.parse({ + id: getEntityDefinitionId('user'), + name: 'EA User Store', + indexPatterns: ENTITY_STORE_DEFAULT_SOURCE_INDICES, + identityFields: ['user.name'], + displayNameTemplate: '{{user.name}}', + metadata: [ + 'user.domain', + 'user.email', + 'user.full_name', + 'user.hash', + 'user.id', + 'user.name', + 'user.roles', + ], + history: { + timestampField: '@timestamp', + interval: '1m', + }, + version: '1.0.0', + }); diff --git a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/utils/utils.ts b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/utils/utils.ts index 2a54bb20181c8..6443f2824581e 100644 --- a/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/utils/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/utils/utils.ts @@ -11,12 +11,12 @@ import type { EngineDescriptor, EntityType, } from '../../../../../common/api/entity_analytics/entity_store/common.gen'; -import { HOST_ENTITY_DEFINITION, USER_ENTITY_DEFINITION } from '../definition'; +import { buildHostEntityDefinition, buildUserEntityDefinition } from '../definition'; import { entityEngineDescriptorTypeName } from '../saved_object'; export const getEntityDefinition = (entityType: EntityType) => { - if (entityType === 'host') return HOST_ENTITY_DEFINITION; - if (entityType === 'user') return USER_ENTITY_DEFINITION; + if (entityType === 'host') return buildHostEntityDefinition(); + if (entityType === 'user') return buildUserEntityDefinition(); throw new Error(`Unsupported entity type: ${entityType}`); };