[8.x] [ES `body` removal] `@elastic/kibana-cloud-security-posture` (#204860) (#205110)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES `body` removal]
`@elastic/kibana-cloud-security-posture`
(#204860)](https://github.com/elastic/kibana/pull/204860)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alejandro Fernández
Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2024-12-23T16:24:51Z","message":"[ES
`body` removal] `@elastic/kibana-cloud-security-posture`
(#204860)","sha":"795cf28f0b27509adb58037e958208fd39707a97","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor"],"title":"[ES
`body` removal]
`@elastic/kibana-cloud-security-posture`","number":204860,"url":"https://github.com/elastic/kibana/pull/204860","mergeCommit":{"message":"[ES
`body` removal] `@elastic/kibana-cloud-security-posture`
(#204860)","sha":"795cf28f0b27509adb58037e958208fd39707a97"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204860","number":204860,"mergeCommit":{"message":"[ES
`body` removal] `@elastic/kibana-cloud-security-posture`
(#204860)","sha":"795cf28f0b27509adb58037e958208fd39707a97"}}]}]
BACKPORT-->

Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
This commit is contained in:
Kibana Machine 2024-12-24 05:20:03 +11:00 committed by GitHub
parent eda8fc8aab
commit ccf8bcb420
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 34 additions and 27 deletions

View file

@ -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';

View file

@ -37,8 +37,11 @@ export const useMisconfigurationFindings = (options: UseCspOptions) => {
rawResponse: { hits, aggregations },
} = await lastValueFrom(
data.search.search<LatestFindingsRequest, LatestFindingsResponse>({
// 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)

View file

@ -35,8 +35,11 @@ export const useMisconfigurationPreview = (options: UseCspOptions) => {
rawResponse: { aggregations },
} = await lastValueFrom(
data.search.search<LatestFindingsRequest, LatestFindingsResponse>({
// 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)

View file

@ -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<LatestFindingsRequest, LatestFindingsResponse>({
params: getVulnerabilitiesQuery(options, pageParam),
params: getVulnerabilitiesQuery(options, pageParam) as LatestFindingsRequest['params'],
})
);

View file

@ -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<LatestFindingsRequest, LatestFindingsResponse>({
params: getVulnerabilitiesQuery(options, true),
params: getVulnerabilitiesQuery(options, true) as LatestFindingsRequest['params'],
})
);

View file

@ -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';

View file

@ -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,

View file

@ -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,

View file

@ -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: {

View file

@ -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';

View file

@ -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<LatestFindingsRequest, LatestFindingsResponse>({
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');

View file

@ -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';

View file

@ -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<LatestFindingsRequest, LatestFindingsResponse>({
params: getVulnerabilitiesQuery(options, pageParam),
params: getVulnerabilitiesQuery(options, pageParam) as LatestFindingsRequest['params'],
})
);

View file

@ -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;

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';