Move Findings Flyout to Security Solution or Shared Package Phase 1 (#212053)

## Summary

As a part of Expandable Findings flyout, we will need to move some
Constants, Types, Functions, Components into Security Solution plugin or
Shared package

This PR is phase 1 for Findings (Misconfiguration flyout) which include
moving constants and types into shared package or security solution
plugin

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Rickyanto Ang 2025-02-26 00:53:24 -08:00 committed by GitHub
parent c9616593c1
commit 9d1d297ae9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 101 additions and 49 deletions

View file

@ -41,6 +41,8 @@ export const LATEST_VULNERABILITIES_RETENTION_POLICY = '3d';
// meant as a temp workaround to get good enough posture view for 3rd party integrations, see https://github.com/elastic/security-team/issues/10683
export const CDR_3RD_PARTY_RETENTION_POLICY = '90d';
export const CSP_MISCONFIGURATIONS_DATASET = 'cloud_security_posture.findings';
export const VULNERABILITIES_SEVERITY: Record<VulnSeverity, VulnSeverity> = {
LOW: 'LOW',
MEDIUM: 'MEDIUM',
@ -54,3 +56,12 @@ export const MISCONFIGURATION_STATUS: Record<string, MisconfigurationEvaluationS
FAILED: 'failed',
UNKNOWN: 'unknown',
};
export const CSP_MOMENT_FORMAT = 'MMMM D, YYYY @ HH:mm:ss.SSS';
// A mapping of in-development features to their status. These features should be hidden from users but can be easily
// activated via a simple code change in a single location.
export const INTERNAL_FEATURE_FLAGS = {
showManageRulesMock: false,
showFindingFlyoutEvidence: true,
} as const;

View file

@ -24,6 +24,13 @@ export type {
} from './schema/vulnerabilities/csp_vulnerability_finding';
export type { BenchmarksCisId } from './types/benchmark';
export type { VulnSeverity } from './types/vulnerabilities';
export type { BenchmarkId, BenchmarkName } from './types/types_old';
export type {
CspNavigationItem,
CspPageNavigationItem,
CspBenchmarksPage,
CloudSecurityPosturePageId,
} from './types/navigation';
export type { MisconfigurationEvaluationStatus } from './types/misconfigurations';
export * from './constants';
export {

View file

@ -0,0 +1,34 @@
/*
* 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 interface CspNavigationItem {
readonly name: string;
readonly path: string;
readonly disabled?: boolean;
}
export interface CspPageNavigationItem extends CspNavigationItem {
id: CloudSecurityPosturePageId;
}
export type CspPage =
| 'dashboard'
| 'cspm_dashboard'
| 'kspm_dashboard'
| 'vulnerability_dashboard'
| 'findings'
| 'benchmarks';
export type CspBenchmarksPage = 'rules';
export type CloudSecurityPosturePageId =
| 'cloud_security_posture-dashboard'
| 'cloud_security_posture-cspm-dashboard'
| 'cloud_security_posture-kspm-dashboard'
| 'cloud_security_posture-vulnerability_dashboard'
| 'cloud_security_posture-findings'
| 'cloud_security_posture-benchmarks'
| 'cloud_security_posture-benchmarks-rules';

View file

@ -0,0 +1,11 @@
/*
* 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 { CspBenchmarkRuleMetadata } from '../schema/rules/latest';
export type BenchmarkId = CspBenchmarkRuleMetadata['benchmark']['id'];
export type BenchmarkName = CspBenchmarkRuleMetadata['benchmark']['name'];

View file

@ -5,7 +5,11 @@
* 2.0.
*/
import { CLOUD_SECURITY_POSTURE_BASE_PATH } from '@kbn/cloud-security-posture-common';
import {
CLOUD_SECURITY_POSTURE_BASE_PATH,
CspBenchmarksPage,
CspPageNavigationItem,
} from '@kbn/cloud-security-posture-common';
import { i18n } from '@kbn/i18n';
export const NAV_ITEMS_NAMES = {
@ -59,3 +63,11 @@ export const findingsNavigation = {
id: 'cloud_security_posture-findings-vulnerabilities-resourceId',
},
};
export const benchmarksNavigation: Record<CspBenchmarksPage, CspPageNavigationItem> = {
rules: {
name: NAV_ITEMS_NAMES.RULES,
path: `${CLOUD_SECURITY_POSTURE_BASE_PATH}/benchmarks/:benchmarkId/:benchmarkVersion/rules/:ruleId?`,
id: 'cloud_security_posture-benchmarks-rules',
},
};

View file

@ -77,13 +77,6 @@ export const POSTURE_TYPE_ALL = 'all';
export const CSPM_FINDINGS_STATS_INTERVAL = 5;
// A mapping of in-development features to their status. These features should be hidden from users but can be easily
// activated via a simple code change in a single location.
export const INTERNAL_FEATURE_FLAGS = {
showManageRulesMock: false,
showFindingFlyoutEvidence: true,
} as const;
export const CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE = 'csp-rule-template';
export const INTERNAL_CSP_SETTINGS_SAVED_OBJECT_TYPE = 'cloud-security-posture-settings';
export const INTERNAL_CSP_SETTINGS_SAVED_OBJECT_ID = 'csp-internal-settings';

View file

@ -103,8 +103,6 @@ export interface ComplianceDashboardDataV2 {
benchmarks: BenchmarkData[];
}
export type BenchmarkId = CspBenchmarkRuleMetadata['benchmark']['id'];
export type BenchmarkName = CspBenchmarkRuleMetadata['benchmark']['name'];
export type RuleSection = CspBenchmarkRuleMetadata['section'];
// Fleet Integration types

View file

@ -15,6 +15,7 @@ import {
PackagePolicyInput,
UpdatePackagePolicy,
} from '@kbn/fleet-plugin/common';
import type { BenchmarkId } from '@kbn/cloud-security-posture-common';
import type { BenchmarkRuleSelectParams } from '@kbn/cloud-security-posture-common/schema/rules/latest';
import type { BenchmarkRuleSelectParams as BenchmarkRuleSelectParamsV4 } from '@kbn/cloud-security-posture-common/schema/rules/v4';
import {
@ -26,7 +27,6 @@ import {
AZURE_CREDENTIALS_TYPE_TO_FIELDS_MAP,
} from '../constants';
import type {
BenchmarkId,
Score,
AwsCredentialsType,
GcpCredentialsType,

View file

@ -9,7 +9,8 @@ import React from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Redirect } from 'react-router-dom';
import { Routes, Route } from '@kbn/shared-ux-router';
import { benchmarksNavigation, cloudPosturePages } from '../common/navigation/constants';
import { benchmarksNavigation } from '@kbn/cloud-security-posture';
import { cloudPosturePages } from '../common/navigation/constants';
import type { CspSecuritySolutionContext } from '..';
import { SecuritySolutionContext } from './security_solution_context';
import * as pages from '../pages';

View file

@ -23,7 +23,6 @@ import {
import eksLogo from '../assets/icons/cis_eks_logo.svg';
import googleCloudLogo from '../assets/icons/google_cloud_logo.svg';
export const CSP_MOMENT_FORMAT = 'MMMM D, YYYY @ HH:mm:ss.SSS';
export const DEFAULT_VISIBLE_ROWS_PER_PAGE = 25;
export const LOCAL_STORAGE_DATA_TABLE_PAGE_SIZE_KEY = 'cloudPosture:dataTable:pageSize';

View file

@ -12,7 +12,7 @@ import {
} from '@kbn/cloud-security-posture-common';
import { NAV_ITEMS_NAMES } from '@kbn/cloud-security-posture/src/constants/navigation';
import { CNVM_POLICY_TEMPLATE } from '../../../common/constants';
import type { CspBenchmarksPage, CspPage, CspPageNavigationItem } from './types';
import type { CspPage, CspPageNavigationItem } from './types';
const CSPM_DASHBOARD_TAB_NAME = 'Cloud';
const KSPM_DASHBOARD_TAB_NAME = 'Kubernetes';
@ -50,14 +50,6 @@ export const cloudPosturePages: Record<CspPage, CspPageNavigationItem> = {
},
};
export const benchmarksNavigation: Record<CspBenchmarksPage, CspPageNavigationItem> = {
rules: {
name: NAV_ITEMS_NAMES.RULES,
path: `${CLOUD_SECURITY_POSTURE_BASE_PATH}/benchmarks/:benchmarkId/:benchmarkVersion/rules/:ruleId?`,
id: 'cloud_security_posture-benchmarks-rules',
},
};
const ELASTIC_BASE_SHORT_URL = 'https://ela.st';
export const cspIntegrationDocsNavigation = {

View file

@ -8,7 +8,6 @@
import { CspFinding, CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common';
import { isNativeCspFinding } from './is_native_csp_finding';
export const CSP_MISCONFIGURATIONS_DATASET = 'cloud_security_posture.findings';
export const CSP_VULN_DATASET = 'cloud_security_posture.vulnerabilities';
export const WIZ_MISCONFIGURATIONS_DATASET = 'wiz.cloud_configuration_finding';
export const WIZ_VULN_DATASET = 'wiz.vulnerability';

View file

@ -4,9 +4,10 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { CSP_MISCONFIGURATIONS_DATASET, CSP_VULN_DATASET } from './get_vendor_name';
import { CSP_VULN_DATASET } from './get_vendor_name';
import { isNativeCspFinding } from './is_native_csp_finding';
import { CspFinding } from '@kbn/cloud-security-posture-common';
import { CSP_MISCONFIGURATIONS_DATASET } from '@kbn/cloud-security-posture-common';
import { CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common/schema/vulnerabilities/csp_vulnerability_finding';
describe('isNativeCspFinding', () => {

View file

@ -5,9 +5,9 @@
* 2.0.
*/
import { CspFinding } from '@kbn/cloud-security-posture-common';
import { CspFinding, CSP_MISCONFIGURATIONS_DATASET } from '@kbn/cloud-security-posture-common';
import { CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common/schema/vulnerabilities/csp_vulnerability_finding';
import { CSP_MISCONFIGURATIONS_DATASET, CSP_VULN_DATASET } from './get_vendor_name';
import { CSP_VULN_DATASET } from './get_vendor_name';
export const isNativeCspFinding = (finding: CspFinding | CspVulnerabilityFinding) =>
finding.data_stream?.dataset === CSP_MISCONFIGURATIONS_DATASET ||

View file

@ -8,7 +8,7 @@
import React from 'react';
import { EuiIcon, EuiToolTip, IconSize } from '@elastic/eui';
import { CSSInterpolation } from '@emotion/serialize';
import type { BenchmarkId } from '../../common/types_old';
import type { BenchmarkId } from '@kbn/cloud-security-posture-common';
import cisEksIcon from '../assets/icons/cis_eks_logo.svg';
import googleCloudLogo from '../assets/icons/google_cloud_logo.svg';

View file

@ -10,10 +10,11 @@ import { type CustomAssetsAccordionProps, CustomAssetsAccordion } from '@kbn/fle
import { i18n } from '@kbn/i18n';
import { useParams } from 'react-router-dom';
import { EuiSpacer } from '@elastic/eui';
import { benchmarksNavigation } from '@kbn/cloud-security-posture';
import { CloudSecurityPolicyTemplate } from '../../../common/types_old';
import { VULN_MGMT_POLICY_TEMPLATE } from '../../../common/constants';
import { useKibana } from '../../common/hooks/use_kibana';
import { benchmarksNavigation, cloudPosturePages } from '../../common/navigation/constants';
import { cloudPosturePages } from '../../common/navigation/constants';
const SECURITY_APP_NAME = 'securitySolutionUI';

View file

@ -9,7 +9,7 @@ import React from 'react';
import moment, { type MomentInput } from 'moment';
import { css } from '@emotion/react';
import { EuiToolTip } from '@elastic/eui';
import { CSP_MOMENT_FORMAT } from '../common/constants';
import { CSP_MOMENT_FORMAT } from '@kbn/cloud-security-posture-common';
// Offset top-aligned tooltips so that cell actions are visible
const datagridToolTipOffset = css`

View file

@ -23,6 +23,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { generatePath } from 'react-router-dom';
import type { BenchmarksCisId } from '@kbn/cloud-security-posture-common';
import { useNavigateFindings } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { benchmarksNavigation } from '@kbn/cloud-security-posture';
import { FINDINGS_GROUPING_OPTIONS } from '../../common/constants';
import type { BenchmarkScore, Benchmark } from '../../../common/types/latest';
import * as TEST_SUBJ from './test_subjects';
@ -31,7 +32,6 @@ import { FullSizeCenteredPage } from '../../components/full_size_centered_page';
import { ComplianceScoreBar } from '../../components/compliance_score_bar';
import { getBenchmarkCisName, getBenchmarkApplicableTo } from '../../../common/utils/helpers';
import { CISBenchmarkIcon } from '../../components/cis_benchmark_icon';
import { benchmarksNavigation } from '../../common/navigation/constants';
import {
GetBenchmarkDynamicValues,
useBenchmarkDynamicValues,

View file

@ -34,30 +34,28 @@ import { i18n } from '@kbn/i18n';
import type { HttpSetup } from '@kbn/core/public';
import { generatePath } from 'react-router-dom';
import { css } from '@emotion/react';
import { CspEvaluationBadge } from '@kbn/cloud-security-posture';
import type { CspFinding } from '@kbn/cloud-security-posture-common';
import { CspEvaluationBadge, benchmarksNavigation } from '@kbn/cloud-security-posture';
import type { CspFinding, BenchmarkId } from '@kbn/cloud-security-posture-common';
import { BenchmarkName, CSP_MISCONFIGURATIONS_DATASET } from '@kbn/cloud-security-posture-common';
import { CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common/schema/vulnerabilities/csp_vulnerability_finding';
import { isNativeCspFinding } from '../../../common/utils/is_native_csp_finding';
import {
CSP_MISCONFIGURATIONS_DATASET,
getVendorName,
} from '../../../common/utils/get_vendor_name';
import { getVendorName } from '../../../common/utils/get_vendor_name';
import { truthy } from '../../../../common/utils/helpers';
import { benchmarksNavigation } from '../../../common/navigation/constants';
import cisLogoIcon from '../../../assets/icons/cis_logo.svg';
import { TakeAction } from '../../../components/take_action';
import { TableTab } from './table_tab';
import { JsonTab } from './json_tab';
import { OverviewTab } from './overview_tab';
import { RuleTab } from './rule_tab';
import type { BenchmarkId } from '../../../../common/types_old';
import { CISBenchmarkIcon } from '../../../components/cis_benchmark_icon';
import { BenchmarkName } from '../../../../common/types_old';
import { FINDINGS_FLYOUT, FINDINGS_MISCONFIGS_FLYOUT_DESCRIPTION_LIST } from '../test_subjects';
import { useKibana } from '../../../common/hooks/use_kibana';
import { createDetectionRuleFromBenchmarkRule } from '../utils/create_detection_rule_from_benchmark';
import { CspInlineDescriptionList } from '../../../components/csp_inline_description_list';
const FINDINGS_MISCONFIGS_FLYOUT_DESCRIPTION_LIST = 'misconfigs-findings-flyout-description-list';
const FINDINGS_FLYOUT = 'findings_flyout';
const tabs = [
{
id: 'overview',

View file

@ -21,6 +21,8 @@ import { i18n } from '@kbn/i18n';
import {
CDR_MISCONFIGURATIONS_INDEX_PATTERN,
CDR_MISCONFIGURATIONS_DATA_VIEW_ID_PREFIX,
CSP_MOMENT_FORMAT,
INTERNAL_FEATURE_FLAGS,
} from '@kbn/cloud-security-posture-common';
import { FormattedMessage } from '@kbn/i18n-react';
import { isEmpty } from 'lodash';
@ -28,8 +30,6 @@ import type { CspFinding } from '@kbn/cloud-security-posture-common';
import { useDataView } from '@kbn/cloud-security-posture/src/hooks/use_data_view';
import { getVendorName } from '../../../common/utils/get_vendor_name';
import { truthy } from '../../../../common/utils/helpers';
import { CSP_MOMENT_FORMAT } from '../../../common/constants';
import { INTERNAL_FEATURE_FLAGS } from '../../../../common/constants';
import { useKibana } from '../../../common/hooks/use_kibana';
import {
BenchmarkIcons,

View file

@ -5,12 +5,7 @@
* 2.0.
*/
export const FINDINGS_FLYOUT = 'findings_flyout';
export const LATEST_FINDINGS_CONTAINER = 'latest_findings_container';
export const LATEST_FINDINGS_TABLE = 'latest_findings_table';
export const FINDINGS_GROUPING_COUNTER = 'findings_grouping_counter';
export const FINDINGS_MISCONFIGS_FLYOUT_DESCRIPTION_LIST =
'misconfigs-findings-flyout-description-list';

View file

@ -15,7 +15,7 @@ import type {
import { extractErrorMessage } from '@kbn/cloud-security-posture-common';
import semVerCompare from 'semver/functions/compare';
import semVerCoerce from 'semver/functions/coerce';
import { benchmarksNavigation } from '../../common/navigation/constants';
import { benchmarksNavigation } from '@kbn/cloud-security-posture';
import { buildRuleKey } from '../../../common/utils/rules_states';
import { RulesTable } from './rules_table';
import { RulesTableHeader } from './rules_table_header';

View file

@ -8,9 +8,9 @@
import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
import { CspBenchmarkRule } from '@kbn/cloud-security-posture-common/schema/rules/latest';
import type { BenchmarkId } from '@kbn/cloud-security-posture-common';
import { CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE } from '../../../common/constants';
import { BenchmarkId } from '../../../common/types_old';
import { getBenchmarkFilter } from '../../../common/utils/helpers';
export const getRulesCountForPolicy = async (