Skip to content

Commit ca63513

Browse files
committed
[Security Solution][Detections] Associate Endpoint Exceptions List to Rule during rule creation/update (#71794)
* Add checkbox to associate rule with global endpoint exception list This works on creation, now we need edit. * Fix DomNesting error on ML Card Description EuiText generates a div, but this is inside of an EuiCard which is a paragraph. Defines a span with equivalent styles, instead. * Change default stack of alerts histogram to signal.rule.name
1 parent 3ecce04 commit ca63513

12 files changed

Lines changed: 61 additions & 7 deletions

File tree

x-pack/plugins/security_solution/public/detections/components/alerts_histogram_panel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const NO_LEGEND_DATA: LegendItem[] = [];
8383
export const AlertsHistogramPanel = memo<AlertsHistogramPanelProps>(
8484
({
8585
chartHeight,
86-
defaultStackByOption = alertsHistogramOptions[0],
86+
defaultStackByOption = alertsHistogramOptions[8], // signal.rule.name
8787
deleteQuery,
8888
filters,
8989
headerChildren,

x-pack/plugins/security_solution/public/detections/components/rules/select_rule_type/ml_card_description.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66

77
import { FormattedMessage } from '@kbn/i18n/react';
8-
import { EuiText, EuiLink } from '@elastic/eui';
8+
import { EuiLink } from '@elastic/eui';
9+
import styled from 'styled-components';
910
import React from 'react';
1011

1112
import { ML_TYPE_DESCRIPTION } from './translations';
@@ -15,11 +16,15 @@ interface MlCardDescriptionProps {
1516
hasValidLicense?: boolean;
1617
}
1718

19+
const SmallText = styled.span`
20+
font-size: ${({ theme }) => theme.eui.euiFontSizeS};
21+
`;
22+
1823
const MlCardDescriptionComponent: React.FC<MlCardDescriptionProps> = ({
1924
subscriptionUrl,
2025
hasValidLicense = false,
2126
}) => (
22-
<EuiText size="s">
27+
<SmallText>
2328
{hasValidLicense ? (
2429
ML_TYPE_DESCRIPTION
2530
) : (
@@ -38,7 +43,7 @@ const MlCardDescriptionComponent: React.FC<MlCardDescriptionProps> = ({
3843
}}
3944
/>
4045
)}
41-
</EuiText>
46+
</SmallText>
4247
);
4348

4449
MlCardDescriptionComponent.displayName = 'MlCardDescriptionComponent';

x-pack/plugins/security_solution/public/detections/components/rules/step_about_rule/default_value.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const stepAboutDefaultValue: AboutStepRule = {
1818
author: [],
1919
name: '',
2020
description: '',
21+
isAssociatedToEndpointList: false,
2122
isBuildingBlock: false,
2223
isNew: true,
2324
severity: { value: 'low', mapping: [] },

x-pack/plugins/security_solution/public/detections/components/rules/step_about_rule/index.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ describe('StepAboutRuleComponent', () => {
165165
await wait();
166166
const expected: Omit<AboutStepRule, 'isNew'> = {
167167
author: [],
168+
isAssociatedToEndpointList: false,
168169
isBuildingBlock: false,
169170
license: '',
170171
ruleNameOverride: '',
@@ -223,6 +224,7 @@ describe('StepAboutRuleComponent', () => {
223224
await wait();
224225
const expected: Omit<AboutStepRule, 'isNew'> = {
225226
author: [],
227+
isAssociatedToEndpointList: false,
226228
isBuildingBlock: false,
227229
license: '',
228230
ruleNameOverride: '',

x-pack/plugins/security_solution/public/detections/components/rules/step_about_rule/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,20 @@ const StepAboutRuleComponent: FC<StepAboutRuleProps> = ({
282282
}}
283283
/>
284284
<EuiSpacer size="l" />
285-
<EuiFormRow label={I18n.BUILDING_BLOCK} isInvalid={false} fullWidth>
285+
<EuiFormRow label={I18n.GLOBAL_ENDPOINT_EXCEPTION_LIST} fullWidth>
286+
<CommonUseField
287+
path="isAssociatedToEndpointList"
288+
componentProps={{
289+
idAria: 'detectionEngineStepAboutRuleAssociatedToEndpointList',
290+
'data-test-subj': 'detectionEngineStepAboutRuleAssociatedToEndpointList',
291+
euiFieldProps: {
292+
fullWidth: true,
293+
isDisabled: isLoading,
294+
},
295+
}}
296+
/>
297+
</EuiFormRow>
298+
<EuiFormRow label={I18n.BUILDING_BLOCK} fullWidth>
286299
<CommonUseField
287300
path="isBuildingBlock"
288301
componentProps={{
@@ -291,7 +304,6 @@ const StepAboutRuleComponent: FC<StepAboutRuleProps> = ({
291304
euiFieldProps: {
292305
fullWidth: true,
293306
isDisabled: isLoading,
294-
placeholder: '',
295307
},
296308
}}
297309
/>

x-pack/plugins/security_solution/public/detections/components/rules/step_about_rule/schema.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ export const schema: FormSchema = {
9191
),
9292
labelAppend: OptionalFieldLabel,
9393
},
94+
isAssociatedToEndpointList: {
95+
type: FIELD_TYPES.CHECKBOX,
96+
label: i18n.translate(
97+
'xpack.securitySolution.detectionEngine.createRule.stepAboutRule.fieldAssociatedToEndpointListLabel',
98+
{
99+
defaultMessage: 'Associate rule to Global Endpoint Exception List',
100+
}
101+
),
102+
labelAppend: OptionalFieldLabel,
103+
},
94104
severity: {
95105
value: {
96106
type: FIELD_TYPES.SUPER_SELECT,

x-pack/plugins/security_solution/public/detections/components/rules/step_about_rule/translations.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ export const ADD_FALSE_POSITIVE = i18n.translate(
2626
defaultMessage: 'Add false positive example',
2727
}
2828
);
29+
30+
export const GLOBAL_ENDPOINT_EXCEPTION_LIST = i18n.translate(
31+
'xpack.securitySolution.detectionEngine.createRule.stepAboutRuleForm.endpointExceptionListLabel',
32+
{
33+
defaultMessage: 'Global endpoint exception list',
34+
}
35+
);
36+
2937
export const BUILDING_BLOCK = i18n.translate(
3038
'xpack.securitySolution.detectionEngine.createRule.stepAboutRuleForm.buildingBlockLabel',
3139
{

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/__mocks__/mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export const mockRuleWithEverything = (id: string): Rule => ({
167167
export const mockAboutStepRule = (isNew = false): AboutStepRule => ({
168168
isNew,
169169
author: ['Elastic'],
170+
isAssociatedToEndpointList: false,
170171
isBuildingBlock: false,
171172
timestampOverride: '',
172173
ruleNameOverride: '',

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/create/helpers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export const formatAboutStepData = (aboutStepData: AboutStepRule): AboutStepRule
153153
riskScore,
154154
severity,
155155
threat,
156+
isAssociatedToEndpointList,
156157
isBuildingBlock,
157158
isNew,
158159
note,
@@ -163,6 +164,13 @@ export const formatAboutStepData = (aboutStepData: AboutStepRule): AboutStepRule
163164
const resp = {
164165
author: author.filter((item) => !isEmpty(item)),
165166
...(isBuildingBlock ? { building_block_type: 'default' } : {}),
167+
...(isAssociatedToEndpointList
168+
? {
169+
exceptions_list: [
170+
{ id: 'endpoint_list', namespace_type: 'agnostic', type: 'endpoint' },
171+
] as AboutStepRuleJson['exceptions_list'],
172+
}
173+
: {}),
166174
false_positives: falsePositives.filter((item) => !isEmpty(item)),
167175
references: references.filter((item) => !isEmpty(item)),
168176
risk_score: riskScore.value,

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ describe('rule helpers', () => {
8383
title: 'Titled timeline',
8484
},
8585
};
86-
const aboutRuleStepData = {
86+
87+
const aboutRuleStepData: AboutStepRule = {
8788
author: [],
8889
description: '24/7',
8990
falsePositives: ['test'],
91+
isAssociatedToEndpointList: false,
9092
isBuildingBlock: false,
9193
isNew: false,
9294
license: 'Elastic License',

0 commit comments

Comments
 (0)