-
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.
Merge branch 'master' into one-line-remove-non-null-assert
- Loading branch information
Showing
51 changed files
with
1,130 additions
and
636 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
224 changes: 164 additions & 60 deletions
224
packages/kbn-securitysolution-list-utils/src/get_filters/index.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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
49 changes: 49 additions & 0 deletions
49
...es/kbn-securitysolution-list-utils/src/get_host_isolation_exceptions_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,49 @@ | ||
/* | ||
* 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 { getHostIsolationExceptionsFilter } from '.'; | ||
|
||
describe('getHostIsolationExceptionsFilter', () => { | ||
test('it returns filter to search for "exception-list" namespace host isolation exceptions', () => { | ||
const filter = getHostIsolationExceptionsFilter(true, ['exception-list']); | ||
|
||
expect(filter).toEqual( | ||
'(exception-list.attributes.list_id: endpoint_host_isolation_exceptions*)' | ||
); | ||
}); | ||
|
||
test('it returns filter to search for "exception-list" and "agnostic" namespace host isolation exceptions', () => { | ||
const filter = getHostIsolationExceptionsFilter(true, [ | ||
'exception-list', | ||
'exception-list-agnostic', | ||
]); | ||
|
||
expect(filter).toEqual( | ||
'(exception-list.attributes.list_id: endpoint_host_isolation_exceptions* OR exception-list-agnostic.attributes.list_id: endpoint_host_isolation_exceptions*)' | ||
); | ||
}); | ||
|
||
test('it returns filter to exclude "exception-list" namespace host isolation exceptions', () => { | ||
const filter = getHostIsolationExceptionsFilter(false, ['exception-list']); | ||
|
||
expect(filter).toEqual( | ||
'(not exception-list.attributes.list_id: endpoint_host_isolation_exceptions*)' | ||
); | ||
}); | ||
|
||
test('it returns filter to exclude "exception-list" and "agnostic" namespace host isolation exceptions', () => { | ||
const filter = getHostIsolationExceptionsFilter(false, [ | ||
'exception-list', | ||
'exception-list-agnostic', | ||
]); | ||
|
||
expect(filter).toEqual( | ||
'(not exception-list.attributes.list_id: endpoint_host_isolation_exceptions* AND not exception-list-agnostic.attributes.list_id: endpoint_host_isolation_exceptions*)' | ||
); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/kbn-securitysolution-list-utils/src/get_host_isolation_exceptions_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_HOST_ISOLATION_EXCEPTIONS_LIST_ID } from '@kbn/securitysolution-list-constants'; | ||
import { SavedObjectType } from '../types'; | ||
|
||
export const getHostIsolationExceptionsFilter = ( | ||
showFilter: boolean, | ||
namespaceTypes: SavedObjectType[] | ||
): string => { | ||
if (showFilter) { | ||
const filters = namespaceTypes.map((namespace) => { | ||
return `${namespace}.attributes.list_id: ${ENDPOINT_HOST_ISOLATION_EXCEPTIONS_LIST_ID}*`; | ||
}); | ||
return `(${filters.join(' OR ')})`; | ||
} else { | ||
const filters = namespaceTypes.map((namespace) => { | ||
return `not ${namespace}.attributes.list_id: ${ENDPOINT_HOST_ISOLATION_EXCEPTIONS_LIST_ID}*`; | ||
}); | ||
return `(${filters.join(' AND ')})`; | ||
} | ||
}; |
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
Oops, something went wrong.