diff --git a/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/common.gen.ts b/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/common.gen.ts index 4ed3039fa13a6..370d649cae76b 100644 --- a/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/common.gen.ts +++ b/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/common.gen.ts @@ -16,8 +16,8 @@ import { z } from '@kbn/zod'; -export type UserEntityRecord = z.infer; -export const UserEntityRecord = z.object({ +export type UserEntity = z.infer; +export const UserEntity = z.object({ user: z .object({ full_name: z.array(z.string()).optional(), @@ -44,8 +44,8 @@ export const UserEntityRecord = z.object({ .optional(), }); -export type HostEntityRecord = z.infer; -export const HostEntityRecord = z.object({ +export type HostEntity = z.infer; +export const HostEntity = z.object({ host: z .object({ hostname: z.array(z.string()).optional(), diff --git a/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/common.schema.yaml b/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/common.schema.yaml index c2ad948abd801..8123330b5d498 100644 --- a/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/common.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/common.schema.yaml @@ -6,7 +6,7 @@ info: paths: {} components: schemas: - UserEntityRecord: + UserEntity: type: object properties: user: @@ -77,7 +77,7 @@ components: - type - firstSeenTimestamp - definitionId - HostEntityRecord: + HostEntity: type: object properties: host: diff --git a/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/list_entities.gen.ts b/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/list_entities.gen.ts index 805c39f848a13..a31494eeb6890 100644 --- a/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/list_entities.gen.ts +++ b/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/list_entities.gen.ts @@ -18,7 +18,7 @@ import { z } from '@kbn/zod'; import { ArrayFromString } from '@kbn/zod-helpers'; import { EntityType, InspectQuery } from '../common.gen'; -import { UserEntityRecord, HostEntityRecord } from './common.gen'; +import { UserEntity, HostEntity } from './common.gen'; export type ListEntitiesRequestQuery = z.infer; export const ListEntitiesRequestQuery = z.object({ @@ -36,7 +36,7 @@ export type ListEntitiesRequestQueryInput = z.input; export const ListEntitiesResponse = z.object({ - records: z.array(z.union([UserEntityRecord, HostEntityRecord])), + records: z.array(z.union([UserEntity, HostEntity])), page: z.number().int().min(1), per_page: z.number().int().min(1).max(1000), total: z.number().int().min(0), diff --git a/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/list_entities.schema.yaml b/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/list_entities.schema.yaml index 93a833548c25f..9c43785ec36ce 100644 --- a/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/list_entities.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/entity_analytics/entity_store/entities/list_entities.schema.yaml @@ -63,8 +63,8 @@ paths: type: array items: oneOf: - - $ref: './common.schema.yaml#/components/schemas/UserEntityRecord' - - $ref: './common.schema.yaml#/components/schemas/HostEntityRecord' + - $ref: './common.schema.yaml#/components/schemas/UserEntity' + - $ref: './common.schema.yaml#/components/schemas/HostEntity' page: type: integer minimum: 1 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 a591a333f1af1..51d9f5176f654 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 @@ -11,8 +11,8 @@ import type { EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_c import type { SortOrder } from '@elastic/elasticsearch/lib/api/types'; import { createQueryFilterClauses } from '../../../utils/build_query'; import type { - HostEntityRecord, - UserEntityRecord, + HostEntity, + UserEntity, } from '../../../../common/api/entity_analytics/entity_store/entities/common.gen'; import type { InitEntityStoreRequestBody, @@ -137,7 +137,7 @@ export class EntityStoreDataClient { } public async searchEntities(params: SearchEntitiesParams): Promise<{ - records: Array; + records: Array; total: number; inspect: InspectQuery; }> { @@ -154,7 +154,7 @@ export class EntityStoreDataClient { }, }; - const response = await this.options.esClient.search({ + const response = await this.options.esClient.search({ index, query, size: Math.min(perPage, MAX_SEARCH_RESPONSE_SIZE), @@ -166,7 +166,7 @@ export class EntityStoreDataClient { const total = typeof hits.total === 'number' ? hits.total : hits.total?.value ?? 0; - const records = hits.hits.map((hit) => hit._source as UserEntityRecord | HostEntityRecord); + const records = hits.hits.map((hit) => hit._source as UserEntity | HostEntity); const inspect: InspectQuery = { dsl: [JSON.stringify({ index, body: query }, null, 2)],