diff --git a/x-pack/plugins/cloud_security_posture/common/constants.ts b/x-pack/plugins/cloud_security_posture/common/constants.ts index d2fffa9d26a2b..770f4ef5d06e3 100644 --- a/x-pack/plugins/cloud_security_posture/common/constants.ts +++ b/x-pack/plugins/cloud_security_posture/common/constants.ts @@ -10,7 +10,7 @@ import { VulnSeverity, AwsCredentialsTypeFieldMap, GcpCredentialsTypeFieldMap, -} from './types'; +} from './types_old'; export const STATUS_ROUTE_PATH = '/internal/cloud_security_posture/status'; export const STATUS_API_CURRENT_VERSION = '1'; @@ -23,8 +23,8 @@ export const VULNERABILITIES_DASHBOARD_ROUTE_PATH = export const BENCHMARKS_ROUTE_PATH = '/internal/cloud_security_posture/benchmarks'; export const BENCHMARKS_API_CURRENT_VERSION = '1'; -export const FIND_CSP_RULE_TEMPLATE_ROUTE_PATH = '/internal/cloud_security_posture/rules/_find'; -export const FIND_CSP_RULE_TEMPLATE_API_CURRENT_VERSION = '1'; +export const FIND_CSP_BENCHMARK_RULE_ROUTE_PATH = '/internal/cloud_security_posture/rules/_find'; +export const FIND_CSP_BENCHMARK_RULE_API_CURRENT_VERSION = '1'; export const DETECTION_RULE_ALERTS_STATUS_API_CURRENT_VERSION = '1'; export const DETECTION_RULE_RULES_API_CURRENT_VERSION = '2023-10-31'; @@ -85,7 +85,7 @@ export const INTERNAL_FEATURE_FLAGS = { showFindingFlyoutEvidence: true, } as const; -export const CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE = 'csp-rule-template'; +export const CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE = 'csp-rule-template'; export const CLOUDBEAT_VANILLA = 'cloudbeat/cis_k8s'; export const CLOUDBEAT_EKS = 'cloudbeat/cis_eks'; diff --git a/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts b/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts index bfe825b59d31b..bef70384b98cf 100644 --- a/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts +++ b/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts @@ -7,7 +7,7 @@ // TODO: this needs to be defined in a versioned schema import type { EcsEvent } from '@kbn/ecs'; -import type { CspRuleTemplateMetadata } from './csp_rule_template_metadata'; +import { CspBenchmarkRuleMetadata } from '../types/latest'; export interface CspFinding { '@timestamp': string; @@ -16,7 +16,7 @@ export interface CspFinding { cloud?: CspFindingCloud; // only available on CSPM findings result: CspFindingResult; resource: CspFindingResource; - rule: CspRuleTemplateMetadata; + rule: CspBenchmarkRuleMetadata; host: CspFindingHost; event: EcsEvent; agent: CspFindingAgent; diff --git a/x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template.ts b/x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template.ts deleted file mode 100644 index 0ed56fb5d7e3b..0000000000000 --- a/x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -import { schema as rt, TypeOf } from '@kbn/config-schema'; -import { - cspRuleTemplateMetadataSchemaV840, - cspRuleTemplateMetadataSchemaV870, -} from './csp_rule_template_metadata'; - -export const cspRuleTemplateSchemaV830 = rt.object({ - audit: rt.string(), - benchmark: rt.object({ name: rt.string(), version: rt.string() }), - default_value: rt.maybe(rt.string()), - description: rt.string(), - enabled: rt.boolean(), - id: rt.string(), - impact: rt.maybe(rt.string()), - muted: rt.boolean(), - name: rt.string(), - profile_applicability: rt.string(), - rationale: rt.string(), - references: rt.maybe(rt.string()), - rego_rule_id: rt.string(), - remediation: rt.string(), - section: rt.string(), - tags: rt.arrayOf(rt.string()), - version: rt.string(), -}); - -export const cspRuleTemplateSchemaV840 = rt.object({ - enabled: rt.boolean(), - metadata: cspRuleTemplateMetadataSchemaV840, - muted: rt.boolean(), -}); - -export const cspRuleTemplateSchemaV870 = rt.object({ - metadata: cspRuleTemplateMetadataSchemaV870, -}); - -export type CspRuleTemplateV830 = TypeOf; -export type CspRuleTemplateV840 = TypeOf; -export type CspRuleTemplateV870 = TypeOf; - -export type CspRuleTemplate = CspRuleTemplateV870; diff --git a/x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template_metadata.ts b/x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template_metadata.ts deleted file mode 100644 index b466ed7e70d2d..0000000000000 --- a/x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template_metadata.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -import { schema as rt, TypeOf } from '@kbn/config-schema'; -import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../constants'; - -export const cspRuleTemplateMetadataSchemaV840 = rt.object({ - audit: rt.string(), - benchmark: rt.object({ - name: rt.string(), - id: rt.string(), - version: rt.string(), - }), - default_value: rt.maybe(rt.string()), - description: rt.string(), - id: rt.string(), - impact: rt.maybe(rt.string()), - name: rt.string(), - profile_applicability: rt.string(), - rationale: rt.string(), - references: rt.maybe(rt.string()), - rego_rule_id: rt.string(), - remediation: rt.string(), - section: rt.string(), - tags: rt.arrayOf(rt.string()), - version: rt.string(), -}); - -export const cspRuleTemplateMetadataSchemaV870 = rt.object({ - audit: rt.string(), - benchmark: rt.object({ - name: rt.string(), - posture_type: rt.maybe( - rt.oneOf([rt.literal(CSPM_POLICY_TEMPLATE), rt.literal(KSPM_POLICY_TEMPLATE)]) - ), - id: rt.string(), - version: rt.string(), - rule_number: rt.maybe(rt.string()), - }), - default_value: rt.maybe(rt.string()), - description: rt.string(), - id: rt.string(), - impact: rt.maybe(rt.string()), - name: rt.string(), - profile_applicability: rt.string(), - rationale: rt.string(), - references: rt.maybe(rt.string()), - rego_rule_id: rt.string(), - remediation: rt.string(), - section: rt.string(), - tags: rt.arrayOf(rt.string()), - version: rt.string(), -}); - -export type CspRuleMetadataV840 = TypeOf; -export type CspRuleMetadataV870 = TypeOf; -export type CspRuleTemplateMetadata = CspRuleMetadataV870; diff --git a/x-pack/plugins/cloud_security_posture/common/schemas/csp_vulnerability_finding.ts b/x-pack/plugins/cloud_security_posture/common/schemas/csp_vulnerability_finding.ts index f650b115316df..efe26dc6648ba 100644 --- a/x-pack/plugins/cloud_security_posture/common/schemas/csp_vulnerability_finding.ts +++ b/x-pack/plugins/cloud_security_posture/common/schemas/csp_vulnerability_finding.ts @@ -7,7 +7,7 @@ // TODO: this needs to be defined in a versioned schema import type { EcsEvent } from '@kbn/ecs'; -import { VulnSeverity } from '../types'; +import { VulnSeverity } from '../types_old'; export interface CspVulnerabilityFinding { '@timestamp': string; diff --git a/x-pack/plugins/cloud_security_posture/common/schemas/index.ts b/x-pack/plugins/cloud_security_posture/common/schemas/index.ts index c7730abc06dba..8c8dcdc52f0f4 100644 --- a/x-pack/plugins/cloud_security_posture/common/schemas/index.ts +++ b/x-pack/plugins/cloud_security_posture/common/schemas/index.ts @@ -4,7 +4,4 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - -export * from './csp_rule_template_metadata'; -export * from './csp_rule_template'; export * from './csp_vulnerability_finding'; diff --git a/x-pack/plugins/cloud_security_posture/common/types/index.ts b/x-pack/plugins/cloud_security_posture/common/types/index.ts new file mode 100644 index 0000000000000..a2aaa3b2ef14e --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/common/types/index.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export * as rulesV1 from './rules/v1'; +export * as rulesV2 from './rules/v2'; +export * as rulesV3 from './rules/v3'; + +// Explicit export of everything from latest +export type { + cspBenchmarkRuleMetadataSchema, + CspBenchmarkRuleMetadata, + CspBenchmarkRule, + FindCspBenchmarkRuleRequest, + FindCspBenchmarkRuleResponse, +} from './latest'; diff --git a/x-pack/plugins/cloud_security_posture/common/types/latest.ts b/x-pack/plugins/cloud_security_posture/common/types/latest.ts new file mode 100644 index 0000000000000..8b55674005249 --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/common/types/latest.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export * from './rules/v3'; diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v1.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v1.ts new file mode 100644 index 0000000000000..afc2b705ab5c3 --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v1.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { schema, TypeOf } from '@kbn/config-schema'; + +// Since version 8.3.0 +export const cspBenchmarkRuleSchema = schema.object({ + audit: schema.string(), + benchmark: schema.object({ name: schema.string(), version: schema.string() }), + default_value: schema.maybe(schema.string()), + description: schema.string(), + enabled: schema.boolean(), + id: schema.string(), + impact: schema.maybe(schema.string()), + muted: schema.boolean(), + name: schema.string(), + profile_applicability: schema.string(), + rationale: schema.string(), + references: schema.maybe(schema.string()), + rego_rule_id: schema.string(), + remediation: schema.string(), + section: schema.string(), + tags: schema.arrayOf(schema.string()), + version: schema.string(), +}); + +export type CspBenchmarkRule = TypeOf; diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v2.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v2.ts new file mode 100644 index 0000000000000..d88ae6adc089a --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v2.ts @@ -0,0 +1,38 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { schema, TypeOf } from '@kbn/config-schema'; + +// Since version 8.4.0 +export const cspBenchmarkRuleMetadataSchema = schema.object({ + audit: schema.string(), + benchmark: schema.object({ + name: schema.string(), + id: schema.string(), + version: schema.string(), + }), + default_value: schema.maybe(schema.string()), + description: schema.string(), + id: schema.string(), + impact: schema.maybe(schema.string()), + name: schema.string(), + profile_applicability: schema.string(), + rationale: schema.string(), + references: schema.maybe(schema.string()), + rego_rule_id: schema.string(), + remediation: schema.string(), + section: schema.string(), + tags: schema.arrayOf(schema.string()), + version: schema.string(), +}); + +export const cspBenchmarkRuleSchema = schema.object({ + enabled: schema.boolean(), + metadata: cspBenchmarkRuleMetadataSchema, + muted: schema.boolean(), +}); + +export type CspBenchmarkRule = TypeOf; diff --git a/x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template_api/get_csp_rule_template.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts similarity index 50% rename from x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template_api/get_csp_rule_template.ts rename to x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts index 350909e540d4d..0b7b90339dff1 100644 --- a/x-pack/plugins/cloud_security_posture/common/schemas/csp_rule_template_api/get_csp_rule_template.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts @@ -5,13 +5,48 @@ * 2.0. */ -import { schema } from '@kbn/config-schema'; +import { schema, TypeOf } from '@kbn/config-schema'; -// this pages follows versioning interface strategy https://docs.elastic.dev/kibana-dev-docs/versioning-interfaces +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../constants'; -const DEFAULT_RULES_TEMPLATE_PER_PAGE = 25; +const DEFAULT_BENCHMARK_RULES_PER_PAGE = 25; -export const findCspRuleTemplateRequest = schema.object({ +// Since version 8.7.0 +export const cspBenchmarkRuleMetadataSchema = schema.object({ + audit: schema.string(), + benchmark: schema.object({ + name: schema.string(), + posture_type: schema.maybe( + schema.oneOf([schema.literal(CSPM_POLICY_TEMPLATE), schema.literal(KSPM_POLICY_TEMPLATE)]) + ), + id: schema.string(), + version: schema.string(), + rule_number: schema.maybe(schema.string()), + }), + default_value: schema.maybe(schema.string()), + description: schema.string(), + id: schema.string(), + impact: schema.maybe(schema.string()), + name: schema.string(), + profile_applicability: schema.string(), + rationale: schema.string(), + references: schema.maybe(schema.string()), + rego_rule_id: schema.string(), + remediation: schema.string(), + section: schema.string(), + tags: schema.arrayOf(schema.string()), + version: schema.string(), +}); + +export type CspBenchmarkRuleMetadata = TypeOf; + +export const cspBenchmarkRuleSchema = schema.object({ + metadata: cspBenchmarkRuleMetadataSchema, +}); + +export type CspBenchmarkRule = TypeOf; + +export const findCspBenchmarkRuleRequestSchema = schema.object({ /** * An Elasticsearch simple_query_string */ @@ -25,16 +60,16 @@ export const findCspRuleTemplateRequest = schema.object({ /** * The number of objects to include in each page */ - perPage: schema.number({ defaultValue: DEFAULT_RULES_TEMPLATE_PER_PAGE, min: 0 }), + perPage: schema.number({ defaultValue: DEFAULT_BENCHMARK_RULES_PER_PAGE, min: 0 }), /** - * Fields to retrieve from CspRuleTemplate saved object + * Fields to retrieve from CspBenchmarkRule saved object */ fields: schema.maybe(schema.arrayOf(schema.string())), /** * The fields to perform the parsed query against. - * Valid fields are fields which mapped to 'text' in cspRuleTemplateSavedObjectMapping + * Valid fields are fields which mapped to 'text' in cspBenchmarkRuleSavedObjectMapping */ searchFields: schema.arrayOf( schema.oneOf([schema.literal('metadata.name.text'), schema.literal('metadata.section.text')]), @@ -85,3 +120,12 @@ export const findCspRuleTemplateRequest = schema.object({ */ section: schema.maybe(schema.string()), }); + +export type FindCspBenchmarkRuleRequest = TypeOf; + +export interface FindCspBenchmarkRuleResponse { + items: CspBenchmarkRule[]; + total: number; + page: number; + perPage: number; +} diff --git a/x-pack/plugins/cloud_security_posture/common/types.ts b/x-pack/plugins/cloud_security_posture/common/types_old.ts similarity index 91% rename from x-pack/plugins/cloud_security_posture/common/types.ts rename to x-pack/plugins/cloud_security_posture/common/types_old.ts index fc4391b5fbf76..abfd590b55ae0 100644 --- a/x-pack/plugins/cloud_security_posture/common/types.ts +++ b/x-pack/plugins/cloud_security_posture/common/types_old.ts @@ -8,10 +8,9 @@ import { type TypeOf } from '@kbn/config-schema'; import type { PackagePolicy, AgentPolicy } from '@kbn/fleet-plugin/common'; import { CspFinding } from './schemas/csp_finding'; import { SUPPORTED_CLOUDBEAT_INPUTS, SUPPORTED_POLICY_TEMPLATES } from './constants'; -import { CspRuleTemplateMetadata } from './schemas/csp_rule_template_metadata'; -import { CspRuleTemplate } from './schemas'; -import { findCspRuleTemplateRequest } from './schemas/csp_rule_template_api/get_csp_rule_template'; + import { getComplianceDashboardSchema } from './schemas/stats'; +import type { CspBenchmarkRuleMetadata } from './types/latest'; export type AwsCredentialsType = | 'assume_role' @@ -151,9 +150,9 @@ export interface Benchmark { rules_count: number; } -export type BenchmarkId = CspRuleTemplateMetadata['benchmark']['id']; -export type BenchmarkName = CspRuleTemplateMetadata['benchmark']['name']; -export type RuleSection = CspRuleTemplateMetadata['section']; +export type BenchmarkId = CspBenchmarkRuleMetadata['benchmark']['id']; +export type BenchmarkName = CspBenchmarkRuleMetadata['benchmark']['name']; +export type RuleSection = CspBenchmarkRuleMetadata['section']; // Fleet Integration types export type PostureInput = typeof SUPPORTED_CLOUDBEAT_INPUTS[number]; @@ -167,17 +166,8 @@ export interface GetBenchmarkResponse { perPage: number; } -export type GetCspRuleTemplateRequest = TypeOf; - export type GetComplianceDashboardRequest = TypeOf; -export interface GetCspRuleTemplateResponse { - items: CspRuleTemplate[]; - total: number; - page: number; - perPage: number; -} - // CNVM DASHBOARD interface AccountVulnStats { diff --git a/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts b/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts index ba8e6f9813832..fd04733bb17c9 100644 --- a/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts +++ b/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts @@ -17,7 +17,7 @@ import { import { CLOUD_SECURITY_POSTURE_PACKAGE_NAME, CLOUDBEAT_VANILLA, - CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE, + CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE, AWS_CREDENTIALS_TYPE_TO_FIELDS_MAP, GCP_CREDENTIALS_TYPE_TO_FIELDS_MAP, AZURE_CREDENTIALS_TYPE_TO_FIELDS_MAP, @@ -30,7 +30,7 @@ import type { GcpCredentialsType, AzureCredentialsType, RuleSection, -} from '../types'; +} from '../types_old'; /** * @example @@ -50,9 +50,9 @@ export const extractErrorMessage = (e: unknown, defaultMessage = 'Unknown Error' }; export const getBenchmarkFilter = (type: BenchmarkId, section?: RuleSection): string => - `${CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id: "${type}"${ + `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id: "${type}"${ section - ? ` AND ${CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE}.attributes.metadata.section: "${section}"` + ? ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.section: "${section}"` : '' }`; diff --git a/x-pack/plugins/cloud_security_posture/public/common/api/use_setup_status_api.ts b/x-pack/plugins/cloud_security_posture/public/common/api/use_setup_status_api.ts index afb7a89c69e6f..35f49282a475e 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/api/use_setup_status_api.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/api/use_setup_status_api.ts @@ -7,7 +7,7 @@ import { useQuery, type UseQueryOptions } from '@tanstack/react-query'; import { useKibana } from '../hooks/use_kibana'; -import { type CspSetupStatus } from '../../../common/types'; +import { type CspSetupStatus } from '../../../common/types_old'; import { STATUS_API_CURRENT_VERSION, STATUS_ROUTE_PATH } from '../../../common/constants'; const getCspSetupStatusQueryKey = 'csp_status_key'; diff --git a/x-pack/plugins/cloud_security_posture/public/common/api/use_stats_api.ts b/x-pack/plugins/cloud_security_posture/public/common/api/use_stats_api.ts index 834a75581519f..dd893ff356865 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/api/use_stats_api.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/api/use_stats_api.ts @@ -7,7 +7,7 @@ import { useQuery, UseQueryOptions } from '@tanstack/react-query'; import { useKibana } from '../hooks/use_kibana'; -import { ComplianceDashboardDataV2, PosturePolicyTemplate } from '../../../common/types'; +import { ComplianceDashboardDataV2, PosturePolicyTemplate } from '../../../common/types_old'; import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE, diff --git a/x-pack/plugins/cloud_security_posture/public/common/api/use_vulnerability_dashboard_api.ts b/x-pack/plugins/cloud_security_posture/public/common/api/use_vulnerability_dashboard_api.ts index 11113949d0972..4114a49cdf181 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/api/use_vulnerability_dashboard_api.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/api/use_vulnerability_dashboard_api.ts @@ -6,7 +6,7 @@ */ import { useQuery, UseQueryOptions } from '@tanstack/react-query'; -import { CnvmDashboardData } from '../../../common/types'; +import { CnvmDashboardData } from '../../../common/types_old'; import { useKibana } from '../hooks/use_kibana'; import { VULNERABILITIES_DASHBOARD_ROUTE_PATH } from '../../../common/constants'; diff --git a/x-pack/plugins/cloud_security_posture/public/common/constants.ts b/x-pack/plugins/cloud_security_posture/public/common/constants.ts index 60e15f54b1687..404ea0f036017 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/constants.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/constants.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { euiThemeVars } from '@kbn/ui-theme'; -import type { CloudSecurityPolicyTemplate, PostureInput } from '../../common/types'; +import type { CloudSecurityPolicyTemplate, PostureInput } from '../../common/types_old'; import { CLOUDBEAT_EKS, CLOUDBEAT_VANILLA, diff --git a/x-pack/plugins/cloud_security_posture/public/common/navigation/constants.ts b/x-pack/plugins/cloud_security_posture/public/common/navigation/constants.ts index ff88d9c38707f..e89d7d610bc9c 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/navigation/constants.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/navigation/constants.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../../common/constants'; -import { PosturePolicyTemplate } from '../../../common/types'; +import { PosturePolicyTemplate } from '../../../common/types_old'; import type { CspBenchmarksPage, CspIntegrationDocNavigationItem, diff --git a/x-pack/plugins/cloud_security_posture/public/common/navigation/use_csp_integration_link.ts b/x-pack/plugins/cloud_security_posture/public/common/navigation/use_csp_integration_link.ts index fb255a9545ad4..1dac88397e8be 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/navigation/use_csp_integration_link.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/navigation/use_csp_integration_link.ts @@ -6,7 +6,7 @@ */ import { pagePathGetters, pkgKeyFromPackageInfo } from '@kbn/fleet-plugin/public'; -import type { CloudSecurityPolicyTemplate } from '../../../common/types'; +import type { CloudSecurityPolicyTemplate } from '../../../common/types_old'; import { useCisKubernetesIntegration } from '../api/use_cis_kubernetes_integration'; import { useKibana } from '../hooks/use_kibana'; diff --git a/x-pack/plugins/cloud_security_posture/public/common/navigation/use_navigate_to_cis_integration_policies.ts b/x-pack/plugins/cloud_security_posture/public/common/navigation/use_navigate_to_cis_integration_policies.ts index af1dc5e795485..f5c7a6e5cc5e4 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/navigation/use_navigate_to_cis_integration_policies.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/navigation/use_navigate_to_cis_integration_policies.ts @@ -9,7 +9,7 @@ import { pagePathGetters, pkgKeyFromPackageInfo } from '@kbn/fleet-plugin/public import { useCisKubernetesIntegration } from '../api/use_cis_kubernetes_integration'; import { useKibana } from '../hooks/use_kibana'; import { useCspBenchmarkIntegrations } from '../../pages/benchmarks/use_csp_benchmark_integrations'; -import { PostureTypes } from '../../../common/types'; +import { PostureTypes } from '../../../common/types_old'; export const useCISIntegrationPoliciesLink = ({ postureType, diff --git a/x-pack/plugins/cloud_security_posture/public/common/utils/get_enabled_csp_integration_details.ts b/x-pack/plugins/cloud_security_posture/public/common/utils/get_enabled_csp_integration_details.ts index 4cf3d7d129f0c..cd0a413648bed 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/utils/get_enabled_csp_integration_details.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/utils/get_enabled_csp_integration_details.ts @@ -6,7 +6,7 @@ */ import type { PackagePolicy } from '@kbn/fleet-plugin/common'; -import type { PostureInput } from '../../../common/types'; +import type { PostureInput } from '../../../common/types_old'; import { SUPPORTED_CLOUDBEAT_INPUTS } from '../../../common/constants'; import { cloudPostureIntegrations, type CloudPostureIntegrations } from '../constants'; diff --git a/x-pack/plugins/cloud_security_posture/public/common/utils/get_vulnerability_colors.ts b/x-pack/plugins/cloud_security_posture/public/common/utils/get_vulnerability_colors.ts index 6cb1423a77511..db5776bb82ccc 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/utils/get_vulnerability_colors.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/utils/get_vulnerability_colors.ts @@ -7,7 +7,7 @@ import { euiThemeVars } from '@kbn/ui-theme'; import { VULNERABILITIES_SEVERITY } from '../../../common/constants'; -import { VulnSeverity } from '../../../common/types'; +import { VulnSeverity } from '../../../common/types_old'; export const getCvsScoreColor = (score: number): string | undefined => { if (score <= 4) { diff --git a/x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.tsx b/x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.tsx index 4feee3a5e2287..98f99fbd29245 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.tsx @@ -11,7 +11,7 @@ import { CIS_AWS, CIS_GCP, CIS_AZURE, CIS_K8S, CIS_EKS } from '../../common/cons import { CISBenchmarkIcon } from './cis_benchmark_icon'; import { CompactFormattedNumber } from './compact_formatted_number'; import { useNavigateFindings } from '../common/hooks/use_navigate_findings'; -import { BenchmarkData } from '../../common/types'; +import { BenchmarkData } from '../../common/types_old'; // order in array will determine order of appearance in the dashboard const benchmarks = [ diff --git a/x-pack/plugins/cloud_security_posture/public/components/cis_benchmark_icon.tsx b/x-pack/plugins/cloud_security_posture/public/components/cis_benchmark_icon.tsx index 50f9ca1b15d9d..b0b5703937c90 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/cis_benchmark_icon.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/cis_benchmark_icon.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { EuiIcon, EuiToolTip, IconSize } from '@elastic/eui'; import { CSSInterpolation } from '@emotion/serialize'; -import type { BenchmarkId } from '../../common/types'; +import type { BenchmarkId } from '../../common/types_old'; import cisEksIcon from '../assets/icons/cis_eks_logo.svg'; import googleCloudLogo from '../assets/icons/google_cloud_logo.svg'; diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/aws_credentials_form.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/aws_credentials_form.tsx index 4be4ac082f60f..947e48f434554 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/aws_credentials_form.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/aws_credentials_form.tsx @@ -35,7 +35,7 @@ import { } from '../utils'; import { SetupFormat, useAwsCredentialsForm } from './hooks'; import { AWS_ORGANIZATION_ACCOUNT } from '../policy_template_form'; -import { AwsCredentialsType } from '../../../../common/types'; +import { AwsCredentialsType } from '../../../../common/types_old'; interface AWSSetupInfoContentProps { integrationLink: string; diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/get_aws_credentials_form_options.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/get_aws_credentials_form_options.tsx index 71882d4cc67cf..c4b19f87636b6 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/get_aws_credentials_form_options.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/get_aws_credentials_form_options.tsx @@ -10,7 +10,7 @@ import { EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { NewPackagePolicyInput } from '@kbn/fleet-plugin/common'; -import { AwsCredentialsType } from '../../../../common/types'; +import { AwsCredentialsType } from '../../../../common/types_old'; const AssumeRoleDescription = (
diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/hooks.ts b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/hooks.ts index 190ae47a61aec..d4824f5bc04b6 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/hooks.ts +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/aws_credentials_form/hooks.ts @@ -19,7 +19,7 @@ import { getInputVarsFields, } from './get_aws_credentials_form_options'; import { CLOUDBEAT_AWS } from '../../../../common/constants'; -import { AwsCredentialsType } from '../../../../common/types'; +import { AwsCredentialsType } from '../../../../common/types_old'; /** * Update CloudFormation template and stack name in the Agent Policy * based on the selected policy template diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/azure_credentials_form.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/azure_credentials_form.tsx index e941d81112d0c..06de63c3cff0c 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/azure_credentials_form.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/azure_credentials_form.tsx @@ -29,7 +29,7 @@ import { AzureOptions, getAzureCredentialsFormManualOptions, } from './get_azure_credentials_form_options'; -import { AzureCredentialsType } from '../../../../common/types'; +import { AzureCredentialsType } from '../../../../common/types_old'; import { SetupFormat, useAzureCredentialsForm } from './hooks'; import { getPosturePolicy, NewPackagePolicyPostureInput } from '../utils'; import { CspRadioOption, RadioGroup } from '../csp_boxed_radio_group'; diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/get_azure_credentials_form_options.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/get_azure_credentials_form_options.tsx index fb28255a08985..d6044118f1afd 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/get_azure_credentials_form_options.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/get_azure_credentials_form_options.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiText } from '@elastic/eui'; -import { AzureCredentialsType } from '../../../../common/types'; +import { AzureCredentialsType } from '../../../../common/types_old'; export type AzureCredentialsFields = Record; diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/hooks.ts b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/hooks.ts index a229c1a1486f0..2eb56fc6ace83 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/hooks.ts +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/azure_credentials_form/hooks.ts @@ -19,7 +19,7 @@ import { getInputVarsFields, } from './get_azure_credentials_form_options'; import { CLOUDBEAT_AZURE } from '../../../../common/constants'; -import { AzureCredentialsType } from '../../../../common/types'; +import { AzureCredentialsType } from '../../../../common/types_old'; export type SetupFormat = 'arm_template' | 'manual'; diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/custom_assets_extension.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/custom_assets_extension.tsx index 774acadbd03ba..c7708cba837cc 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/custom_assets_extension.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/custom_assets_extension.tsx @@ -10,7 +10,7 @@ import { type CustomAssetsAccordionProps, CustomAssetsAccordion } from '@kbn/fle import { i18n } from '@kbn/i18n'; import { useParams } from 'react-router-dom'; import { EuiSpacer } from '@elastic/eui'; -import { CloudSecurityPolicyTemplate } from '../../../common/types'; +import { CloudSecurityPolicyTemplate } from '../../../common/types_old'; import { VULN_MGMT_POLICY_TEMPLATE } from '../../../common/constants'; import { useKibana } from '../../common/hooks/use_kibana'; import { benchmarksNavigation, cloudPosturePages } from '../../common/navigation/constants'; diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/gcp_credential_form.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/gcp_credential_form.tsx index 4f0adecb60e5b..45a3f8a6639a5 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/gcp_credential_form.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/gcp_credential_form.tsx @@ -25,7 +25,7 @@ import type { NewPackagePolicy } from '@kbn/fleet-plugin/public'; import { NewPackagePolicyInput, PackageInfo } from '@kbn/fleet-plugin/common'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; -import { GcpCredentialsType } from '../../../common/types'; +import { GcpCredentialsType } from '../../../common/types_old'; import { CLOUDBEAT_GCP, SETUP_ACCESS_CLOUD_SHELL, diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/mocks.ts b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/mocks.ts index 4c1b04a260df1..ae933a0f941a8 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/mocks.ts +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/mocks.ts @@ -15,7 +15,7 @@ import { CLOUDBEAT_AWS, CLOUDBEAT_VULN_MGMT_AWS, } from '../../../common/constants'; -import type { PostureInput } from '../../../common/types'; +import type { PostureInput } from '../../../common/types_old'; export const getMockPolicyAWS = () => getPolicyMock(CLOUDBEAT_AWS, 'cspm', 'aws'); export const getMockPolicyGCP = () => getPolicyMock(CLOUDBEAT_GCP, 'cspm', 'gcp'); diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_form.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_form.tsx index 25360d33d1114..89ec1007f7d53 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_form.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_form.tsx @@ -32,7 +32,7 @@ import { i18n } from '@kbn/i18n'; import { AZURE_ARM_TEMPLATE_CREDENTIAL_TYPE } from './azure_credentials_form/azure_credentials_form'; import { CspRadioGroupProps, RadioGroup } from './csp_boxed_radio_group'; import { assert } from '../../../common/utils/helpers'; -import type { CloudSecurityPolicyTemplate, PostureInput } from '../../../common/types'; +import type { CloudSecurityPolicyTemplate, PostureInput } from '../../../common/types_old'; import { CLOUDBEAT_AWS, CLOUDBEAT_VANILLA, diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_selectors.tsx b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_selectors.tsx index ef21868dd404d..aa1e2b7942575 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_selectors.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_selectors.tsx @@ -15,7 +15,7 @@ import { VULN_MGMT_POLICY_TEMPLATE, CNVM_POLICY_TEMPLATE, } from '../../../common/constants'; -import type { PostureInput, CloudSecurityPolicyTemplate } from '../../../common/types'; +import type { PostureInput, CloudSecurityPolicyTemplate } from '../../../common/types_old'; import { getPolicyTemplateInputOptions, type NewPackagePolicyPostureInput } from './utils'; import { RadioGroup } from './csp_boxed_radio_group'; import { AzureCredentialsForm } from './azure_credentials_form/azure_credentials_form'; diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/utils.ts b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/utils.ts index ae7c02ade79d1..1f005ccb950f4 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/utils.ts +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/utils.ts @@ -30,7 +30,7 @@ import { VULN_MGMT_POLICY_TEMPLATE, } from '../../../common/constants'; import { getDefaultAwsVarsGroup } from './aws_credentials_form/aws_credentials_form'; -import type { PostureInput, CloudSecurityPolicyTemplate } from '../../../common/types'; +import type { PostureInput, CloudSecurityPolicyTemplate } from '../../../common/types_old'; import { cloudPostureIntegrations } from '../../common/constants'; import { DEFAULT_EKS_VARS_GROUP } from './eks_credentials_form'; diff --git a/x-pack/plugins/cloud_security_posture/public/components/no_findings_states.tsx b/x-pack/plugins/cloud_security_posture/public/components/no_findings_states.tsx index 422695c7ff576..f070b1e0ad345 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/no_findings_states.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/no_findings_states.tsx @@ -30,7 +30,7 @@ import { } from './test_subjects'; import { CloudPosturePage, PACKAGE_NOT_INSTALLED_TEST_SUBJECT } from './cloud_posture_page'; import { useCspSetupStatusApi } from '../common/api/use_setup_status_api'; -import type { IndexDetails, PostureTypes } from '../../common/types'; +import type { IndexDetails, PostureTypes } from '../../common/types_old'; import { cspIntegrationDocsNavigation } from '../common/navigation/constants'; import noDataIllustration from '../assets/illustrations/no_data_illustration.svg'; import { useCspIntegrationLink } from '../common/navigation/use_csp_integration_link'; diff --git a/x-pack/plugins/cloud_security_posture/public/components/no_vulnerabilities_states.tsx b/x-pack/plugins/cloud_security_posture/public/components/no_vulnerabilities_states.tsx index 7dee3e94e70a6..14872bcc19210 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/no_vulnerabilities_states.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/no_vulnerabilities_states.tsx @@ -25,7 +25,7 @@ import { VULN_MGMT_POLICY_TEMPLATE } from '../../common/constants'; import { FullSizeCenteredPage } from './full_size_centered_page'; import { CloudPosturePage } from './cloud_posture_page'; import { useCspSetupStatusApi } from '../common/api/use_setup_status_api'; -import type { IndexDetails } from '../../common/types'; +import type { IndexDetails } from '../../common/types_old'; import { NO_VULNERABILITIES_STATUS_TEST_SUBJ, CNVM_NOT_INSTALLED_ACTION_SUBJ, @@ -33,7 +33,7 @@ import { import noDataIllustration from '../assets/illustrations/no_data_illustration.svg'; import { useCspIntegrationLink } from '../common/navigation/use_csp_integration_link'; import { useCISIntegrationPoliciesLink } from '../common/navigation/use_navigate_to_cis_integration_policies'; -import { PostureTypes } from '../../common/types'; +import { PostureTypes } from '../../common/types_old'; const REFETCH_INTERVAL_MS = 20000; diff --git a/x-pack/plugins/cloud_security_posture/public/components/vulnerability_badges.tsx b/x-pack/plugins/cloud_security_posture/public/components/vulnerability_badges.tsx index b94efbd2de1a0..20b1326d65526 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/vulnerability_badges.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/vulnerability_badges.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { css } from '@emotion/react'; import { float } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getCvsScoreColor, getSeverityStatusColor } from '../common/utils/get_vulnerability_colors'; -import { VulnSeverity } from '../../common/types'; +import { VulnSeverity } from '../../common/types_old'; import { VULNERABILITIES_CVSS_SCORE_BADGE_SUBJ } from './test_subjects'; interface CVSScoreBadgeProps { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks_table.tsx b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks_table.tsx index e37a9d6fcbe9c..d2b6495667372 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks_table.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks_table.tsx @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n'; import type { PackagePolicy } from '@kbn/fleet-plugin/common'; import { FormattedMessage } from '@kbn/i18n-react'; import { TimestampTableCell } from '../../components/timestamp_table_cell'; -import type { Benchmark } from '../../../common/types'; +import type { Benchmark } from '../../../common/types_old'; import { useKibana } from '../../common/hooks/use_kibana'; import { benchmarksNavigation } from '../../common/navigation/constants'; import * as TEST_SUBJ from './test_subjects'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/use_csp_benchmark_integrations.ts b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/use_csp_benchmark_integrations.ts index 95d955c69047e..8704846407fc7 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/use_csp_benchmark_integrations.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/use_csp_benchmark_integrations.ts @@ -10,7 +10,7 @@ import type { ListResult } from '@kbn/fleet-plugin/common'; import { BENCHMARKS_API_CURRENT_VERSION, BENCHMARKS_ROUTE_PATH } from '../../../common/constants'; import type { BenchmarksQueryParams } from '../../../common/schemas/benchmark'; import { useKibana } from '../../common/hooks/use_kibana'; -import type { Benchmark } from '../../../common/types'; +import type { Benchmark } from '../../../common/types_old'; const QUERY_KEY = 'csp_benchmark_integrations'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_charts/compliance_score_chart.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_charts/compliance_score_chart.tsx index 2067a9c98fd23..01821e04403ff 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_charts/compliance_score_chart.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_charts/compliance_score_chart.tsx @@ -35,7 +35,7 @@ import { DASHBOARD_COMPLIANCE_SCORE_CHART } from '../test_subjects'; import { statusColors } from '../../../common/constants'; import { RULE_FAILED, RULE_PASSED } from '../../../../common/constants'; import { CompactFormattedNumber } from '../../../components/compact_formatted_number'; -import type { Evaluation, PostureTrend, Stats } from '../../../../common/types'; +import type { Evaluation, PostureTrend, Stats } from '../../../../common/types_old'; import { useKibana } from '../../../common/hooks/use_kibana'; interface ComplianceScoreChartProps { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_charts/risks_table.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_charts/risks_table.tsx index ac7048533ead5..d8fce2e0bfaa0 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_charts/risks_table.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_charts/risks_table.tsx @@ -17,7 +17,7 @@ import { import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; import { ComplianceScoreBar } from '../../../components/compliance_score_bar'; -import { ComplianceDashboardData, GroupedFindingsEvaluation } from '../../../../common/types'; +import { ComplianceDashboardData, GroupedFindingsEvaluation } from '../../../../common/types_old'; export interface RisksTableProps { data: ComplianceDashboardData['groupedFindingsEvaluation']; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_dashboard.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_dashboard.test.tsx index 18e5118f772e5..adf85dd5f84db 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_dashboard.test.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_dashboard.test.tsx @@ -36,7 +36,7 @@ import { BaseCspSetupStatus, ComplianceDashboardDataV2, CspStatusCode, -} from '../../../common/types'; +} from '../../../common/types_old'; jest.mock('../../common/api/use_setup_status_api'); jest.mock('../../common/api/use_stats_api'); diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_dashboard.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_dashboard.tsx index 9e3b8df0c1d3e..61a56ecd3187c 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_dashboard.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/compliance_dashboard.tsx @@ -17,7 +17,7 @@ import type { PosturePolicyTemplate, ComplianceDashboardDataV2, BaseCspSetupStatus, -} from '../../../common/types'; +} from '../../../common/types_old'; import { CloudPosturePageTitle } from '../../components/cloud_posture_page_title'; import { CloudPosturePage, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmark_details_box.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmark_details_box.tsx index de982b50f48f6..dc140fef121b3 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmark_details_box.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmark_details_box.tsx @@ -18,7 +18,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { getBenchmarkIdQuery } from './benchmarks_section'; -import { BenchmarkData } from '../../../../common/types'; +import { BenchmarkData } from '../../../../common/types_old'; import { useNavigateFindings } from '../../../common/hooks/use_navigate_findings'; import { CISBenchmarkIcon } from '../../../components/cis_benchmark_icon'; import cisLogoIcon from '../../../assets/icons/cis_logo.svg'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmarks_section.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmarks_section.tsx index 2ac91288475de..d3a6cf3ab12d7 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmarks_section.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmarks_section.tsx @@ -17,7 +17,7 @@ import type { ComplianceDashboardDataV2, Evaluation, PosturePolicyTemplate, -} from '../../../../common/types'; +} from '../../../../common/types_old'; import { RisksTable } from '../compliance_charts/risks_table'; import { RULE_FAILED } from '../../../../common/constants'; import { LOCAL_STORAGE_DASHBOARD_BENCHMARK_SORT_KEY } from '../../../common/constants'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/summary_section.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/summary_section.tsx index ca4a55c45ebdd..e63152a00590e 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/summary_section.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/summary_section.tsx @@ -25,7 +25,7 @@ import type { ComplianceDashboardDataV2, Evaluation, PosturePolicyTemplate, -} from '../../../../common/types'; +} from '../../../../common/types_old'; import { RisksTable } from '../compliance_charts/risks_table'; import { NavFilter, useNavigateFindings } from '../../../common/hooks/use_navigate_findings'; import { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/mock.ts b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/mock.ts index b4a8eae816b24..93eddb2d6454d 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/mock.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { BenchmarkData, ComplianceDashboardDataV2 } from '../../../common/types'; +import { BenchmarkData, ComplianceDashboardDataV2 } from '../../../common/types_old'; export const getMockDashboardData = () => ({ ...mockDashboardData, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_flyout.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_flyout.tsx index 2542c57aab44f..edc8e7f35bb35 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_flyout.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_flyout.tsx @@ -35,9 +35,9 @@ import { TableTab } from './table_tab'; import { JsonTab } from './json_tab'; import { OverviewTab } from './overview_tab'; import { RuleTab } from './rule_tab'; -import type { BenchmarkId } from '../../../../common/types'; +import type { BenchmarkId } from '../../../../common/types_old'; import { CISBenchmarkIcon } from '../../../components/cis_benchmark_icon'; -import { BenchmarkName } from '../../../../common/types'; +import { BenchmarkName } from '../../../../common/types_old'; import { FINDINGS_FLYOUT } from '../test_subjects'; import { createDetectionRuleFromFinding } from '../utils/create_detection_rule_from_finding'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings_grouping.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings_grouping.tsx index be5253cc710b7..9d092de673edf 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings_grouping.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings_grouping.tsx @@ -15,7 +15,7 @@ import { } from '@kbn/securitysolution-grouping/src'; import { useMemo } from 'react'; import { DataView } from '@kbn/data-views-plugin/common'; -import { Evaluation } from '../../../../common/types'; +import { Evaluation } from '../../../../common/types_old'; import { LATEST_FINDINGS_RETENTION_POLICY } from '../../../../common/constants'; import { FindingsGroupingAggregation, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings_table.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings_table.tsx index 2bcc895ddd4b0..50ebb01f363f0 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings_table.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings_table.tsx @@ -9,7 +9,7 @@ import { DataView } from '@kbn/data-views-plugin/common'; import { Filter } from '@kbn/es-query'; import { useMemo } from 'react'; import { FindingsBaseURLQuery } from '../../../common/types'; -import { Evaluation } from '../../../../common/types'; +import { Evaluation } from '../../../../common/types_old'; import { LOCAL_STORAGE_DATA_TABLE_PAGE_SIZE_KEY } from '../../../common/constants'; import { useCloudPostureDataTable } from '../../../common/hooks/use_cloud_posture_data_table'; import { getFilters } from '../utils/get_filters'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings_by_resource/findings_by_resource_container.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings_by_resource/findings_by_resource_container.tsx index 3054ad352a5bd..85095b149bce4 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings_by_resource/findings_by_resource_container.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings_by_resource/findings_by_resource_container.tsx @@ -10,7 +10,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { TrackApplicationView } from '@kbn/usage-collection-plugin/public'; import { CspFinding } from '../../../../common/schemas/csp_finding'; -import type { Evaluation } from '../../../../common/types'; +import type { Evaluation } from '../../../../common/types_old'; import { FindingsSearchBar } from '../layout/findings_search_bar'; import * as TEST_SUBJECTS from '../test_subjects'; import { usePageSlice } from '../../../common/hooks/use_page_slice'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings_by_resource/resource_findings/resource_findings_container.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings_by_resource/resource_findings/resource_findings_container.tsx index f606241862ee2..bc6e67b887096 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings_by_resource/resource_findings/resource_findings_container.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings_by_resource/resource_findings/resource_findings_container.tsx @@ -17,7 +17,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { generatePath } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; import { CspInlineDescriptionList } from '../../../../components/csp_inline_description_list'; -import type { Evaluation } from '../../../../../common/types'; +import type { Evaluation } from '../../../../../common/types_old'; import { CspFinding } from '../../../../../common/schemas/csp_finding'; import { CloudPosturePageTitle } from '../../../../components/cloud_posture_page_title'; import * as TEST_SUBJECTS from '../../test_subjects'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/layout/findings_distribution_bar.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/layout/findings_distribution_bar.tsx index 1cf084220ea29..35f6fd008d4b9 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/layout/findings_distribution_bar.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/layout/findings_distribution_bar.tsx @@ -20,7 +20,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { getAbbreviatedNumber } from '../../../common/utils/get_abbreviated_number'; import { RULE_FAILED, RULE_PASSED } from '../../../../common/constants'; import { statusColors } from '../../../common/constants'; -import type { Evaluation } from '../../../../common/types'; +import type { Evaluation } from '../../../../common/types_old'; interface Props { passed: number; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_container.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_container.test.tsx index 6b0998d4ce218..6301c9cc20b7c 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_container.test.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_container.test.tsx @@ -9,19 +9,19 @@ import React from 'react'; import { RulesContainer } from './rules_container'; import { render, screen } from '@testing-library/react'; import { QueryClient } from '@tanstack/react-query'; -import { useFindCspRuleTemplates } from './use_csp_rules'; +import { useFindCspBenchmarkRule } from './use_csp_benchmark_rules'; import * as TEST_SUBJECTS from './test_subjects'; import { Chance } from 'chance'; import { TestProvider } from '../../test/test_provider'; +import type { CspBenchmarkRule } from '../../../common/types/latest'; import { useParams } from 'react-router-dom'; import { coreMock } from '@kbn/core/public/mocks'; -import { CspRuleTemplate } from '../../../common/schemas'; const chance = new Chance(); -jest.mock('./use_csp_rules', () => ({ - useFindCspRuleTemplates: jest.fn(), - useBulkUpdateCspRuleTemplates: jest.fn(), +jest.mock('./use_csp_benchmark_rules', () => ({ + useFindCspBenchmarkRule: jest.fn(), + useBulkUpdateCspBenchmarkRule: jest.fn(), })); jest.mock('react-router-dom', () => ({ @@ -52,7 +52,7 @@ const getWrapper = return {children}; }; -const getRuleMock = (id = chance.guid()): CspRuleTemplate => +const getRuleMock = (id = chance.guid()): CspBenchmarkRule => ({ metadata: { audit: chance.sentence(), @@ -75,7 +75,7 @@ const getRuleMock = (id = chance.guid()): CspRuleTemplate => tags: [chance.word(), chance.word()], version: chance.sentence(), }, - } as CspRuleTemplate); + } as CspBenchmarkRule); const params = { packagePolicyId: chance.guid(), @@ -93,7 +93,7 @@ describe('', () => { const Wrapper = getWrapper(); const rule1 = getRuleMock(); - (useFindCspRuleTemplates as jest.Mock).mockReturnValue({ + (useFindCspBenchmarkRule as jest.Mock).mockReturnValue({ status: 'success', data: { total: 1, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_container.tsx b/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_container.tsx index 81472e29b6ee7..5ec1971b1f0ac 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_container.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_container.tsx @@ -7,20 +7,23 @@ import React, { useState, useMemo } from 'react'; import { EuiPanel, EuiSpacer } from '@elastic/eui'; import { useParams } from 'react-router-dom'; -import { CspRuleTemplate } from '../../../common/schemas'; import { extractErrorMessage } from '../../../common/utils/helpers'; import { RulesTable } from './rules_table'; import { RulesTableHeader } from './rules_table_header'; -import { useFindCspRuleTemplates, type RulesQuery, type RulesQueryResult } from './use_csp_rules'; +import { + useFindCspBenchmarkRule, + type RulesQuery, + type RulesQueryResult, +} from './use_csp_benchmark_rules'; import * as TEST_SUBJECTS from './test_subjects'; import { RuleFlyout } from './rules_flyout'; import { LOCAL_STORAGE_PAGE_SIZE_RULES_KEY } from '../../common/constants'; import { usePageSize } from '../../common/hooks/use_page_size'; - +import type { CspBenchmarkRule } from '../../../common/types/latest'; interface RulesPageData { - rules_page: CspRuleTemplate[]; - all_rules: CspRuleTemplate[]; - rules_map: Map; + rules_page: CspBenchmarkRule[]; + all_rules: CspBenchmarkRule[]; + rules_map: Map; total: number; error?: string; loading: boolean; @@ -32,7 +35,7 @@ const getRulesPageData = ( { status, data, error }: Pick, query: RulesQuery ): RulesPageData => { - const rules = data?.items || ([] as CspRuleTemplate[]); + const rules = data?.items || ([] as CspBenchmarkRule[]); const page = getPage(rules, query); @@ -46,7 +49,7 @@ const getRulesPageData = ( }; }; -const getPage = (data: CspRuleTemplate[], { page, perPage }: RulesQuery) => +const getPage = (data: CspBenchmarkRule[], { page, perPage }: RulesQuery) => data.slice(page * perPage, (page + 1) * perPage); const MAX_ITEMS_PER_PAGE = 10000; @@ -64,7 +67,7 @@ export const RulesContainer = () => { perPage: pageSize || 10, }); - const { data, status, error } = useFindCspRuleTemplates( + const { data, status, error } = useFindCspBenchmarkRule( { section: rulesQuery.section, search: rulesQuery.search, @@ -80,7 +83,7 @@ export const RulesContainer = () => { ); // We need to make this call again without the filters. this way the section list is always full - const allRules = useFindCspRuleTemplates( + const allRules = useFindCspBenchmarkRule( { page: 1, perPage: MAX_ITEMS_PER_PAGE, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_flyout.tsx b/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_flyout.tsx index 49ab9bb79fab8..da9fe29ee26c7 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_flyout.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_flyout.tsx @@ -18,14 +18,15 @@ import { EuiFlexGroup, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { CspRuleTemplate, CspRuleTemplateMetadata } from '../../../common/schemas'; + +import { CspBenchmarkRule, CspBenchmarkRuleMetadata } from '../../../common/types/latest'; import { getRuleList } from '../configurations/findings_flyout/rule_tab'; import { getRemediationList } from '../configurations/findings_flyout/overview_tab'; import * as TEST_SUBJECTS from './test_subjects'; interface RuleFlyoutProps { onClose(): void; - rule: CspRuleTemplate; + rule: CspBenchmarkRule; } const tabs = [ @@ -85,7 +86,7 @@ export const RuleFlyout = ({ onClose, rule }: RuleFlyoutProps) => { ); }; -const RuleOverviewTab = ({ rule }: { rule: CspRuleTemplateMetadata }) => ( +const RuleOverviewTab = ({ rule }: { rule: CspBenchmarkRuleMetadata }) => ( diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_table.tsx b/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_table.tsx index 167589024529b..c6ce3485f68db 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_table.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/rules_table.tsx @@ -14,7 +14,7 @@ import { useEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { CspRuleTemplate } from '../../../common/schemas'; +import { CspBenchmarkRule } from '../../../common/types/latest'; import type { RulesState } from './rules_container'; import * as TEST_SUBJECTS from './test_subjects'; @@ -41,20 +41,20 @@ export const RulesTable = ({ const { euiTheme } = useEuiTheme(); const columns = useMemo(() => getColumns({ setSelectedRuleId }), [setSelectedRuleId]); - const euiPagination: EuiBasicTableProps['pagination'] = { + const euiPagination: EuiBasicTableProps['pagination'] = { pageIndex: page, pageSize, totalItemCount: total, pageSizeOptions: [10, 25, 100], }; - const onTableChange = ({ page: pagination }: Criteria) => { + const onTableChange = ({ page: pagination }: Criteria) => { if (!pagination) return; setPagination({ page: pagination.index, perPage: pagination.size }); }; - const rowProps = (row: CspRuleTemplate) => ({ - ['data-test-subj']: TEST_SUBJECTS.getCspRuleTemplatesTableRowItemTestId(row.metadata.id), + const rowProps = (row: CspBenchmarkRule) => ({ + ['data-test-subj']: TEST_SUBJECTS.getCspBenchmarkRuleTableRowItemTestId(row.metadata.id), style: { background: row.metadata.id === selectedRuleId ? euiTheme.colors.highlight : undefined, }, @@ -79,7 +79,7 @@ type GetColumnProps = Pick; const getColumns = ({ setSelectedRuleId, -}: GetColumnProps): Array> => [ +}: GetColumnProps): Array> => [ { field: 'metadata.benchmark.rule_number', name: i18n.translate('xpack.csp.rules.rulesTable.ruleNumberColumnLabel', { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/test_subjects.ts b/x-pack/plugins/cloud_security_posture/public/pages/rules/test_subjects.ts index dbbc6877e2dcf..5f7de36484609 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/test_subjects.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/test_subjects.ts @@ -13,5 +13,5 @@ export const CSP_RULES_TABLE = 'csp_rules_table'; export const CSP_RULES_TABLE_ROW_ITEM_NAME = 'csp_rules_table_row_item_name'; export const CSP_RULES_FLYOUT_CONTAINER = 'csp_rules_flyout_container'; -export const getCspRuleTemplatesTableRowItemTestId = (id: string) => +export const getCspBenchmarkRuleTableRowItemTestId = (id: string) => `${CSP_RULES_TABLE_ROW_ITEM_NAME}_${id}`; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_benchmark_rules.ts b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_benchmark_rules.ts new file mode 100644 index 0000000000000..8dca9b63c1930 --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_benchmark_rules.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { useQuery } from '@tanstack/react-query'; +import { + FindCspBenchmarkRuleRequest, + FindCspBenchmarkRuleResponse, +} from '../../../common/types/latest'; +import { useKibana } from '../../common/hooks/use_kibana'; + +import { + CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE, + FIND_CSP_BENCHMARK_RULE_API_CURRENT_VERSION, + FIND_CSP_BENCHMARK_RULE_ROUTE_PATH, +} from '../../../common/constants'; + +export type RulesQuery = Pick< + FindCspBenchmarkRuleRequest, + 'section' | 'search' | 'page' | 'perPage' +>; +export type RulesQueryResult = ReturnType; + +export const useFindCspBenchmarkRule = ( + { search, page, perPage, section }: RulesQuery, + packagePolicyId: string +) => { + const { http } = useKibana().services; + + return useQuery( + [CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE, { section, search, page, perPage, packagePolicyId }], + () => { + return http.get(FIND_CSP_BENCHMARK_RULE_ROUTE_PATH, { + query: { packagePolicyId, page, perPage, search, section }, + version: FIND_CSP_BENCHMARK_RULE_API_CURRENT_VERSION, + }); + } + ); +}; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_integration.tsx b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_integration.tsx index 6d1a01b3d3c2e..76477b1705e97 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_integration.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_integration.tsx @@ -18,7 +18,7 @@ import { useKibana } from '../../common/hooks/use_kibana'; export const useCspIntegrationInfo = ({ packagePolicyId, policyId }: PageUrlParams) => { const { http } = useKibana().services; - return useQuery(['cspRulesInfo', { packagePolicyId, policyId }], () => + return useQuery(['cspBenchmarkRuleInfo', { packagePolicyId, policyId }], () => Promise.all([ http .get(packagePolicyRouteService.getInfoPath(packagePolicyId), { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules.ts b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules.ts deleted file mode 100644 index ac150e05bf95e..0000000000000 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ -import { useQuery } from '@tanstack/react-query'; -import { GetCspRuleTemplateRequest, GetCspRuleTemplateResponse } from '../../../common/types'; -import { useKibana } from '../../common/hooks/use_kibana'; - -import { - CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE, - FIND_CSP_RULE_TEMPLATE_API_CURRENT_VERSION, - FIND_CSP_RULE_TEMPLATE_ROUTE_PATH, -} from '../../../common/constants'; - -export type RulesQuery = Pick; -export type RulesQueryResult = ReturnType; - -export const useFindCspRuleTemplates = ( - { search, page, perPage, section }: RulesQuery, - packagePolicyId: string -) => { - const { http } = useKibana().services; - - return useQuery( - [CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE, { section, search, page, perPage, packagePolicyId }], - () => { - return http.get(FIND_CSP_RULE_TEMPLATE_ROUTE_PATH, { - query: { packagePolicyId, page, perPage, search, section }, - version: FIND_CSP_RULE_TEMPLATE_API_CURRENT_VERSION, - }); - } - ); -}; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/vulnerabilities_by_resource/severity_map.tsx b/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/vulnerabilities_by_resource/severity_map.tsx index 94ebaf30572b3..af47c20ddc50f 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/vulnerabilities_by_resource/severity_map.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/vulnerabilities_by_resource/severity_map.tsx @@ -17,7 +17,7 @@ import { import { PaletteColorStop } from '@elastic/eui/src/components/color_picker/color_palette_picker'; import { i18n } from '@kbn/i18n'; import { getSeverityStatusColor } from '../../../common/utils/get_vulnerability_colors'; -import { VulnSeverity } from '../../../../common/types'; +import { VulnSeverity } from '../../../../common/types_old'; import { SeverityStatusBadge } from '../../../components/vulnerability_badges'; interface Props { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/_mocks_/vulnerability_dashboard.mock.ts b/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/_mocks_/vulnerability_dashboard.mock.ts index 6d7f909a82e53..0148105bbc83a 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/_mocks_/vulnerability_dashboard.mock.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/_mocks_/vulnerability_dashboard.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CnvmDashboardData } from '../../../../common/types'; +import { CnvmDashboardData } from '../../../../common/types_old'; export const mockCnvmDashboardData: CnvmDashboardData = { cnvmStatistics: { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/vulnerability_table_panel_section.tsx b/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/vulnerability_table_panel_section.tsx index 14c3451fd2731..1ba912b1d125b 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/vulnerability_table_panel_section.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/vulnerability_table_panel_section.tsx @@ -21,7 +21,7 @@ import { VulnerabilityStat, VulnerableResourceStat, VulnSeverity, -} from '../../../common/types'; +} from '../../../common/types_old'; import { DASHBOARD_TABLE_TYPES } from './vulnerability_table_panel.config'; import { VulnerabilityTablePanel } from './vulnerability_table_panel'; import { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/vulnerability_trend_graph.tsx b/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/vulnerability_trend_graph.tsx index a8c528f7f8804..493d38348ed62 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/vulnerability_trend_graph.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/vulnerability_dashboard/vulnerability_trend_graph.tsx @@ -20,7 +20,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { truthy } from '../../../common/utils/helpers'; import { useNavigateVulnerabilities } from '../../common/hooks/use_navigate_findings'; -import { VulnStatsTrend, VulnSeverity } from '../../../common/types'; +import { VulnStatsTrend, VulnSeverity } from '../../../common/types_old'; import { useVulnerabilityDashboardApi } from '../../common/api/use_vulnerability_dashboard_api'; import { getSeverityStatusColor } from '../../common/utils/get_vulnerability_colors'; import { ChartPanel } from '../../components/chart_panel'; diff --git a/x-pack/plugins/cloud_security_posture/public/test/fixtures/csp_benchmark_integration.ts b/x-pack/plugins/cloud_security_posture/public/test/fixtures/csp_benchmark_integration.ts index bc9243fad2792..4b5d4f1bfe028 100644 --- a/x-pack/plugins/cloud_security_posture/public/test/fixtures/csp_benchmark_integration.ts +++ b/x-pack/plugins/cloud_security_posture/public/test/fixtures/csp_benchmark_integration.ts @@ -8,7 +8,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import Chance from 'chance'; -import type { Benchmark } from '../../../common/types'; +import type { Benchmark } from '../../../common/types_old'; type CreateCspBenchmarkIntegrationFixtureInput = { chance?: Chance.Chance; diff --git a/x-pack/plugins/cloud_security_posture/server/lib/check_index_status.ts b/x-pack/plugins/cloud_security_posture/server/lib/check_index_status.ts index ebce74d89b2dc..67eb611f9557e 100644 --- a/x-pack/plugins/cloud_security_posture/server/lib/check_index_status.ts +++ b/x-pack/plugins/cloud_security_posture/server/lib/check_index_status.ts @@ -7,7 +7,7 @@ import { ElasticsearchClient, type Logger } from '@kbn/core/server'; import { getSafePostureTypeRuntimeMapping } from '../../common/runtime_mappings/get_safe_posture_type_runtime_mapping'; -import { IndexStatus, PostureTypes } from '../../common/types'; +import { IndexStatus, PostureTypes } from '../../common/types_old'; export interface PostureTypeAndRetention { postureType?: PostureTypes; diff --git a/x-pack/plugins/cloud_security_posture/server/lib/fleet_util.ts b/x-pack/plugins/cloud_security_posture/server/lib/fleet_util.ts index cd67f29cef1b4..109d1b46986c9 100644 --- a/x-pack/plugins/cloud_security_posture/server/lib/fleet_util.ts +++ b/x-pack/plugins/cloud_security_posture/server/lib/fleet_util.ts @@ -19,7 +19,7 @@ import type { PackagePolicyInput, } from '@kbn/fleet-plugin/common'; import { errors } from '@elastic/elasticsearch'; -import { CloudSecurityPolicyTemplate, PostureTypes } from '../../common/types'; +import { CloudSecurityPolicyTemplate, PostureTypes } from '../../common/types_old'; import { SUPPORTED_POLICY_TEMPLATES, CLOUD_SECURITY_POSTURE_PACKAGE_NAME, diff --git a/x-pack/plugins/cloud_security_posture/server/lib/telemetry/collectors/types.ts b/x-pack/plugins/cloud_security_posture/server/lib/telemetry/collectors/types.ts index cb8d6eec64dcb..f9eb6094277a4 100644 --- a/x-pack/plugins/cloud_security_posture/server/lib/telemetry/collectors/types.ts +++ b/x-pack/plugins/cloud_security_posture/server/lib/telemetry/collectors/types.ts @@ -6,7 +6,7 @@ */ import { AggregationsMultiBucketBase } from '@elastic/elasticsearch/lib/api/types'; -import { CspStatusCode } from '../../../../common/types'; +import { CspStatusCode } from '../../../../common/types_old'; export type CloudSecurityUsageCollectorType = | 'Indices' diff --git a/x-pack/plugins/cloud_security_posture/server/routes/csp_rule_template/get_csp_rule_templates.test.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/find.test.ts similarity index 68% rename from x-pack/plugins/cloud_security_posture/server/routes/csp_rule_template/get_csp_rule_templates.test.ts rename to x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/find.test.ts index f894d031c4bc0..ffec7d5b9b261 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/csp_rule_template/get_csp_rule_templates.test.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/find.test.ts @@ -5,12 +5,12 @@ * 2.0. */ -import { getSortedCspRulesTemplates } from './get_csp_rule_template'; -import { CspRuleTemplate } from '../../../common/schemas'; +import { getSortedCspBenchmarkRulesTemplates } from './v1'; +import { CspBenchmarkRule } from '../../../../common/types/latest'; -describe('getSortedCspRulesTemplates', () => { +describe('getSortedCspBenchmarkRules', () => { it('sorts by metadata.benchmark.rule_number, invalid semantic version still should still get sorted and empty values should be sorted last', () => { - const cspRulesTemplates = [ + const cspBenchmarkRules = [ { metadata: { benchmark: { rule_number: '1.0.0' } } }, { metadata: { benchmark: { rule_number: '2.0.0' } } }, { metadata: { benchmark: { rule_number: '1.1.0' } } }, @@ -18,11 +18,11 @@ describe('getSortedCspRulesTemplates', () => { { metadata: { benchmark: { rule_number: 'invalid' } } }, { metadata: { benchmark: { rule_number: '3.0' } } }, { metadata: { benchmark: {} } }, - ] as CspRuleTemplate[]; + ] as CspBenchmarkRule[]; - const sortedCspRulesTemplates = getSortedCspRulesTemplates(cspRulesTemplates); + const sortedCspBenchmarkRules = getSortedCspBenchmarkRulesTemplates(cspBenchmarkRules); - expect(sortedCspRulesTemplates).toEqual([ + expect(sortedCspBenchmarkRules).toEqual([ { metadata: { benchmark: { rule_number: '1.0.0' } } }, { metadata: { benchmark: { rule_number: '1.0.1' } } }, { metadata: { benchmark: { rule_number: '1.1.0' } } }, @@ -34,36 +34,36 @@ describe('getSortedCspRulesTemplates', () => { }); it('edge case - returns empty array if input is empty', () => { - const cspRulesTemplates: CspRuleTemplate[] = []; + const cspBenchmarkRules: CspBenchmarkRule[] = []; - const sortedCspRulesTemplates = getSortedCspRulesTemplates(cspRulesTemplates); + const sortedCspBenchmarkRules = getSortedCspBenchmarkRulesTemplates(cspBenchmarkRules); - expect(sortedCspRulesTemplates).toEqual([]); + expect(sortedCspBenchmarkRules).toEqual([]); }); it('edge case - returns sorted array even if input only has one element', () => { - const cspRulesTemplates = [ + const cspBenchmarkRules = [ { metadata: { benchmark: { rule_number: '1.0.0' } } }, - ] as CspRuleTemplate[]; + ] as CspBenchmarkRule[]; - const sortedCspRulesTemplates = getSortedCspRulesTemplates(cspRulesTemplates); + const sortedCspBenchmarkRules = getSortedCspBenchmarkRulesTemplates(cspBenchmarkRules); - expect(sortedCspRulesTemplates).toEqual([ + expect(sortedCspBenchmarkRules).toEqual([ { metadata: { benchmark: { rule_number: '1.0.0' } } }, ]); }); it('returns sorted array even with undefined or null properties', () => { - const cspRulesTemplates = [ + const cspBenchmarkRules = [ { metadata: { benchmark: { rule_number: '1.0.0' } } }, { metadata: { benchmark: { rule_number: undefined } } }, { metadata: { benchmark: { rule_number: '2.0.0' } } }, { metadata: { benchmark: { rule_number: null } } }, - ] as CspRuleTemplate[]; + ] as CspBenchmarkRule[]; - const sortedCspRulesTemplates = getSortedCspRulesTemplates(cspRulesTemplates); + const sortedCspBenchmarkRules = getSortedCspBenchmarkRulesTemplates(cspBenchmarkRules); - expect(sortedCspRulesTemplates).toEqual([ + expect(sortedCspBenchmarkRules).toEqual([ { metadata: { benchmark: { rule_number: '1.0.0' } } }, { metadata: { benchmark: { rule_number: '2.0.0' } } }, { metadata: { benchmark: { rule_number: null } } }, @@ -72,15 +72,15 @@ describe('getSortedCspRulesTemplates', () => { }); it('returns sorted array with invalid semantic versions', () => { - const cspRulesTemplates = [ + const cspBenchmarkRules = [ { metadata: { benchmark: { rule_number: '1.0.0' } } }, { metadata: { benchmark: { rule_number: '2.0' } } }, { metadata: { benchmark: { rule_number: '3.0.0' } } }, - ] as CspRuleTemplate[]; + ] as CspBenchmarkRule[]; - const sortedCspRulesTemplates = getSortedCspRulesTemplates(cspRulesTemplates); + const sortedCspBenchmarkRules = getSortedCspBenchmarkRulesTemplates(cspBenchmarkRules); - expect(sortedCspRulesTemplates).toEqual([ + expect(sortedCspBenchmarkRules).toEqual([ { metadata: { benchmark: { rule_number: '1.0.0' } } }, { metadata: { benchmark: { rule_number: '2.0' } } }, { metadata: { benchmark: { rule_number: '3.0.0' } } }, diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/find.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/find.ts new file mode 100644 index 0000000000000..aa4856fd9bada --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/find.ts @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { transformError } from '@kbn/securitysolution-es-utils'; +import { + FindCspBenchmarkRuleRequest, + FindCspBenchmarkRuleResponse, + findCspBenchmarkRuleRequestSchema, +} from '../../../../common/types/latest'; + +import { FIND_CSP_BENCHMARK_RULE_ROUTE_PATH } from '../../../../common/constants'; +import { CspRouter } from '../../../types'; +import { findRuleHandler as findRuleHandlerV1 } from './v1'; + +export const defineFindCspBenchmarkRuleRoute = (router: CspRouter) => + router.versioned + .get({ + access: 'internal', + path: FIND_CSP_BENCHMARK_RULE_ROUTE_PATH, + }) + .addVersion( + { + version: '1', + validate: { + request: { + query: findCspBenchmarkRuleRequestSchema, + }, + }, + }, + async (context, request, response) => { + if (!(await context.fleet).authz.fleet.all) { + return response.forbidden(); + } + + const requestBody: FindCspBenchmarkRuleRequest = request.query; + const cspContext = await context.csp; + + try { + const cspBenchmarkRules: FindCspBenchmarkRuleResponse = await findRuleHandlerV1( + cspContext.soClient, + requestBody + ); + return response.ok({ body: cspBenchmarkRules }); + } catch (err) { + const error = transformError(err); + cspContext.logger.error(`Failed to fetch csp rules templates ${err}`); + return response.customError({ + body: { message: error.message }, + statusCode: error.statusCode, + }); + } + } + ); diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/v1.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/v1.ts new file mode 100644 index 0000000000000..6bd0d14a2f540 --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/find/v1.ts @@ -0,0 +1,88 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import semverValid from 'semver/functions/valid'; +import semverCompare from 'semver/functions/compare'; +import { NewPackagePolicy } from '@kbn/fleet-plugin/common'; +import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server'; +import { getBenchmarkFilter } from '../../../../common/utils/helpers'; +import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../../../common/constants'; +import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../benchmarks/benchmarks'; +import { getBenchmarkFromPackagePolicy } from '../../../../common/utils/helpers'; + +import type { + CspBenchmarkRule, + FindCspBenchmarkRuleRequest, + FindCspBenchmarkRuleResponse, +} from '../../../../common/types/latest'; + +export const getSortedCspBenchmarkRulesTemplates = (cspBenchmarkRules: CspBenchmarkRule[]) => { + return cspBenchmarkRules.slice().sort((a, b) => { + const ruleNumberA = a?.metadata?.benchmark?.rule_number; + const ruleNumberB = b?.metadata?.benchmark?.rule_number; + + const versionA = semverValid(ruleNumberA); + const versionB = semverValid(ruleNumberB); + + if (versionA !== null && versionB !== null) { + return semverCompare(versionA, versionB); + } else { + return String(ruleNumberA).localeCompare(String(ruleNumberB)); + } + }); +}; + +export const getBenchmarkIdFromPackagePolicyId = async ( + soClient: SavedObjectsClientContract, + packagePolicyId: string +): Promise => { + const res = await soClient.get( + PACKAGE_POLICY_SAVED_OBJECT_TYPE, + packagePolicyId + ); + return getBenchmarkFromPackagePolicy(res.attributes.inputs); +}; + +export const findRuleHandler = async ( + soClient: SavedObjectsClientContract, + options: FindCspBenchmarkRuleRequest +): Promise => { + if ( + (!options.packagePolicyId && !options.benchmarkId) || + (options.packagePolicyId && options.benchmarkId) + ) { + throw new Error('Please provide either benchmarkId or packagePolicyId, but not both'); + } + + const benchmarkId = options.benchmarkId + ? options.benchmarkId + : await getBenchmarkIdFromPackagePolicyId(soClient, options.packagePolicyId!); + + const cspCspBenchmarkRulesSo = await soClient.find({ + type: CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE, + searchFields: options.searchFields, + search: options.search ? `"${options.search}"*` : '', + page: options.page, + perPage: options.perPage, + sortField: options.sortField, + fields: options?.fields, + filter: getBenchmarkFilter(benchmarkId, options.section), + }); + + const cspBenchmarkRules = cspCspBenchmarkRulesSo.saved_objects.map( + (cspBenchmarkRule) => cspBenchmarkRule.attributes + ); + + // Semantic version sorting using semver for valid versions and custom comparison for invalid versions + const sortedCspBenchmarkRules = getSortedCspBenchmarkRulesTemplates(cspBenchmarkRules); + + return { + items: sortedCspBenchmarkRules, + total: cspCspBenchmarkRulesSo.total, + page: options.page, + perPage: options.perPage, + }; +}; diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmarks/benchmarks.test.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmarks/benchmarks.test.ts index 25fc95e1f8a20..42209b205e177 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/benchmarks/benchmarks.test.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmarks/benchmarks.test.ts @@ -174,7 +174,7 @@ describe('benchmarks API', () => { }); }); - describe('test addPackagePolicyCspRuleTemplates', () => { + describe('test addPackagePolicyCspBenchmarkRule', () => { it('should retrieve the rules count by the filtered benchmark type', async () => { const benchmark = 'cis_k8s'; mockSoClient.find.mockResolvedValueOnce({ diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmarks/benchmarks.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmarks/benchmarks.ts index 4c78265c1c15e..0c920754fb77b 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/benchmarks/benchmarks.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmarks/benchmarks.ts @@ -7,15 +7,15 @@ import type { SavedObjectsClientContract } from '@kbn/core/server'; import { transformError } from '@kbn/securitysolution-es-utils'; import type { AgentPolicy, ListResult, PackagePolicy } from '@kbn/fleet-plugin/common'; -import { CspRuleTemplate } from '../../../common/schemas'; -import { CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE } from '../../../common/constants'; +import { CspBenchmarkRule } from '../../../common/types/latest'; +import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../../common/constants'; import { BENCHMARKS_ROUTE_PATH, CLOUD_SECURITY_POSTURE_PACKAGE_NAME, POSTURE_TYPE_ALL, } from '../../../common/constants'; import { benchmarksQueryParamsSchema } from '../../../common/schemas/benchmark'; -import type { Benchmark } from '../../../common/types'; +import type { Benchmark } from '../../../common/types_old'; import { getBenchmarkFromPackagePolicy, getBenchmarkFilter, @@ -28,7 +28,7 @@ import { getCspAgentPolicies, getCspPackagePolicies, } from '../../lib/fleet_util'; -import { BenchmarkId } from '../../../common/types'; +import { BenchmarkId } from '../../../common/types_old'; export const PACKAGE_POLICY_SAVED_OBJECT_TYPE = 'ingest-package-policies'; @@ -36,8 +36,8 @@ export const getRulesCountForPolicy = async ( soClient: SavedObjectsClientContract, benchmarkId: BenchmarkId ): Promise => { - const rules = await soClient.find({ - type: CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE, + const rules = await soClient.find({ + type: CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE, filter: getBenchmarkFilter(benchmarkId), perPage: 0, }); diff --git a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/compliance_dashboard.ts b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/compliance_dashboard.ts index 88c7afd5aca11..614f85dcf9374 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/compliance_dashboard.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/compliance_dashboard.ts @@ -15,7 +15,7 @@ import type { ComplianceDashboardData, GetComplianceDashboardRequest, ComplianceDashboardDataV2, -} from '../../../common/types'; +} from '../../../common/types_old'; import { LATEST_FINDINGS_INDEX_DEFAULT_NS, STATS_ROUTE_PATH } from '../../../common/constants'; import { getGroupedFindingsEvaluation } from './get_grouped_findings_evaluation'; import { ClusterWithoutTrend, getClusters } from './get_clusters'; diff --git a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_benchmarks.ts b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_benchmarks.ts index b1f8335a61866..130af8d20a2b8 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_benchmarks.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_benchmarks.ts @@ -13,7 +13,7 @@ import type { } from '@elastic/elasticsearch/lib/api/types'; import type { Logger } from '@kbn/core/server'; import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types'; -import type { BenchmarkData } from '../../../common/types'; +import type { BenchmarkData } from '../../../common/types_old'; import { failedFindingsAggQuery, BenchmarkVersionQueryResult, diff --git a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.ts b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.ts index 51d5c71673ed1..e793863621340 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.ts @@ -16,7 +16,7 @@ import type { import type { Logger } from '@kbn/core/server'; import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types'; import { CspFinding } from '../../../common/schemas/csp_finding'; -import type { Cluster } from '../../../common/types'; +import type { Cluster } from '../../../common/types_old'; import { getPostureStatsFromAggs, failedFindingsAggQuery } from './get_grouped_findings_evaluation'; import type { FailedFindingsQueryResult } from './get_grouped_findings_evaluation'; import { findingsEvaluationAggsQuery, getStatsFromFindingsEvaluationsAggs } from './get_stats'; diff --git a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_grouped_findings_evaluation.ts b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_grouped_findings_evaluation.ts index 74b239f14d242..ec915d0d62330 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_grouped_findings_evaluation.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_grouped_findings_evaluation.ts @@ -14,7 +14,7 @@ import type { import type { Logger } from '@kbn/core/server'; import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types'; import { calculatePostureScore } from '../../../common/utils/helpers'; -import type { ComplianceDashboardData } from '../../../common/types'; +import type { ComplianceDashboardData } from '../../../common/types_old'; import { KeyDocCount } from './compliance_dashboard'; export interface FailedFindingsQueryResult { diff --git a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_stats.ts b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_stats.ts index f639f8a7e1421..e02b355f27e18 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_stats.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_stats.ts @@ -10,7 +10,7 @@ import type { QueryDslQueryContainer, SearchRequest } from '@elastic/elasticsear import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types'; import type { Logger } from '@kbn/core/server'; import { calculatePostureScore } from '../../../common/utils/helpers'; -import type { ComplianceDashboardData } from '../../../common/types'; +import type { ComplianceDashboardData } from '../../../common/types_old'; export interface FindingsEvaluationsQueryResult { failed_findings: { diff --git a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_trends.ts b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_trends.ts index 00acd14d960fa..150c531f4a1fa 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_trends.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_trends.ts @@ -8,7 +8,7 @@ import { ElasticsearchClient, Logger } from '@kbn/core/server'; import { calculatePostureScore } from '../../../common/utils/helpers'; import { BENCHMARK_SCORE_INDEX_DEFAULT_NS } from '../../../common/constants'; -import type { PosturePolicyTemplate, Stats } from '../../../common/types'; +import type { PosturePolicyTemplate, Stats } from '../../../common/types_old'; import { toBenchmarkDocFieldKey } from '../../lib/mapping_field_util'; import { CSPM_FINDINGS_STATS_INTERVAL } from '../../tasks/findings_stats_task'; diff --git a/x-pack/plugins/cloud_security_posture/server/routes/csp_rule_template/get_csp_rule_template.ts b/x-pack/plugins/cloud_security_posture/server/routes/csp_rule_template/get_csp_rule_template.ts deleted file mode 100644 index 0b249e9f3656e..0000000000000 --- a/x-pack/plugins/cloud_security_posture/server/routes/csp_rule_template/get_csp_rule_template.ts +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { NewPackagePolicy } from '@kbn/fleet-plugin/common'; -import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server'; -import { transformError } from '@kbn/securitysolution-es-utils'; -import semverCompare from 'semver/functions/compare'; -import semverValid from 'semver/functions/valid'; -import { GetCspRuleTemplateRequest, GetCspRuleTemplateResponse } from '../../../common/types'; -import { CspRuleTemplate } from '../../../common/schemas'; -import { findCspRuleTemplateRequest } from '../../../common/schemas/csp_rule_template_api/get_csp_rule_template'; -import { getBenchmarkFromPackagePolicy, getBenchmarkFilter } from '../../../common/utils/helpers'; - -import { - CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE, - FIND_CSP_RULE_TEMPLATE_ROUTE_PATH, -} from '../../../common/constants'; -import { CspRouter } from '../../types'; -import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../benchmarks/benchmarks'; - -export const getSortedCspRulesTemplates = (cspRulesTemplates: CspRuleTemplate[]) => { - return cspRulesTemplates.slice().sort((a, b) => { - const ruleNumberA = a?.metadata?.benchmark?.rule_number; - const ruleNumberB = b?.metadata?.benchmark?.rule_number; - - const versionA = semverValid(ruleNumberA); - const versionB = semverValid(ruleNumberB); - - if (versionA !== null && versionB !== null) { - return semverCompare(versionA, versionB); - } else { - return String(ruleNumberA).localeCompare(String(ruleNumberB)); - } - }); -}; - -const getBenchmarkIdFromPackagePolicyId = async ( - soClient: SavedObjectsClientContract, - packagePolicyId: string -): Promise => { - const res = await soClient.get( - PACKAGE_POLICY_SAVED_OBJECT_TYPE, - packagePolicyId - ); - return getBenchmarkFromPackagePolicy(res.attributes.inputs); -}; - -const findCspRuleTemplateHandler = async ( - soClient: SavedObjectsClientContract, - options: GetCspRuleTemplateRequest -): Promise => { - if ( - (!options.packagePolicyId && !options.benchmarkId) || - (options.packagePolicyId && options.benchmarkId) - ) { - throw new Error('Please provide either benchmarkId or packagePolicyId, but not both'); - } - - const benchmarkId = options.benchmarkId - ? options.benchmarkId - : await getBenchmarkIdFromPackagePolicyId(soClient, options.packagePolicyId!); - - const cspRulesTemplatesSo = await soClient.find({ - type: CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE, - searchFields: options.searchFields, - search: options.search ? `"${options.search}"*` : '', - page: options.page, - perPage: options.perPage, - sortField: options.sortField, - fields: options?.fields, - filter: getBenchmarkFilter(benchmarkId, options.section), - }); - - const cspRulesTemplates = cspRulesTemplatesSo.saved_objects.map( - (cspRuleTemplate) => cspRuleTemplate.attributes - ); - - // Semantic version sorting using semver for valid versions and custom comparison for invalid versions - const sortedCspRulesTemplates = getSortedCspRulesTemplates(cspRulesTemplates); - - return { - items: sortedCspRulesTemplates, - total: cspRulesTemplatesSo.total, - page: options.page, - perPage: options.perPage, - }; -}; - -export const defineFindCspRuleTemplateRoute = (router: CspRouter) => - router.versioned - .get({ - access: 'internal', - path: FIND_CSP_RULE_TEMPLATE_ROUTE_PATH, - }) - .addVersion( - { - version: '1', - validate: { - request: { - query: findCspRuleTemplateRequest, - }, - }, - }, - async (context, request, response) => { - if (!(await context.fleet).authz.fleet.all) { - return response.forbidden(); - } - - const requestBody: GetCspRuleTemplateRequest = request.query; - const cspContext = await context.csp; - - try { - const cspRulesTemplates: GetCspRuleTemplateResponse = await findCspRuleTemplateHandler( - cspContext.soClient, - requestBody - ); - return response.ok({ body: cspRulesTemplates }); - } catch (err) { - const error = transformError(err); - cspContext.logger.error(`Failed to fetch csp rules templates ${err}`); - return response.customError({ - body: { message: error.message }, - statusCode: error.statusCode, - }); - } - } - ); diff --git a/x-pack/plugins/cloud_security_posture/server/routes/setup_routes.ts b/x-pack/plugins/cloud_security_posture/server/routes/setup_routes.ts index a0e33bce73d3f..49022dd1f5fe6 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/setup_routes.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/setup_routes.ts @@ -17,7 +17,7 @@ import { defineGetComplianceDashboardRoute } from './compliance_dashboard/compli import { defineGetVulnerabilitiesDashboardRoute } from './vulnerabilities_dashboard/vulnerabilities_dashboard'; import { defineGetBenchmarksRoute } from './benchmarks/benchmarks'; import { defineGetCspStatusRoute } from './status/status'; -import { defineFindCspRuleTemplateRoute } from './csp_rule_template/get_csp_rule_template'; +import { defineFindCspBenchmarkRuleRoute } from './benchmark_rules/find/find'; import { defineGetDetectionEngineAlertsStatus } from './detection_engine/get_detection_engine_alerts_count_by_rule_tags'; /** @@ -38,7 +38,7 @@ export async function setupRoutes({ defineGetVulnerabilitiesDashboardRoute(router); defineGetBenchmarksRoute(router); defineGetCspStatusRoute(router); - defineFindCspRuleTemplateRoute(router); + defineFindCspBenchmarkRuleRoute(router); defineGetDetectionEngineAlertsStatus(router); core.http.registerRouteHandlerContext( diff --git a/x-pack/plugins/cloud_security_posture/server/routes/status/status.ts b/x-pack/plugins/cloud_security_posture/server/routes/status/status.ts index ed3bcd99746fc..df2fc0d36fc63 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/status/status.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/status/status.ts @@ -44,7 +44,7 @@ import type { CspStatusCode, IndexStatus, PostureTypes, -} from '../../../common/types'; +} from '../../../common/types_old'; import { getAgentStatusesByAgentPolicies, getCspAgentPolicies, diff --git a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_patchable_vulnerabilities.ts b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_patchable_vulnerabilities.ts index 6eec795e2dad6..3f4db5e90a526 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_patchable_vulnerabilities.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_patchable_vulnerabilities.ts @@ -7,7 +7,7 @@ import { SearchRequest } from '@elastic/elasticsearch/lib/api/types'; import { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; -import { AggFieldBucket, PatchableVulnerabilityStat } from '../../../common/types'; +import { AggFieldBucket, PatchableVulnerabilityStat } from '../../../common/types_old'; import { LATEST_VULNERABILITIES_INDEX_DEFAULT_NS } from '../../../common/constants'; interface VulnerabilityBucket { diff --git a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_vulnerabilities.ts b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_vulnerabilities.ts index cd8c5b64f532d..8efb0fd33c61e 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_vulnerabilities.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_vulnerabilities.ts @@ -7,7 +7,7 @@ import { SearchRequest } from '@elastic/elasticsearch/lib/api/types'; import { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; -import { VulnerabilityStat } from '../../../common/types'; +import { VulnerabilityStat } from '../../../common/types_old'; import { LATEST_VULNERABILITIES_INDEX_DEFAULT_NS } from '../../../common/constants'; interface VulnerabilityBucket { diff --git a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_vulnerable_resources.ts b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_vulnerable_resources.ts index 0a41a11aeedea..50f54f69e0a64 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_vulnerable_resources.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_top_vulnerable_resources.ts @@ -7,7 +7,7 @@ import { SearchRequest } from '@elastic/elasticsearch/lib/api/types'; import { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; -import { AggFieldBucket, VulnerableResourceStat } from '../../../common/types'; +import { AggFieldBucket, VulnerableResourceStat } from '../../../common/types_old'; import { LATEST_VULNERABILITIES_INDEX_DEFAULT_NS } from '../../../common/constants'; interface ResourceBucket { diff --git a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_vulnerabilities_trend.ts b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_vulnerabilities_trend.ts index a3e335734e74c..5a619b125deab 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_vulnerabilities_trend.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/get_vulnerabilities_trend.ts @@ -7,7 +7,7 @@ import { ElasticsearchClient } from '@kbn/core/server'; import { BENCHMARK_SCORE_INDEX_DEFAULT_NS } from '../../../common/constants'; -import { VulnStatsTrend } from '../../../common/types'; +import { VulnStatsTrend } from '../../../common/types_old'; interface LastDocBucket { key_as_string: string; diff --git a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/vulnerabilities_dashboard.ts b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/vulnerabilities_dashboard.ts index 7f676226559aa..f7de7f1be4b65 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/vulnerabilities_dashboard.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/vulnerabilities_dashboard/vulnerabilities_dashboard.ts @@ -7,7 +7,7 @@ import { transformError } from '@kbn/securitysolution-es-utils'; import { getVulnerabilitiesTrends } from './get_vulnerabilities_trend'; -import type { CnvmDashboardData } from '../../../common/types'; +import type { CnvmDashboardData } from '../../../common/types_old'; import { VULNERABILITIES_DASHBOARD_ROUTE_PATH } from '../../../common/constants'; import { CspRouter } from '../../types'; import { getVulnerabilitiesStatistics } from './get_vulnerabilities_statistics'; diff --git a/x-pack/plugins/cloud_security_posture/server/saved_objects/csp_benchmark_rule.ts b/x-pack/plugins/cloud_security_posture/server/saved_objects/csp_benchmark_rule.ts new file mode 100644 index 0000000000000..ebf90aa500097 --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/server/saved_objects/csp_benchmark_rule.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; +import { SavedObjectsType } from '@kbn/core/server'; +import { rulesV1, rulesV2, rulesV3 } from '../../common/types'; +import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../common/constants'; +import { cspBenchmarkRuleMigrations } from './migrations'; +import { cspBenchmarkRuleSavedObjectMapping } from './mappings'; + +export const cspBenchmarkRule: SavedObjectsType = { + name: CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE, + indexPattern: SECURITY_SOLUTION_SAVED_OBJECT_INDEX, + hidden: false, + namespaceType: 'agnostic', + management: { + importableAndExportable: true, + visibleInManagement: true, + }, + schemas: { + '8.3.0': rulesV1.cspBenchmarkRuleSchema, + '8.4.0': rulesV2.cspBenchmarkRuleSchema, + '8.7.0': rulesV3.cspBenchmarkRuleSchema, + }, + migrations: cspBenchmarkRuleMigrations, + mappings: cspBenchmarkRuleSavedObjectMapping, +}; diff --git a/x-pack/plugins/cloud_security_posture/server/saved_objects/mappings.ts b/x-pack/plugins/cloud_security_posture/server/saved_objects/mappings.ts index f4befec2e4811..f672d271c8b5f 100644 --- a/x-pack/plugins/cloud_security_posture/server/saved_objects/mappings.ts +++ b/x-pack/plugins/cloud_security_posture/server/saved_objects/mappings.ts @@ -7,7 +7,7 @@ import { SavedObjectsTypeMappingDefinition } from '@kbn/core/server'; -export const cspRuleTemplateSavedObjectMapping: SavedObjectsTypeMappingDefinition = { +export const cspBenchmarkRuleSavedObjectMapping: SavedObjectsTypeMappingDefinition = { dynamic: false, properties: { metadata: { diff --git a/x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/csp_rule_template.ts b/x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/csp_benchmark_rule.ts similarity index 68% rename from x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/csp_rule_template.ts rename to x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/csp_benchmark_rule.ts index f6f59b21b4a68..e440342d2083d 100644 --- a/x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/csp_rule_template.ts +++ b/x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/csp_benchmark_rule.ts @@ -10,16 +10,12 @@ import { SavedObjectUnsanitizedDoc, SavedObjectMigrationContext, } from '@kbn/core/server'; -import { - CspRuleTemplateV830, - CspRuleTemplateV840, - CspRuleTemplateV870, -} from '../../../common/schemas/csp_rule_template'; +import { rulesV1, rulesV2, rulesV3 } from '../../../common/types'; -function migrateCspRuleTemplatesToV840( - doc: SavedObjectUnsanitizedDoc, +function migrateCspBenchmarkRuleToV840( + doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext -): SavedObjectUnsanitizedDoc { +): SavedObjectUnsanitizedDoc { const { enabled, muted, benchmark, ...metadata } = doc.attributes; return { ...doc, @@ -37,10 +33,10 @@ function migrateCspRuleTemplatesToV840( }; } -function migrateCspRuleTemplatesToV870( - doc: SavedObjectUnsanitizedDoc, +function migrateCspBenchmarkRuleToV870( + doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext -): SavedObjectUnsanitizedDoc { +): SavedObjectUnsanitizedDoc { // Keeps only metadata, deprecated state const { muted, enabled, ...attributes } = doc.attributes; @@ -59,7 +55,7 @@ function migrateCspRuleTemplatesToV870( }; } -export const cspRuleTemplateMigrations: SavedObjectMigrationMap = { - '8.4.0': migrateCspRuleTemplatesToV840, - '8.7.0': migrateCspRuleTemplatesToV870, +export const cspBenchmarkRuleMigrations: SavedObjectMigrationMap = { + '8.4.0': migrateCspBenchmarkRuleToV840, + '8.7.0': migrateCspBenchmarkRuleToV870, }; diff --git a/x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/index.ts b/x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/index.ts index 991b7469a9129..595a9566f9b77 100644 --- a/x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/index.ts +++ b/x-pack/plugins/cloud_security_posture/server/saved_objects/migrations/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export * from './csp_rule_template'; +export * from './csp_benchmark_rule'; diff --git a/x-pack/plugins/cloud_security_posture/server/saved_objects/saved_objects.ts b/x-pack/plugins/cloud_security_posture/server/saved_objects/saved_objects.ts index e218808caa420..eed21b5b91916 100644 --- a/x-pack/plugins/cloud_security_posture/server/saved_objects/saved_objects.ts +++ b/x-pack/plugins/cloud_security_posture/server/saved_objects/saved_objects.ts @@ -7,20 +7,17 @@ import { SavedObjectsServiceSetup } from '@kbn/core/server'; import { SECURITY_SOLUTION_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; -import { cspRuleTemplateSavedObjectMapping } from './mappings'; -import { cspRuleTemplateMigrations } from './migrations'; -import { - cspRuleTemplateSchemaV830, - cspRuleTemplateSchemaV840, - cspRuleTemplateSchemaV870, - CspRuleTemplate, -} from '../../common/schemas'; +import { rulesV1, rulesV2, rulesV3 } from '../../common/types'; +import { cspBenchmarkRuleSavedObjectMapping } from './mappings'; +import { cspBenchmarkRuleMigrations } from './migrations'; -import { CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE } from '../../common/constants'; +import { CspBenchmarkRule } from '../../common/types/latest'; + +import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../common/constants'; export function setupSavedObjects(savedObjects: SavedObjectsServiceSetup) { - savedObjects.registerType({ - name: CSP_RULE_TEMPLATE_SAVED_OBJECT_TYPE, + savedObjects.registerType({ + name: CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE, indexPattern: SECURITY_SOLUTION_SAVED_OBJECT_INDEX, hidden: false, namespaceType: 'agnostic', @@ -29,11 +26,11 @@ export function setupSavedObjects(savedObjects: SavedObjectsServiceSetup) { visibleInManagement: true, }, schemas: { - '8.3.0': cspRuleTemplateSchemaV830, - '8.4.0': cspRuleTemplateSchemaV840, - '8.7.0': cspRuleTemplateSchemaV870, + '8.3.0': rulesV1.cspBenchmarkRuleSchema, + '8.4.0': rulesV2.cspBenchmarkRuleSchema, + '8.7.0': rulesV3.cspBenchmarkRuleSchema, }, - migrations: cspRuleTemplateMigrations, - mappings: cspRuleTemplateSavedObjectMapping, + migrations: cspBenchmarkRuleMigrations, + mappings: cspBenchmarkRuleSavedObjectMapping, }); } diff --git a/x-pack/plugins/cloud_security_posture/server/types.ts b/x-pack/plugins/cloud_security_posture/server/types.ts index 1b3c4fd840347..3c84de12decf6 100644 --- a/x-pack/plugins/cloud_security_posture/server/types.ts +++ b/x-pack/plugins/cloud_security_posture/server/types.ts @@ -34,7 +34,7 @@ import type { import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server'; import type { FleetStartContract, FleetRequestHandlerContext } from '@kbn/fleet-plugin/server'; import { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/server'; -import { CspStatusCode, IndexDetails } from '../common/types'; +import { CspStatusCode, IndexDetails } from '../common/types_old'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface CspServerPluginSetup {} diff --git a/x-pack/plugins/cloud_security_posture/tsconfig.json b/x-pack/plugins/cloud_security_posture/tsconfig.json index 48fc1a30594f5..ad1a97748967f 100755 --- a/x-pack/plugins/cloud_security_posture/tsconfig.json +++ b/x-pack/plugins/cloud_security_posture/tsconfig.json @@ -60,7 +60,7 @@ "@kbn/core-http-server-mocks", "@kbn/field-formats-plugin", "@kbn/data-view-field-editor-plugin", - "@kbn/securitysolution-grouping" + "@kbn/securitysolution-grouping", ], "exclude": ["target/**/*"] } diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/benchmark.ts b/x-pack/test/api_integration/apis/cloud_security_posture/benchmark.ts index f8735da12c9e4..ccaa3940258ec 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/benchmark.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/benchmark.ts @@ -5,7 +5,7 @@ * 2.0. */ import expect from '@kbn/expect'; -import type { GetBenchmarkResponse } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { GetBenchmarkResponse } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; import { FtrProviderContext } from '../../ftr_provider_context'; import { createPackagePolicy } from './helper'; diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/get_csp_rule_template.ts b/x-pack/test/api_integration/apis/cloud_security_posture/find_csp_benchmark_rule.ts similarity index 90% rename from x-pack/test/api_integration/apis/cloud_security_posture/get_csp_rule_template.ts rename to x-pack/test/api_integration/apis/cloud_security_posture/find_csp_benchmark_rule.ts index 485e36d5ff67e..f3b02be244462 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/get_csp_rule_template.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/find_csp_benchmark_rule.ts @@ -6,8 +6,10 @@ */ import expect from '@kbn/expect'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; -import type { GetCspRuleTemplateResponse } from '@kbn/cloud-security-posture-plugin/common/types'; -import { CspRuleTemplate } from '@kbn/cloud-security-posture-plugin/common/schemas'; +import type { + CspBenchmarkRule, + FindCspBenchmarkRuleResponse, +} from '@kbn/cloud-security-posture-plugin/common/types/latest'; import { FtrProviderContext } from '../../ftr_provider_context'; import { createPackagePolicy } from './helper'; @@ -118,7 +120,7 @@ export default function ({ getService }: FtrProviderContext) { 'kspm' ); - const { body }: { body: GetCspRuleTemplateResponse } = await supertest + const { body }: { body: FindCspBenchmarkRuleResponse } = await supertest .get(`/internal/cloud_security_posture/rules/_find`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set('kbn-xsrf', 'xxxx') @@ -130,7 +132,7 @@ export default function ({ getService }: FtrProviderContext) { expect(body.items.length).greaterThan(0); const allRulesHaveCorrectBenchmarkId = body.items.every( - (rule: CspRuleTemplate) => rule.metadata.benchmark.id === 'cis_k8s' + (rule: CspBenchmarkRule) => rule.metadata.benchmark.id === 'cis_k8s' ); expect(allRulesHaveCorrectBenchmarkId).to.eql( @@ -149,7 +151,7 @@ export default function ({ getService }: FtrProviderContext) { 'kspm' ); - const { body }: { body: GetCspRuleTemplateResponse } = await supertest + const { body }: { body: FindCspBenchmarkRuleResponse } = await supertest .get(`/internal/cloud_security_posture/rules/_find`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set('kbn-xsrf', 'xxxx') @@ -162,7 +164,7 @@ export default function ({ getService }: FtrProviderContext) { expect(body.items.length).greaterThan(0); const allowedFields = ['name', 'section', 'id']; - const fieldsMatched = body.items.every((rule: CspRuleTemplate) => { + const fieldsMatched = body.items.every((rule: CspBenchmarkRule) => { const keys = Object.keys(rule.metadata); return ( keys.length === allowedFields.length && keys.every((key) => allowedFields.includes(key)) @@ -182,7 +184,7 @@ export default function ({ getService }: FtrProviderContext) { 'kspm' ); - const { body }: { body: GetCspRuleTemplateResponse } = await supertest + const { body }: { body: FindCspBenchmarkRuleResponse } = await supertest .get(`/internal/cloud_security_posture/rules/_find`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set('kbn-xsrf', 'xxxx') @@ -196,7 +198,7 @@ export default function ({ getService }: FtrProviderContext) { expect(body.items.length).greaterThan(0); // check if the items are sorted by metadata.section field - const sections = body.items.map((rule: CspRuleTemplate) => rule.metadata.section); + const sections = body.items.map((rule: CspBenchmarkRule) => rule.metadata.section); const isSorted = sections.every( (section, index) => index === 0 || section >= sections[index - 1] ); @@ -216,7 +218,7 @@ export default function ({ getService }: FtrProviderContext) { 'kspm' ); - const { body }: { body: GetCspRuleTemplateResponse } = await supertest + const { body }: { body: FindCspBenchmarkRuleResponse } = await supertest .get(`/internal/cloud_security_posture/rules/_find`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set('kbn-xsrf', 'xxxx') diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts b/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts index 434d3fd308974..de9fdfe9952ea 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts @@ -9,7 +9,7 @@ import type { SuperTest, Test } from 'supertest'; import { Client } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; -import type { IndexDetails } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { IndexDetails } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { SecurityService } from '../../../../../test/common/services/security/security'; export const deleteIndex = (es: Client, indexToBeDeleted: string[]) => { diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/index.ts b/x-pack/test/api_integration/apis/cloud_security_posture/index.ts index 9ba1111514a8b..c1a64ff01397e 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/index.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/index.ts @@ -17,7 +17,7 @@ export default function ({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./status/status_unprivileged')); loadTestFile(require.resolve('./status/status_indexing')); loadTestFile(require.resolve('./benchmark')); - loadTestFile(require.resolve('./get_csp_rule_template')); + loadTestFile(require.resolve('./find_csp_benchmark_rule')); // Place your tests files under this directory and add the following here: // loadTestFile(require.resolve('./your test name')); diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_index_timeout.ts b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_index_timeout.ts index 46cd700c7964c..3eda0f6a7b01a 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_index_timeout.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_index_timeout.ts @@ -5,7 +5,7 @@ * 2.0. */ import expect from '@kbn/expect'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; import { FINDINGS_INDEX_DEFAULT_NS, diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_indexed.ts b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_indexed.ts index 0ba63bd6d436e..6ba3fbe5c31ef 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_indexed.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_indexed.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { FINDINGS_INDEX_DEFAULT_NS, LATEST_FINDINGS_INDEX_DEFAULT_NS, diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_indexing.ts b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_indexing.ts index 216f5aee17627..f55f5533718ed 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_indexing.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_indexing.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { FINDINGS_INDEX_DEFAULT_NS, LATEST_FINDINGS_INDEX_DEFAULT_NS, diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_not_deployed_not_installed.ts b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_not_deployed_not_installed.ts index c991311922758..f67e2d5a0814b 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_not_deployed_not_installed.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_not_deployed_not_installed.ts @@ -5,7 +5,7 @@ * 2.0. */ import expect from '@kbn/expect'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; import { FtrProviderContext } from '../../../ftr_provider_context'; import { createPackagePolicy } from '../helper'; diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_unprivileged.ts b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_unprivileged.ts index 06f80adf46034..e80e80c322568 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_unprivileged.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_unprivileged.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { BENCHMARK_SCORE_INDEX_DEFAULT_NS, LATEST_FINDINGS_INDEX_DEFAULT_NS, diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_waiting_for_results.ts b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_waiting_for_results.ts index dce7e655c0e67..a148f160bfd81 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/status/status_waiting_for_results.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/status/status_waiting_for_results.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { setupFleetAndAgents } from '../../../../fleet_api_integration/apis/agents/services'; import { generateAgent } from '../../../../fleet_api_integration/helpers'; import { FtrProviderContext } from '../../../ftr_provider_context'; diff --git a/x-pack/test/cloud_security_posture_api/routes/stats.ts b/x-pack/test/cloud_security_posture_api/routes/stats.ts index 92dac0d6b0277..f558a0f6e7137 100644 --- a/x-pack/test/cloud_security_posture_api/routes/stats.ts +++ b/x-pack/test/cloud_security_posture_api/routes/stats.ts @@ -15,7 +15,7 @@ import { ComplianceDashboardData, ComplianceDashboardDataV2, PostureTrend, -} from '@kbn/cloud-security-posture-plugin/common/types'; +} from '@kbn/cloud-security-posture-plugin/common/types_old'; import expect from '@kbn/expect'; import { FtrProviderContext } from '../ftr_provider_context'; import { diff --git a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/benchmark.ts b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/benchmark.ts index 53802db8caf3d..f67febd8e4a13 100644 --- a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/benchmark.ts +++ b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/benchmark.ts @@ -5,7 +5,7 @@ * 2.0. */ import expect from '@kbn/expect'; -import type { GetBenchmarkResponse } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { GetBenchmarkResponse } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST, diff --git a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/get_csp_rule_template.ts b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/find_csp_benchmark_rule.ts similarity index 91% rename from x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/get_csp_rule_template.ts rename to x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/find_csp_benchmark_rule.ts index 19208865deb5c..8209e9965a9a2 100644 --- a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/get_csp_rule_template.ts +++ b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/find_csp_benchmark_rule.ts @@ -9,8 +9,11 @@ import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST, } from '@kbn/core-http-common'; -import type { GetCspRuleTemplateResponse } from '@kbn/cloud-security-posture-plugin/common/types'; -import { CspRuleTemplate } from '@kbn/cloud-security-posture-plugin/common/schemas'; +import type { + CspBenchmarkRule, + FindCspBenchmarkRuleResponse, +} from '@kbn/cloud-security-posture-plugin/common/types/latest'; + import { FtrProviderContext } from '../../../ftr_provider_context'; import { createPackagePolicy } from '../../../../../test/api_integration/apis/cloud_security_posture/helper'; // eslint-disable-line @kbn/imports/no_boundary_crossing @@ -19,6 +22,7 @@ export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); + // find csp benchmark rule tests describe('GET internal/cloud_security_posture/rules/_find', function () { // security_exception: action [indices:admin/create] is unauthorized for user [elastic] with effective roles [superuser] on restricted indices [.fleet-actions-7], this action is granted by the index privileges [create_index,manage,all] this.tags(['failsOnMKI']); @@ -126,7 +130,7 @@ export default function ({ getService }: FtrProviderContext) { 'kspm' ); - const { body }: { body: GetCspRuleTemplateResponse } = await supertest + const { body }: { body: FindCspBenchmarkRuleResponse } = await supertest .get(`/internal/cloud_security_posture/rules/_find`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'xxx') @@ -139,7 +143,7 @@ export default function ({ getService }: FtrProviderContext) { expect(body.items.length).greaterThan(0); const allRulesHaveCorrectBenchmarkId = body.items.every( - (rule: CspRuleTemplate) => rule.metadata.benchmark.id === 'cis_k8s' + (rule: CspBenchmarkRule) => rule.metadata.benchmark.id === 'cis_k8s' ); expect(allRulesHaveCorrectBenchmarkId).to.eql( @@ -158,7 +162,7 @@ export default function ({ getService }: FtrProviderContext) { 'kspm' ); - const { body }: { body: GetCspRuleTemplateResponse } = await supertest + const { body }: { body: FindCspBenchmarkRuleResponse } = await supertest .get(`/internal/cloud_security_posture/rules/_find`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'xxx') @@ -172,7 +176,7 @@ export default function ({ getService }: FtrProviderContext) { expect(body.items.length).greaterThan(0); const allowedFields = ['name', 'section', 'id']; - const fieldsMatched = body.items.every((rule: CspRuleTemplate) => { + const fieldsMatched = body.items.every((rule: CspBenchmarkRule) => { const keys = Object.keys(rule.metadata); return ( keys.length === allowedFields.length && keys.every((key) => allowedFields.includes(key)) @@ -192,7 +196,7 @@ export default function ({ getService }: FtrProviderContext) { 'kspm' ); - const { body }: { body: GetCspRuleTemplateResponse } = await supertest + const { body }: { body: FindCspBenchmarkRuleResponse } = await supertest .get(`/internal/cloud_security_posture/rules/_find`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'xxx') @@ -207,7 +211,7 @@ export default function ({ getService }: FtrProviderContext) { expect(body.items.length).greaterThan(0); // check if the items are sorted by metadata.section field - const sections = body.items.map((rule: CspRuleTemplate) => rule.metadata.section); + const sections = body.items.map((rule: CspBenchmarkRule) => rule.metadata.section); const isSorted = sections.every( (section, index) => index === 0 || section >= sections[index - 1] ); @@ -227,7 +231,7 @@ export default function ({ getService }: FtrProviderContext) { 'kspm' ); - const { body }: { body: GetCspRuleTemplateResponse } = await supertest + const { body }: { body: FindCspBenchmarkRuleResponse } = await supertest .get(`/internal/cloud_security_posture/rules/_find`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .set('kbn-xsrf', 'xxxx') diff --git a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/index.ts b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/index.ts index 2e0281d1ab43f..9a4a40ab4add9 100644 --- a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/index.ts +++ b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/index.ts @@ -14,7 +14,7 @@ export default function ({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./status/status_indexed')); loadTestFile(require.resolve('./status/status_indexing')); loadTestFile(require.resolve('./benchmark')); - loadTestFile(require.resolve('./get_csp_rule_template')); + loadTestFile(require.resolve('./find_csp_benchmark_rule')); loadTestFile(require.resolve('./telemetry')); // TODO: migrate status_unprivileged tests from stateful, if it feasible in serverless with the new security model diff --git a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_indexed.ts b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_indexed.ts index ace5eef6a5499..ec3216971ec35 100644 --- a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_indexed.ts +++ b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_indexed.ts @@ -9,7 +9,7 @@ import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST, } from '@kbn/core-http-common'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { FINDINGS_INDEX_DEFAULT_NS, LATEST_FINDINGS_INDEX_DEFAULT_NS, diff --git a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_indexing.ts b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_indexing.ts index 316fb54f829c6..17e1e6458edaa 100644 --- a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_indexing.ts +++ b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_indexing.ts @@ -9,7 +9,7 @@ import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST, } from '@kbn/core-http-common'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { FINDINGS_INDEX_DEFAULT_NS, LATEST_FINDINGS_INDEX_DEFAULT_NS, diff --git a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_not_deployed_not_installed.ts b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_not_deployed_not_installed.ts index ac516bc68434c..9dc25ca4a1133 100644 --- a/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_not_deployed_not_installed.ts +++ b/x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/status/status_not_deployed_not_installed.ts @@ -5,7 +5,7 @@ * 2.0. */ import expect from '@kbn/expect'; -import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-plugin/common/types_old'; import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST,