From 5bb102e5a9813a401377a44fd54a143acccd8a73 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:02:40 +1100 Subject: [PATCH] [8.x] [Security Solution] Allows editing and exporting prebuilt rules from the Rule Management and Rule Details pages (#198202) (#200103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution] Allows editing and exporting prebuilt rules from the Rule Management and Rule Details pages (#198202)](https://github.com/elastic/kibana/pull/198202) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Davis Plumlee <56367316+dplumlee@users.noreply.github.com> --- .../rules_table/use_rules_table_actions.tsx | 4 ++- .../rules/rule_actions_overflow/index.tsx | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_rules_table_actions.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_rules_table_actions.tsx index f3d0930d7c1fe..a4c85391a8063 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_rules_table_actions.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_rules_table_actions.tsx @@ -25,6 +25,7 @@ import { useDownloadExportedRules } from '../../../rule_management/logic/bulk_ac import { useHasActionsPrivileges } from './use_has_actions_privileges'; import type { TimeRange } from '../../../rule_gaps/types'; import { useScheduleRuleRun } from '../../../rule_gaps/logic/use_schedule_rule_run'; +import { useIsPrebuiltRulesCustomizationEnabled } from '../../../rule_management/hooks/use_is_prebuilt_rules_customization_enabled'; import { ManualRuleRunEventTypes } from '../../../../common/lib/telemetry'; export const useRulesTableActions = ({ @@ -46,6 +47,7 @@ export const useRulesTableActions = ({ const { bulkExport } = useBulkExport(); const downloadExportedRules = useDownloadExportedRules(); const { scheduleRuleRun } = useScheduleRuleRun(); + const isPrebuiltRulesCustomizationEnabled = useIsPrebuiltRulesCustomizationEnabled(); return [ { @@ -116,7 +118,7 @@ export const useRulesTableActions = ({ await downloadExportedRules(response); } }, - enabled: (rule: Rule) => !rule.immutable, + enabled: (rule: Rule) => isPrebuiltRulesCustomizationEnabled || !rule.immutable, }, { type: 'icon', diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx index a786b95979d43..f34fca18ca6e3 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx @@ -14,6 +14,7 @@ import { } from '@elastic/eui'; import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; +import { useIsPrebuiltRulesCustomizationEnabled } from '../../../../detection_engine/rule_management/hooks/use_is_prebuilt_rules_customization_enabled'; import { useScheduleRuleRun } from '../../../../detection_engine/rule_gaps/logic/use_schedule_rule_run'; import type { TimeRange } from '../../../../detection_engine/rule_gaps/types'; import { APP_UI_ID, SecurityPageName } from '../../../../../common/constants'; @@ -72,6 +73,7 @@ const RuleActionsOverflowComponent = ({ application: { navigateToApp }, telemetry, } = useKibana().services; + const isPrebuiltRulesCustomizationEnabled = useIsPrebuiltRulesCustomizationEnabled(); const { startTransaction } = useStartTransaction(); const { executeBulkAction } = useExecuteBulkAction({ suppressSuccessToast: true }); const { bulkExport } = useBulkExport(); @@ -137,7 +139,10 @@ const RuleActionsOverflowComponent = ({ { startTransaction({ name: SINGLE_RULE_ACTIONS.EXPORT }); @@ -203,21 +208,22 @@ const RuleActionsOverflowComponent = ({ ] : [], [ - bulkExport, + rule, canDuplicateRuleWithActions, + userHasPermissions, + isPrebuiltRulesCustomizationEnabled, + startTransaction, closePopover, + showBulkDuplicateExceptionsConfirmation, executeBulkAction, navigateToApp, - onRuleDeletedCallback, - rule, - showBulkDuplicateExceptionsConfirmation, - showManualRuleRunConfirmation, - startTransaction, - userHasPermissions, + bulkExport, downloadExportedRules, - confirmDeletion, - scheduleRuleRun, + showManualRuleRunConfirmation, telemetry, + scheduleRuleRun, + confirmDeletion, + onRuleDeletedCallback, ] );