From f97c94062fc5fc06faaf5d784701b0f84fb08e59 Mon Sep 17 00:00:00 2001 From: animehart Date: Tue, 20 Aug 2024 15:31:14 -0700 Subject: [PATCH 01/17] preliminary adding types to csp and csp-common packages --- .../constants.ts | 20 ++++ .../index.ts | 14 +++ .../schema/csp_finding.ts | 113 ++++++++++++++++++ .../tsconfig.json | 23 ++++ .../types.ts | 43 +++++++ .../types/latest.ts | 18 +++ .../kbn-cloud-security-posture/index.ts | 17 +++ .../kbn-cloud-security-posture/tsconfig.json | 38 ++++++ .../kbn-cloud-security-posture/type.ts | 47 ++++++++ 9 files changed, 333 insertions(+) create mode 100644 x-pack/packages/kbn-cloud-security-posture-common/constants.ts create mode 100644 x-pack/packages/kbn-cloud-security-posture-common/index.ts create mode 100644 x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts create mode 100644 x-pack/packages/kbn-cloud-security-posture-common/tsconfig.json create mode 100644 x-pack/packages/kbn-cloud-security-posture-common/types.ts create mode 100644 x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts create mode 100644 x-pack/packages/kbn-cloud-security-posture/index.ts create mode 100644 x-pack/packages/kbn-cloud-security-posture/tsconfig.json create mode 100644 x-pack/packages/kbn-cloud-security-posture/type.ts diff --git a/x-pack/packages/kbn-cloud-security-posture-common/constants.ts b/x-pack/packages/kbn-cloud-security-posture-common/constants.ts new file mode 100644 index 00000000000000..935e747b20fa82 --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture-common/constants.ts @@ -0,0 +1,20 @@ +/* + * 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 const KSPM_POLICY_TEMPLATE = 'kspm'; +export const CSPM_POLICY_TEMPLATE = 'cspm'; +export const CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN = + 'logs-cloud_security_posture.findings_latest-default'; +export const CDR_LATEST_THIRD_PARTY_MISCONFIGURATIONS_INDEX_PATTERN = + 'logs-*_latest_misconfigurations_cdr'; +export const CDR_MISCONFIGURATIONS_INDEX_PATTERN = `${CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN},${CDR_LATEST_THIRD_PARTY_MISCONFIGURATIONS_INDEX_PATTERN}`; +export const LATEST_FINDINGS_RETENTION_POLICY = '26h'; +export const MAX_FINDINGS_TO_LOAD = 500; +export const CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH = + '/internal/cloud_security_posture/rules/_get_states'; +export const CSP_GET_BENCHMARK_RULES_STATE_API_CURRENT_VERSION = '1'; +export const STATUS_ROUTE_PATH = '/internal/cloud_security_posture/status'; +export const STATUS_API_CURRENT_VERSION = '1'; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/index.ts b/x-pack/packages/kbn-cloud-security-posture-common/index.ts new file mode 100644 index 00000000000000..aaa711940d5ddd --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture-common/index.ts @@ -0,0 +1,14 @@ +/* + * 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 './types'; +export * from './constants'; +export * from './schema/csp_finding'; +export type { CspBenchmarkRulesStates } from './types/latest'; +/* TODO: Uncomment this in phase 3*/ +// export { showErrorToast } from './utils/show_error_toast'; +// export { buildMutedRulesFilter } from './utils/helpers'; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts b/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts new file mode 100644 index 00000000000000..a2d5e6d6256564 --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts @@ -0,0 +1,113 @@ +/* + * 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 type { EcsDataStream, EcsEvent } from '@elastic/ecs'; +import { TypeOf, schema } from '@kbn/config-schema'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../constants'; + +export type CspBenchmarkRuleMetadata = TypeOf; + +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 interface CspFinding { + '@timestamp': string; + cluster_id?: string; + orchestrator?: CspFindingOrchestrator; + cloud?: CspFindingCloud; // only available on CSPM findings + result: CspFindingResult; + resource: CspFindingResource; + rule: CspBenchmarkRuleMetadata; + host: CspFindingHost; + event: EcsEvent; + data_stream: EcsDataStream; + agent: CspFindingAgent; + ecs: { + version: string; + }; +} + +interface CspFindingOrchestrator { + cluster?: { + id?: string; + name?: string; + }; +} + +interface CspFindingCloud { + provider: 'aws' | 'azure' | 'gcp'; + account: { + name: string; + id: string; + }; + region?: string; +} + +interface CspFindingResult { + evaluation: 'passed' | 'failed'; + expected?: Record; + evidence: Record; +} + +interface CspFindingResource { + name: string; + sub_type: string; + raw: object; + id: string; + type: string; + [other_keys: string]: unknown; +} + +interface CspFindingHost { + id: string; + containerized: boolean; + ip: string[]; + mac: string[]; + name: string; + hostname: string; + architecture: string; + os: { + kernel: string; + codename: string; + type: string; + platform: string; + version: string; + family: string; + name: string; + }; + [other_keys: string]: unknown; +} + +interface CspFindingAgent { + version: string; + // ephemeral_id: string; + id: string; + name: string; + type: string; +} diff --git a/x-pack/packages/kbn-cloud-security-posture-common/tsconfig.json b/x-pack/packages/kbn-cloud-security-posture-common/tsconfig.json new file mode 100644 index 00000000000000..f37dfaa93dc7d8 --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture-common/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/config-schema", + "@kbn/data-views-plugin", + "@kbn/core", + "@kbn/i18n", + ] + } \ No newline at end of file diff --git a/x-pack/packages/kbn-cloud-security-posture-common/types.ts b/x-pack/packages/kbn-cloud-security-posture-common/types.ts new file mode 100644 index 00000000000000..1a48a7bb41f2a4 --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture-common/types.ts @@ -0,0 +1,43 @@ +/* + * 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 type CspStatusCode = + | 'indexed' // latest findings index exists and has results + | 'indexing' // index timeout was not surpassed since installation, assumes data is being indexed + | 'unprivileged' // user lacks privileges for the latest findings index + | 'index-timeout' // index timeout was surpassed since installation + | 'not-deployed' // no healthy agents were deployed + | 'not-installed' // number of installed csp integrations is 0; + | 'waiting_for_results'; // have healthy agents but no findings at all, assumes data is being indexed for the 1st time + +export type IndexStatus = + | 'not-empty' // Index contains documents + | 'empty' // Index doesn't contain documents (or doesn't exist) + | 'unprivileged'; // User doesn't have access to query the index + +export interface IndexDetails { + index: string; + status: IndexStatus; +} + +export interface BaseCspSetupBothPolicy { + status: CspStatusCode; + installedPackagePolicies: number; + healthyAgents: number; +} + +export interface BaseCspSetupStatus { + indicesDetails: IndexDetails[]; + latestPackageVersion: string; + cspm: BaseCspSetupBothPolicy; + kspm: BaseCspSetupBothPolicy; + vuln_mgmt: BaseCspSetupBothPolicy; + isPluginInitialized: boolean; + installedPackageVersion?: string | undefined; +} + +export type CspSetupStatus = BaseCspSetupStatus; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts b/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts new file mode 100644 index 00000000000000..63f93ed47734bb --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts @@ -0,0 +1,18 @@ +/* + * 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'; + +export type CspBenchmarkRulesStates = TypeOf; +const ruleStateAttributes = schema.object({ + muted: schema.boolean(), + benchmark_id: schema.string(), + benchmark_version: schema.string(), + rule_number: schema.string(), + rule_id: schema.string(), +}); + +const rulesStates = schema.recordOf(schema.string(), ruleStateAttributes); diff --git a/x-pack/packages/kbn-cloud-security-posture/index.ts b/x-pack/packages/kbn-cloud-security-posture/index.ts new file mode 100644 index 00000000000000..0c3c46e9180774 --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture/index.ts @@ -0,0 +1,17 @@ +/* + * 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 './type'; +/* TODO: Uncomment this in phase 3*/ +// export { useMisconfigurationPreview } from './src/hooks/use_misconfiguration_preview'; +// export { useGetCspBenchmarkRulesStatesApi } from './src/hooks/use_get_benchmark_rules_state_api'; +// export { useCspSetupStatusApi } from './src/hooks/use_csp_setup_status_api'; +// export { +// getAggregationCount, +// getFindingsCountAggQuery, +// isIndexWithDocsAvailable, +// } from './src/utils/utils'; diff --git a/x-pack/packages/kbn-cloud-security-posture/tsconfig.json b/x-pack/packages/kbn-cloud-security-posture/tsconfig.json new file mode 100644 index 00000000000000..1574f9c2b6a2eb --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture/tsconfig.json @@ -0,0 +1,38 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/kibana-react-plugin", + "@kbn/core", + "@kbn/cloud-security-posture-common", + "@kbn/search-types", + "@kbn/licensing-plugin", + "@kbn/data-views-plugin", + "@kbn/unified-search-plugin", + "@kbn/ui-actions-plugin", + "@kbn/field-formats-plugin", + "@kbn/data-view-field-editor-plugin", + "@kbn/data-plugin", + "@kbn/kibana-utils-plugin", + "@kbn/charts-plugin", + "@kbn/discover-plugin", + "@kbn/fleet-plugin", + "@kbn/usage-collection-plugin", + "@kbn/share-plugin", + "@kbn/es-query", + ] + } \ No newline at end of file diff --git a/x-pack/packages/kbn-cloud-security-posture/type.ts b/x-pack/packages/kbn-cloud-security-posture/type.ts new file mode 100644 index 00000000000000..5a5f507effe96b --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture/type.ts @@ -0,0 +1,47 @@ +/* + * 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 type { LicensingPluginStart } from '@kbn/licensing-plugin/public'; +import { DataViewsServicePublic } from '@kbn/data-views-plugin/public'; +import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; +import { UiActionsStart } from '@kbn/ui-actions-plugin/public'; +import { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; +import { IndexPatternFieldEditorStart } from '@kbn/data-view-field-editor-plugin/public'; +import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; +import { ToastsStart } from '@kbn/core/public'; +import { Storage } from '@kbn/kibana-utils-plugin/public'; + +import type { ChartsPluginStart } from '@kbn/charts-plugin/public'; +import type { DiscoverStart } from '@kbn/discover-plugin/public'; +import type { FleetStart } from '@kbn/fleet-plugin/public'; +import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; +import { SharePluginStart } from '@kbn/share-plugin/public'; + +import type { BoolQuery } from '@kbn/es-query'; +export interface FindingsBaseEsQuery { + query?: { + bool: BoolQuery; + }; +} + +export interface CspClientPluginStartDeps { + data: DataPublicPluginStart; + dataViews: DataViewsServicePublic; + dataViewFieldEditor: IndexPatternFieldEditorStart; + unifiedSearch: UnifiedSearchPublicPluginStart; + uiActions: UiActionsStart; + fieldFormats: FieldFormatsStart; + toastNotifications: ToastsStart; + charts: ChartsPluginStart; + discover: DiscoverStart; + fleet: FleetStart; + licensing: LicensingPluginStart; + share: SharePluginStart; + storage: Storage; + + usageCollection?: UsageCollectionStart; +} From 598986821fb6c05ea8cde0eb14dccb6a0a6ed421 Mon Sep 17 00:00:00 2001 From: animehart Date: Tue, 20 Aug 2024 17:05:17 -0700 Subject: [PATCH 02/17] moving types from csp plugin to csp packages + updating import and export statement --- .../index.ts | 1 + .../schema/csp_finding.ts | 31 +------- .../schema/rules.ts | 36 +++++++++ .../types.ts | 1 + .../types/latest.ts | 4 +- .../kbn-cloud-security-posture/type.ts | 6 ++ .../common/constants.ts | 29 ++++--- .../common/schemas/csp_finding.ts | 78 +------------------ .../common/types/rules/v3.ts | 36 ++------- .../common/types/rules/v4.ts | 16 +--- .../common/types_old.ts | 38 +++------ .../public/common/constants.ts | 3 +- .../public/common/types.ts | 9 +-- .../cloud_security_posture/public/types.ts | 48 ++---------- 14 files changed, 93 insertions(+), 243 deletions(-) create mode 100644 x-pack/packages/kbn-cloud-security-posture-common/schema/rules.ts diff --git a/x-pack/packages/kbn-cloud-security-posture-common/index.ts b/x-pack/packages/kbn-cloud-security-posture-common/index.ts index aaa711940d5ddd..658f89de2ffb74 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/index.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/index.ts @@ -8,6 +8,7 @@ export * from './types'; export * from './constants'; export * from './schema/csp_finding'; +export * from './schema/rules'; export type { CspBenchmarkRulesStates } from './types/latest'; /* TODO: Uncomment this in phase 3*/ // export { showErrorToast } from './utils/show_error_toast'; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts b/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts index a2d5e6d6256564..ffd4220475c47a 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts @@ -5,36 +5,7 @@ * 2.0. */ import type { EcsDataStream, EcsEvent } from '@elastic/ecs'; -import { TypeOf, schema } from '@kbn/config-schema'; -import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../constants'; - -export type CspBenchmarkRuleMetadata = TypeOf; - -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(), -}); +import { CspBenchmarkRuleMetadata } from './rules'; export interface CspFinding { '@timestamp': string; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/schema/rules.ts b/x-pack/packages/kbn-cloud-security-posture-common/schema/rules.ts new file mode 100644 index 00000000000000..f7c0771d5a23f1 --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture-common/schema/rules.ts @@ -0,0 +1,36 @@ +/* + * 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 { TypeOf, schema } from '@kbn/config-schema'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../constants'; + +export type CspBenchmarkRuleMetadata = TypeOf; + +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(), +}); diff --git a/x-pack/packages/kbn-cloud-security-posture-common/types.ts b/x-pack/packages/kbn-cloud-security-posture-common/types.ts index 1a48a7bb41f2a4..87429bdc712ba5 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/types.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/types.ts @@ -38,6 +38,7 @@ export interface BaseCspSetupStatus { vuln_mgmt: BaseCspSetupBothPolicy; isPluginInitialized: boolean; installedPackageVersion?: string | undefined; + hasMisconfigurationsFindings?: boolean; } export type CspSetupStatus = BaseCspSetupStatus; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts b/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts index 63f93ed47734bb..613910e8b5682c 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts @@ -7,7 +7,7 @@ import { schema, TypeOf } from '@kbn/config-schema'; export type CspBenchmarkRulesStates = TypeOf; -const ruleStateAttributes = schema.object({ +export const ruleStateAttributes = schema.object({ muted: schema.boolean(), benchmark_id: schema.string(), benchmark_version: schema.string(), @@ -15,4 +15,4 @@ const ruleStateAttributes = schema.object({ rule_id: schema.string(), }); -const rulesStates = schema.recordOf(schema.string(), ruleStateAttributes); +export const rulesStates = schema.recordOf(schema.string(), ruleStateAttributes); diff --git a/x-pack/packages/kbn-cloud-security-posture/type.ts b/x-pack/packages/kbn-cloud-security-posture/type.ts index 5a5f507effe96b..70daabecf67d3b 100644 --- a/x-pack/packages/kbn-cloud-security-posture/type.ts +++ b/x-pack/packages/kbn-cloud-security-posture/type.ts @@ -5,6 +5,7 @@ * 2.0. */ +import type { CloudSetup } from '@kbn/cloud-plugin/public'; import type { LicensingPluginStart } from '@kbn/licensing-plugin/public'; import { DataViewsServicePublic } from '@kbn/data-views-plugin/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; @@ -20,6 +21,7 @@ import type { DiscoverStart } from '@kbn/discover-plugin/public'; import type { FleetStart } from '@kbn/fleet-plugin/public'; import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; import { SharePluginStart } from '@kbn/share-plugin/public'; +import { SpacesPluginStart } from '@kbn/spaces-plugin/public'; import type { BoolQuery } from '@kbn/es-query'; export interface FindingsBaseEsQuery { @@ -29,6 +31,7 @@ export interface FindingsBaseEsQuery { } export interface CspClientPluginStartDeps { + // required data: DataPublicPluginStart; dataViews: DataViewsServicePublic; dataViewFieldEditor: IndexPatternFieldEditorStart; @@ -42,6 +45,9 @@ export interface CspClientPluginStartDeps { licensing: LicensingPluginStart; share: SharePluginStart; storage: Storage; + spaces: SpacesPluginStart; + cloud: CloudSetup; + // optional usageCollection?: UsageCollectionStart; } diff --git a/x-pack/plugins/cloud_security_posture/common/constants.ts b/x-pack/plugins/cloud_security_posture/common/constants.ts index 720251dee5a77a..db7ff20923151a 100644 --- a/x-pack/plugins/cloud_security_posture/common/constants.ts +++ b/x-pack/plugins/cloud_security_posture/common/constants.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { KSPM_POLICY_TEMPLATE, CSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { AwsCredentialsTypeFieldMap, GcpCredentialsTypeFieldMap, @@ -12,9 +13,20 @@ import { VulnSeverity, } from './types_old'; +export { + KSPM_POLICY_TEMPLATE, + CSPM_POLICY_TEMPLATE, + CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN, + CDR_LATEST_THIRD_PARTY_MISCONFIGURATIONS_INDEX_PATTERN, + CDR_MISCONFIGURATIONS_INDEX_PATTERN, + LATEST_FINDINGS_RETENTION_POLICY, + CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH, + CSP_GET_BENCHMARK_RULES_STATE_API_CURRENT_VERSION, + STATUS_ROUTE_PATH, + STATUS_API_CURRENT_VERSION, +} from '@kbn/cloud-security-posture-common'; + export const CLOUD_SECURITY_INTERTAL_PREFIX_ROUTE_PATH = '/internal/cloud_security_posture/'; -export const STATUS_ROUTE_PATH = '/internal/cloud_security_posture/status'; -export const STATUS_API_CURRENT_VERSION = '1'; export const STATS_ROUTE_PATH = '/internal/cloud_security_posture/stats/{policy_template}'; @@ -31,10 +43,6 @@ export const CSP_BENCHMARK_RULES_BULK_ACTION_ROUTE_PATH = '/internal/cloud_security_posture/rules/_bulk_action'; export const CSP_BENCHMARK_RULES_BULK_ACTION_API_CURRENT_VERSION = '1'; -export const CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH = - '/internal/cloud_security_posture/rules/_get_states'; -export const CSP_GET_BENCHMARK_RULES_STATE_API_CURRENT_VERSION = '1'; - export const GET_DETECTION_RULE_ALERTS_STATUS_PATH = '/internal/cloud_security_posture/detection_engine_rules/alerts/_status'; export const DETECTION_RULE_ALERTS_STATUS_API_CURRENT_VERSION = '1'; @@ -45,11 +53,6 @@ export const CLOUD_SECURITY_POSTURE_PACKAGE_NAME = 'cloud_security_posture'; export const CDR_MISCONFIGURATIONS_DATA_VIEW_NAME = 'Latest Cloud Security Misconfigurations'; export const CDR_MISCONFIGURATIONS_DATA_VIEW_ID_PREFIX = 'security_solution_cdr_latest_misconfigurations'; -export const CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN = - 'logs-cloud_security_posture.findings_latest-default'; -export const CDR_LATEST_THIRD_PARTY_MISCONFIGURATIONS_INDEX_PATTERN = - 'logs-*_latest_misconfigurations_cdr'; -export const CDR_MISCONFIGURATIONS_INDEX_PATTERN = `${CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN},${CDR_LATEST_THIRD_PARTY_MISCONFIGURATIONS_INDEX_PATTERN}`; export const CDR_VULNERABILITIES_DATA_VIEW_NAME = 'Latest Cloud Security Vulnerabilities'; export const CDR_VULNERABILITIES_DATA_VIEW_ID_PREFIX = @@ -65,8 +68,6 @@ export const LATEST_FINDINGS_INDEX_TEMPLATE_NAME = 'logs-cloud_security_posture. export const LATEST_FINDINGS_INDEX_DEFAULT_NS = 'logs-cloud_security_posture.findings_latest-default'; -export const LATEST_FINDINGS_RETENTION_POLICY = '26h'; - export const BENCHMARK_SCORE_INDEX_TEMPLATE_NAME = 'logs-cloud_security_posture.scores'; export const BENCHMARK_SCORE_INDEX_PATTERN = 'logs-cloud_security_posture.scores-*'; export const BENCHMARK_SCORE_INDEX_DEFAULT_NS = 'logs-cloud_security_posture.scores-default'; @@ -127,8 +128,6 @@ export const CIS_GCP = 'cis_gcp'; export const CIS_K8S = 'cis_k8s'; export const CIS_EKS = 'cis_eks'; export const CIS_AZURE = 'cis_azure'; -export const KSPM_POLICY_TEMPLATE = 'kspm'; -export const CSPM_POLICY_TEMPLATE = 'cspm'; export const VULN_MGMT_POLICY_TEMPLATE = 'vuln_mgmt'; export const CNVM_POLICY_TEMPLATE = 'cnvm'; export const SUPPORTED_POLICY_TEMPLATES = [ 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 7ac4e79393f016..2789e65a778d46 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 @@ -6,81 +6,5 @@ */ // TODO: this needs to be defined in a versioned schema -import type { EcsDataStream, EcsEvent } from '@elastic/ecs'; -import { CspBenchmarkRuleMetadata } from '../types/latest'; -export interface CspFinding { - '@timestamp': string; - cluster_id?: string; - orchestrator?: CspFindingOrchestrator; - cloud?: CspFindingCloud; // only available on CSPM findings - result: CspFindingResult; - resource: CspFindingResource; - rule: CspBenchmarkRuleMetadata; - host: CspFindingHost; - event: EcsEvent; - data_stream: EcsDataStream; - agent: CspFindingAgent; - ecs: { - version: string; - }; -} - -interface CspFindingOrchestrator { - cluster?: { - id?: string; - name?: string; - }; -} - -interface CspFindingCloud { - provider: 'aws' | 'azure' | 'gcp'; - account: { - name: string; - id: string; - }; - region?: string; -} - -interface CspFindingResult { - evaluation: 'passed' | 'failed'; - expected?: Record; - evidence: Record; -} - -interface CspFindingResource { - name: string; - sub_type: string; - raw: object; - id: string; - type: string; - [other_keys: string]: unknown; -} - -interface CspFindingHost { - id: string; - containerized: boolean; - ip: string[]; - mac: string[]; - name: string; - hostname: string; - architecture: string; - os: { - kernel: string; - codename: string; - type: string; - platform: string; - version: string; - family: string; - name: string; - }; - [other_keys: string]: unknown; -} - -interface CspFindingAgent { - version: string; - // ephemeral_id: string; - id: string; - name: string; - type: string; -} +export type { CspFinding } from '@kbn/cloud-security-posture-common'; diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts index a00bf1a8077e6c..3f443f0fbd2542 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts @@ -6,7 +6,13 @@ */ import { schema, TypeOf } from '@kbn/config-schema'; -import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../constants'; + +import { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common'; + +export type { + CspBenchmarkRuleMetadata, + cspBenchmarkRuleMetadataSchema, +} from '@kbn/cloud-security-posture-common'; export const DEFAULT_BENCHMARK_RULES_PER_PAGE = 25; @@ -14,36 +20,8 @@ export const DEFAULT_BENCHMARK_RULES_PER_PAGE = 25; export type FindCspBenchmarkRuleRequest = TypeOf; -export type CspBenchmarkRuleMetadata = TypeOf; - export type CspBenchmarkRule = TypeOf; -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 const cspBenchmarkRuleSchema = schema.object({ metadata: cspBenchmarkRuleMetadataSchema, }); diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts index 33134eed32e38e..fecd60bd70c993 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts @@ -6,6 +6,8 @@ */ import { schema, TypeOf } from '@kbn/config-schema'; +import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; +import { ruleStateAttributes, rulesStates } from '@kbn/cloud-security-posture-common/types/latest'; import { BenchmarksCisId } from '../latest'; import { DEFAULT_BENCHMARK_RULES_PER_PAGE } from './v3'; export type { @@ -16,6 +18,8 @@ export type { FindCspBenchmarkRuleResponse, } from './v3'; +export type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; + export type FindCspBenchmarkRuleRequest = TypeOf; export type RulesToUpdate = TypeOf; @@ -26,8 +30,6 @@ export type CspBenchmarkRulesBulkActionRequestSchema = TypeOf< export type RuleStateAttributes = TypeOf; -export type CspBenchmarkRulesStates = TypeOf; - export type CspSettings = TypeOf; export const findCspBenchmarkRuleRequestSchema = schema.object({ @@ -143,16 +145,6 @@ export interface CspBenchmarkRulesBulkActionResponse { message: string; } -const ruleStateAttributes = schema.object({ - muted: schema.boolean(), - benchmark_id: schema.string(), - benchmark_version: schema.string(), - rule_number: schema.string(), - rule_id: schema.string(), -}); - -const rulesStates = schema.recordOf(schema.string(), ruleStateAttributes); - export const cspSettingsSchema = schema.object({ rules: rulesStates, }); diff --git a/x-pack/plugins/cloud_security_posture/common/types_old.ts b/x-pack/plugins/cloud_security_posture/common/types_old.ts index 19e18902b7ea1d..30419d1e35090f 100644 --- a/x-pack/plugins/cloud_security_posture/common/types_old.ts +++ b/x-pack/plugins/cloud_security_posture/common/types_old.ts @@ -11,6 +11,15 @@ import { SUPPORTED_CLOUDBEAT_INPUTS, SUPPORTED_POLICY_TEMPLATES } from './consta import { getComplianceDashboardSchema } from './schemas/stats'; import type { CspBenchmarkRuleMetadata } from './types/latest'; +export type { + CspFinding, + IndexStatus, + IndexDetails, + BaseCspSetupBothPolicy, + BaseCspSetupStatus, + CspSetupStatus, +} from '@kbn/cloud-security-posture-common'; + export type AwsCredentialsType = | 'assume_role' | 'direct_access_keys' @@ -109,35 +118,6 @@ export type CspStatusCode = | 'not-installed' // number of installed csp integrations is 0; | 'waiting_for_results'; // have healthy agents but no findings at all, assumes data is being indexed for the 1st time -export type IndexStatus = - | 'not-empty' // Index contains documents - | 'empty' // Index doesn't contain documents (or doesn't exist) - | 'unprivileged'; // User doesn't have access to query the index - -export interface IndexDetails { - index: string; - status: IndexStatus; -} - -export interface BaseCspSetupBothPolicy { - status: CspStatusCode; - installedPackagePolicies: number; - healthyAgents: number; -} - -export interface BaseCspSetupStatus { - indicesDetails: IndexDetails[]; - latestPackageVersion: string; - cspm: BaseCspSetupBothPolicy; - kspm: BaseCspSetupBothPolicy; - vuln_mgmt: BaseCspSetupBothPolicy; - isPluginInitialized: boolean; - installedPackageVersion?: string | undefined; - hasMisconfigurationsFindings?: boolean; -} - -export type CspSetupStatus = BaseCspSetupStatus; - export type BenchmarkId = CspBenchmarkRuleMetadata['benchmark']['id']; export type BenchmarkName = CspBenchmarkRuleMetadata['benchmark']['name']; export type RuleSection = CspBenchmarkRuleMetadata['section']; 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 8054917ba7462a..5c0e6e84d47b94 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/constants.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/constants.ts @@ -29,13 +29,14 @@ import aksLogo from '../assets/icons/cis_aks_logo.svg'; import gkeLogo from '../assets/icons/cis_gke_logo.svg'; import googleCloudLogo from '../assets/icons/google_cloud_logo.svg'; +export { MAX_FINDINGS_TO_LOAD } from '@kbn/cloud-security-posture-common'; + export const statusColors = { passed: euiThemeVars.euiColorSuccess, failed: euiThemeVars.euiColorVis9, }; export const CSP_MOMENT_FORMAT = 'MMMM D, YYYY @ HH:mm:ss.SSS'; -export const MAX_FINDINGS_TO_LOAD = 500; export const DEFAULT_VISIBLE_ROWS_PER_PAGE = 25; export const LOCAL_STORAGE_DATA_TABLE_PAGE_SIZE_KEY = 'cloudPosture:dataTable:pageSize'; diff --git a/x-pack/plugins/cloud_security_posture/public/common/types.ts b/x-pack/plugins/cloud_security_posture/public/common/types.ts index d0d491c256e0e1..4cc8479fb20791 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/types.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/types.ts @@ -5,7 +5,8 @@ * 2.0. */ import type { Criteria } from '@elastic/eui'; -import type { BoolQuery, Filter, Query, EsQueryConfig } from '@kbn/es-query'; +import type { Filter, Query, EsQueryConfig } from '@kbn/es-query'; +export type { FindingsBaseEsQuery } from '@kbn/cloud-security-posture'; export interface FindingsBaseURLQuery { query: Query; @@ -24,12 +25,6 @@ export interface FindingsBaseESQueryConfig { config: EsQueryConfig; } -export interface FindingsBaseEsQuery { - query?: { - bool: BoolQuery; - }; -} - export type Sort = NonNullable['sort']>; interface RuleSeverityMapping { diff --git a/x-pack/plugins/cloud_security_posture/public/types.ts b/x-pack/plugins/cloud_security_posture/public/types.ts index bd45c007112b08..0993b906e6e195 100755 --- a/x-pack/plugins/cloud_security_posture/public/types.ts +++ b/x-pack/plugins/cloud_security_posture/public/types.ts @@ -6,29 +6,17 @@ */ import type { CloudSetup } from '@kbn/cloud-plugin/public'; -import type { LicensingPluginStart } from '@kbn/licensing-plugin/public'; -import { DataViewsServicePublic } from '@kbn/data-views-plugin/public'; import type { ComponentType, ReactNode } from 'react'; -import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; -import { UiActionsSetup, UiActionsStart } from '@kbn/ui-actions-plugin/public'; -import { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; -import { IndexPatternFieldEditorStart } from '@kbn/data-view-field-editor-plugin/public'; -import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public'; -import { CoreStart, ToastsStart } from '@kbn/core/public'; -import { Storage } from '@kbn/kibana-utils-plugin/public'; - -import type { ChartsPluginStart } from '@kbn/charts-plugin/public'; -import type { DiscoverStart } from '@kbn/discover-plugin/public'; -import type { FleetSetup, FleetStart } from '@kbn/fleet-plugin/public'; -import type { - UsageCollectionSetup, - UsageCollectionStart, -} from '@kbn/usage-collection-plugin/public'; -import { SharePluginStart } from '@kbn/share-plugin/public'; -import { SpacesPluginStart } from '@kbn/spaces-plugin/public'; +import { UiActionsSetup } from '@kbn/ui-actions-plugin/public'; +import type { DataPublicPluginSetup } from '@kbn/data-plugin/public'; +import { CoreStart } from '@kbn/core/public'; +import type { FleetSetup } from '@kbn/fleet-plugin/public'; +import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; import type { CspRouterProps } from './application/csp_router'; import type { CloudSecurityPosturePageId } from './common/navigation/types'; +export type { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; + /** * The cloud security posture's public plugin setup interface. */ @@ -53,28 +41,6 @@ export interface CspClientPluginSetupDeps { usageCollection?: UsageCollectionSetup; } -export interface CspClientPluginStartDeps { - // required - data: DataPublicPluginStart; - dataViews: DataViewsServicePublic; - dataViewFieldEditor: IndexPatternFieldEditorStart; - unifiedSearch: UnifiedSearchPublicPluginStart; - uiActions: UiActionsStart; - fieldFormats: FieldFormatsStart; - toastNotifications: ToastsStart; - charts: ChartsPluginStart; - discover: DiscoverStart; - fleet: FleetStart; - licensing: LicensingPluginStart; - share: SharePluginStart; - storage: Storage; - spaces: SpacesPluginStart; - cloud: CloudSetup; - - // optional - usageCollection?: UsageCollectionStart; -} - /** * Methods exposed from the security solution to the cloud security posture application. */ From 6283bd4024f0f070cfbb85099b17684e57804424 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 21 Aug 2024 00:20:16 +0000 Subject: [PATCH 03/17] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- .../tsconfig.json | 39 +++++----- .../kbn-cloud-security-posture/tsconfig.json | 71 +++++++++---------- .../cloud_security_posture/tsconfig.json | 5 +- 3 files changed, 56 insertions(+), 59 deletions(-) diff --git a/x-pack/packages/kbn-cloud-security-posture-common/tsconfig.json b/x-pack/packages/kbn-cloud-security-posture-common/tsconfig.json index f37dfaa93dc7d8..1eb47d23c1542a 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/tsconfig.json +++ b/x-pack/packages/kbn-cloud-security-posture-common/tsconfig.json @@ -1,23 +1,20 @@ { - "extends": "../../../tsconfig.base.json", - "compilerOptions": { - "outDir": "target/types", - "types": [ - "jest", - "node", - ] - }, - "include": [ - "**/*.ts", - "**/*.tsx", - ], - "exclude": [ - "target/**/*" - ], - "kbn_references": [ - "@kbn/config-schema", - "@kbn/data-views-plugin", - "@kbn/core", - "@kbn/i18n", + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", ] - } \ No newline at end of file + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/config-schema", + ] +} diff --git a/x-pack/packages/kbn-cloud-security-posture/tsconfig.json b/x-pack/packages/kbn-cloud-security-posture/tsconfig.json index 1574f9c2b6a2eb..a2652215c4e796 100644 --- a/x-pack/packages/kbn-cloud-security-posture/tsconfig.json +++ b/x-pack/packages/kbn-cloud-security-posture/tsconfig.json @@ -1,38 +1,37 @@ { - "extends": "../../../tsconfig.base.json", - "compilerOptions": { - "outDir": "target/types", - "types": [ - "jest", - "node", - "react" - ] - }, - "include": [ - "**/*.ts", - "**/*.tsx", - ], - "exclude": [ - "target/**/*" - ], - "kbn_references": [ - "@kbn/kibana-react-plugin", - "@kbn/core", - "@kbn/cloud-security-posture-common", - "@kbn/search-types", - "@kbn/licensing-plugin", - "@kbn/data-views-plugin", - "@kbn/unified-search-plugin", - "@kbn/ui-actions-plugin", - "@kbn/field-formats-plugin", - "@kbn/data-view-field-editor-plugin", - "@kbn/data-plugin", - "@kbn/kibana-utils-plugin", - "@kbn/charts-plugin", - "@kbn/discover-plugin", - "@kbn/fleet-plugin", - "@kbn/usage-collection-plugin", - "@kbn/share-plugin", - "@kbn/es-query", + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" ] - } \ No newline at end of file + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/licensing-plugin", + "@kbn/data-views-plugin", + "@kbn/unified-search-plugin", + "@kbn/ui-actions-plugin", + "@kbn/field-formats-plugin", + "@kbn/data-view-field-editor-plugin", + "@kbn/data-plugin", + "@kbn/kibana-utils-plugin", + "@kbn/charts-plugin", + "@kbn/discover-plugin", + "@kbn/fleet-plugin", + "@kbn/usage-collection-plugin", + "@kbn/share-plugin", + "@kbn/es-query", + "@kbn/cloud-plugin", + "@kbn/spaces-plugin", + ] +} diff --git a/x-pack/plugins/cloud_security_posture/tsconfig.json b/x-pack/plugins/cloud_security_posture/tsconfig.json index 83891e3269eca4..6e19e9b4d09fa6 100755 --- a/x-pack/plugins/cloud_security_posture/tsconfig.json +++ b/x-pack/plugins/cloud_security_posture/tsconfig.json @@ -57,7 +57,6 @@ "@kbn/kibana-utils-plugin", "@kbn/ui-actions-plugin", "@kbn/core-http-server-mocks", - "@kbn/field-formats-plugin", "@kbn/data-view-field-editor-plugin", "@kbn/grouping", "@kbn/alerting-plugin", @@ -65,7 +64,9 @@ "@kbn/code-editor-mock", "@kbn/search-types", "@kbn/react-kibana-mount", - "@kbn/spaces-plugin" + "@kbn/spaces-plugin", + "@kbn/cloud-security-posture-common", + "@kbn/cloud-security-posture" ], "exclude": ["target/**/*"] } From 7fafa525d7474f418c91061372749568dbb3ee05 Mon Sep 17 00:00:00 2001 From: animehart Date: Tue, 20 Aug 2024 23:32:46 -0700 Subject: [PATCH 04/17] attempt on fixing bundle size leak --- .../packages/kbn-cloud-security-posture-common/index.ts | 2 +- .../cloud_security_posture/common/types/rules/v3.ts | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/x-pack/packages/kbn-cloud-security-posture-common/index.ts b/x-pack/packages/kbn-cloud-security-posture-common/index.ts index 658f89de2ffb74..bfb81d554ff428 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/index.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/index.ts @@ -8,7 +8,7 @@ export * from './types'; export * from './constants'; export * from './schema/csp_finding'; -export * from './schema/rules'; +export type { CspBenchmarkRuleMetadata } from './schema/rules'; export type { CspBenchmarkRulesStates } from './types/latest'; /* TODO: Uncomment this in phase 3*/ // export { showErrorToast } from './utils/show_error_toast'; diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts index 3f443f0fbd2542..7805a38ed412b8 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts @@ -7,12 +7,11 @@ import { schema, TypeOf } from '@kbn/config-schema'; -import { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common'; +import { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common/schema/rules'; -export type { - CspBenchmarkRuleMetadata, - cspBenchmarkRuleMetadataSchema, -} from '@kbn/cloud-security-posture-common'; +export type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; + +export type { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common/schema/rules'; export const DEFAULT_BENCHMARK_RULES_PER_PAGE = 25; From 72f00b0151f8c8f221d907f2bde98be7b4ad58e2 Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 23 Aug 2024 10:21:48 -0700 Subject: [PATCH 05/17] change schema import to be from schema folder + updating index.ts exports to be more specific --- .../index.ts | 21 ++++++++++++------- .../schema/rules.ts | 12 +++++++++++ .../types/latest.ts | 18 ---------------- .../kbn-cloud-security-posture/index.ts | 9 -------- .../common/types/rules/v3.ts | 4 ++-- .../common/types/rules/v4.ts | 2 +- 6 files changed, 29 insertions(+), 37 deletions(-) delete mode 100644 x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts diff --git a/x-pack/packages/kbn-cloud-security-posture-common/index.ts b/x-pack/packages/kbn-cloud-security-posture-common/index.ts index bfb81d554ff428..e4f1d8468578e6 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/index.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/index.ts @@ -5,11 +5,18 @@ * 2.0. */ -export * from './types'; +// Careful of exporting anything from this file as any file(s) you export here will cause your page bundle size to increase. +// If you're using functions/types/etc... internally or within integration tests it's best to import directly from their paths +// than expose the functions/types/etc... here. You should _only_ expose functions/types/etc... that need to be shared with other plugins here. + +export type { + CspStatusCode, + IndexStatus, + IndexDetails, + BaseCspSetupBothPolicy, + BaseCspSetupStatus, + CspSetupStatus, +} from './types'; export * from './constants'; -export * from './schema/csp_finding'; -export type { CspBenchmarkRuleMetadata } from './schema/rules'; -export type { CspBenchmarkRulesStates } from './types/latest'; -/* TODO: Uncomment this in phase 3*/ -// export { showErrorToast } from './utils/show_error_toast'; -// export { buildMutedRulesFilter } from './utils/helpers'; +export type { CspFinding } from './schema/csp_finding'; +export type { CspBenchmarkRuleMetadata, CspBenchmarkRulesStates } from './schema/rules'; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/schema/rules.ts b/x-pack/packages/kbn-cloud-security-posture-common/schema/rules.ts index f7c0771d5a23f1..67bb37e4e1702c 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/schema/rules.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/schema/rules.ts @@ -34,3 +34,15 @@ export const cspBenchmarkRuleMetadataSchema = schema.object({ tags: schema.arrayOf(schema.string()), version: schema.string(), }); + +export const ruleStateAttributes = schema.object({ + muted: schema.boolean(), + benchmark_id: schema.string(), + benchmark_version: schema.string(), + rule_number: schema.string(), + rule_id: schema.string(), +}); + +export const rulesStates = schema.recordOf(schema.string(), ruleStateAttributes); + +export type CspBenchmarkRulesStates = TypeOf; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts b/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts deleted file mode 100644 index 613910e8b5682c..00000000000000 --- a/x-pack/packages/kbn-cloud-security-posture-common/types/latest.ts +++ /dev/null @@ -1,18 +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, TypeOf } from '@kbn/config-schema'; - -export type CspBenchmarkRulesStates = TypeOf; -export const ruleStateAttributes = schema.object({ - muted: schema.boolean(), - benchmark_id: schema.string(), - benchmark_version: schema.string(), - rule_number: schema.string(), - rule_id: schema.string(), -}); - -export const rulesStates = schema.recordOf(schema.string(), ruleStateAttributes); diff --git a/x-pack/packages/kbn-cloud-security-posture/index.ts b/x-pack/packages/kbn-cloud-security-posture/index.ts index 0c3c46e9180774..a0e4ba8dbc1b25 100644 --- a/x-pack/packages/kbn-cloud-security-posture/index.ts +++ b/x-pack/packages/kbn-cloud-security-posture/index.ts @@ -6,12 +6,3 @@ */ export * from './type'; -/* TODO: Uncomment this in phase 3*/ -// export { useMisconfigurationPreview } from './src/hooks/use_misconfiguration_preview'; -// export { useGetCspBenchmarkRulesStatesApi } from './src/hooks/use_get_benchmark_rules_state_api'; -// export { useCspSetupStatusApi } from './src/hooks/use_csp_setup_status_api'; -// export { -// getAggregationCount, -// getFindingsCountAggQuery, -// isIndexWithDocsAvailable, -// } from './src/utils/utils'; diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts index 7805a38ed412b8..2e4ac39e24db10 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts @@ -7,11 +7,11 @@ import { schema, TypeOf } from '@kbn/config-schema'; -import { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common/schema/rules'; +import { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common/schema'; export type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; -export type { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common/schema/rules'; +export type { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common/schema'; export const DEFAULT_BENCHMARK_RULES_PER_PAGE = 25; diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts index fecd60bd70c993..6281691cf6f274 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts @@ -7,7 +7,7 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; -import { ruleStateAttributes, rulesStates } from '@kbn/cloud-security-posture-common/types/latest'; +import { ruleStateAttributes, rulesStates } from '@kbn/cloud-security-posture-common/schema'; import { BenchmarksCisId } from '../latest'; import { DEFAULT_BENCHMARK_RULES_PER_PAGE } from './v3'; export type { From 783626e8660d852138839b8e88456da7e3da1ae7 Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 23 Aug 2024 10:22:31 -0700 Subject: [PATCH 06/17] forgot to add index.ts in last commit --- .../kbn-cloud-security-posture-common/schema/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 x-pack/packages/kbn-cloud-security-posture-common/schema/index.ts diff --git a/x-pack/packages/kbn-cloud-security-posture-common/schema/index.ts b/x-pack/packages/kbn-cloud-security-posture-common/schema/index.ts new file mode 100644 index 00000000000000..981633d2a3fad6 --- /dev/null +++ b/x-pack/packages/kbn-cloud-security-posture-common/schema/index.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 { ruleStateAttributes, cspBenchmarkRuleMetadataSchema, rulesStates } from './rules'; From a89617dff46c2da0375506286a60f02d0c575810 Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 23 Aug 2024 11:20:22 -0700 Subject: [PATCH 07/17] removed re export on csp plugin + updated imports to be directly from csp package --- .../cloud_security_posture/common/constants.ts | 13 ------------- .../cloud_security_posture/common/schemas/stats.ts | 2 +- .../cloud_security_posture/common/types/index.ts | 2 -- .../cloud_security_posture/common/types/rules/v3.ts | 4 ---- .../cloud_security_posture/common/types/rules/v4.ts | 10 +--------- .../cloud_security_posture/common/types/rules/v5.ts | 9 +-------- .../cloud_security_posture/common/types_old.ts | 2 +- .../common/utils/detection_rules.test.ts | 2 +- .../common/utils/detection_rules.ts | 2 +- .../common/utils/rules_states.ts | 2 +- .../public/common/api/use_setup_status_api.ts | 2 +- .../public/common/api/use_stats_api.ts | 7 ++----- .../public/common/constants.ts | 5 +---- .../common/hooks/use_benchmark_dynamic_values.ts | 2 +- .../public/common/navigation/constants.ts | 2 +- .../cloud_security_data_table.tsx | 2 +- .../fleet_extensions/policy_template_selectors.tsx | 8 ++------ .../public/components/fleet_extensions/utils.ts | 3 +-- .../no_findings_states/no_findings_states.tsx | 2 +- .../compliance_dashboard/compliance_dashboard.tsx | 2 +- .../dashboard_sections/benchmarks_section.test.tsx | 2 +- .../dashboard_sections/summary_section.test.tsx | 2 +- .../dashboard_sections/summary_section.tsx | 8 ++------ .../findings_flyout/findings_flyout.test.tsx | 2 +- .../configurations/findings_flyout/overview_tab.tsx | 2 +- .../use_get_benchmark_rules_state_api.ts | 4 ++-- .../latest_findings/use_grouped_findings.tsx | 2 +- .../latest_findings/use_latest_findings.ts | 12 ++++++------ .../use_latest_findings_grouping.tsx | 2 +- .../utils/create_detection_rule_from_benchmark.ts | 7 +++---- .../public/pages/rules/rules_flyout.tsx | 2 +- .../public/pages/rules/use_csp_rules_state.ts | 6 ++++-- .../hooks/use_latest_vulnerabilities.tsx | 3 ++- .../mock_server/handlers/dataview.handlers.mock.ts | 6 ++---- .../server/create_indices/latest_indices.ts | 2 +- .../create_transforms/latest_findings_transform.ts | 2 +- .../cloud_security_posture/server/lib/fleet_util.ts | 3 +-- .../collectors/cloud_accounts_stats_collector.ts | 3 +-- .../routes/benchmark_rules/bulk_action/utils.ts | 2 +- .../routes/benchmark_rules/get_states/get_states.ts | 6 ++++-- .../server/routes/benchmark_rules/get_states/v1.ts | 3 ++- .../server/routes/status/status.test.ts | 3 ++- .../server/routes/status/status.ts | 12 +++++++----- .../server/saved_objects/data_views.ts | 2 +- 44 files changed, 68 insertions(+), 113 deletions(-) diff --git a/x-pack/plugins/cloud_security_posture/common/constants.ts b/x-pack/plugins/cloud_security_posture/common/constants.ts index db7ff20923151a..b35780c4384037 100644 --- a/x-pack/plugins/cloud_security_posture/common/constants.ts +++ b/x-pack/plugins/cloud_security_posture/common/constants.ts @@ -13,19 +13,6 @@ import { VulnSeverity, } from './types_old'; -export { - KSPM_POLICY_TEMPLATE, - CSPM_POLICY_TEMPLATE, - CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN, - CDR_LATEST_THIRD_PARTY_MISCONFIGURATIONS_INDEX_PATTERN, - CDR_MISCONFIGURATIONS_INDEX_PATTERN, - LATEST_FINDINGS_RETENTION_POLICY, - CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH, - CSP_GET_BENCHMARK_RULES_STATE_API_CURRENT_VERSION, - STATUS_ROUTE_PATH, - STATUS_API_CURRENT_VERSION, -} from '@kbn/cloud-security-posture-common'; - export const CLOUD_SECURITY_INTERTAL_PREFIX_ROUTE_PATH = '/internal/cloud_security_posture/'; export const STATS_ROUTE_PATH = '/internal/cloud_security_posture/stats/{policy_template}'; diff --git a/x-pack/plugins/cloud_security_posture/common/schemas/stats.ts b/x-pack/plugins/cloud_security_posture/common/schemas/stats.ts index e8b3657996e0f0..3b2fa14c06b304 100644 --- a/x-pack/plugins/cloud_security_posture/common/schemas/stats.ts +++ b/x-pack/plugins/cloud_security_posture/common/schemas/stats.ts @@ -6,7 +6,7 @@ */ import { schema } from '@kbn/config-schema'; -import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../constants'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; // this pages follows versioning interface strategy https://docs.elastic.dev/kibana-dev-docs/versioning-interfaces diff --git a/x-pack/plugins/cloud_security_posture/common/types/index.ts b/x-pack/plugins/cloud_security_posture/common/types/index.ts index 04fa2a95a8d5ee..c59071d1142516 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/index.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/index.ts @@ -16,8 +16,6 @@ export * as benchmarkV2 from './benchmarks/v2'; // Explicit export of everything from latest export type { - cspBenchmarkRuleMetadataSchema, - CspBenchmarkRuleMetadata, CspBenchmarkRule, FindCspBenchmarkRuleRequest, FindCspBenchmarkRuleResponse, diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts index 2e4ac39e24db10..7c0a536de79a5d 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v3.ts @@ -9,10 +9,6 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common/schema'; -export type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; - -export type { cspBenchmarkRuleMetadataSchema } from '@kbn/cloud-security-posture-common/schema'; - export const DEFAULT_BENCHMARK_RULES_PER_PAGE = 25; // Since version 8.7.0 diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts index 6281691cf6f274..2ff64e0108a73b 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts @@ -10,15 +10,7 @@ import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; import { ruleStateAttributes, rulesStates } from '@kbn/cloud-security-posture-common/schema'; import { BenchmarksCisId } from '../latest'; import { DEFAULT_BENCHMARK_RULES_PER_PAGE } from './v3'; -export type { - cspBenchmarkRuleMetadataSchema, - CspBenchmarkRuleMetadata, - cspBenchmarkRuleSchema, - CspBenchmarkRule, - FindCspBenchmarkRuleResponse, -} from './v3'; - -export type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; +export type { cspBenchmarkRuleSchema, CspBenchmarkRule, FindCspBenchmarkRuleResponse } from './v3'; export type FindCspBenchmarkRuleRequest = TypeOf; diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v5.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v5.ts index 6f30ed446531aa..1d70528d457eaa 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v5.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v5.ts @@ -7,20 +7,13 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { DEFAULT_BENCHMARK_RULES_PER_PAGE } from './v3'; -export type { - cspBenchmarkRuleMetadataSchema, - CspBenchmarkRuleMetadata, - cspBenchmarkRuleSchema, - CspBenchmarkRule, - FindCspBenchmarkRuleResponse, -} from './v3'; +export type { cspBenchmarkRuleSchema, CspBenchmarkRule, FindCspBenchmarkRuleResponse } from './v3'; export type { PageUrlParams, rulesToUpdate, CspBenchmarkRulesBulkActionRequestSchema, CspBenchmarkRulesBulkActionResponse, RuleStateAttributes, - CspBenchmarkRulesStates, cspSettingsSchema, CspSettings, BulkActionBenchmarkRulesResponse, diff --git a/x-pack/plugins/cloud_security_posture/common/types_old.ts b/x-pack/plugins/cloud_security_posture/common/types_old.ts index 30419d1e35090f..c034ecd1bfdab8 100644 --- a/x-pack/plugins/cloud_security_posture/common/types_old.ts +++ b/x-pack/plugins/cloud_security_posture/common/types_old.ts @@ -5,11 +5,11 @@ * 2.0. */ import { type TypeOf } from '@kbn/config-schema'; +import type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; import { CspFinding } from './schemas/csp_finding'; import { SUPPORTED_CLOUDBEAT_INPUTS, SUPPORTED_POLICY_TEMPLATES } from './constants'; import { getComplianceDashboardSchema } from './schemas/stats'; -import type { CspBenchmarkRuleMetadata } from './types/latest'; export type { CspFinding, diff --git a/x-pack/plugins/cloud_security_posture/common/utils/detection_rules.test.ts b/x-pack/plugins/cloud_security_posture/common/utils/detection_rules.test.ts index a067ef4e1871a5..fa514fe0fc2a5a 100644 --- a/x-pack/plugins/cloud_security_posture/common/utils/detection_rules.test.ts +++ b/x-pack/plugins/cloud_security_posture/common/utils/detection_rules.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CspBenchmarkRuleMetadata } from '../types'; +import type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; import { convertRuleTagsToMatchAllKQL, convertRuleTagsToMatchAnyKQL, diff --git a/x-pack/plugins/cloud_security_posture/common/utils/detection_rules.ts b/x-pack/plugins/cloud_security_posture/common/utils/detection_rules.ts index 61567211c8d226..4ae83852909554 100644 --- a/x-pack/plugins/cloud_security_posture/common/utils/detection_rules.ts +++ b/x-pack/plugins/cloud_security_posture/common/utils/detection_rules.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CspBenchmarkRuleMetadata } from '../types/latest'; +import type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; const CSP_RULE_TAG = 'Cloud Security'; const CSP_RULE_TAG_USE_CASE = 'Use Case: Configuration Audit'; diff --git a/x-pack/plugins/cloud_security_posture/common/utils/rules_states.ts b/x-pack/plugins/cloud_security_posture/common/utils/rules_states.ts index a343c91af91f92..2a55a20a136ccd 100644 --- a/x-pack/plugins/cloud_security_posture/common/utils/rules_states.ts +++ b/x-pack/plugins/cloud_security_posture/common/utils/rules_states.ts @@ -5,7 +5,7 @@ * 2.0. */ import { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types'; -import { CspBenchmarkRulesStates } from '../types/latest'; +import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; export const buildMutedRulesFilter = ( rulesStates: CspBenchmarkRulesStates 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 35f49282a475e0..30721bdc5dd601 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 @@ -6,9 +6,9 @@ */ import { useQuery, type UseQueryOptions } from '@tanstack/react-query'; +import { STATUS_API_CURRENT_VERSION, STATUS_ROUTE_PATH } from '@kbn/cloud-security-posture-common'; import { useKibana } from '../hooks/use_kibana'; 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 e973633210d9c5..77497d16cd76c0 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 @@ -6,13 +6,10 @@ */ import { useQuery, UseQueryOptions } from '@tanstack/react-query'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { useKibana } from '../hooks/use_kibana'; import { ComplianceDashboardDataV2, PosturePolicyTemplate } from '../../../common/types_old'; -import { - CSPM_POLICY_TEMPLATE, - KSPM_POLICY_TEMPLATE, - STATS_ROUTE_PATH, -} from '../../../common/constants'; +import { STATS_ROUTE_PATH } from '../../../common/constants'; // TODO: consolidate both hooks into one hook with a dynamic key export const CSPM_STATS_QUERY_KEY = ['csp_cspm_dashboard_stats']; 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 5c0e6e84d47b94..8eb996dd156438 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/constants.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/constants.ts @@ -7,6 +7,7 @@ import { i18n } from '@kbn/i18n'; import { euiThemeVars } from '@kbn/ui-theme'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import type { CloudSecurityPolicyTemplate, PostureInput } from '../../common/types_old'; import { CLOUDBEAT_EKS, @@ -15,8 +16,6 @@ import { CLOUDBEAT_GCP, CLOUDBEAT_AZURE, CLOUDBEAT_VULN_MGMT_AWS, - KSPM_POLICY_TEMPLATE, - CSPM_POLICY_TEMPLATE, VULN_MGMT_POLICY_TEMPLATE, CLOUDBEAT_VULN_MGMT_GCP, CLOUDBEAT_VULN_MGMT_AZURE, @@ -29,8 +28,6 @@ import aksLogo from '../assets/icons/cis_aks_logo.svg'; import gkeLogo from '../assets/icons/cis_gke_logo.svg'; import googleCloudLogo from '../assets/icons/google_cloud_logo.svg'; -export { MAX_FINDINGS_TO_LOAD } from '@kbn/cloud-security-posture-common'; - export const statusColors = { passed: euiThemeVars.euiColorSuccess, failed: euiThemeVars.euiColorVis9, diff --git a/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.ts b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.ts index 5fe3f8f69050ad..7f9a2b5fd35f6d 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.ts @@ -6,8 +6,8 @@ */ import { i18n } from '@kbn/i18n'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { useCspIntegrationLink } from '../navigation/use_csp_integration_link'; -import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../../common/constants'; import { BenchmarksCisId } from '../../../common/types/benchmarks/v2'; type BenchmarkDynamicNames = 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 d01aac0c575771..75fbcaff2751aa 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 @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../../common/constants'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { PosturePolicyTemplate } from '../../../common/types_old'; import type { CspBenchmarksPage, diff --git a/x-pack/plugins/cloud_security_posture/public/components/cloud_security_data_table/cloud_security_data_table.tsx b/x-pack/plugins/cloud_security_posture/public/components/cloud_security_data_table/cloud_security_data_table.tsx index 68a28a869efb72..377329ce651a9d 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/cloud_security_data_table/cloud_security_data_table.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/cloud_security_data_table/cloud_security_data_table.tsx @@ -26,10 +26,10 @@ import { AddFieldFilterHandler } from '@kbn/unified-field-list'; import { generateFilters } from '@kbn/data-plugin/public'; import { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import useLocalStorage from 'react-use/lib/useLocalStorage'; +import { MAX_FINDINGS_TO_LOAD } from '@kbn/cloud-security-posture-common'; import { useKibana } from '../../common/hooks/use_kibana'; import { CloudPostureDataTableResult } from '../../common/hooks/use_cloud_posture_data_table'; import { EmptyState } from '../empty_state'; -import { MAX_FINDINGS_TO_LOAD } from '../../common/constants'; import { useStyles } from './use_styles'; import { AdditionalControls } from './additional_controls'; import { useDataViewContext } from '../../common/contexts/data_view_context'; 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 ee76d40e1dcac0..c0c489f935be00 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 @@ -10,12 +10,8 @@ import { FormattedMessage } from '@kbn/i18n-react'; import type { NewPackagePolicy, PackageInfo } from '@kbn/fleet-plugin/common'; import { SetupTechnology } from '@kbn/fleet-plugin/public'; import { PackagePolicyReplaceDefineStepExtensionComponentProps } from '@kbn/fleet-plugin/public/types'; -import { - CSPM_POLICY_TEMPLATE, - KSPM_POLICY_TEMPLATE, - VULN_MGMT_POLICY_TEMPLATE, - CNVM_POLICY_TEMPLATE, -} from '../../../common/constants'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; +import { VULN_MGMT_POLICY_TEMPLATE, CNVM_POLICY_TEMPLATE } from '../../../common/constants'; import type { PostureInput, CloudSecurityPolicyTemplate } from '../../../common/types_old'; import { getPolicyTemplateInputOptions, type NewPackagePolicyPostureInput } from './utils'; import { RadioGroup } from './csp_boxed_radio_group'; 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 656c70a0dcbfd3..5fc4ab08e414c2 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 @@ -13,6 +13,7 @@ import type { RegistryVarsEntry, } from '@kbn/fleet-plugin/common'; import { SetupTechnology } from '@kbn/fleet-plugin/public'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import merge from 'lodash/merge'; import semverValid from 'semver/functions/valid'; import semverCoerce from 'semver/functions/coerce'; @@ -24,8 +25,6 @@ import { CLOUDBEAT_GCP, CLOUDBEAT_VANILLA, CLOUDBEAT_VULN_MGMT_AWS, - CSPM_POLICY_TEMPLATE, - KSPM_POLICY_TEMPLATE, SUPPORTED_CLOUDBEAT_INPUTS, SUPPORTED_POLICY_TEMPLATES, VULN_MGMT_POLICY_TEMPLATE, diff --git a/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx b/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx index 97dfce7b84c1ec..518f53bbc2d68a 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx @@ -20,7 +20,7 @@ import { import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; -import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../../common/constants'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { FullSizeCenteredPage } from '../full_size_centered_page'; import { useCISIntegrationPoliciesLink } from '../../common/navigation/use_navigate_to_cis_integration_policies'; import { 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 af341d5c04606f..5ad3f12ef0fd0d 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 @@ -13,6 +13,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { Route, Routes } from '@kbn/shared-ux-router'; import { Redirect, useHistory, useLocation } from 'react-router-dom'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { NO_FINDINGS_STATUS_TEST_SUBJ } from '../../components/test_subjects'; import { useCspIntegrationLink } from '../../common/navigation/use_csp_integration_link'; import type { @@ -41,7 +42,6 @@ import { useCspSetupStatusApi } from '../../common/api/use_setup_status_api'; import { NoFindingsStates } from '../../components/no_findings_states'; import { SummarySection } from './dashboard_sections/summary_section'; import { BenchmarksSection } from './dashboard_sections/benchmarks_section'; -import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../../common/constants'; import { cloudPosturePages, cspIntegrationDocsNavigation } from '../../common/navigation/constants'; import { NO_FINDINGS_STATUS_REFRESH_INTERVAL_MS } from '../../common/constants'; import { encodeQuery } from '../../common/navigation/query_utils'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmarks_section.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmarks_section.test.tsx index 79b644af377957..d9c773522581f3 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmarks_section.test.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/benchmarks_section.test.tsx @@ -6,12 +6,12 @@ */ import React from 'react'; +import { KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { BenchmarksSection } from './benchmarks_section'; import { getMockDashboardData, getBenchmarkMockData } from '../mock'; import { TestProvider } from '../../../test/test_provider'; -import { KSPM_POLICY_TEMPLATE } from '../../../../common/constants'; import { DASHBOARD_TABLE_COLUMN_SCORE_TEST_ID, DASHBOARD_TABLE_HEADER_SCORE_TEST_ID, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/summary_section.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/summary_section.test.tsx index 04c83825295931..089bd4def089fe 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/summary_section.test.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/compliance_dashboard/dashboard_sections/summary_section.test.tsx @@ -6,13 +6,13 @@ */ import React from 'react'; +import { KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { render, screen } from '@testing-library/react'; import { expectIdsInDoc } from '../../../test/utils'; import { DASHBOARD_COUNTER_CARDS } from '../test_subjects'; import { SummarySection } from './summary_section'; import { mockDashboardData } from '../mock'; import { TestProvider } from '../../../test/test_provider'; -import { KSPM_POLICY_TEMPLATE } from '../../../../common/constants'; describe('', () => { const renderCloudSummarySection = (alterMockData = {}) => { 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 64d0a225f20d47..15282395628261 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 @@ -15,6 +15,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; +import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { useCspIntegrationLink } from '../../../common/navigation/use_csp_integration_link'; import { DASHBOARD_COUNTER_CARDS, DASHBOARD_SUMMARY_CONTAINER } from '../test_subjects'; import { CspCounterCard, CspCounterCardProps } from '../../../components/csp_counter_card'; @@ -28,12 +29,7 @@ import type { } from '../../../../common/types_old'; import { RisksTable } from '../compliance_charts/risks_table'; import { NavFilter, useNavigateFindings } from '../../../common/hooks/use_navigate_findings'; -import { - CSPM_POLICY_TEMPLATE, - KSPM_POLICY_TEMPLATE, - RULE_FAILED, - RULE_PASSED, -} from '../../../../common/constants'; +import { RULE_FAILED, RULE_PASSED } from '../../../../common/constants'; import { AccountsEvaluatedWidget } from '../../../components/accounts_evaluated_widget'; import { FINDINGS_GROUPING_OPTIONS } from '../../../common/constants'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_flyout.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_flyout.test.tsx index 118ebb86e0d645..a2fbc66188acd4 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_flyout.test.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_flyout.test.tsx @@ -5,11 +5,11 @@ * 2.0. */ import React from 'react'; +import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; import userEvent from '@testing-library/user-event'; import { FindingsRuleFlyout } from './findings_flyout'; import { render, screen } from '@testing-library/react'; import { TestProvider } from '../../../test/test_provider'; -import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '../../../../common/constants'; import { mockFindingsHit, mockWizFinding } from '../__mocks__/findings'; const onPaginate = jest.fn(); diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx index 38c526df1e7584..7a751e6e3ce21f 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx @@ -18,6 +18,7 @@ import React, { useMemo } from 'react'; import moment from 'moment'; import type { EuiDescriptionListProps, EuiAccordionProps } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; import { FormattedMessage } from '@kbn/i18n-react'; import { isEmpty } from 'lodash'; import { getDatasetDisplayName } from '../../../common/utils/get_dataset_display_name'; @@ -26,7 +27,6 @@ import { CSP_MOMENT_FORMAT } from '../../../common/constants'; import { INTERNAL_FEATURE_FLAGS, CDR_MISCONFIGURATIONS_DATA_VIEW_ID_PREFIX, - CDR_MISCONFIGURATIONS_INDEX_PATTERN, } from '../../../../common/constants'; import { useDataView } from '../../../common/api/use_data_view'; import { useKibana } from '../../../common/hooks/use_kibana'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_get_benchmark_rules_state_api.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_get_benchmark_rules_state_api.ts index ceada5c3148ebc..ddc626c169ed74 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_get_benchmark_rules_state_api.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_get_benchmark_rules_state_api.ts @@ -6,11 +6,11 @@ */ import { useQuery } from '@tanstack/react-query'; -import { CspBenchmarkRulesStates } from '../../../../common/types/latest'; import { CSP_GET_BENCHMARK_RULES_STATE_API_CURRENT_VERSION, CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH, -} from '../../../../common/constants'; + CspBenchmarkRulesStates, +} from '@kbn/cloud-security-posture-common'; import { useKibana } from '../../../common/hooks/use_kibana'; export const getRuleStatesKey = ['get_rules_state_key']; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx index 9c1125257520e6..532998f0f712f1 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_grouped_findings.tsx @@ -10,7 +10,7 @@ import type { IKibanaSearchResponse } from '@kbn/search-types'; import { GenericBuckets, GroupingQuery, RootAggregation } from '@kbn/grouping/src'; import { useQuery } from '@tanstack/react-query'; import { lastValueFrom } from 'rxjs'; -import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '../../../../common/constants'; +import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; import { useKibana } from '../../../common/hooks/use_kibana'; import { showErrorToast } from '../../../common/utils/show_error_toast'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts index 3af41c5921416a..a021d7509d5357 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts @@ -11,18 +11,18 @@ import type { IKibanaSearchResponse, IKibanaSearchRequest } from '@kbn/search-ty import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { buildDataTableRecord } from '@kbn/discover-utils'; import { EsHitRecord } from '@kbn/discover-utils/types'; +import { MAX_FINDINGS_TO_LOAD } from '@kbn/cloud-security-posture-common'; +import { + CDR_MISCONFIGURATIONS_INDEX_PATTERN, + LATEST_FINDINGS_RETENTION_POLICY, + CspBenchmarkRulesStates, +} from '@kbn/cloud-security-posture-common'; import { CspFinding } from '../../../../common/schemas/csp_finding'; import { useKibana } from '../../../common/hooks/use_kibana'; import type { FindingsBaseEsQuery } from '../../../common/types'; import { getAggregationCount, getFindingsCountAggQuery } from '../utils/utils'; -import { - CDR_MISCONFIGURATIONS_INDEX_PATTERN, - LATEST_FINDINGS_RETENTION_POLICY, -} from '../../../../common/constants'; -import { MAX_FINDINGS_TO_LOAD } from '../../../common/constants'; import { showErrorToast } from '../../../common/utils/show_error_toast'; import { useGetCspBenchmarkRulesStatesApi } from './use_get_benchmark_rules_state_api'; -import { CspBenchmarkRulesStates } from '../../../../common/types/latest'; import { buildMutedRulesFilter } from '../../../../common/utils/rules_states'; interface UseFindingsOptions extends FindingsBaseEsQuery { 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 0235960207e27d..d94f063933b0e6 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,13 +15,13 @@ import { } from '@kbn/grouping/src'; import { useMemo } from 'react'; import { buildEsQuery, Filter } from '@kbn/es-query'; +import { LATEST_FINDINGS_RETENTION_POLICY } from '@kbn/cloud-security-posture-common'; import { FINDINGS_GROUPING_OPTIONS, LOCAL_STORAGE_FINDINGS_GROUPING_KEY, } from '../../../common/constants'; import { useDataViewContext } from '../../../common/contexts/data_view_context'; import { Evaluation } from '../../../../common/types_old'; -import { LATEST_FINDINGS_RETENTION_POLICY } from '../../../../common/constants'; import { FindingsGroupingAggregation, FindingsRootGroupingAggregation, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/utils/create_detection_rule_from_benchmark.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/utils/create_detection_rule_from_benchmark.ts index d77e6ddf6389ce..289c6c2cb153f7 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/utils/create_detection_rule_from_benchmark.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/utils/create_detection_rule_from_benchmark.ts @@ -6,11 +6,10 @@ */ import { HttpSetup } from '@kbn/core/public'; +import { LATEST_FINDINGS_RETENTION_POLICY } from '@kbn/cloud-security-posture-common'; import { CspBenchmarkRule } from '../../../../common/types/latest'; -import { - FINDINGS_INDEX_PATTERN, - LATEST_FINDINGS_RETENTION_POLICY, -} from '../../../../common/constants'; +import { FINDINGS_INDEX_PATTERN } from '../../../../common/constants'; + import { createDetectionRule } from '../../../common/api/create_detection_rule'; import { generateBenchmarkRuleTags } from '../../../../common/utils/detection_rules'; 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 264a8229d11a33..842c87e87d6e50 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 @@ -23,9 +23,9 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { HttpSetup } from '@kbn/core/public'; +import type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; import { useKibana } from '../../common/hooks/use_kibana'; import { getFindingsDetectionRuleSearchTags } from '../../../common/utils/detection_rules'; -import { 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'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules_state.ts b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules_state.ts index e712b130e16514..f488754e3f673a 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules_state.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules_state.ts @@ -6,8 +6,10 @@ */ import { useQuery } from '@tanstack/react-query'; -import { CspBenchmarkRulesStates } from '../../../common/types/latest'; -import { CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH } from '../../../common/constants'; +import { + CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH, + CspBenchmarkRulesStates, +} from '@kbn/cloud-security-posture-common'; import { useKibana } from '../../common/hooks/use_kibana'; export const CSP_RULES_STATES_QUERY_KEY = ['csp_rules_states_v1']; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx b/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx index 15760e80ad7c29..7ce1c5b6814df5 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx @@ -16,7 +16,8 @@ import { } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { buildDataTableRecord } from '@kbn/discover-utils'; import { EsHitRecord } from '@kbn/discover-utils/types'; -import { MAX_FINDINGS_TO_LOAD, VULNERABILITY_FIELDS } from '../../../common/constants'; +import { MAX_FINDINGS_TO_LOAD } from '@kbn/cloud-security-posture-common'; +import { VULNERABILITY_FIELDS } from '../../../common/constants'; import { CspVulnerabilityFinding } from '../../../../common/schemas'; import { LATEST_VULNERABILITIES_INDEX_PATTERN, diff --git a/x-pack/plugins/cloud_security_posture/public/test/mock_server/handlers/dataview.handlers.mock.ts b/x-pack/plugins/cloud_security_posture/public/test/mock_server/handlers/dataview.handlers.mock.ts index fb7a25fbcdadf0..62430421f7358a 100644 --- a/x-pack/plugins/cloud_security_posture/public/test/mock_server/handlers/dataview.handlers.mock.ts +++ b/x-pack/plugins/cloud_security_posture/public/test/mock_server/handlers/dataview.handlers.mock.ts @@ -6,10 +6,8 @@ */ import { http, HttpResponse } from 'msw'; -import { - CDR_MISCONFIGURATIONS_DATA_VIEW_ID_PREFIX, - CDR_MISCONFIGURATIONS_INDEX_PATTERN, -} from '../../../../common/constants'; +import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; +import { CDR_MISCONFIGURATIONS_DATA_VIEW_ID_PREFIX } from '../../../../common/constants'; const generateDataViewField = (name: string, type: 'string' | 'date' = 'string') => ({ name, diff --git a/x-pack/plugins/cloud_security_posture/server/create_indices/latest_indices.ts b/x-pack/plugins/cloud_security_posture/server/create_indices/latest_indices.ts index 91c7ae74de9e84..2994c88bef2907 100644 --- a/x-pack/plugins/cloud_security_posture/server/create_indices/latest_indices.ts +++ b/x-pack/plugins/cloud_security_posture/server/create_indices/latest_indices.ts @@ -5,9 +5,9 @@ * 2.0. */ +import { CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; import { FINDINGS_INDEX_NAME, - CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN, LATEST_FINDINGS_INDEX_TEMPLATE_NAME, LATEST_FINDINGS_INDEX_DEFAULT_NS, VULNERABILITIES_INDEX_NAME, diff --git a/x-pack/plugins/cloud_security_posture/server/create_transforms/latest_findings_transform.ts b/x-pack/plugins/cloud_security_posture/server/create_transforms/latest_findings_transform.ts index 556ab0c7c830c9..aa428c7083eca4 100644 --- a/x-pack/plugins/cloud_security_posture/server/create_transforms/latest_findings_transform.ts +++ b/x-pack/plugins/cloud_security_posture/server/create_transforms/latest_findings_transform.ts @@ -5,11 +5,11 @@ * 2.0. */ import type { TransformPutTransformRequest } from '@elastic/elasticsearch/lib/api/types'; +import { LATEST_FINDINGS_RETENTION_POLICY } from '@kbn/cloud-security-posture-common'; import { CLOUD_SECURITY_POSTURE_PACKAGE_NAME, FINDINGS_INDEX_PATTERN, LATEST_FINDINGS_INDEX_DEFAULT_NS, - LATEST_FINDINGS_RETENTION_POLICY, } from '../../common/constants'; const LATEST_FINDINGS_TRANSFORM_V830 = 'cloud_security_posture.findings_latest-default-0.0.1'; 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 5a11ddebdd9d33..a82eeb70c3d403 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 @@ -5,6 +5,7 @@ * 2.0. */ import { flatMap, uniq } from 'lodash'; +import { KSPM_POLICY_TEMPLATE, CSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import type { SavedObjectsClientContract, Logger } from '@kbn/core/server'; import type { AgentPolicyServiceInterface, @@ -23,8 +24,6 @@ import { CloudSecurityPolicyTemplate, PostureTypes } from '../../common/types_ol import { SUPPORTED_POLICY_TEMPLATES, CLOUD_SECURITY_POSTURE_PACKAGE_NAME, - KSPM_POLICY_TEMPLATE, - CSPM_POLICY_TEMPLATE, } from '../../common/constants'; import { CSP_FLEET_PACKAGE_KUERY } from '../../common/utils/helpers'; import { diff --git a/x-pack/plugins/cloud_security_posture/server/lib/telemetry/collectors/cloud_accounts_stats_collector.ts b/x-pack/plugins/cloud_security_posture/server/lib/telemetry/collectors/cloud_accounts_stats_collector.ts index 5cd7c6dc03766a..32043329b07069 100644 --- a/x-pack/plugins/cloud_security_posture/server/lib/telemetry/collectors/cloud_accounts_stats_collector.ts +++ b/x-pack/plugins/cloud_security_posture/server/lib/telemetry/collectors/cloud_accounts_stats_collector.ts @@ -6,6 +6,7 @@ */ import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; import type { ISavedObjectsRepository, Logger } from '@kbn/core/server'; +import { KSPM_POLICY_TEMPLATE, CSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import type { SearchRequest } from '@elastic/elasticsearch/lib/api/types'; import { getPackagePolicyIdRuntimeMapping } from '../../../../common/runtime_mappings/get_package_policy_id_mapping'; import { getIdentifierRuntimeMapping } from '../../../../common/runtime_mappings/get_identifier_runtime_mapping'; @@ -17,8 +18,6 @@ import type { CloudSecurityAccountsStats, } from './types'; import { - CSPM_POLICY_TEMPLATE, - KSPM_POLICY_TEMPLATE, LATEST_FINDINGS_INDEX_DEFAULT_NS, LATEST_VULNERABILITIES_INDEX_DEFAULT_NS, VULN_MGMT_POLICY_TEMPLATE, diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/bulk_action/utils.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/bulk_action/utils.ts index df5db4cb2e1ab1..d59a30a410618c 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/bulk_action/utils.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/bulk_action/utils.ts @@ -6,12 +6,12 @@ */ import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server'; +import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; import type { FindResult, RulesClient } from '@kbn/alerting-plugin/server'; import type { RuleParams } from '@kbn/alerting-plugin/server/application/rule/types'; import type { CspBenchmarkRule, RulesToUpdate, - CspBenchmarkRulesStates, CspSettings, } from '../../../../common/types/rules/v4'; import { diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/get_states.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/get_states.ts index a55bcd92ab3c81..79615644494162 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/get_states.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/get_states.ts @@ -6,9 +6,11 @@ */ import { transformError } from '@kbn/securitysolution-es-utils'; +import { + CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH, + CspBenchmarkRulesStates, +} from '@kbn/cloud-security-posture-common'; import { CspRouter } from '../../../types'; -import { CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH } from '../../../../common/constants'; -import { CspBenchmarkRulesStates } from '../../../../common/types/rules/v4'; import { getCspBenchmarkRulesStatesHandler } from './v1'; export const defineGetCspBenchmarkRulesStatesRoute = (router: CspRouter) => diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts index 4d28b995cbdaf9..6a72ef5ea2880b 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts @@ -10,7 +10,8 @@ import { } from '@kbn/core-saved-objects-api-server'; import { transformError } from '@kbn/securitysolution-es-utils'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { CspBenchmarkRulesStates, CspSettings } from '../../../../common/types/rules/v4'; +import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; +import { CspSettings } from '../../../../common/types/rules/v4'; import { INTERNAL_CSP_SETTINGS_SAVED_OBJECT_ID, INTERNAL_CSP_SETTINGS_SAVED_OBJECT_TYPE, diff --git a/x-pack/plugins/cloud_security_posture/server/routes/status/status.test.ts b/x-pack/plugins/cloud_security_posture/server/routes/status/status.test.ts index 24d213b92ad8b1..e3b844a551a4e1 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/status/status.test.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/status/status.test.ts @@ -5,8 +5,9 @@ * 2.0. */ +import { CSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { calculateIntegrationStatus } from './status'; -import { CSPM_POLICY_TEMPLATE, VULN_MGMT_POLICY_TEMPLATE } from '../../../common/constants'; +import { VULN_MGMT_POLICY_TEMPLATE } from '../../../common/constants'; import { Installation } from '@kbn/fleet-plugin/common'; const mockInstallation: Installation = { 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 868deaed0fd828..7042c943afdad1 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 @@ -6,6 +6,13 @@ */ import { transformError } from '@kbn/securitysolution-es-utils'; +import { + KSPM_POLICY_TEMPLATE, + CSPM_POLICY_TEMPLATE, + STATUS_ROUTE_PATH, + LATEST_FINDINGS_RETENTION_POLICY, + CDR_MISCONFIGURATIONS_INDEX_PATTERN, +} from '@kbn/cloud-security-posture-common'; import type { SavedObjectsClientContract, Logger, ElasticsearchClient } from '@kbn/core/server'; import type { AgentPolicyServiceInterface, @@ -19,20 +26,15 @@ import { schema } from '@kbn/config-schema'; import { VersionedRoute } from '@kbn/core-http-server/src/versioning/types'; import { CLOUD_SECURITY_POSTURE_PACKAGE_NAME, - STATUS_ROUTE_PATH, LATEST_FINDINGS_INDEX_DEFAULT_NS, FINDINGS_INDEX_PATTERN, BENCHMARK_SCORE_INDEX_DEFAULT_NS, VULNERABILITIES_INDEX_PATTERN, - KSPM_POLICY_TEMPLATE, - CSPM_POLICY_TEMPLATE, POSTURE_TYPES, LATEST_VULNERABILITIES_INDEX_DEFAULT_NS, VULN_MGMT_POLICY_TEMPLATE, POSTURE_TYPE_ALL, LATEST_VULNERABILITIES_RETENTION_POLICY, - LATEST_FINDINGS_RETENTION_POLICY, - CDR_MISCONFIGURATIONS_INDEX_PATTERN, } from '../../../common/constants'; import type { CspApiRequestHandlerContext, diff --git a/x-pack/plugins/cloud_security_posture/server/saved_objects/data_views.ts b/x-pack/plugins/cloud_security_posture/server/saved_objects/data_views.ts index 8a9f44b3aec46c..e99f0365e6099f 100644 --- a/x-pack/plugins/cloud_security_posture/server/saved_objects/data_views.ts +++ b/x-pack/plugins/cloud_security_posture/server/saved_objects/data_views.ts @@ -15,11 +15,11 @@ import { DataViewAttributes } from '@kbn/data-views-plugin/common'; import { SpacesServiceStart } from '@kbn/spaces-plugin/server'; import { DataViewsServerPluginStart } from '@kbn/data-views-plugin/server'; import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common'; +import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; import { CDR_MISCONFIGURATIONS_DATA_VIEW_ID_PREFIX, CDR_MISCONFIGURATIONS_DATA_VIEW_NAME, - CDR_MISCONFIGURATIONS_INDEX_PATTERN, CDR_VULNERABILITIES_DATA_VIEW_ID_PREFIX, CDR_VULNERABILITIES_DATA_VIEW_NAME, CDR_VULNERABILITIES_INDEX_PATTERN, From 6600a3411768c36129413eb59dd18adf24792043 Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 23 Aug 2024 12:43:34 -0700 Subject: [PATCH 08/17] fix ci failure: forgot to edit some file --- .../public/components/fleet_extensions/policy_template_form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f70fb3a18f6900..f57b5d453d81ff 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 @@ -28,6 +28,7 @@ import type { PackagePolicyReplaceDefineStepExtensionComponentProps, } from '@kbn/fleet-plugin/public/types'; import { PackageInfo, PackagePolicy } from '@kbn/fleet-plugin/common'; +import { CSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; import { useParams } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; import { useIsSubscriptionStatusValid } from '../../common/hooks/use_is_subscription_status_valid'; @@ -39,7 +40,6 @@ import { CLOUDBEAT_AWS, CLOUDBEAT_VANILLA, CLOUDBEAT_VULN_MGMT_AWS, - CSPM_POLICY_TEMPLATE, SUPPORTED_POLICY_TEMPLATES, } from '../../../common/constants'; import { From 19d74512c90cd49012b2bc0e217e87737de24dd8 Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 23 Aug 2024 15:56:10 -0700 Subject: [PATCH 09/17] fix check types failure --- .../server/cloud_security/constants.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution_serverless/server/cloud_security/constants.ts b/x-pack/plugins/security_solution_serverless/server/cloud_security/constants.ts index cd5a6a79eed335..8eb74f781096a4 100644 --- a/x-pack/plugins/security_solution_serverless/server/cloud_security/constants.ts +++ b/x-pack/plugins/security_solution_serverless/server/cloud_security/constants.ts @@ -6,10 +6,12 @@ */ import { - CNVM_POLICY_TEMPLATE, CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE, CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN, +} from '@kbn/cloud-security-posture-common'; +import { + CNVM_POLICY_TEMPLATE, LATEST_VULNERABILITIES_INDEX_PATTERN, } from '@kbn/cloud-security-posture-plugin/common/constants'; import { INTEGRATION_PACKAGE_NAME } from '@kbn/cloud-defend-plugin/common/constants'; From 51b44b94be20f634a71cc3a000e678bbbac4fc07 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 23 Aug 2024 23:07:17 +0000 Subject: [PATCH 10/17] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/plugins/security_solution_serverless/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/security_solution_serverless/tsconfig.json b/x-pack/plugins/security_solution_serverless/tsconfig.json index b6bfbea1cc7be5..55a4882655dc76 100644 --- a/x-pack/plugins/security_solution_serverless/tsconfig.json +++ b/x-pack/plugins/security_solution_serverless/tsconfig.json @@ -45,5 +45,6 @@ "@kbn/discover-plugin", "@kbn/logging", "@kbn/integration-assistant-plugin", + "@kbn/cloud-security-posture-common", ] } From e2b8f4842be451fd131e73ed4d18dce8d18b26b4 Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 23 Aug 2024 16:25:24 -0700 Subject: [PATCH 11/17] fix failed FTR due to forgot updating imports on that file --- .../routes/helper/user_roles_utilites.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/cloud_security_posture_api/routes/helper/user_roles_utilites.ts b/x-pack/test/cloud_security_posture_api/routes/helper/user_roles_utilites.ts index 6716cc859f2784..ae51bbdf9e154f 100644 --- a/x-pack/test/cloud_security_posture_api/routes/helper/user_roles_utilites.ts +++ b/x-pack/test/cloud_security_posture_api/routes/helper/user_roles_utilites.ts @@ -5,8 +5,8 @@ * 2.0. */ +import { CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; import { - CDR_LATEST_NATIVE_MISCONFIGURATIONS_INDEX_PATTERN, BENCHMARK_SCORE_INDEX_PATTERN, LATEST_VULNERABILITIES_INDEX_PATTERN, ALERTS_INDEX_PATTERN, From 9f2814e99c8f0dd54dbcf03533e8150211e6ec7a Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 23 Aug 2024 23:46:05 +0000 Subject: [PATCH 12/17] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/test/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 160aa0a3d81f69..1173ef6b4d492f 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -179,6 +179,7 @@ "@kbn/cases-api-integration-test-plugin", "@kbn/security-solution-plugin/public/management/cypress", "@kbn/management-settings-ids", - "@kbn/mock-idp-utils" + "@kbn/mock-idp-utils", + "@kbn/cloud-security-posture-common" ] } From 113376a19b153366a2685ec76716b425b02463ad Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 23 Aug 2024 18:31:27 -0700 Subject: [PATCH 13/17] remove re exports and update imports of csp_finding related types to be directly from csp common package --- .../common/schemas/csp_finding.ts | 10 ---------- .../cloud_security_posture/common/types_old.ts | 11 +---------- .../cloud_security_posture/common/utils/helpers.ts | 2 +- .../no_findings_states/no_findings_states.tsx | 3 ++- .../public/components/no_vulnerabilities_states.tsx | 2 +- .../compliance_dashboard.test.tsx | 7 ++----- .../compliance_dashboard/compliance_dashboard.tsx | 7 ++----- .../public/pages/configurations/__mocks__/findings.ts | 2 +- .../configurations/configurations.handlers.mock.ts | 2 +- .../findings_detection_rule_counter.tsx | 2 +- .../findings_flyout/findings_flyout.tsx | 2 +- .../pages/configurations/findings_flyout/json_tab.tsx | 2 +- .../configurations/findings_flyout/overview_tab.tsx | 2 +- .../pages/configurations/findings_flyout/rule_tab.tsx | 2 +- .../configurations/findings_flyout/table_tab.tsx | 2 +- .../latest_findings/latest_findings_table.tsx | 2 +- .../latest_findings/use_latest_findings.ts | 2 +- .../server/lib/check_index_status.ts | 3 ++- .../routes/compliance_dashboard/get_clusters.ts | 2 +- .../server/routes/status/status.ts | 8 ++------ x-pack/plugins/cloud_security_posture/server/types.ts | 3 ++- .../apis/cloud_security_posture/helper.ts | 2 +- .../status/status_index_timeout.ts | 2 +- .../cloud_security_posture/status/status_indexed.ts | 2 +- .../cloud_security_posture/status/status_indexing.ts | 2 +- .../status/status_not_deployed_not_installed.ts | 2 +- .../status/status_unprivileged.ts | 2 +- .../status/status_waiting_for_results.ts | 2 +- .../cloud_security_posture/status/status_indexed.ts | 2 +- .../cloud_security_posture/status/status_indexing.ts | 2 +- .../status/status_not_deployed_not_installed.ts | 2 +- 31 files changed, 36 insertions(+), 62 deletions(-) delete mode 100644 x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts 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 deleted file mode 100644 index 2789e65a778d46..00000000000000 --- a/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts +++ /dev/null @@ -1,10 +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. - */ - -// TODO: this needs to be defined in a versioned schema - -export type { CspFinding } from '@kbn/cloud-security-posture-common'; diff --git a/x-pack/plugins/cloud_security_posture/common/types_old.ts b/x-pack/plugins/cloud_security_posture/common/types_old.ts index c034ecd1bfdab8..09c0d5e7b6cab7 100644 --- a/x-pack/plugins/cloud_security_posture/common/types_old.ts +++ b/x-pack/plugins/cloud_security_posture/common/types_old.ts @@ -6,20 +6,11 @@ */ import { type TypeOf } from '@kbn/config-schema'; import type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; -import { CspFinding } from './schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; import { SUPPORTED_CLOUDBEAT_INPUTS, SUPPORTED_POLICY_TEMPLATES } from './constants'; import { getComplianceDashboardSchema } from './schemas/stats'; -export type { - CspFinding, - IndexStatus, - IndexDetails, - BaseCspSetupBothPolicy, - BaseCspSetupStatus, - CspSetupStatus, -} from '@kbn/cloud-security-posture-common'; - export type AwsCredentialsType = | 'assume_role' | 'direct_access_keys' 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 6222b457e7ad68..529144aa6e853c 100644 --- a/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts +++ b/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts @@ -6,6 +6,7 @@ */ import { Truthy } from 'lodash'; +import { BaseCspSetupStatus } from '@kbn/cloud-security-posture-common'; import { NewPackagePolicy, NewPackagePolicyInput, @@ -25,7 +26,6 @@ import { import type { BenchmarkId, Score, - BaseCspSetupStatus, AwsCredentialsType, GcpCredentialsType, AzureCredentialsType, diff --git a/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx b/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx index 518f53bbc2d68a..f534496cee4b9a 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx @@ -21,6 +21,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; +import type { IndexDetails } from '@kbn/cloud-security-posture-common'; import { FullSizeCenteredPage } from '../full_size_centered_page'; import { useCISIntegrationPoliciesLink } from '../../common/navigation/use_navigate_to_cis_integration_policies'; import { @@ -30,7 +31,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, CspStatusCode } from '../../../common/types_old'; +import type { PostureTypes, CspStatusCode } from '../../../common/types_old'; import noDataIllustration from '../../assets/illustrations/no_data_illustration.svg'; import { useCspIntegrationLink } from '../../common/navigation/use_csp_integration_link'; import { NO_FINDINGS_STATUS_REFRESH_INTERVAL_MS } from '../../common/constants'; 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 a2b1aa1d0d8315..a15cf0aacd6fac 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 @@ -21,11 +21,11 @@ import { import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; +import type { IndexDetails } from '@kbn/cloud-security-posture-common'; 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_old'; import { NO_VULNERABILITIES_STATUS_TEST_SUBJ, CNVM_NOT_INSTALLED_ACTION_SUBJ, 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 915e135967defb..e2511fdd13f0af 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 @@ -8,6 +8,7 @@ import React from 'react'; import { coreMock } from '@kbn/core/public/mocks'; +import { BaseCspSetupStatus } from '@kbn/cloud-security-posture-common'; import { render, screen } from '@testing-library/react'; import { TestProvider } from '../../test/test_provider'; import { ComplianceDashboard, getDefaultTab } from '.'; @@ -31,11 +32,7 @@ import { KSPM_INTEGRATION_NOT_INSTALLED_TEST_SUBJECT, PACKAGE_NOT_INSTALLED_TEST_SUBJECT, } from '../../components/cloud_posture_page'; -import { - BaseCspSetupStatus, - ComplianceDashboardDataV2, - CspStatusCode, -} from '../../../common/types_old'; +import { ComplianceDashboardDataV2, CspStatusCode } from '../../../common/types_old'; import { cloudPosturePages } from '../../common/navigation/constants'; import { MemoryRouter } from 'react-router-dom'; 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 5ad3f12ef0fd0d..1629a000d5e641 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 @@ -14,13 +14,10 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { Route, Routes } from '@kbn/shared-ux-router'; import { Redirect, useHistory, useLocation } from 'react-router-dom'; import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; +import type { BaseCspSetupStatus } from '@kbn/cloud-security-posture-common'; import { NO_FINDINGS_STATUS_TEST_SUBJ } from '../../components/test_subjects'; import { useCspIntegrationLink } from '../../common/navigation/use_csp_integration_link'; -import type { - PosturePolicyTemplate, - ComplianceDashboardDataV2, - BaseCspSetupStatus, -} from '../../../common/types_old'; +import type { PosturePolicyTemplate, ComplianceDashboardDataV2 } 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/configurations/__mocks__/findings.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/__mocks__/findings.ts index 4b01603b4c03b0..296310f5c0d0bb 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/__mocks__/findings.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/__mocks__/findings.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CspFinding } from '../../../../common/schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; export const mockFindingsHit: CspFinding = { result: { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts index e79f737b11a3ca..475763db96147b 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts @@ -6,7 +6,7 @@ */ import { estypes } from '@elastic/elasticsearch'; -import { CspFinding } from '../../../common/schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; import { isArray } from 'lodash'; import { http, HttpResponse } from 'msw'; import { v4 as uuidV4 } from 'uuid'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_detection_rule_counter.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_detection_rule_counter.tsx index 0ab35a37c8ee48..56a69154867b37 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_detection_rule_counter.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_detection_rule_counter.tsx @@ -7,7 +7,7 @@ import type { HttpSetup } from '@kbn/core/public'; import React from 'react'; -import { CspFinding } from '../../../../common/schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; import { DetectionRuleCounter } from '../../../components/detection_rule_counter'; import { getFindingsDetectionRuleSearchTags } from '../../../../common/utils/detection_rules'; import { createDetectionRuleFromBenchmarkRule } from '../utils/create_detection_rule_from_benchmark'; 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 4d8c5b6569efdd..2c3eeca62a680c 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,11 +35,11 @@ import type { HttpSetup } from '@kbn/core/public'; import { generatePath } from 'react-router-dom'; import { css } from '@emotion/react'; import { euiThemeVars } from '@kbn/ui-theme'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; import { CSP_DATASET, getDatasetDisplayName } from '../../../common/utils/get_dataset_display_name'; import { truthy } from '../../../../common/utils/helpers'; import { benchmarksNavigation } from '../../../common/navigation/constants'; import cisLogoIcon from '../../../assets/icons/cis_logo.svg'; -import { CspFinding } from '../../../../common/schemas/csp_finding'; import { CspEvaluationBadge } from '../../../components/csp_evaluation_badge'; import { TakeAction } from '../../../components/take_action'; import { TableTab } from './table_tab'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/json_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/json_tab.tsx index 30f8237de91b05..df0e4cda904b78 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/json_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/json_tab.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { CodeEditor } from '@kbn/code-editor'; import { XJsonLang } from '@kbn/monaco'; -import { CspFinding } from '../../../../common/schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; export const JsonTab = ({ data }: { data: CspFinding }) => (
diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx index 7a751e6e3ce21f..d7651ca3732b5f 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx @@ -21,6 +21,7 @@ import { i18n } from '@kbn/i18n'; import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; import { FormattedMessage } from '@kbn/i18n-react'; import { isEmpty } from 'lodash'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; import { getDatasetDisplayName } from '../../../common/utils/get_dataset_display_name'; import { truthy } from '../../../../common/utils/helpers'; import { CSP_MOMENT_FORMAT } from '../../../common/constants'; @@ -30,7 +31,6 @@ import { } from '../../../../common/constants'; import { useDataView } from '../../../common/api/use_data_view'; import { useKibana } from '../../../common/hooks/use_kibana'; -import { CspFinding } from '../../../../common/schemas/csp_finding'; import { BenchmarkIcons, CodeBlock, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx index 6a7eea41410e91..6d1f9fe164df76 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx @@ -9,7 +9,7 @@ import { EuiBadge, EuiDescriptionList } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; -import { CspFinding } from '../../../../common/schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; import { RulesDetectionRuleCounter } from '../../rules/rules_detection_rule_counter'; import { BenchmarkIcons, CspFlyoutMarkdown, EMPTY_VALUE, RuleNameLink } from './findings_flyout'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/table_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/table_tab.tsx index 075291c434592e..1beeb8b662d7a0 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/table_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/table_tab.tsx @@ -15,7 +15,7 @@ import { import React from 'react'; import { getFlattenedObject } from '@kbn/std'; import { i18n } from '@kbn/i18n'; -import { CspFinding } from '../../../../common/schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; interface FlattenedItem { key: string; // flattened dot notation object path for CspFinding; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/latest_findings_table.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/latest_findings_table.tsx index 2d9e1c3f25ae1e..6641fcfbc980cd 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/latest_findings_table.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/latest_findings_table.tsx @@ -11,7 +11,7 @@ import { DataTableRecord } from '@kbn/discover-utils/types'; import { HttpSetup } from '@kbn/core-http-browser'; import { i18n } from '@kbn/i18n'; import { EuiDataGridCellValueElementProps, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import { CspFinding } from '../../../../common/schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; import { getDatasetDisplayName } from '../../../common/utils/get_dataset_display_name'; import * as TEST_SUBJECTS from '../test_subjects'; import { FindingsDistributionBar } from '../layout/findings_distribution_bar'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts index a021d7509d5357..fcb1f1d2297c01 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts @@ -16,8 +16,8 @@ import { CDR_MISCONFIGURATIONS_INDEX_PATTERN, LATEST_FINDINGS_RETENTION_POLICY, CspBenchmarkRulesStates, + CspFinding, } from '@kbn/cloud-security-posture-common'; -import { CspFinding } from '../../../../common/schemas/csp_finding'; import { useKibana } from '../../../common/hooks/use_kibana'; import type { FindingsBaseEsQuery } from '../../../common/types'; import { getAggregationCount, getFindingsCountAggQuery } from '../utils/utils'; 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 67eb611f9557e1..1c968bff37362d 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 @@ -6,8 +6,9 @@ */ import { ElasticsearchClient, type Logger } from '@kbn/core/server'; +import { IndexStatus } from '@kbn/cloud-security-posture-common'; import { getSafePostureTypeRuntimeMapping } from '../../common/runtime_mappings/get_safe_posture_type_runtime_mapping'; -import { IndexStatus, PostureTypes } from '../../common/types_old'; +import { PostureTypes } from '../../common/types_old'; export interface PostureTypeAndRetention { postureType?: PostureTypes; 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 e7938636213409..857f1e50b72a0c 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 @@ -15,7 +15,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 { CspFinding } from '../../../common/schemas/csp_finding'; +import { CspFinding } from '@kbn/cloud-security-posture-common'; import type { Cluster } from '../../../common/types_old'; import { getPostureStatsFromAggs, failedFindingsAggQuery } from './get_grouped_findings_evaluation'; import type { FailedFindingsQueryResult } from './get_grouped_findings_evaluation'; 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 7042c943afdad1..260a005ab189c5 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 @@ -13,6 +13,7 @@ import { LATEST_FINDINGS_RETENTION_POLICY, CDR_MISCONFIGURATIONS_INDEX_PATTERN, } from '@kbn/cloud-security-posture-common'; +import type { CspSetupStatus, IndexStatus } from '@kbn/cloud-security-posture-common'; import type { SavedObjectsClientContract, Logger, ElasticsearchClient } from '@kbn/core/server'; import type { AgentPolicyServiceInterface, @@ -42,12 +43,7 @@ import type { CspRouter, StatusResponseInfo, } from '../../types'; -import type { - CspSetupStatus, - CspStatusCode, - IndexStatus, - PostureTypes, -} from '../../../common/types_old'; +import type { CspStatusCode, PostureTypes } from '../../../common/types_old'; import { getAgentStatusesByAgentPolicies, getCspAgentPolicies, diff --git a/x-pack/plugins/cloud_security_posture/server/types.ts b/x-pack/plugins/cloud_security_posture/server/types.ts index 1190c0a1c5556e..6da6601a9478ee 100644 --- a/x-pack/plugins/cloud_security_posture/server/types.ts +++ b/x-pack/plugins/cloud_security_posture/server/types.ts @@ -30,12 +30,13 @@ import type { PackagePolicyClient, } from '@kbn/fleet-plugin/server'; import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server'; +import { IndexDetails } from '@kbn/cloud-security-posture-common'; import type { FleetStartContract, FleetRequestHandlerContext } from '@kbn/fleet-plugin/server'; import { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/server'; import type { AlertingApiRequestHandlerContext } from '@kbn/alerting-plugin/server'; import type { AlertingPluginSetup } from '@kbn/alerting-plugin/public/plugin'; import { SpacesPluginStart } from '@kbn/spaces-plugin/server'; -import { CspStatusCode, IndexDetails } from '../common/types_old'; +import { CspStatusCode } from '../common/types_old'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface CspServerPluginSetup {} 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 199cacf99dea27..13bc2ee7de9d2f 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 { Agent as SuperTestAgent } 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_old'; +import type { IndexDetails } from '@kbn/cloud-security-posture-common'; import { CLOUD_SECURITY_PLUGIN_VERSION } from '@kbn/cloud-security-posture-plugin/common/constants'; import { SecurityService } from '@kbn/test-suites-src/common/services/security/security'; 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 3eda0f6a7b01a2..b82140727fc248 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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; 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 5e6d639490e457..1793944480ac77 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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; 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 f55f5533718ed4..ab8345284380af 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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; 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 f67e2d5a0814bc..ef442c575981ae 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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; 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 e80e80c322568b..fe234e45e21f0a 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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; 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 a148f160bfd81e..bfb5321bdcba9a 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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; 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_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 1b44c42ecb22eb..ff0208459856f1 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 @@ -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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; 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 4e81938a597e98..80a07bd6ee79c0 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 @@ -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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; 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 eb7b6f4424c0d7..d3510ea98b7bb7 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_old'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; import { createPackagePolicy } from '@kbn/test-suites-xpack/api_integration/apis/cloud_security_posture/helper'; import { FtrProviderContext } from '../../../../ftr_provider_context'; From 3398ecfd53e80f5dd6b89980152dd823df7637f2 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Sat, 24 Aug 2024 01:45:46 +0000 Subject: [PATCH 14/17] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/test_serverless/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/test_serverless/tsconfig.json b/x-pack/test_serverless/tsconfig.json index b1f73748b5e0d2..310f87573b610b 100644 --- a/x-pack/test_serverless/tsconfig.json +++ b/x-pack/test_serverless/tsconfig.json @@ -101,5 +101,6 @@ "@kbn/ml-trained-models-utils", "@kbn/test-suites-src", "@kbn/console-plugin", + "@kbn/cloud-security-posture-common", ] } From 8c69b3e11df63e2fafbc21178808e5f8be1faaee Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 23 Aug 2024 20:23:34 -0700 Subject: [PATCH 15/17] fix check types failure + removed re-export and update import statement for types or interface to be directly from csp package now --- .../public/common/api/use_data_view.ts | 2 +- .../public/common/api/use_setup_status_api.ts | 2 +- .../public/common/hooks/use_kibana.ts | 2 +- .../plugins/cloud_security_posture/public/common/types.ts | 1 - .../public/pages/configurations/configurations.test.tsx | 2 +- .../configurations/latest_findings/use_latest_findings.ts | 2 +- .../pages/configurations/layout/findings_search_bar.tsx | 2 +- .../vulnerabilities/hooks/use_latest_vulnerabilities.tsx | 2 +- x-pack/plugins/cloud_security_posture/public/plugin.tsx | 8 ++------ .../public/test/mock_server/mock_server.ts | 2 +- .../public/test/mock_server/mock_server_test_provider.tsx | 2 +- .../cloud_security_posture/public/test/test_provider.tsx | 2 +- x-pack/plugins/cloud_security_posture/public/types.ts | 2 -- 13 files changed, 12 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/cloud_security_posture/public/common/api/use_data_view.ts b/x-pack/plugins/cloud_security_posture/public/common/api/use_data_view.ts index 41b40da90a6d4f..304230498d4f4c 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/api/use_data_view.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/api/use_data_view.ts @@ -8,7 +8,7 @@ import { useQuery } from '@tanstack/react-query'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common'; -import { CspClientPluginStartDeps } from '../../types'; +import { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; /** * Hook to retrieve a Data View by it's Index Pattern title 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 30721bdc5dd601..003f8417722853 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,8 +7,8 @@ import { useQuery, type UseQueryOptions } from '@tanstack/react-query'; import { STATUS_API_CURRENT_VERSION, STATUS_ROUTE_PATH } from '@kbn/cloud-security-posture-common'; +import type { CspSetupStatus } from '@kbn/cloud-security-posture-common'; import { useKibana } from '../hooks/use_kibana'; -import { type CspSetupStatus } from '../../../common/types_old'; const getCspSetupStatusQueryKey = 'csp_status_key'; diff --git a/x-pack/plugins/cloud_security_posture/public/common/hooks/use_kibana.ts b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_kibana.ts index 1c6f252080e11c..a392e9213dffcf 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/hooks/use_kibana.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_kibana.ts @@ -7,7 +7,7 @@ import type { CoreStart } from '@kbn/core/public'; import { useKibana as useKibanaBase } from '@kbn/kibana-react-plugin/public'; -import type { CspClientPluginStartDeps } from '../../types'; +import type { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; type CspKibanaContext = CoreStart & CspClientPluginStartDeps; diff --git a/x-pack/plugins/cloud_security_posture/public/common/types.ts b/x-pack/plugins/cloud_security_posture/public/common/types.ts index 4cc8479fb20791..62e0abe6776795 100644 --- a/x-pack/plugins/cloud_security_posture/public/common/types.ts +++ b/x-pack/plugins/cloud_security_posture/public/common/types.ts @@ -6,7 +6,6 @@ */ import type { Criteria } from '@elastic/eui'; import type { Filter, Query, EsQueryConfig } from '@kbn/es-query'; -export type { FindingsBaseEsQuery } from '@kbn/cloud-security-posture'; export interface FindingsBaseURLQuery { query: Query; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.test.tsx index 8b1d54b5a1798d..f782d90474a3c8 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.test.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.test.tsx @@ -17,7 +17,7 @@ import { MemoryRouter } from '@kbn/shared-ux-router'; import { findingsNavigation } from '../../common/navigation/constants'; import userEvent from '@testing-library/user-event'; import { FilterManager } from '@kbn/data-plugin/public'; -import { CspClientPluginStartDeps } from '../../types'; +import { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; import * as statusHandlers from '../../../server/routes/status/status.handlers.mock'; import { bsearchFindingsHandler, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts index fcb1f1d2297c01..2adae42e2819c0 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts @@ -18,8 +18,8 @@ import { CspBenchmarkRulesStates, CspFinding, } from '@kbn/cloud-security-posture-common'; +import type { FindingsBaseEsQuery } from '@kbn/cloud-security-posture'; import { useKibana } from '../../../common/hooks/use_kibana'; -import type { FindingsBaseEsQuery } from '../../../common/types'; import { getAggregationCount, getFindingsCountAggQuery } from '../utils/utils'; import { showErrorToast } from '../../../common/utils/show_error_toast'; import { useGetCspBenchmarkRulesStatesApi } from './use_get_benchmark_rules_state_api'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/layout/findings_search_bar.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/layout/findings_search_bar.tsx index 755ecb86c73ba2..61d4a5cc7d6dc2 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/layout/findings_search_bar.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/layout/findings_search_bar.tsx @@ -10,10 +10,10 @@ import { EuiThemeComputed, useEuiTheme } from '@elastic/eui'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { i18n } from '@kbn/i18n'; import type { Filter } from '@kbn/es-query'; +import type { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; import { useDataViewContext } from '../../../common/contexts/data_view_context'; import { SecuritySolutionContext } from '../../../application/security_solution_context'; import type { FindingsBaseURLQuery } from '../../../common/types'; -import type { CspClientPluginStartDeps } from '../../../types'; import { PLUGIN_NAME } from '../../../../common'; type SearchBarQueryProps = Pick; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx b/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx index 7ce1c5b6814df5..3b1d3a156f305d 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/hooks/use_latest_vulnerabilities.tsx @@ -17,6 +17,7 @@ import { import { buildDataTableRecord } from '@kbn/discover-utils'; import { EsHitRecord } from '@kbn/discover-utils/types'; import { MAX_FINDINGS_TO_LOAD } from '@kbn/cloud-security-posture-common'; +import { FindingsBaseEsQuery } from '@kbn/cloud-security-posture'; import { VULNERABILITY_FIELDS } from '../../../common/constants'; import { CspVulnerabilityFinding } from '../../../../common/schemas'; import { @@ -25,7 +26,6 @@ import { } from '../../../../common/constants'; import { useKibana } from '../../../common/hooks/use_kibana'; import { showErrorToast } from '../../../common/utils/show_error_toast'; -import { FindingsBaseEsQuery } from '../../../common/types'; import { getCaseInsensitiveSortScript } from '../utils/custom_sort_script'; type LatestFindingsRequest = IKibanaSearchRequest; type LatestFindingsResponse = IKibanaSearchResponse< diff --git a/x-pack/plugins/cloud_security_posture/public/plugin.tsx b/x-pack/plugins/cloud_security_posture/public/plugin.tsx index bf014f83c1b0d1..d07d930660ec65 100755 --- a/x-pack/plugins/cloud_security_posture/public/plugin.tsx +++ b/x-pack/plugins/cloud_security_posture/public/plugin.tsx @@ -9,14 +9,10 @@ import type { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; +import type { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; import { CspLoadingState } from './components/csp_loading_state'; import type { CspRouterProps } from './application/csp_router'; -import type { - CspClientPluginSetup, - CspClientPluginStart, - CspClientPluginSetupDeps, - CspClientPluginStartDeps, -} from './types'; +import type { CspClientPluginSetup, CspClientPluginStart, CspClientPluginSetupDeps } from './types'; import { CLOUD_SECURITY_POSTURE_PACKAGE_NAME } from '../common/constants'; import { SetupContext } from './application/setup_context'; diff --git a/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server.ts b/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server.ts index 999f130c275cc0..86ec3e3108f277 100644 --- a/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server.ts +++ b/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server.ts @@ -13,9 +13,9 @@ import { createStubDataView } from '@kbn/data-views-plugin/common/stubs'; import { indexPatternFieldEditorPluginMock as dataViewFieldEditorMock } from '@kbn/data-view-field-editor-plugin/public/mocks'; import SearchBar from '@kbn/unified-search-plugin/public/search_bar/search_bar'; import { http, HttpResponse, JsonBodyType } from 'msw'; +import { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; import { defaultHandlers } from './handlers'; import { getMockDependencies } from '../fixtures/get_mock_dependencies'; -import { CspClientPluginStartDeps } from '../../types'; import { MOCK_SERVER_LICENSING_INFO_URL } from './handlers/licensing.handlers.mock'; /** diff --git a/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server_test_provider.tsx b/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server_test_provider.tsx index 19143d46418363..0a2db4ca596435 100644 --- a/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server_test_provider.tsx +++ b/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server_test_provider.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import type { CoreStart } from '@kbn/core/public'; -import { CspClientPluginStartDeps } from '../../types'; +import { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; import { TestProvider } from '../test_provider'; import { getMockServerDependencies } from './mock_server'; interface MockServerDependencies { diff --git a/x-pack/plugins/cloud_security_posture/public/test/test_provider.tsx b/x-pack/plugins/cloud_security_posture/public/test/test_provider.tsx index ab3173ec8c5819..278ba2f0b1690c 100755 --- a/x-pack/plugins/cloud_security_posture/public/test/test_provider.tsx +++ b/x-pack/plugins/cloud_security_posture/public/test/test_provider.tsx @@ -14,7 +14,7 @@ import { Route, Routes } from '@kbn/shared-ux-router'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { coreMock } from '@kbn/core/public/mocks'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; -import type { CspClientPluginStartDeps } from '../types'; +import type { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; import { getMockDependencies } from './fixtures/get_mock_dependencies'; interface CspAppDeps { diff --git a/x-pack/plugins/cloud_security_posture/public/types.ts b/x-pack/plugins/cloud_security_posture/public/types.ts index 0993b906e6e195..f03d47e43575d1 100755 --- a/x-pack/plugins/cloud_security_posture/public/types.ts +++ b/x-pack/plugins/cloud_security_posture/public/types.ts @@ -15,8 +15,6 @@ import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; import type { CspRouterProps } from './application/csp_router'; import type { CloudSecurityPosturePageId } from './common/navigation/types'; -export type { CspClientPluginStartDeps } from '@kbn/cloud-security-posture'; - /** * The cloud security posture's public plugin setup interface. */ From 447c47bbb8a17c359ebf39037b140a7a2b0efc23 Mon Sep 17 00:00:00 2001 From: animehart Date: Sat, 24 Aug 2024 00:03:16 -0700 Subject: [PATCH 16/17] updating CspStatusCode imports to be directly from csp common package --- .../plugins/cloud_security_posture/common/types_old.ts | 9 --------- .../components/no_findings_states/no_findings_states.tsx | 4 ++-- .../compliance_dashboard/compliance_dashboard.test.tsx | 4 ++-- .../server/lib/telemetry/collectors/types.ts | 2 +- .../server/routes/status/status.ts | 8 ++++++-- x-pack/plugins/cloud_security_posture/server/types.ts | 2 +- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/cloud_security_posture/common/types_old.ts b/x-pack/plugins/cloud_security_posture/common/types_old.ts index 09c0d5e7b6cab7..f512fb5ffd87d1 100644 --- a/x-pack/plugins/cloud_security_posture/common/types_old.ts +++ b/x-pack/plugins/cloud_security_posture/common/types_old.ts @@ -100,15 +100,6 @@ export interface ComplianceDashboardDataV2 { benchmarks: BenchmarkData[]; } -export type CspStatusCode = - | 'indexed' // latest findings index exists and has results - | 'indexing' // index timeout was not surpassed since installation, assumes data is being indexed - | 'unprivileged' // user lacks privileges for the latest findings index - | 'index-timeout' // index timeout was surpassed since installation - | 'not-deployed' // no healthy agents were deployed - | 'not-installed' // number of installed csp integrations is 0; - | 'waiting_for_results'; // have healthy agents but no findings at all, assumes data is being indexed for the 1st time - export type BenchmarkId = CspBenchmarkRuleMetadata['benchmark']['id']; export type BenchmarkName = CspBenchmarkRuleMetadata['benchmark']['name']; export type RuleSection = CspBenchmarkRuleMetadata['section']; diff --git a/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx b/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx index f534496cee4b9a..096c6f0e8aae50 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/no_findings_states/no_findings_states.tsx @@ -21,7 +21,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '@kbn/cloud-security-posture-common'; -import type { IndexDetails } from '@kbn/cloud-security-posture-common'; +import type { IndexDetails, CspStatusCode } from '@kbn/cloud-security-posture-common'; import { FullSizeCenteredPage } from '../full_size_centered_page'; import { useCISIntegrationPoliciesLink } from '../../common/navigation/use_navigate_to_cis_integration_policies'; import { @@ -31,7 +31,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 { PostureTypes, CspStatusCode } from '../../../common/types_old'; +import type { PostureTypes } from '../../../common/types_old'; import noDataIllustration from '../../assets/illustrations/no_data_illustration.svg'; import { useCspIntegrationLink } from '../../common/navigation/use_csp_integration_link'; import { NO_FINDINGS_STATUS_REFRESH_INTERVAL_MS } from '../../common/constants'; 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 e2511fdd13f0af..49e91b86f0f96a 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 @@ -8,7 +8,7 @@ import React from 'react'; import { coreMock } from '@kbn/core/public/mocks'; -import { BaseCspSetupStatus } from '@kbn/cloud-security-posture-common'; +import { BaseCspSetupStatus, CspStatusCode } from '@kbn/cloud-security-posture-common'; import { render, screen } from '@testing-library/react'; import { TestProvider } from '../../test/test_provider'; import { ComplianceDashboard, getDefaultTab } from '.'; @@ -32,7 +32,7 @@ import { KSPM_INTEGRATION_NOT_INSTALLED_TEST_SUBJECT, PACKAGE_NOT_INSTALLED_TEST_SUBJECT, } from '../../components/cloud_posture_page'; -import { ComplianceDashboardDataV2, CspStatusCode } from '../../../common/types_old'; +import { ComplianceDashboardDataV2 } from '../../../common/types_old'; import { cloudPosturePages } from '../../common/navigation/constants'; import { MemoryRouter } from 'react-router-dom'; 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 d5db37879554b9..baa4601565c858 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_old'; +import { CspStatusCode } from '@kbn/cloud-security-posture-common'; export type CloudSecurityUsageCollectorType = | 'Indices' 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 260a005ab189c5..2434cf03c84737 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 @@ -13,7 +13,11 @@ import { LATEST_FINDINGS_RETENTION_POLICY, CDR_MISCONFIGURATIONS_INDEX_PATTERN, } from '@kbn/cloud-security-posture-common'; -import type { CspSetupStatus, IndexStatus } from '@kbn/cloud-security-posture-common'; +import type { + CspSetupStatus, + IndexStatus, + CspStatusCode, +} from '@kbn/cloud-security-posture-common'; import type { SavedObjectsClientContract, Logger, ElasticsearchClient } from '@kbn/core/server'; import type { AgentPolicyServiceInterface, @@ -43,7 +47,7 @@ import type { CspRouter, StatusResponseInfo, } from '../../types'; -import type { CspStatusCode, PostureTypes } from '../../../common/types_old'; +import type { PostureTypes } from '../../../common/types_old'; import { getAgentStatusesByAgentPolicies, getCspAgentPolicies, diff --git a/x-pack/plugins/cloud_security_posture/server/types.ts b/x-pack/plugins/cloud_security_posture/server/types.ts index 6da6601a9478ee..4f7492b6f02601 100644 --- a/x-pack/plugins/cloud_security_posture/server/types.ts +++ b/x-pack/plugins/cloud_security_posture/server/types.ts @@ -36,7 +36,7 @@ import { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/s import type { AlertingApiRequestHandlerContext } from '@kbn/alerting-plugin/server'; import type { AlertingPluginSetup } from '@kbn/alerting-plugin/public/plugin'; import { SpacesPluginStart } from '@kbn/spaces-plugin/server'; -import { CspStatusCode } from '../common/types_old'; +import { CspStatusCode } from '@kbn/cloud-security-posture-common'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface CspServerPluginSetup {} From ceafb0bbec9a63d5802fa4436c8c0e99ca6cbd2f Mon Sep 17 00:00:00 2001 From: animehart Date: Mon, 26 Aug 2024 08:00:26 -0700 Subject: [PATCH 17/17] PR Comments: Updated type imports to explicitly use import type instead of just import --- .../index.ts | 2 +- .../schema/csp_finding.ts | 84 ------------------- .../types.ts | 78 +++++++++++++++++ .../common/types/rules/v4.ts | 2 +- .../common/types_old.ts | 2 +- .../common/utils/helpers.ts | 2 +- .../common/utils/rules_states.ts | 2 +- .../compliance_dashboard.test.tsx | 2 +- .../configurations/__mocks__/findings.ts | 2 +- .../configurations.handlers.mock.ts | 2 +- .../findings_detection_rule_counter.tsx | 2 +- .../findings_flyout/findings_flyout.tsx | 2 +- .../findings_flyout/json_tab.tsx | 2 +- .../findings_flyout/overview_tab.tsx | 2 +- .../findings_flyout/rule_tab.tsx | 2 +- .../findings_flyout/table_tab.tsx | 2 +- .../latest_findings/latest_findings_table.tsx | 2 +- .../use_get_benchmark_rules_state_api.ts | 2 +- .../latest_findings/use_latest_findings.ts | 3 +- .../public/pages/rules/use_csp_rules_state.ts | 6 +- .../server/lib/check_index_status.ts | 2 +- .../benchmark_rules/bulk_action/utils.ts | 2 +- .../benchmark_rules/get_states/get_states.ts | 6 +- .../routes/benchmark_rules/get_states/v1.ts | 2 +- .../compliance_dashboard/get_clusters.ts | 2 +- .../cloud_security_posture/server/types.ts | 3 +- 26 files changed, 104 insertions(+), 116 deletions(-) delete mode 100644 x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts diff --git a/x-pack/packages/kbn-cloud-security-posture-common/index.ts b/x-pack/packages/kbn-cloud-security-posture-common/index.ts index e4f1d8468578e6..f4d7ac2e34dd9c 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/index.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/index.ts @@ -16,7 +16,7 @@ export type { BaseCspSetupBothPolicy, BaseCspSetupStatus, CspSetupStatus, + CspFinding, } from './types'; export * from './constants'; -export type { CspFinding } from './schema/csp_finding'; export type { CspBenchmarkRuleMetadata, CspBenchmarkRulesStates } from './schema/rules'; diff --git a/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts b/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts deleted file mode 100644 index ffd4220475c47a..00000000000000 --- a/x-pack/packages/kbn-cloud-security-posture-common/schema/csp_finding.ts +++ /dev/null @@ -1,84 +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 type { EcsDataStream, EcsEvent } from '@elastic/ecs'; -import { CspBenchmarkRuleMetadata } from './rules'; - -export interface CspFinding { - '@timestamp': string; - cluster_id?: string; - orchestrator?: CspFindingOrchestrator; - cloud?: CspFindingCloud; // only available on CSPM findings - result: CspFindingResult; - resource: CspFindingResource; - rule: CspBenchmarkRuleMetadata; - host: CspFindingHost; - event: EcsEvent; - data_stream: EcsDataStream; - agent: CspFindingAgent; - ecs: { - version: string; - }; -} - -interface CspFindingOrchestrator { - cluster?: { - id?: string; - name?: string; - }; -} - -interface CspFindingCloud { - provider: 'aws' | 'azure' | 'gcp'; - account: { - name: string; - id: string; - }; - region?: string; -} - -interface CspFindingResult { - evaluation: 'passed' | 'failed'; - expected?: Record; - evidence: Record; -} - -interface CspFindingResource { - name: string; - sub_type: string; - raw: object; - id: string; - type: string; - [other_keys: string]: unknown; -} - -interface CspFindingHost { - id: string; - containerized: boolean; - ip: string[]; - mac: string[]; - name: string; - hostname: string; - architecture: string; - os: { - kernel: string; - codename: string; - type: string; - platform: string; - version: string; - family: string; - name: string; - }; - [other_keys: string]: unknown; -} - -interface CspFindingAgent { - version: string; - // ephemeral_id: string; - id: string; - name: string; - type: string; -} diff --git a/x-pack/packages/kbn-cloud-security-posture-common/types.ts b/x-pack/packages/kbn-cloud-security-posture-common/types.ts index 87429bdc712ba5..7a9d5fee09c8f9 100644 --- a/x-pack/packages/kbn-cloud-security-posture-common/types.ts +++ b/x-pack/packages/kbn-cloud-security-posture-common/types.ts @@ -4,6 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +import type { EcsDataStream, EcsEvent } from '@elastic/ecs'; +import type { CspBenchmarkRuleMetadata } from './schema/rules'; export type CspStatusCode = | 'indexed' // latest findings index exists and has results @@ -42,3 +44,79 @@ export interface BaseCspSetupStatus { } export type CspSetupStatus = BaseCspSetupStatus; + +export interface CspFinding { + '@timestamp': string; + cluster_id?: string; + orchestrator?: CspFindingOrchestrator; + cloud?: CspFindingCloud; // only available on CSPM findings + result: CspFindingResult; + resource: CspFindingResource; + rule: CspBenchmarkRuleMetadata; + host: CspFindingHost; + event: EcsEvent; + data_stream: EcsDataStream; + agent: CspFindingAgent; + ecs: { + version: string; + }; +} + +interface CspFindingOrchestrator { + cluster?: { + id?: string; + name?: string; + }; +} + +interface CspFindingCloud { + provider: 'aws' | 'azure' | 'gcp'; + account: { + name: string; + id: string; + }; + region?: string; +} + +interface CspFindingResult { + evaluation: 'passed' | 'failed'; + expected?: Record; + evidence: Record; +} + +interface CspFindingResource { + name: string; + sub_type: string; + raw: object; + id: string; + type: string; + [other_keys: string]: unknown; +} + +interface CspFindingHost { + id: string; + containerized: boolean; + ip: string[]; + mac: string[]; + name: string; + hostname: string; + architecture: string; + os: { + kernel: string; + codename: string; + type: string; + platform: string; + version: string; + family: string; + name: string; + }; + [other_keys: string]: unknown; +} + +interface CspFindingAgent { + version: string; + // ephemeral_id: string; + id: string; + name: string; + type: string; +} diff --git a/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts b/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts index 2ff64e0108a73b..231fb4c65a9bb2 100644 --- a/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts +++ b/x-pack/plugins/cloud_security_posture/common/types/rules/v4.ts @@ -6,7 +6,7 @@ */ import { schema, TypeOf } from '@kbn/config-schema'; -import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; +import type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; import { ruleStateAttributes, rulesStates } from '@kbn/cloud-security-posture-common/schema'; import { BenchmarksCisId } from '../latest'; import { DEFAULT_BENCHMARK_RULES_PER_PAGE } from './v3'; diff --git a/x-pack/plugins/cloud_security_posture/common/types_old.ts b/x-pack/plugins/cloud_security_posture/common/types_old.ts index f512fb5ffd87d1..b5e399e4e639ca 100644 --- a/x-pack/plugins/cloud_security_posture/common/types_old.ts +++ b/x-pack/plugins/cloud_security_posture/common/types_old.ts @@ -6,7 +6,7 @@ */ import { type TypeOf } from '@kbn/config-schema'; import type { CspBenchmarkRuleMetadata } from '@kbn/cloud-security-posture-common'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; import { SUPPORTED_CLOUDBEAT_INPUTS, SUPPORTED_POLICY_TEMPLATES } from './constants'; import { getComplianceDashboardSchema } from './schemas/stats'; 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 529144aa6e853c..950803c2c65c9e 100644 --- a/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts +++ b/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts @@ -6,7 +6,7 @@ */ import { Truthy } from 'lodash'; -import { BaseCspSetupStatus } from '@kbn/cloud-security-posture-common'; +import type { BaseCspSetupStatus } from '@kbn/cloud-security-posture-common'; import { NewPackagePolicy, NewPackagePolicyInput, diff --git a/x-pack/plugins/cloud_security_posture/common/utils/rules_states.ts b/x-pack/plugins/cloud_security_posture/common/utils/rules_states.ts index 2a55a20a136ccd..9a142729e410b3 100644 --- a/x-pack/plugins/cloud_security_posture/common/utils/rules_states.ts +++ b/x-pack/plugins/cloud_security_posture/common/utils/rules_states.ts @@ -5,7 +5,7 @@ * 2.0. */ import { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types'; -import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; +import type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; export const buildMutedRulesFilter = ( rulesStates: CspBenchmarkRulesStates 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 49e91b86f0f96a..46b0e59612083a 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 @@ -8,7 +8,7 @@ import React from 'react'; import { coreMock } from '@kbn/core/public/mocks'; -import { BaseCspSetupStatus, CspStatusCode } from '@kbn/cloud-security-posture-common'; +import type { BaseCspSetupStatus, CspStatusCode } from '@kbn/cloud-security-posture-common'; import { render, screen } from '@testing-library/react'; import { TestProvider } from '../../test/test_provider'; import { ComplianceDashboard, getDefaultTab } from '.'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/__mocks__/findings.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/__mocks__/findings.ts index 296310f5c0d0bb..4693459c0985d7 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/__mocks__/findings.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/__mocks__/findings.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; export const mockFindingsHit: CspFinding = { result: { diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts index 475763db96147b..10e79145cd02e6 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts @@ -6,7 +6,7 @@ */ import { estypes } from '@elastic/elasticsearch'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; import { isArray } from 'lodash'; import { http, HttpResponse } from 'msw'; import { v4 as uuidV4 } from 'uuid'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_detection_rule_counter.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_detection_rule_counter.tsx index 56a69154867b37..7a3ef68a21ad97 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_detection_rule_counter.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/findings_detection_rule_counter.tsx @@ -7,7 +7,7 @@ import type { HttpSetup } from '@kbn/core/public'; import React from 'react'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; import { DetectionRuleCounter } from '../../../components/detection_rule_counter'; import { getFindingsDetectionRuleSearchTags } from '../../../../common/utils/detection_rules'; import { createDetectionRuleFromBenchmarkRule } from '../utils/create_detection_rule_from_benchmark'; 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 2c3eeca62a680c..e1086f81367a3f 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,7 +35,7 @@ import type { HttpSetup } from '@kbn/core/public'; import { generatePath } from 'react-router-dom'; import { css } from '@emotion/react'; import { euiThemeVars } from '@kbn/ui-theme'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; import { CSP_DATASET, getDatasetDisplayName } from '../../../common/utils/get_dataset_display_name'; import { truthy } from '../../../../common/utils/helpers'; import { benchmarksNavigation } from '../../../common/navigation/constants'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/json_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/json_tab.tsx index df0e4cda904b78..712ea0399cf1df 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/json_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/json_tab.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { CodeEditor } from '@kbn/code-editor'; import { XJsonLang } from '@kbn/monaco'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; export const JsonTab = ({ data }: { data: CspFinding }) => (
diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx index d7651ca3732b5f..d25d6d63d213f0 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/overview_tab.tsx @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { CDR_MISCONFIGURATIONS_INDEX_PATTERN } from '@kbn/cloud-security-posture-common'; import { FormattedMessage } from '@kbn/i18n-react'; import { isEmpty } from 'lodash'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; import { getDatasetDisplayName } from '../../../common/utils/get_dataset_display_name'; import { truthy } from '../../../../common/utils/helpers'; import { CSP_MOMENT_FORMAT } from '../../../common/constants'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx index 6d1f9fe164df76..26007205f43fe5 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/rule_tab.tsx @@ -9,7 +9,7 @@ import { EuiBadge, EuiDescriptionList } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; import { RulesDetectionRuleCounter } from '../../rules/rules_detection_rule_counter'; import { BenchmarkIcons, CspFlyoutMarkdown, EMPTY_VALUE, RuleNameLink } from './findings_flyout'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/table_tab.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/table_tab.tsx index 1beeb8b662d7a0..ad449c4ddccdc2 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/table_tab.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/findings_flyout/table_tab.tsx @@ -15,7 +15,7 @@ import { import React from 'react'; import { getFlattenedObject } from '@kbn/std'; import { i18n } from '@kbn/i18n'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; interface FlattenedItem { key: string; // flattened dot notation object path for CspFinding; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/latest_findings_table.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/latest_findings_table.tsx index 6641fcfbc980cd..209c5ed2b2d067 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/latest_findings_table.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/latest_findings_table.tsx @@ -11,7 +11,7 @@ import { DataTableRecord } from '@kbn/discover-utils/types'; import { HttpSetup } from '@kbn/core-http-browser'; import { i18n } from '@kbn/i18n'; import { EuiDataGridCellValueElementProps, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; import { getDatasetDisplayName } from '../../../common/utils/get_dataset_display_name'; import * as TEST_SUBJECTS from '../test_subjects'; import { FindingsDistributionBar } from '../layout/findings_distribution_bar'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_get_benchmark_rules_state_api.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_get_benchmark_rules_state_api.ts index ddc626c169ed74..cf79ef80b11969 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_get_benchmark_rules_state_api.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_get_benchmark_rules_state_api.ts @@ -9,8 +9,8 @@ import { useQuery } from '@tanstack/react-query'; import { CSP_GET_BENCHMARK_RULES_STATE_API_CURRENT_VERSION, CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH, - CspBenchmarkRulesStates, } from '@kbn/cloud-security-posture-common'; +import type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; import { useKibana } from '../../../common/hooks/use_kibana'; export const getRuleStatesKey = ['get_rules_state_key']; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts index 2adae42e2819c0..5a77337ba171c2 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/latest_findings/use_latest_findings.ts @@ -15,9 +15,8 @@ import { MAX_FINDINGS_TO_LOAD } from '@kbn/cloud-security-posture-common'; import { CDR_MISCONFIGURATIONS_INDEX_PATTERN, LATEST_FINDINGS_RETENTION_POLICY, - CspBenchmarkRulesStates, - CspFinding, } from '@kbn/cloud-security-posture-common'; +import type { CspBenchmarkRulesStates, CspFinding } from '@kbn/cloud-security-posture-common'; import type { FindingsBaseEsQuery } from '@kbn/cloud-security-posture'; import { useKibana } from '../../../common/hooks/use_kibana'; import { getAggregationCount, getFindingsCountAggQuery } from '../utils/utils'; diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules_state.ts b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules_state.ts index f488754e3f673a..640dc922744818 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules_state.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/use_csp_rules_state.ts @@ -6,10 +6,8 @@ */ import { useQuery } from '@tanstack/react-query'; -import { - CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH, - CspBenchmarkRulesStates, -} from '@kbn/cloud-security-posture-common'; +import { CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH } from '@kbn/cloud-security-posture-common'; +import type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; import { useKibana } from '../../common/hooks/use_kibana'; export const CSP_RULES_STATES_QUERY_KEY = ['csp_rules_states_v1']; 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 1c968bff37362d..85d4a7f76a5c96 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 @@ -6,7 +6,7 @@ */ import { ElasticsearchClient, type Logger } from '@kbn/core/server'; -import { IndexStatus } from '@kbn/cloud-security-posture-common'; +import type { IndexStatus } from '@kbn/cloud-security-posture-common'; import { getSafePostureTypeRuntimeMapping } from '../../common/runtime_mappings/get_safe_posture_type_runtime_mapping'; import { PostureTypes } from '../../common/types_old'; diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/bulk_action/utils.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/bulk_action/utils.ts index 1f179d87fdcc80..e733f6cc96003f 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/bulk_action/utils.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/bulk_action/utils.ts @@ -6,7 +6,7 @@ */ import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server'; -import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; +import type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; import type { FindResult, RulesClient } from '@kbn/alerting-plugin/server'; import type { RuleParams } from '@kbn/alerting-plugin/server/application/rule/types'; import type { diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/get_states.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/get_states.ts index 79615644494162..44dd77cc67059b 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/get_states.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/get_states.ts @@ -6,10 +6,8 @@ */ import { transformError } from '@kbn/securitysolution-es-utils'; -import { - CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH, - CspBenchmarkRulesStates, -} from '@kbn/cloud-security-posture-common'; +import { CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH } from '@kbn/cloud-security-posture-common'; +import type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; import { CspRouter } from '../../../types'; import { getCspBenchmarkRulesStatesHandler } from './v1'; diff --git a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts index 6a72ef5ea2880b..1c7ddccf91bba0 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/benchmark_rules/get_states/v1.ts @@ -10,7 +10,7 @@ import { } from '@kbn/core-saved-objects-api-server'; import { transformError } from '@kbn/securitysolution-es-utils'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; +import type { CspBenchmarkRulesStates } from '@kbn/cloud-security-posture-common'; import { CspSettings } from '../../../../common/types/rules/v4'; import { INTERNAL_CSP_SETTINGS_SAVED_OBJECT_ID, 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 857f1e50b72a0c..4cb7ec3c918e6e 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 @@ -15,7 +15,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 { CspFinding } from '@kbn/cloud-security-posture-common'; +import type { CspFinding } from '@kbn/cloud-security-posture-common'; import type { Cluster } from '../../../common/types_old'; import { getPostureStatsFromAggs, failedFindingsAggQuery } from './get_grouped_findings_evaluation'; import type { FailedFindingsQueryResult } from './get_grouped_findings_evaluation'; diff --git a/x-pack/plugins/cloud_security_posture/server/types.ts b/x-pack/plugins/cloud_security_posture/server/types.ts index 4f7492b6f02601..4524cab151dd29 100644 --- a/x-pack/plugins/cloud_security_posture/server/types.ts +++ b/x-pack/plugins/cloud_security_posture/server/types.ts @@ -30,13 +30,12 @@ import type { PackagePolicyClient, } from '@kbn/fleet-plugin/server'; import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server'; -import { IndexDetails } from '@kbn/cloud-security-posture-common'; +import type { CspStatusCode, IndexDetails } from '@kbn/cloud-security-posture-common'; import type { FleetStartContract, FleetRequestHandlerContext } from '@kbn/fleet-plugin/server'; import { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/server'; import type { AlertingApiRequestHandlerContext } from '@kbn/alerting-plugin/server'; import type { AlertingPluginSetup } from '@kbn/alerting-plugin/public/plugin'; import { SpacesPluginStart } from '@kbn/spaces-plugin/server'; -import { CspStatusCode } from '@kbn/cloud-security-posture-common'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface CspServerPluginSetup {}