Skip to content

Commit

Permalink
[8.16] [Security Solution][Hotfix] Avoid blocking prebuilt rule upgra…
Browse files Browse the repository at this point in the history
…de upon conflicts with disabled feature flag (#198106) (#198111)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Security Solution][Hotfix] Avoid blocking prebuilt rule upgrade upon
conflicts with disabled feature flag
(#198106)](#198106)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Maxim
Palenov","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-29T07:36:33Z","message":"[Security
Solution][Hotfix] Avoid blocking prebuilt rule upgrade upon conflicts
with disabled feature flag (#198106)\n\n## Summary\r\n\r\nIt turned out
some of the update rule buttons are disabled. This is a side effect of
the functionality not fully hidden under a feature flag. This PR hides
prebuilt rule customisation functionality disabling update rule buttons
under `prebuiltRulesCustomizationEnabled` feature flag.\r\n\r\n##
Before\r\n\r\n![image](https://github.com/user-attachments/assets/b7ca5ff8-be37-47a7-ad7e-b85386909f38)\r\n\r\n##
After\r\n\r\n<img width=\"1719\" alt=\"image\"
src=\"https://github.com/user-attachments/assets/349223dc-dda5-46fb-832f-d7097a81580e\">\r\n\r\n<img
width=\"1721\" alt=\"image\"
src=\"https://github.com/user-attachments/assets/a28512f6-e605-460e-884d-571ab408a7d9\">","sha":"9622f62153f597ea91b34f7e2c877fe70b30f231","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rule
Management","Feature:Prebuilt Detection
Rules","backport:prev-major"],"title":"[Security Solution][Hotfix] Avoid
blocking prebuilt rule upgrade upon conflicts with disabled feature
flag","number":198106,"url":"https://github.com/elastic/kibana/pull/198106","mergeCommit":{"message":"[Security
Solution][Hotfix] Avoid blocking prebuilt rule upgrade upon conflicts
with disabled feature flag (#198106)\n\n## Summary\r\n\r\nIt turned out
some of the update rule buttons are disabled. This is a side effect of
the functionality not fully hidden under a feature flag. This PR hides
prebuilt rule customisation functionality disabling update rule buttons
under `prebuiltRulesCustomizationEnabled` feature flag.\r\n\r\n##
Before\r\n\r\n![image](https://github.com/user-attachments/assets/b7ca5ff8-be37-47a7-ad7e-b85386909f38)\r\n\r\n##
After\r\n\r\n<img width=\"1719\" alt=\"image\"
src=\"https://github.com/user-attachments/assets/349223dc-dda5-46fb-832f-d7097a81580e\">\r\n\r\n<img
width=\"1721\" alt=\"image\"
src=\"https://github.com/user-attachments/assets/a28512f6-e605-460e-884d-571ab408a7d9\">","sha":"9622f62153f597ea91b34f7e2c877fe70b30f231"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198106","number":198106,"mergeCommit":{"message":"[Security
Solution][Hotfix] Avoid blocking prebuilt rule upgrade upon conflicts
with disabled feature flag (#198106)\n\n## Summary\r\n\r\nIt turned out
some of the update rule buttons are disabled. This is a side effect of
the functionality not fully hidden under a feature flag. This PR hides
prebuilt rule customisation functionality disabling update rule buttons
under `prebuiltRulesCustomizationEnabled` feature flag.\r\n\r\n##
Before\r\n\r\n![image](https://github.com/user-attachments/assets/b7ca5ff8-be37-47a7-ad7e-b85386909f38)\r\n\r\n##
After\r\n\r\n<img width=\"1719\" alt=\"image\"
src=\"https://github.com/user-attachments/assets/349223dc-dda5-46fb-832f-d7097a81580e\">\r\n\r\n<img
width=\"1721\" alt=\"image\"
src=\"https://github.com/user-attachments/assets/a28512f6-e605-460e-884d-571ab408a7d9\">","sha":"9622f62153f597ea91b34f7e2c877fe70b30f231"}}]}]
BACKPORT-->

Co-authored-by: Maxim Palenov <[email protected]>
  • Loading branch information
kibanamachine and maximpn authored Oct 29, 2024
1 parent 58c5d2c commit e3ffdc8
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { useCallback, useMemo, useState } from 'react';
import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features';
import type {
RulesUpgradeState,
FieldsUpgradeState,
Expand All @@ -32,6 +33,9 @@ interface UseRulesUpgradeStateResult {
export function usePrebuiltRulesUpgradeState(
ruleUpgradeInfos: RuleUpgradeInfoForReview[]
): UseRulesUpgradeStateResult {
const isPrebuiltRulesCustomizationEnabled = useIsExperimentalFeatureEnabled(
'prebuiltRulesCustomizationEnabled'
);
const [rulesResolvedConflicts, setRulesResolvedConflicts] = useState<RulesResolvedConflicts>({});

const setRuleFieldResolvedValue = useCallback(
Expand Down Expand Up @@ -61,16 +65,17 @@ export function usePrebuiltRulesUpgradeState(
ruleUpgradeInfo.diff.fields,
rulesResolvedConflicts[ruleUpgradeInfo.rule_id] ?? {}
),
hasUnresolvedConflicts:
getUnacceptedConflictsCount(
ruleUpgradeInfo.diff.fields,
rulesResolvedConflicts[ruleUpgradeInfo.rule_id] ?? {}
) > 0,
hasUnresolvedConflicts: isPrebuiltRulesCustomizationEnabled
? getUnacceptedConflictsCount(
ruleUpgradeInfo.diff.fields,
rulesResolvedConflicts[ruleUpgradeInfo.rule_id] ?? {}
) > 0
: false,
};
}

return state;
}, [ruleUpgradeInfos, rulesResolvedConflicts]);
}, [ruleUpgradeInfos, rulesResolvedConflicts, isPrebuiltRulesCustomizationEnabled]);

return {
rulesUpgradeState,
Expand Down

0 comments on commit e3ffdc8

Please sign in to comment.