forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Add "Customized Elastic rule" badge to Rule Detai…
…ls page (elastic#186914) **Resolves: elastic#180170 ## Summary This PR adds a "Customized Elastic rule" badge to the Rule Details page. This badge is only displayed if a rule has `rule_source.is_customized` set to `true` and the feature flag is turned on. Tests for this feature will be added later under a separate ticket (elastic#186916). ### Screenshots **Customized Elastic rule – has badge** <img width="827" alt="Schermafbeelding 2024-06-25 om 19 29 47" src="https://github.com/elastic/kibana/assets/15949146/be64271f-5f91-46a9-aa71-35594c788586"> **Custom rule – no badge** <img width="827" alt="Schermafbeelding 2024-06-25 om 19 29 02" src="https://github.com/elastic/kibana/assets/15949146/c576bf52-efde-46dd-88af-9fdf5f0b44ea">
- Loading branch information
1 parent
0ffd02c
commit 199e2ad
Showing
5 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 type { RuleResponse } from './rule_schemas.gen'; | ||
|
||
export function isCustomizedPrebuiltRule(rule: RuleResponse): boolean { | ||
return rule.rule_source?.type === 'external' && rule.rule_source.is_customized; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...tection_engine/rule_management/components/rule_details/customized_prebuilt_rule_badge.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { EuiBadge } from '@elastic/eui'; | ||
import * as i18n from './translations'; | ||
import { isCustomizedPrebuiltRule } from '../../../../../common/api/detection_engine'; | ||
import type { RuleResponse } from '../../../../../common/api/detection_engine'; | ||
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; | ||
|
||
interface CustomizedPrebuiltRuleBadgeProps { | ||
rule: RuleResponse | null; | ||
} | ||
|
||
export const CustomizedPrebuiltRuleBadge: React.FC<CustomizedPrebuiltRuleBadgeProps> = ({ | ||
rule, | ||
}) => { | ||
const isPrebuiltRulesCustomizationEnabled = useIsExperimentalFeatureEnabled( | ||
'prebuiltRulesCustomizationEnabled' | ||
); | ||
|
||
if (!isPrebuiltRulesCustomizationEnabled) { | ||
return null; | ||
} | ||
|
||
if (rule === null || !isCustomizedPrebuiltRule(rule)) { | ||
return null; | ||
} | ||
|
||
return <EuiBadge color="hollow">{i18n.CUSTOMIZED_PREBUILT_RULE_LABEL}</EuiBadge>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters