diff --git a/packages/kbn-rule-data-utils/src/paths.ts b/packages/kbn-rule-data-utils/src/paths.ts index 8a4623f9c6c41..63808dcc5470c 100644 --- a/packages/kbn-rule-data-utils/src/paths.ts +++ b/packages/kbn-rule-data-utils/src/paths.ts @@ -10,3 +10,6 @@ export const ruleDetailsRoute = '/rule/:ruleId'; export const triggersActionsRoute = '/app/management/insightsAndAlerting/triggersActions'; export const getRuleDetailsRoute = (ruleId: string) => ruleDetailsRoute.replace(':ruleId', ruleId); +export const getManagementRuleDetailsFullPath = (id: string): string => { + return `${triggersActionsRoute}${getRuleDetailsRoute(id)}`; +}; diff --git a/x-pack/examples/alerting_example/server/alert_types/always_firing.ts b/x-pack/examples/alerting_example/server/alert_types/always_firing.ts index a1fa6581f4aca..9d3cb9c91fee4 100644 --- a/x-pack/examples/alerting_example/server/alert_types/always_firing.ts +++ b/x-pack/examples/alerting_example/server/alert_types/always_firing.ts @@ -8,6 +8,7 @@ import uuid from 'uuid'; import { range } from 'lodash'; import { RuleType } from '@kbn/alerting-plugin/server'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { DEFAULT_INSTANCES_TO_GENERATE, ALERTING_EXAMPLE_APP_ID, @@ -76,4 +77,5 @@ export const alertType: RuleType< }; }, producer: ALERTING_EXAMPLE_APP_ID, + getRulePagePath: getManagementRuleDetailsFullPath, }; diff --git a/x-pack/examples/alerting_example/server/alert_types/astros.ts b/x-pack/examples/alerting_example/server/alert_types/astros.ts index f929fbb2e0879..e0ee3d5fbeebc 100644 --- a/x-pack/examples/alerting_example/server/alert_types/astros.ts +++ b/x-pack/examples/alerting_example/server/alert_types/astros.ts @@ -7,6 +7,7 @@ import axios from 'axios'; import { RuleType } from '@kbn/alerting-plugin/server'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { Operator, Craft, ALERTING_EXAMPLE_APP_ID } from '../../common/constants'; interface PeopleInSpace { @@ -79,4 +80,5 @@ export const alertType: RuleType< }; }, producer: ALERTING_EXAMPLE_APP_ID, + getRulePagePath: getManagementRuleDetailsFullPath, }; diff --git a/x-pack/plugins/alerting/server/task_runner/execution_handler.ts b/x-pack/plugins/alerting/server/task_runner/execution_handler.ts index aefd0b0c9dfff..2b36dca849898 100644 --- a/x-pack/plugins/alerting/server/task_runner/execution_handler.ts +++ b/x-pack/plugins/alerting/server/task_runner/execution_handler.ts @@ -7,7 +7,6 @@ import type { PublicMethodsOf } from '@kbn/utility-types'; import { Logger } from '@kbn/core/server'; -import { getRuleDetailsRoute, triggersActionsRoute } from '@kbn/rule-data-utils'; import { asSavedObjectExecutionSource } from '@kbn/actions-plugin/server'; import { isEphemeralTaskRejectedDueToCapacityError } from '@kbn/task-manager-plugin/server'; import { ExecuteOptions as EnqueueExecutionOptions } from '@kbn/actions-plugin/server/create_execute_function'; @@ -291,7 +290,7 @@ export class ExecutionHandler< try { const ruleUrl = new URL( - `${triggersActionsRoute}${getRuleDetailsRoute(this.taskInstance.params.alertId)}`, + this.ruleType.getRulePagePath(this.taskInstance.params.alertId), this.taskRunnerContext.kibanaBaseUrl ); diff --git a/x-pack/plugins/alerting/server/types.ts b/x-pack/plugins/alerting/server/types.ts index 88f5d8d1562de..0985518a95d3a 100644 --- a/x-pack/plugins/alerting/server/types.ts +++ b/x-pack/plugins/alerting/server/types.ts @@ -193,6 +193,7 @@ export interface RuleType< cancelAlertsOnRuleTimeout?: boolean; doesSetRecoveryContext?: boolean; getSummarizedAlerts?: GetSummarizedAlertsFn; + getRulePagePath: (id: string) => string; } export type UntypedRuleType = RuleType< RuleTypeParams, diff --git a/x-pack/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts b/x-pack/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts index d85b8df2798fe..3b6a41d1e7486 100644 --- a/x-pack/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts @@ -19,6 +19,7 @@ import { KibanaRequest } from '@kbn/core/server'; import { termQuery } from '@kbn/observability-plugin/server'; import { createLifecycleRuleTypeFactory } from '@kbn/rule-registry-plugin/server'; import { ProcessorEvent } from '@kbn/observability-plugin/common'; +import { getObservabilityRuleDetailsFullPath } from '@kbn/observability-plugin/common/utils/paths'; import { ApmRuleType, RULE_TYPES_CONFIG, @@ -319,6 +320,7 @@ export function registerAnomalyRuleType({ return {}; }, + getRulePagePath: getObservabilityRuleDetailsFullPath, }) ); } diff --git a/x-pack/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts b/x-pack/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts index d9826aae392c8..ae11cdd5c780b 100644 --- a/x-pack/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts @@ -15,6 +15,7 @@ import { import { createLifecycleRuleTypeFactory } from '@kbn/rule-registry-plugin/server'; import { termQuery } from '@kbn/observability-plugin/server'; import { ProcessorEvent } from '@kbn/observability-plugin/common'; +import { getObservabilityRuleDetailsFullPath } from '@kbn/observability-plugin/common/utils/paths'; import { ENVIRONMENT_NOT_DEFINED, getEnvironmentEsField, @@ -206,6 +207,7 @@ export function registerErrorCountRuleType({ return {}; }, + getRulePagePath: getObservabilityRuleDetailsFullPath, }) ); } diff --git a/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts b/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts index b4c7a6212b62d..2e1277595917d 100644 --- a/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts @@ -17,6 +17,7 @@ import { asDuration } from '@kbn/observability-plugin/common/utils/formatters'; import { termQuery } from '@kbn/observability-plugin/server'; import { createLifecycleRuleTypeFactory } from '@kbn/rule-registry-plugin/server'; import { ProcessorEvent } from '@kbn/observability-plugin/common'; +import { getObservabilityRuleDetailsFullPath } from '@kbn/observability-plugin/common/utils/paths'; import { getAlertUrlTransaction } from '../../../../../common/utils/formatters'; import { SearchAggregatedTransactionSetting } from '../../../../../common/aggregated_transactions'; import { @@ -279,6 +280,7 @@ export function registerTransactionDurationRuleType({ return {}; }, + getRulePagePath: getObservabilityRuleDetailsFullPath, }); alerting.registerType(ruleType); diff --git a/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts b/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts index 73f7ccda26401..1967b1ed64606 100644 --- a/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts +++ b/x-pack/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts @@ -16,6 +16,7 @@ import { createLifecycleRuleTypeFactory } from '@kbn/rule-registry-plugin/server import { asPercent } from '@kbn/observability-plugin/common/utils/formatters'; import { termQuery } from '@kbn/observability-plugin/server'; import { ProcessorEvent } from '@kbn/observability-plugin/common'; +import { getObservabilityRuleDetailsFullPath } from '@kbn/observability-plugin/common/utils/paths'; import { ENVIRONMENT_NOT_DEFINED, getEnvironmentEsField, @@ -274,6 +275,7 @@ export function registerTransactionErrorRateRuleType({ return {}; }, + getRulePagePath: getObservabilityRuleDetailsFullPath, }) ); } diff --git a/x-pack/plugins/infra/server/lib/alerting/log_threshold/register_log_threshold_rule_type.ts b/x-pack/plugins/infra/server/lib/alerting/log_threshold/register_log_threshold_rule_type.ts index 169d674bfd475..3b0d9d458fc6e 100644 --- a/x-pack/plugins/infra/server/lib/alerting/log_threshold/register_log_threshold_rule_type.ts +++ b/x-pack/plugins/infra/server/lib/alerting/log_threshold/register_log_threshold_rule_type.ts @@ -7,6 +7,7 @@ import { i18n } from '@kbn/i18n'; import { PluginSetupContract } from '@kbn/alerting-plugin/server'; +import { getObservabilityRuleDetailsFullPath } from '@kbn/observability-plugin/common/utils/paths'; import { createLogThresholdExecutor, FIRED_ACTIONS } from './log_threshold_executor'; import { LOG_DOCUMENT_COUNT_RULE_TYPE_ID, @@ -142,5 +143,6 @@ export async function registerLogThresholdRuleType( }, producer: 'logs', getSummarizedAlerts: libs.logsRules.createGetSummarizedAlerts(), + getRulePagePath: getObservabilityRuleDetailsFullPath, }); } diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_anomaly/register_metric_anomaly_rule_type.ts b/x-pack/plugins/infra/server/lib/alerting/metric_anomaly/register_metric_anomaly_rule_type.ts index b27ae6889fd28..27eb36668b18f 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_anomaly/register_metric_anomaly_rule_type.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_anomaly/register_metric_anomaly_rule_type.ts @@ -14,6 +14,7 @@ import { AlertInstanceContext as AlertContext, } from '@kbn/alerting-plugin/server'; import { RecoveredActionGroupId } from '@kbn/alerting-plugin/common'; +import { getObservabilityRuleDetailsFullPath } from '@kbn/observability-plugin/common/utils/paths'; import { createMetricAnomalyExecutor, FIRED_ACTIONS, @@ -114,4 +115,5 @@ export const registerMetricAnomalyRuleType = ( }, ], }, + getRulePagePath: getObservabilityRuleDetailsFullPath, }); diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts index cb98a6a23d4f0..310ffb33a1865 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/register_metric_threshold_rule_type.ts @@ -9,6 +9,7 @@ import { schema } from '@kbn/config-schema'; import { i18n } from '@kbn/i18n'; import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common'; import { PluginSetupContract, RuleType } from '@kbn/alerting-plugin/server'; +import { getObservabilityRuleDetailsFullPath } from '@kbn/observability-plugin/common/utils/paths'; import { Comparator, METRIC_THRESHOLD_ALERT_TYPE_ID } from '../../../../common/alerting/metrics'; import { METRIC_EXPLORER_AGGREGATIONS } from '../../../../common/http_api'; import { InfraBackendLibs } from '../../infra_types'; @@ -126,5 +127,6 @@ export async function registerMetricThresholdRuleType( }, producer: 'infrastructure', getSummarizedAlerts: libs.metricsRules.createGetSummarizedAlerts(), + getRulePagePath: getObservabilityRuleDetailsFullPath, }); } diff --git a/x-pack/plugins/ml/server/lib/alerts/register_anomaly_detection_alert_type.ts b/x-pack/plugins/ml/server/lib/alerts/register_anomaly_detection_alert_type.ts index 442267c2c98d8..70dd23d0598e1 100644 --- a/x-pack/plugins/ml/server/lib/alerts/register_anomaly_detection_alert_type.ts +++ b/x-pack/plugins/ml/server/lib/alerts/register_anomaly_detection_alert_type.ts @@ -13,6 +13,7 @@ import { AlertInstanceState, RuleTypeState, } from '@kbn/alerting-plugin/common'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-registry-plugin/common/technical_rule_data_field_names'; import { ML_ALERT_TYPES } from '../../../common/constants/alerts'; import { PLUGIN_ID } from '../../../common/constants/app'; import { MINIMUM_FULL_LICENSE } from '../../../common/license'; @@ -159,5 +160,6 @@ export function registerAnomalyDetectionAlertType({ } } }, + getRulePagePath: getManagementRuleDetailsFullPath, }); } diff --git a/x-pack/plugins/ml/server/lib/alerts/register_jobs_monitoring_rule_type.ts b/x-pack/plugins/ml/server/lib/alerts/register_jobs_monitoring_rule_type.ts index 5c75cec536944..479249172b4f8 100644 --- a/x-pack/plugins/ml/server/lib/alerts/register_jobs_monitoring_rule_type.ts +++ b/x-pack/plugins/ml/server/lib/alerts/register_jobs_monitoring_rule_type.ts @@ -19,6 +19,7 @@ import { RuleTypeState, } from '@kbn/alerting-plugin/common'; import type { RuleExecutorOptions } from '@kbn/alerting-plugin/server'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { ML_ALERT_TYPES } from '../../../common/constants/alerts'; import { PLUGIN_ID } from '../../../common/constants/app'; import { MINIMUM_FULL_LICENSE } from '../../../common/license'; @@ -180,5 +181,6 @@ export function registerJobsMonitoringRuleType({ } } }, + getRulePagePath: getManagementRuleDetailsFullPath, }); } diff --git a/x-pack/plugins/monitoring/server/alerts/base_rule.ts b/x-pack/plugins/monitoring/server/alerts/base_rule.ts index 1888265c124f6..3ea32bb41bd5c 100644 --- a/x-pack/plugins/monitoring/server/alerts/base_rule.ts +++ b/x-pack/plugins/monitoring/server/alerts/base_rule.ts @@ -17,6 +17,7 @@ import { import { Rule, RuleTypeParams, RawAlertInstance, SanitizedRule } from '@kbn/alerting-plugin/common'; import { ActionsClient } from '@kbn/actions-plugin/server'; import { parseDuration } from '@kbn/alerting-plugin/common'; +import { getObservabilityRuleDetailsFullPath } from '@kbn/observability-plugin/common/utils/paths'; import { AlertState, AlertNodeState, @@ -102,6 +103,7 @@ export class BaseRule { actionVariables: { context: actionVariables, }, + getRulePagePath: getObservabilityRuleDetailsFullPath, }; } diff --git a/x-pack/plugins/observability/common/utils/paths.ts b/x-pack/plugins/observability/common/utils/paths.ts new file mode 100644 index 0000000000000..c6a92021cbc7d --- /dev/null +++ b/x-pack/plugins/observability/common/utils/paths.ts @@ -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. + */ + +export const observabilityRuleDetailsRoute = '/app/observability/alerts/rules/:ruleId'; + +export const getObservabilityRuleDetailsFullPath = (id: string): string => + observabilityRuleDetailsRoute.replace(':ruleId', id); diff --git a/x-pack/plugins/security_solution/common/constants.ts b/x-pack/plugins/security_solution/common/constants.ts index e88580e1a338f..bb93435698371 100644 --- a/x-pack/plugins/security_solution/common/constants.ts +++ b/x-pack/plugins/security_solution/common/constants.ts @@ -147,6 +147,7 @@ export const DETECTION_RESPONSE_PATH = '/detection_response' as const; export const DETECTIONS_PATH = '/detections' as const; export const ALERTS_PATH = '/alerts' as const; export const RULES_PATH = '/rules' as const; +export const RULE_DETAILS_PATH = `${RULES_PATH}/id` as const; export const RULES_CREATE_PATH = `${RULES_PATH}/create` as const; export const EXCEPTIONS_PATH = '/exceptions' as const; export const HOSTS_PATH = '/hosts' as const; @@ -171,6 +172,7 @@ export const APP_MANAGEMENT_PATH = `${APP_PATH}${MANAGEMENT_PATH}` as const; export const APP_ALERTS_PATH = `${APP_PATH}${ALERTS_PATH}` as const; export const APP_RULES_PATH = `${APP_PATH}${RULES_PATH}` as const; +export const APP_RULE_DETAILS_PATH = `${APP_PATH}${RULE_DETAILS_PATH}` as const; export const APP_EXCEPTIONS_PATH = `${APP_PATH}${EXCEPTIONS_PATH}` as const; export const APP_HOSTS_PATH = `${APP_PATH}${HOSTS_PATH}` as const; diff --git a/x-pack/plugins/security_solution/common/utils/paths.ts b/x-pack/plugins/security_solution/common/utils/paths.ts new file mode 100644 index 0000000000000..ae304ee6df9ae --- /dev/null +++ b/x-pack/plugins/security_solution/common/utils/paths.ts @@ -0,0 +1,12 @@ +/* + * 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 { APP_RULE_DETAILS_PATH } from '../constants'; + +export const getSecuritySolutionRuleDetailsFullPath = (id: string): string => { + return `${APP_RULE_DETAILS_PATH}/${id}`; +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx index 0aa6fa9c20875..70fbfe9c4a680 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx @@ -85,6 +85,7 @@ import { APP_UI_ID, DEFAULT_INDEX_KEY, DEFAULT_THREAT_INDEX_KEY, + RULE_DETAILS_PATH, } from '../../../../../common/constants'; import { useGlobalFullScreen } from '../../../../common/containers/use_full_screen'; import { Display } from '../../../../hosts/pages/display'; @@ -251,31 +252,31 @@ const RuleDetailsPageComponent: React.FC = ({ id: RuleDetailTabs.alerts, name: RULE_DETAILS_TAB_NAME[RuleDetailTabs.alerts], disabled: false, - href: `/rules/id/${ruleId}/${RuleDetailTabs.alerts}`, + href: `${RULE_DETAILS_PATH}/${ruleId}/${RuleDetailTabs.alerts}`, }, [RuleDetailTabs.exceptions]: { id: RuleDetailTabs.exceptions, name: RULE_DETAILS_TAB_NAME[RuleDetailTabs.exceptions], disabled: rule == null, - href: `/rules/id/${ruleId}/${RuleDetailTabs.exceptions}`, + href: `${RULE_DETAILS_PATH}/${ruleId}/${RuleDetailTabs.exceptions}`, }, [RuleDetailTabs.endpointExceptions]: { id: RuleDetailTabs.endpointExceptions, name: RULE_DETAILS_TAB_NAME[RuleDetailTabs.endpointExceptions], disabled: rule == null, - href: `/rules/id/${ruleId}/${RuleDetailTabs.endpointExceptions}`, + href: `${RULE_DETAILS_PATH}/${ruleId}/${RuleDetailTabs.endpointExceptions}`, }, [RuleDetailTabs.executionResults]: { id: RuleDetailTabs.executionResults, name: RULE_DETAILS_TAB_NAME[RuleDetailTabs.executionResults], disabled: !isExistingRule, - href: `/rules/id/${ruleId}/${RuleDetailTabs.executionResults}`, + href: `${RULE_DETAILS_PATH}/${ruleId}/${RuleDetailTabs.executionResults}`, }, [RuleDetailTabs.executionEvents]: { id: RuleDetailTabs.executionEvents, name: RULE_DETAILS_TAB_NAME[RuleDetailTabs.executionEvents], disabled: !isExistingRule, - href: `/rules/id/${ruleId}/${RuleDetailTabs.executionEvents}`, + href: `${RULE_DETAILS_PATH}/${ruleId}/${RuleDetailTabs.executionEvents}`, }, }), [isExistingRule, rule, ruleId] @@ -800,7 +801,7 @@ const RuleDetailsPageComponent: React.FC = ({ - + <> @@ -850,7 +851,9 @@ const RuleDetailsPageComponent: React.FC = ({ )} - + = ({ /> = ({ data-test-subj="endpointExceptionsTab" /> - + - + diff --git a/x-pack/plugins/security_solution/public/rules/routes.tsx b/x-pack/plugins/security_solution/public/rules/routes.tsx index 5cfaae23907d2..cdc336f61c867 100644 --- a/x-pack/plugins/security_solution/public/rules/routes.tsx +++ b/x-pack/plugins/security_solution/public/rules/routes.tsx @@ -10,7 +10,7 @@ import { Redirect, Switch } from 'react-router-dom'; import { Route } from '@kbn/kibana-react-plugin/public'; import { TrackApplicationView } from '@kbn/usage-collection-plugin/public'; import * as i18n from './translations'; -import { RULES_PATH, SecurityPageName } from '../../common/constants'; +import { RULES_PATH, RULE_DETAILS_PATH, SecurityPageName } from '../../common/constants'; import { NotFoundPage } from '../app/404'; import { RulesPage } from '../detection_engine/rule_management_ui/pages/rule_management'; import { CreateRulePage } from '../detection_engine/rule_creation_ui/pages/rule_creation'; @@ -25,12 +25,12 @@ import { SpyRoute } from '../common/utils/route/spy_routes'; const RulesSubRoutes = [ { - path: '/rules/id/:detailName/edit', + path: `${RULE_DETAILS_PATH}/:detailName/edit`, main: EditRulePage, exact: true, }, { - path: `/rules/id/:detailName/:tabName(${RuleDetailTabs.alerts}|${RuleDetailTabs.exceptions}|${RuleDetailTabs.endpointExceptions}|${RuleDetailTabs.executionResults}|${RuleDetailTabs.executionEvents})`, + path: `${RULE_DETAILS_PATH}/:detailName/:tabName(${RuleDetailTabs.alerts}|${RuleDetailTabs.exceptions}|${RuleDetailTabs.endpointExceptions}|${RuleDetailTabs.executionResults}|${RuleDetailTabs.executionEvents})`, main: RuleDetailsPage, exact: true, }, @@ -54,7 +54,7 @@ const RulesContainerComponent: React.FC = () => { { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_rules_notification_alert_type.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_rules_notification_alert_type.ts index 2bb349f6f070b..4e2ef420c891c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_rules_notification_alert_type.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_rules_notification_alert_type.ts @@ -26,6 +26,7 @@ import { getSignals } from './get_signals'; import { legacyExtractReferences } from './legacy_saved_object_references/legacy_extract_references'; // eslint-disable-next-line no-restricted-imports import { legacyInjectReferences } from './legacy_saved_object_references/legacy_inject_references'; +import { getSecuritySolutionRuleDetailsFullPath } from '../../../../../../common/utils/paths'; /** * @deprecated Once we are confident all rules relying on side-car actions SO's have been migrated to SO references we should remove this function @@ -135,4 +136,5 @@ export const legacyRulesNotificationAlertType = ({ }); } }, + getRulePagePath: getSecuritySolutionRuleDetailsFullPath, }); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/eql/create_eql_alert_type.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/eql/create_eql_alert_type.ts index 6e31a9753d381..241d405c323f3 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/eql/create_eql_alert_type.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/eql/create_eql_alert_type.ts @@ -9,6 +9,7 @@ import { validateNonExact } from '@kbn/securitysolution-io-ts-utils'; import { EQL_RULE_TYPE_ID } from '@kbn/securitysolution-rules'; import { SERVER_APP_ID } from '../../../../../common/constants'; +import { getSecuritySolutionRuleDetailsFullPath } from '../../../../../common/utils/paths'; import type { EqlRuleParams } from '../../rule_schema'; import { eqlRuleParams } from '../../rule_schema'; import { eqlExecutor } from '../../signals/executors/eql'; @@ -97,5 +98,6 @@ export const createEqlAlertType = ( }); return { ...result, state }; }, + getRulePagePath: getSecuritySolutionRuleDetailsFullPath, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/indicator_match/create_indicator_match_alert_type.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/indicator_match/create_indicator_match_alert_type.ts index 796900829d6ea..e74597e852fb6 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/indicator_match/create_indicator_match_alert_type.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/indicator_match/create_indicator_match_alert_type.ts @@ -10,6 +10,7 @@ import { INDICATOR_RULE_TYPE_ID } from '@kbn/securitysolution-rules'; import { SERVER_APP_ID } from '../../../../../common/constants'; import type { ThreatRuleParams } from '../../rule_schema'; +import { getSecuritySolutionRuleDetailsFullPath } from '../../../../../common/utils/paths'; import { threatRuleParams } from '../../rule_schema'; import { threatMatchExecutor } from '../../signals/executors/threat_match'; import type { CreateRuleOptions, SecurityAlertType } from '../types'; @@ -102,5 +103,6 @@ export const createIndicatorMatchAlertType = ( }); return { ...result, state }; }, + getRulePagePath: getSecuritySolutionRuleDetailsFullPath, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/ml/create_ml_alert_type.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/ml/create_ml_alert_type.ts index c652de348484f..cf08a80827a2f 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/ml/create_ml_alert_type.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/ml/create_ml_alert_type.ts @@ -10,6 +10,7 @@ import { ML_RULE_TYPE_ID } from '@kbn/securitysolution-rules'; import { SERVER_APP_ID } from '../../../../../common/constants'; import type { MachineLearningRuleParams } from '../../rule_schema'; +import { getSecuritySolutionRuleDetailsFullPath } from '../../../../../common/utils/paths'; import { machineLearningRuleParams } from '../../rule_schema'; import { mlExecutor } from '../../signals/executors/ml'; import type { CreateRuleOptions, SecurityAlertType } from '../types'; @@ -78,5 +79,6 @@ export const createMlAlertType = ( }); return { ...result, state }; }, + getRulePagePath: getSecuritySolutionRuleDetailsFullPath, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/new_terms/create_new_terms_alert_type.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/new_terms/create_new_terms_alert_type.ts index 8fce33897bd0f..0ca7bfeb3846d 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/new_terms/create_new_terms_alert_type.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/new_terms/create_new_terms_alert_type.ts @@ -35,6 +35,7 @@ import { getUnprocessedExceptionsWarnings, } from '../../signals/utils'; import { createEnrichEventsFunction } from '../../signals/enrichments'; +import { getSecuritySolutionRuleDetailsFullPath } from '../../../../../common/utils/paths'; export const createNewTermsAlertType = ( createOptions: CreateRuleOptions, @@ -306,5 +307,6 @@ export const createNewTermsAlertType = ( } return { ...result, state }; }, + getRulePagePath: getSecuritySolutionRuleDetailsFullPath, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/query/create_query_alert_type.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/query/create_query_alert_type.ts index 4f246e5ada204..fc8a8c813bf5b 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/query/create_query_alert_type.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/query/create_query_alert_type.ts @@ -10,6 +10,7 @@ import { QUERY_RULE_TYPE_ID } from '@kbn/securitysolution-rules'; import { SERVER_APP_ID } from '../../../../../common/constants'; import type { UnifiedQueryRuleParams } from '../../rule_schema'; +import { getSecuritySolutionRuleDetailsFullPath } from '../../../../../common/utils/paths'; import { unifiedQueryRuleParams } from '../../rule_schema'; import { queryExecutor } from '../../signals/executors/query'; import type { CreateQueryRuleOptions, SecurityAlertType } from '../types'; @@ -104,5 +105,6 @@ export const createQueryAlertType = ( }); return { ...result, state }; }, + getRulePagePath: getSecuritySolutionRuleDetailsFullPath, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/saved_query/create_saved_query_alert_type.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/saved_query/create_saved_query_alert_type.ts index 6e761bb6a51a0..9e5e9987ab3fc 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/saved_query/create_saved_query_alert_type.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/saved_query/create_saved_query_alert_type.ts @@ -7,6 +7,7 @@ import { validateNonExact } from '@kbn/securitysolution-io-ts-utils'; import { SAVED_QUERY_RULE_TYPE_ID } from '@kbn/securitysolution-rules'; +import { getSecuritySolutionRuleDetailsFullPath } from '../../../../../common/utils/paths'; import { SERVER_APP_ID } from '../../../../../common/constants'; import type { CompleteRule, UnifiedQueryRuleParams } from '../../rule_schema'; @@ -104,5 +105,6 @@ export const createSavedQueryAlertType = ( }); return { ...result, state }; }, + getRulePagePath: getSecuritySolutionRuleDetailsFullPath, }; }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/threshold/create_threshold_alert_type.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/threshold/create_threshold_alert_type.ts index b465abed15977..a1eac8c260e26 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/threshold/create_threshold_alert_type.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/threshold/create_threshold_alert_type.ts @@ -7,6 +7,7 @@ import { validateNonExact } from '@kbn/securitysolution-io-ts-utils'; import { THRESHOLD_RULE_TYPE_ID } from '@kbn/securitysolution-rules'; +import { getSecuritySolutionRuleDetailsFullPath } from '../../../../../common/utils/paths'; import { SERVER_APP_ID } from '../../../../../common/constants'; import type { ThresholdRuleParams } from '../../rule_schema'; @@ -103,5 +104,6 @@ export const createThresholdAlertType = ( }); return result; }, + getRulePagePath: getSecuritySolutionRuleDetailsFullPath, }; }; diff --git a/x-pack/plugins/stack_alerts/server/rule_types/es_query/rule_type.ts b/x-pack/plugins/stack_alerts/server/rule_types/es_query/rule_type.ts index c56f691cc2580..ea25ce6e11cb8 100644 --- a/x-pack/plugins/stack_alerts/server/rule_types/es_query/rule_type.ts +++ b/x-pack/plugins/stack_alerts/server/rule_types/es_query/rule_type.ts @@ -8,6 +8,7 @@ import { i18n } from '@kbn/i18n'; import { CoreSetup } from '@kbn/core/server'; import { extractReferences, injectReferences } from '@kbn/data-plugin/common'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { RuleType } from '../../types'; import { ActionContext } from './action_context'; import { @@ -187,5 +188,6 @@ export function getRuleType( }, producer: STACK_ALERTS_FEATURE_ID, doesSetRecoveryContext: true, + getRulePagePath: getManagementRuleDetailsFullPath, }; } diff --git a/x-pack/plugins/stack_alerts/server/rule_types/geo_containment/alert_type.ts b/x-pack/plugins/stack_alerts/server/rule_types/geo_containment/alert_type.ts index 4a0c89531c880..1c0866680f7e3 100644 --- a/x-pack/plugins/stack_alerts/server/rule_types/geo_containment/alert_type.ts +++ b/x-pack/plugins/stack_alerts/server/rule_types/geo_containment/alert_type.ts @@ -17,6 +17,7 @@ import { RuleTypeParams, } from '@kbn/alerting-plugin/server'; import { Query } from '@kbn/data-plugin/common/query'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { STACK_ALERTS_FEATURE_ID } from '../../../common'; import { getGeoContainmentExecutor } from './geo_containment'; @@ -259,5 +260,6 @@ export function getAlertType(): GeoContainmentAlertType { return injectEntityAndBoundaryIds(params, references); }, }, + getRulePagePath: getManagementRuleDetailsFullPath, }; } diff --git a/x-pack/plugins/stack_alerts/server/rule_types/index_threshold/rule_type.ts b/x-pack/plugins/stack_alerts/server/rule_types/index_threshold/rule_type.ts index 8b347d58de18c..8f8c344db1445 100644 --- a/x-pack/plugins/stack_alerts/server/rule_types/index_threshold/rule_type.ts +++ b/x-pack/plugins/stack_alerts/server/rule_types/index_threshold/rule_type.ts @@ -11,6 +11,7 @@ import { TimeSeriesQuery, TIME_SERIES_BUCKET_SELECTOR_FIELD, } from '@kbn/triggers-actions-ui-plugin/server'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { RuleType, RuleExecutorOptions, StackAlertsStartDeps } from '../../types'; import { Params, ParamsSchema } from './rule_type_params'; import { ActionContext, BaseActionContext, addMessages } from './action_context'; @@ -129,6 +130,7 @@ export function getRuleType( executor, producer: STACK_ALERTS_FEATURE_ID, doesSetRecoveryContext: true, + getRulePagePath: getManagementRuleDetailsFullPath, }; async function executor( diff --git a/x-pack/plugins/transform/server/lib/alerting/transform_health_rule_type/register_transform_health_rule_type.ts b/x-pack/plugins/transform/server/lib/alerting/transform_health_rule_type/register_transform_health_rule_type.ts index 798a218b131e2..36f427d45357c 100644 --- a/x-pack/plugins/transform/server/lib/alerting/transform_health_rule_type/register_transform_health_rule_type.ts +++ b/x-pack/plugins/transform/server/lib/alerting/transform_health_rule_type/register_transform_health_rule_type.ts @@ -15,6 +15,7 @@ import type { } from '@kbn/alerting-plugin/common'; import { RuleType } from '@kbn/alerting-plugin/server'; import type { PluginSetupContract as AlertingSetup } from '@kbn/alerting-plugin/server'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { PLUGIN, TRANSFORM_RULE_TYPE } from '../../../../common/constants'; import { transformHealthRuleParams, TransformHealthRuleParams } from './schema'; import { transformHealthServiceProvider } from './transform_health_service'; @@ -134,5 +135,6 @@ export function getTransformHealthRuleType(): RuleType< } } }, + getRulePagePath: getManagementRuleDetailsFullPath, }; } diff --git a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts index d41d7a699e6ef..696f7c231db6a 100644 --- a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts +++ b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts @@ -16,6 +16,7 @@ import { RuleTypeState, RuleTypeParams, } from '@kbn/alerting-plugin/server'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { ES_TEST_INDEX_NAME } from '../../../../lib'; import { FixtureStartDeps, FixtureSetupDeps } from './plugin'; @@ -90,6 +91,7 @@ function getAlwaysFiringAlertType() { context: [{ name: 'instanceContextValue', description: 'the instance context value' }], }, executor: curry(alwaysFiringExecutor)(), + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -166,6 +168,7 @@ function getCumulativeFiringAlertType() { runCount, }; }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -210,6 +213,7 @@ function getNeverFiringAlertType() { globalStateValue: true, }; }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -249,6 +253,7 @@ function getFailingAlertType() { }); throw new Error('Failed to execute alert type'); }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -303,6 +308,7 @@ function getExceedsAlertLimitRuleType() { }, }); }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -395,6 +401,7 @@ function getAuthorizationAlertType(core: CoreSetup) { }, }); }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -421,6 +428,7 @@ function getValidationAlertType() { params: paramsSchema, }, async executor() {}, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -492,6 +500,7 @@ function getPatternFiringAlertType() { patternIndex: patternIndex + 1, }; }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -531,6 +540,7 @@ function getPatternSuccessOrFailureAlertType() { patternIndex: patternIndex + 1, }; }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -577,6 +587,7 @@ function getLongRunningPatternRuleType(cancelAlertsOnRuleTimeout: boolean = true } return {}; }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -635,6 +646,7 @@ function getCancellableRuleType() { throw new Error('execution short circuited!'); } }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -652,6 +664,7 @@ export function defineAlertTypes( minimumLicenseRequired: 'basic', isExportable: true, async executor() {}, + getRulePagePath: getManagementRuleDetailsFullPath, }; const goldNoopAlertType: RuleType<{}, {}, {}, {}, {}, 'default'> = { id: 'test.gold.noop', @@ -662,6 +675,7 @@ export function defineAlertTypes( minimumLicenseRequired: 'gold', isExportable: true, async executor() {}, + getRulePagePath: getManagementRuleDetailsFullPath, }; const onlyContextVariablesAlertType: RuleType<{}, {}, {}, {}, {}, 'default'> = { id: 'test.onlyContextVariables', @@ -675,6 +689,7 @@ export function defineAlertTypes( context: [{ name: 'aContextVariable', description: 'this is a context variable' }], }, async executor() {}, + getRulePagePath: getManagementRuleDetailsFullPath, }; const onlyStateVariablesAlertType: RuleType<{}, {}, {}, {}, {}, 'default'> = { id: 'test.onlyStateVariables', @@ -688,6 +703,7 @@ export function defineAlertTypes( minimumLicenseRequired: 'basic', isExportable: true, async executor() {}, + getRulePagePath: getManagementRuleDetailsFullPath, }; const throwAlertType: RuleType<{}, {}, {}, {}, {}, 'default'> = { id: 'test.throw', @@ -705,6 +721,7 @@ export function defineAlertTypes( async executor() { throw new Error('this alert is intended to fail'); }, + getRulePagePath: getManagementRuleDetailsFullPath, }; function getLongRunningRuleType() { const paramsSchema = schema.object({ @@ -729,6 +746,7 @@ export function defineAlertTypes( const { params } = ruleExecutorOptions; await new Promise((resolve) => setTimeout(resolve, params.delay ?? 5000)); }, + getRulePagePath: getManagementRuleDetailsFullPath, }; return result; } @@ -745,6 +763,7 @@ export function defineAlertTypes( isExportable: true, async executor() {}, producer: 'alertsFixture', + getRulePagePath: getManagementRuleDetailsFullPath, }; const multipleSearchesRuleType: RuleType< { numSearches: number; delay: string }, @@ -796,6 +815,7 @@ export function defineAlertTypes( await services.scopedClusterClient.asCurrentUser.search(query as any); } }, + getRulePagePath: getManagementRuleDetailsFullPath, }; alerting.registerType(getAlwaysFiringAlertType()); diff --git a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts_restricted/server/alert_types.ts b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts_restricted/server/alert_types.ts index a902d2a12a837..5eab25234fad3 100644 --- a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts_restricted/server/alert_types.ts +++ b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts_restricted/server/alert_types.ts @@ -7,6 +7,7 @@ import { CoreSetup } from '@kbn/core/server'; import { RuleType } from '@kbn/alerting-plugin/server'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; import { FixtureStartDeps, FixtureSetupDeps } from './plugin'; export function defineAlertTypes( @@ -23,6 +24,7 @@ export function defineAlertTypes( isExportable: true, recoveryActionGroup: { id: 'restrictedRecovered', name: 'Restricted Recovery' }, async executor() {}, + getRulePagePath: getManagementRuleDetailsFullPath, }; const noopUnrestrictedAlertType: RuleType<{}, {}, {}, {}, {}, 'default'> = { id: 'test.unrestricted-noop', @@ -33,6 +35,7 @@ export function defineAlertTypes( minimumLicenseRequired: 'basic', isExportable: true, async executor() {}, + getRulePagePath: getManagementRuleDetailsFullPath, }; alerting.registerType(noopRestrictedAlertType); alerting.registerType(noopUnrestrictedAlertType); diff --git a/x-pack/test/functional_execution_context/fixtures/plugins/alerts/server/plugin.ts b/x-pack/test/functional_execution_context/fixtures/plugins/alerts/server/plugin.ts index e6fc9c5aff6c4..fb0c8333e898f 100644 --- a/x-pack/test/functional_execution_context/fixtures/plugins/alerts/server/plugin.ts +++ b/x-pack/test/functional_execution_context/fixtures/plugins/alerts/server/plugin.ts @@ -12,6 +12,7 @@ import { EncryptedSavedObjectsPluginStart } from '@kbn/encrypted-saved-objects-p import { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-plugin/server'; import { SpacesPluginStart } from '@kbn/spaces-plugin/server'; import { SecurityPluginStart } from '@kbn/security-plugin/server'; +import { getManagementRuleDetailsFullPath } from '@kbn/rule-data-utils'; export interface FixtureSetupDeps { features: FeaturesPluginSetup; @@ -81,6 +82,7 @@ export class FixturePlugin implements Plugin = { isExportable: true, async executor() {}, producer: 'alerts', + getRulePagePath: getManagementRuleDetailsFullPath, }; export const alwaysFiringAlertType: RuleType< @@ -62,6 +64,7 @@ export const alwaysFiringAlertType: RuleType< groupInSeriesIndex: (state.groupInSeriesIndex || 0) + 1, }; }, + getRulePagePath: getManagementRuleDetailsFullPath, }; export const failingAlertType: RuleType = { @@ -80,6 +83,7 @@ export const failingAlertType: RuleType {