-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EDR Workflows][Process descendants filter] Display process descendan…
…t filtering on event filter cards (#187174) ## Summary The modifications indicate to the users if an Event Filter filters process descendants, displayed in 3 places. It's a bit of a prop drilling to be honest, but that was needed to keep `ArtifactXZ` components generic by passing a 'decorator' component from the outside. ### Testing Modifications are behind feature flag: `xpack.securitySolution.enableExperimental.filterProcessDescendantsForEventFiltersEnabled` To change an Event Filter to Process descendant filtering, you just need to change the toggle on the new/edit flyout: <img width="400" alt="image" src="https://github.com/elastic/kibana/assets/39014407/23c64d77-7d28-44c1-9a7f-07499652610b"> ### Manage / Event Filters - `ArtifactEntryCard` <img width="1393" alt="image" src="https://github.com/elastic/kibana/assets/39014407/79459f08-3b30-4f66-b058-e9b2bbaed705"> <img width="675" alt="image" src="https://github.com/elastic/kibana/assets/39014407/7be9d2d8-85d4-4a8d-b650-f1371bcaa903"> ### Manage / Policies / Event Filters tab / Assign flyout - `ArtifactEntryCardMinified` <img width="1315" alt="image" src="https://github.com/elastic/kibana/assets/39014407/57b6564b-8b43-4a37-9d4b-c7db5cbefbeb"> <img width="668" alt="image" src="https://github.com/elastic/kibana/assets/39014407/7e3e1b4a-e0f0-4b20-8b9b-f7d24589ce2a"> ### Manage / Policies / Event Filters tab - when there are assigned filters - `ArtifactEntryCollapsibleCard` <img width="1068" alt="image" src="https://github.com/elastic/kibana/assets/39014407/af31b89e-9845-4625-a95d-f610a57203f4"> <img width="1067" alt="image" src="https://github.com/elastic/kibana/assets/39014407/f9b98c4b-ed47-4f62-8bed-95c65420ab4f"> ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
525d24e
commit c978455
Showing
26 changed files
with
443 additions
and
47 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
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
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
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
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
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
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
81 changes: 81 additions & 0 deletions
81
...entry_card/components/card_decorators/event_filters_process_descendant_indicator.test.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,81 @@ | ||
/* | ||
* 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 userEvent from '@testing-library/user-event'; | ||
import { EventFiltersProcessDescendantIndicator } from './event_filters_process_descendant_indicator'; | ||
import type { AnyArtifact } from '../../types'; | ||
import type { AppContextTestRender } from '../../../../../common/mock/endpoint'; | ||
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint'; | ||
import { | ||
FILTER_PROCESS_DESCENDANTS_TAG, | ||
GLOBAL_ARTIFACT_TAG, | ||
} from '../../../../../../common/endpoint/service/artifacts/constants'; | ||
import type { ArtifactEntryCardDecoratorProps } from '../../artifact_entry_card'; | ||
|
||
describe('EventFiltersProcessDescendantIndicator', () => { | ||
let appTestContext: AppContextTestRender; | ||
let renderResult: ReturnType<AppContextTestRender['render']>; | ||
let render: ( | ||
props: ArtifactEntryCardDecoratorProps | ||
) => ReturnType<AppContextTestRender['render']>; | ||
|
||
const getStandardEventFilter: () => AnyArtifact = () => | ||
({ | ||
tags: [GLOBAL_ARTIFACT_TAG], | ||
} as Partial<AnyArtifact> as AnyArtifact); | ||
|
||
const getProcessDescendantEventFilter: () => AnyArtifact = () => | ||
({ | ||
tags: [GLOBAL_ARTIFACT_TAG, FILTER_PROCESS_DESCENDANTS_TAG], | ||
} as Partial<AnyArtifact> as AnyArtifact); | ||
|
||
beforeEach(() => { | ||
appTestContext = createAppRootMockRenderer(); | ||
render = (props) => { | ||
renderResult = appTestContext.render( | ||
<EventFiltersProcessDescendantIndicator data-test-subj="test" {...props} /> | ||
); | ||
return renderResult; | ||
}; | ||
}); | ||
|
||
it('should not display anything if feature flag is disabled', () => { | ||
appTestContext.setExperimentalFlag({ filterProcessDescendantsForEventFiltersEnabled: false }); | ||
|
||
render({ item: getProcessDescendantEventFilter() }); | ||
|
||
expect(renderResult.queryByTestId('test-processDescendantIndication')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should not display anything if Event Filter is not for process descendants', () => { | ||
appTestContext.setExperimentalFlag({ filterProcessDescendantsForEventFiltersEnabled: true }); | ||
|
||
render({ item: getStandardEventFilter() }); | ||
|
||
expect(renderResult.queryByTestId('test-processDescendantIndication')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should display indication if Event Filter is for process descendants', () => { | ||
appTestContext.setExperimentalFlag({ filterProcessDescendantsForEventFiltersEnabled: true }); | ||
|
||
render({ item: getProcessDescendantEventFilter() }); | ||
|
||
expect(renderResult.getByTestId('test-processDescendantIndication')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should mention additional `event.category is process` entry in tooltip', async () => { | ||
const prefix = 'test-processDescendantIndicationTooltip'; | ||
appTestContext.setExperimentalFlag({ filterProcessDescendantsForEventFiltersEnabled: true }); | ||
render({ item: getProcessDescendantEventFilter() }); | ||
|
||
expect(renderResult.queryByTestId(`${prefix}-tooltipText`)).not.toBeInTheDocument(); | ||
|
||
userEvent.hover(renderResult.getByTestId(`${prefix}-tooltipIcon`)); | ||
expect(await renderResult.findByTestId(`${prefix}-tooltipText`)).toBeInTheDocument(); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
...fact_entry_card/components/card_decorators/event_filters_process_descendant_indicator.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,52 @@ | ||
/* | ||
* 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 { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; | ||
import React, { memo } from 'react'; | ||
import { EuiSpacer, EuiText } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { useTestIdGenerator } from '../../../../hooks/use_test_id_generator'; | ||
import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; | ||
import { isFilterProcessDescendantsEnabled } from '../../../../../../common/endpoint/service/artifacts/utils'; | ||
import { ProcessDescendantsTooltip } from '../../../../pages/event_filters/view/components/process_descendant_tooltip'; | ||
import type { ArtifactEntryCardDecoratorProps } from '../../artifact_entry_card'; | ||
|
||
export const EventFiltersProcessDescendantIndicator = memo<ArtifactEntryCardDecoratorProps>( | ||
({ item, 'data-test-subj': dataTestSubj, ...commonProps }) => { | ||
const getTestId = useTestIdGenerator(dataTestSubj); | ||
const isProcessDescendantFeatureEnabled = useIsExperimentalFeatureEnabled( | ||
'filterProcessDescendantsForEventFiltersEnabled' | ||
); | ||
|
||
if ( | ||
isProcessDescendantFeatureEnabled && | ||
isFilterProcessDescendantsEnabled(item as ExceptionListItemSchema) | ||
) { | ||
return ( | ||
<> | ||
<EuiText {...commonProps} data-test-subj={getTestId('processDescendantIndication')}> | ||
<code> | ||
<strong> | ||
<FormattedMessage | ||
defaultMessage="Filtering descendants of process" | ||
id="xpack.securitySolution.eventFilters.filteringProcessDescendants" | ||
/>{' '} | ||
<ProcessDescendantsTooltip | ||
indicateExtraEntry | ||
data-test-subj={getTestId('processDescendantIndicationTooltip')} | ||
/> | ||
</strong> | ||
</code> | ||
</EuiText> | ||
<EuiSpacer size="m" /> | ||
</> | ||
); | ||
} | ||
|
||
return <></>; | ||
} | ||
); | ||
EventFiltersProcessDescendantIndicator.displayName = 'EventFiltersProcessDescendantIndicator'; |
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
Oops, something went wrong.