diff --git a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_about_rule/index.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_about_rule/index.test.tsx index 3e4ca31aa1050..3d1bfe2fafee2 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_about_rule/index.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_about_rule/index.test.tsx @@ -37,11 +37,13 @@ import { } from '../../../rule_creation/components/alert_suppression_edit'; import { THRESHOLD_ALERT_SUPPRESSION_ENABLED } from '../../../rule_creation/components/threshold_alert_suppression_edit'; import { AlertSuppressionMissingFieldsStrategyEnum } from '../../../../../common/api/detection_engine'; +import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; jest.mock('../../../../common/lib/kibana'); jest.mock('../../../../common/containers/source'); jest.mock('../../../../common/components/ml/hooks/use_get_jobs'); jest.mock('../../../../common/components/ml_popover/hooks/use_security_jobs'); +jest.mock('../../../../common/hooks/use_experimental_features'); jest.mock('@elastic/eui', () => { const original = jest.requireActual('@elastic/eui'); return { @@ -54,6 +56,9 @@ jest.mock('@elastic/eui', () => { }; }); const mockedUseKibana = mockUseKibana(); +(useIsExperimentalFeatureEnabled as jest.Mock).mockImplementation((param) => { + return param === 'endpointExceptionsMovedUnderManagement'; +}); export const stepDefineStepMLRule: DefineStepRule = { ruleType: 'machine_learning', @@ -143,6 +148,19 @@ describe('StepAboutRuleComponent', () => { expect(wrapper.find(StepRuleDescription).exists()).toBeTruthy(); }); + it('only shows endpoint exceptions for rule definition if feature flag enabled', async () => { + const wrapper = mount( {}} />, { + wrappingComponent: TestProviders as EnzymeComponentType<{}>, + }); + await act(async () => { + expect( + wrapper + .find('[data-test-subj="detectionEngineStepAboutRuleAssociatedToEndpointList"]') + .exists() + ).toBeFalsy(); + }); + }); + it('is invalid if description is not present', async () => { let form: FormHook; const wrapper = mount( diff --git a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_about_rule/index.tsx b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_about_rule/index.tsx index 365d72a90e597..5b757a295ecc9 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_about_rule/index.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_about_rule/index.tsx @@ -40,6 +40,7 @@ import { MultiSelectFieldsAutocomplete } from '../multi_select_fields'; import { useAllEsqlRuleFields } from '../../hooks'; import { MaxSignals } from '../max_signals'; import { ThreatMatchIndicatorPathEdit } from '../../../rule_creation/components/threat_match_indicator_path_edit'; +import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; const CommonUseField = getUseField({ component: Field }); @@ -71,6 +72,7 @@ const TagContainer = styled.div` `; TagContainer.displayName = 'TagContainer'; +const GhostFormField = () => <>; const StepAboutRuleComponent: FC = ({ ruleType, @@ -101,6 +103,10 @@ const StepAboutRuleComponent: FC = ({ const [indexPattern, setIndexPattern] = useState(indexIndexPattern); + const endpointExceptionsMovedUnderManagement = useIsExperimentalFeatureEnabled( + 'endpointExceptionsMovedUnderManagement' + ); + useEffect(() => { if (index != null && (dataViewId === '' || dataViewId == null)) { setIndexPattern(indexIndexPattern); @@ -324,18 +330,22 @@ const StepAboutRuleComponent: FC = ({ /> - - - + {!endpointExceptionsMovedUnderManagement ? ( + + + + ) : ( + + )} = { ], }, isAssociatedToEndpointList: { + defaultValue: false, type: FIELD_TYPES.CHECKBOX, label: i18n.translate( 'xpack.securitySolution.detectionEngine.createRule.stepAboutRule.fieldAssociatedToEndpointListLabel',