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][Endpoint] Hide endpoint event filters list in det…
…ections tab (elastic#102644) * Add event filters filter on exception list to hide it in UI * Fixes unit test and added more tests for showEventFilters * fixes test adding showEventFilters test cases * Pass params as js object instead of individual variables Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
6e10c4b
commit c23720e
Showing
8 changed files
with
420 additions
and
42 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
39 changes: 39 additions & 0 deletions
39
packages/kbn-securitysolution-list-utils/src/get_event_filters_filter/index.test.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,39 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { getEventFiltersFilter } from '.'; | ||
|
||
describe('getEventFiltersFilter', () => { | ||
test('it returns filter to search for "exception-list" namespace trusted apps', () => { | ||
const filter = getEventFiltersFilter(true, ['exception-list']); | ||
|
||
expect(filter).toEqual('(exception-list.attributes.list_id: endpoint_event_filters*)'); | ||
}); | ||
|
||
test('it returns filter to search for "exception-list" and "agnostic" namespace trusted apps', () => { | ||
const filter = getEventFiltersFilter(true, ['exception-list', 'exception-list-agnostic']); | ||
|
||
expect(filter).toEqual( | ||
'(exception-list.attributes.list_id: endpoint_event_filters* OR exception-list-agnostic.attributes.list_id: endpoint_event_filters*)' | ||
); | ||
}); | ||
|
||
test('it returns filter to exclude "exception-list" namespace trusted apps', () => { | ||
const filter = getEventFiltersFilter(false, ['exception-list']); | ||
|
||
expect(filter).toEqual('(not exception-list.attributes.list_id: endpoint_event_filters*)'); | ||
}); | ||
|
||
test('it returns filter to exclude "exception-list" and "agnostic" namespace trusted apps', () => { | ||
const filter = getEventFiltersFilter(false, ['exception-list', 'exception-list-agnostic']); | ||
|
||
expect(filter).toEqual( | ||
'(not exception-list.attributes.list_id: endpoint_event_filters* AND not exception-list-agnostic.attributes.list_id: endpoint_event_filters*)' | ||
); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/kbn-securitysolution-list-utils/src/get_event_filters_filter/index.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,27 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { ENDPOINT_EVENT_FILTERS_LIST_ID } from '@kbn/securitysolution-list-constants'; | ||
import { SavedObjectType } from '../types'; | ||
|
||
export const getEventFiltersFilter = ( | ||
showEventFilter: boolean, | ||
namespaceTypes: SavedObjectType[] | ||
): string => { | ||
if (showEventFilter) { | ||
const filters = namespaceTypes.map((namespace) => { | ||
return `${namespace}.attributes.list_id: ${ENDPOINT_EVENT_FILTERS_LIST_ID}*`; | ||
}); | ||
return `(${filters.join(' OR ')})`; | ||
} else { | ||
const filters = namespaceTypes.map((namespace) => { | ||
return `not ${namespace}.attributes.list_id: ${ENDPOINT_EVENT_FILTERS_LIST_ID}*`; | ||
}); | ||
return `(${filters.join(' AND ')})`; | ||
} | ||
}; |
Oops, something went wrong.