From b41dedcbd7d59118d49bd9d23eb3d07f24b070bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Mon, 23 Dec 2024 17:24:51 +0100 Subject: [PATCH] [ES `body` removal] `@elastic/kibana-cloud-security-posture` (#204860) (cherry picked from commit 795cf28f0b27509adb58037e958208fd39707a97) --- .../public/src/components/vulnerability_badges.tsx | 2 +- .../public/src/hooks/use_misconfiguration_findings.ts | 7 +++++-- .../public/src/hooks/use_misconfiguration_preview.ts | 7 +++++-- .../public/src/hooks/use_vulnerabilities_findings.ts | 4 ++-- .../public/src/hooks/use_vulnerabilities_preview.ts | 4 ++-- .../kbn-cloud-security-posture/public/src/types.ts | 2 +- .../public/src/utils/hooks_utils.test.ts | 2 +- .../public/src/utils/hooks_utils.ts | 2 +- .../runtime_mappings/get_package_policy_id_mapping.ts | 2 +- .../latest_findings/use_grouped_findings.tsx | 2 +- .../configurations/latest_findings/use_latest_findings.ts | 8 ++++++-- .../vulnerabilities/hooks/use_grouped_vulnerabilities.tsx | 2 +- .../vulnerabilities/hooks/use_latest_vulnerabilities.tsx | 4 ++-- .../cloud_security_posture/server/create_indices/types.ts | 5 +---- .../server/routes/benchmark_rules/get_states/v1.ts | 2 +- .../cloud_security_posture/server/routes/benchmarks/v2.ts | 2 +- .../get_detection_engine_alerts_count_by_rule_tags.ts | 2 +- .../kubernetes_security/server/routes/aggregate.ts | 2 +- 18 files changed, 34 insertions(+), 27 deletions(-) diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/components/vulnerability_badges.tsx b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/components/vulnerability_badges.tsx index e13d33c0e11cb..4a5572e6f8fbb 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/components/vulnerability_badges.tsx +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/components/vulnerability_badges.tsx @@ -8,7 +8,7 @@ import { EuiBadge, EuiIcon, EuiTextColor } from '@elastic/eui'; import React from 'react'; import { css } from '@emotion/react'; -import { float } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { float } from '@elastic/elasticsearch/lib/api/types'; import type { VulnSeverity } from '@kbn/cloud-security-posture-common'; import { getCvsScoreColor, getSeverityStatusColor } from '../utils/get_vulnerability_colors'; diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_misconfiguration_findings.ts b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_misconfiguration_findings.ts index fa060738651a1..d07ac51cc6075 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_misconfiguration_findings.ts +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_misconfiguration_findings.ts @@ -37,8 +37,11 @@ export const useMisconfigurationFindings = (options: UseCspOptions) => { rawResponse: { hits, aggregations }, } = await lastValueFrom( data.search.search({ - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - params: buildMisconfigurationsFindingsQuery(options, rulesStates!), + params: buildMisconfigurationsFindingsQuery( + options, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + rulesStates! + ) as LatestFindingsRequest['params'], }) ); if (!aggregations && options.ignore_unavailable === false) diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_misconfiguration_preview.ts b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_misconfiguration_preview.ts index d2f4d4f522111..019125bde1f03 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_misconfiguration_preview.ts +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_misconfiguration_preview.ts @@ -35,8 +35,11 @@ export const useMisconfigurationPreview = (options: UseCspOptions) => { rawResponse: { aggregations }, } = await lastValueFrom( data.search.search({ - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - params: buildMisconfigurationsFindingsQuery(options, rulesStates!), + params: buildMisconfigurationsFindingsQuery( + options, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + rulesStates! + ) as LatestFindingsRequest['params'], }) ); if (!aggregations && options.ignore_unavailable === false) diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_vulnerabilities_findings.ts b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_vulnerabilities_findings.ts index 062f5c7740c73..d8e44ad5c4328 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_vulnerabilities_findings.ts +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_vulnerabilities_findings.ts @@ -13,7 +13,7 @@ import { SearchResponse, AggregationsMultiBucketAggregateBase, AggregationsStringRareTermsBucketKeys, -} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +} from '@elastic/elasticsearch/lib/api/types'; import type { CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common/schema/vulnerabilities/latest'; import type { CoreStart } from '@kbn/core/public'; import type { CspClientPluginStartDeps, UseCspOptions } from '../types'; @@ -47,7 +47,7 @@ export const useVulnerabilitiesFindings = (options: UseCspOptions) => { rawResponse: { aggregations, hits }, } = await lastValueFrom( data.search.search({ - params: getVulnerabilitiesQuery(options, pageParam), + params: getVulnerabilitiesQuery(options, pageParam) as LatestFindingsRequest['params'], }) ); diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_vulnerabilities_preview.ts b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_vulnerabilities_preview.ts index ac34636720143..05b810c361be6 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_vulnerabilities_preview.ts +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/hooks/use_vulnerabilities_preview.ts @@ -13,7 +13,7 @@ import { SearchResponse, AggregationsMultiBucketAggregateBase, AggregationsStringRareTermsBucketKeys, -} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +} from '@elastic/elasticsearch/lib/api/types'; import type { CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common/schema/vulnerabilities/latest'; import type { CoreStart } from '@kbn/core/public'; import type { CspClientPluginStartDeps, UseCspOptions } from '../types'; @@ -42,7 +42,7 @@ export const useVulnerabilitiesPreview = (options: UseCspOptions) => { rawResponse: { aggregations }, } = await lastValueFrom( data.search.search({ - params: getVulnerabilitiesQuery(options, true), + params: getVulnerabilitiesQuery(options, true) as LatestFindingsRequest['params'], }) ); diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/types.ts b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/types.ts index 2c7be37de50dd..03fa60479806b 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/types.ts +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/types.ts @@ -23,7 +23,7 @@ import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; import { SharePluginStart } from '@kbn/share-plugin/public'; import { SpacesPluginStart } from '@kbn/spaces-plugin/public'; import { CspFinding } from '@kbn/cloud-security-posture-common'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { IKibanaSearchResponse, IKibanaSearchRequest } from '@kbn/search-types'; import type { BoolQuery } from '@kbn/es-query'; diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/utils/hooks_utils.test.ts b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/utils/hooks_utils.test.ts index 86e8f3c8f668b..8bf53fcddebe4 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/utils/hooks_utils.test.ts +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/utils/hooks_utils.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import { AggregationBuckets, getVulnerabilitiesAggregationCount, diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/utils/hooks_utils.ts b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/utils/hooks_utils.ts index e52b66a0db685..88416477021ca 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/utils/hooks_utils.ts +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/public/src/utils/hooks_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import { buildMutedRulesFilter, CDR_MISCONFIGURATIONS_INDEX_PATTERN, diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/common/runtime_mappings/get_package_policy_id_mapping.ts b/x-pack/solutions/security/plugins/cloud_security_posture/common/runtime_mappings/get_package_policy_id_mapping.ts index 5d76176758af6..228ea25ef76ba 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/common/runtime_mappings/get_package_policy_id_mapping.ts +++ b/x-pack/solutions/security/plugins/cloud_security_posture/common/runtime_mappings/get_package_policy_id_mapping.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types'; export const getPackagePolicyIdRuntimeMapping = (): MappingRuntimeFields => ({ package_policy_identifier: { diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx b/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx index b98ff432a3c96..842e21c58a971 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx +++ b/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { SearchResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { SearchResponse } from '@elastic/elasticsearch/lib/api/types'; import type { IKibanaSearchResponse } from '@kbn/search-types'; import { GenericBuckets, GroupingQuery, RootAggregation } from '@kbn/grouping/src'; import { useQuery } from '@tanstack/react-query'; diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts b/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts index 64353230211bc..33ec005b33750 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts +++ b/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts @@ -8,7 +8,7 @@ import { useInfiniteQuery } from '@tanstack/react-query'; import { number } from 'io-ts'; import { lastValueFrom } from 'rxjs'; import type { IKibanaSearchResponse, IKibanaSearchRequest } from '@kbn/search-types'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import { buildDataTableRecord } from '@kbn/discover-utils'; import { EsHitRecord } from '@kbn/discover-utils/types'; import { showErrorToast } from '@kbn/cloud-security-posture'; @@ -150,7 +150,11 @@ export const useLatestFindings = (options: UseFindingsOptions) => { rawResponse: { hits, aggregations }, } = await lastValueFrom( data.search.search({ - params: getFindingsQuery(options, rulesStates!, pageParam), // ruleStates always exists since it under the `enabled` dependency. + params: getFindingsQuery( + options, + rulesStates!, + pageParam + ) as LatestFindingsRequest['params'], // ruleStates always exists since it under the `enabled` dependency. }) ); if (!aggregations) throw new Error('expected aggregations to be an defined'); diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_grouped_vulnerabilities.tsx b/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_grouped_vulnerabilities.tsx index 9fddf97e28482..db5ec5816040c 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_grouped_vulnerabilities.tsx +++ b/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_grouped_vulnerabilities.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { SearchResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { SearchResponse } from '@elastic/elasticsearch/lib/api/types'; import type { IKibanaSearchResponse } from '@kbn/search-types'; import { GenericBuckets, GroupingQuery, RootAggregation } from '@kbn/grouping/src'; import { useQuery } from '@tanstack/react-query'; diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx b/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx index a998707c4704f..6763547730e1a 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx +++ b/x-pack/solutions/security/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx @@ -13,7 +13,7 @@ import { SearchResponse, AggregationsMultiBucketAggregateBase, AggregationsStringRareTermsBucketKeys, -} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +} from '@elastic/elasticsearch/lib/api/types'; import { buildDataTableRecord } from '@kbn/discover-utils'; import { EsHitRecord } from '@kbn/discover-utils/types'; import { @@ -118,7 +118,7 @@ export const useLatestVulnerabilities = (options: VulnerabilitiesQuery) => { rawResponse: { hits }, } = await lastValueFrom( data.search.search({ - params: getVulnerabilitiesQuery(options, pageParam), + params: getVulnerabilitiesQuery(options, pageParam) as LatestFindingsRequest['params'], }) ); diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/server/create_indices/types.ts b/x-pack/solutions/security/plugins/cloud_security_posture/server/create_indices/types.ts index 190114b3bf055..55b534436ef31 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/server/create_indices/types.ts +++ b/x-pack/solutions/security/plugins/cloud_security_posture/server/create_indices/types.ts @@ -5,10 +5,7 @@ * 2.0. */ -import { - IndicesIndexTemplateSummary, - Metadata, -} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { IndicesIndexTemplateSummary, Metadata } from '@elastic/elasticsearch/lib/api/types'; export interface LatestIndexConfig { findings: IndexConfig; diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts b/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts index e6c2e90cd9886..0a5d27d7dbca1 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts +++ b/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts @@ -9,7 +9,7 @@ import { SavedObjectsClientContract, } from '@kbn/core-saved-objects-api-server'; import { transformError } from '@kbn/securitysolution-es-utils'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { buildMutedRulesFilter } from '@kbn/cloud-security-posture-common'; import type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common/schema/rules/latest'; import type { CspSettings } from '@kbn/cloud-security-posture-common/schema/rules/v4'; diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/benchmarks/v2.ts b/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/benchmarks/v2.ts index 327a2da76f336..a8845d2aa479f 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/benchmarks/v2.ts +++ b/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/benchmarks/v2.ts @@ -6,7 +6,7 @@ */ import { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types'; -import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types'; import type { ElasticsearchClient, Logger } from '@kbn/core/server'; import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server'; import type { CspBenchmarkRule } from '@kbn/cloud-security-posture-common/schema/rules/latest'; diff --git a/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/detection_engine/get_detection_engine_alerts_count_by_rule_tags.ts b/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/detection_engine/get_detection_engine_alerts_count_by_rule_tags.ts index 38a9e356a1446..990a0457dd368 100644 --- a/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/detection_engine/get_detection_engine_alerts_count_by_rule_tags.ts +++ b/x-pack/solutions/security/plugins/cloud_security_posture/server/routes/detection_engine/get_detection_engine_alerts_count_by_rule_tags.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SearchResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { SearchResponse } from '@elastic/elasticsearch/lib/api/types'; import { schema } from '@kbn/config-schema'; import { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; import { transformError } from '@kbn/securitysolution-es-utils'; diff --git a/x-pack/solutions/security/plugins/kubernetes_security/server/routes/aggregate.ts b/x-pack/solutions/security/plugins/kubernetes_security/server/routes/aggregate.ts index 4ddb828b68976..21bc8dada43e3 100644 --- a/x-pack/solutions/security/plugins/kubernetes_security/server/routes/aggregate.ts +++ b/x-pack/solutions/security/plugins/kubernetes_security/server/routes/aggregate.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { SortCombinations } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type { SortCombinations } from '@elastic/elasticsearch/lib/api/types'; import { transformError } from '@kbn/securitysolution-es-utils'; import { schema } from '@kbn/config-schema'; import type { ElasticsearchClient } from '@kbn/core/server';