-
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.
[Security Solution] Search strategy - authentications (#76090)
* move authentications to searchstrategy * useAuthentications * add authenticationFields * remove import from lib * remove duplicated types * getInspectResponse * getInspectResponse * move folder * update path * update path * shallowEqual * revert path * update path * remove redundant types * fix import * fix types Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Patryk Kopyciński <[email protected]>
- Loading branch information
1 parent
01e4420
commit d932830
Showing
25 changed files
with
1,143 additions
and
177 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
x-pack/plugins/security_solution/common/ecs/ecs_fields/extend_map.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,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { extendMap } from './extend_map'; | ||
|
||
describe('ecs_fields test', () => { | ||
describe('extendMap', () => { | ||
test('it should extend a record', () => { | ||
const osFieldsMap: Readonly<Record<string, string>> = { | ||
'os.platform': 'os.platform', | ||
'os.full': 'os.full', | ||
'os.family': 'os.family', | ||
'os.version': 'os.version', | ||
'os.kernel': 'os.kernel', | ||
}; | ||
const expected: Record<string, string> = { | ||
'host.os.family': 'host.os.family', | ||
'host.os.full': 'host.os.full', | ||
'host.os.kernel': 'host.os.kernel', | ||
'host.os.platform': 'host.os.platform', | ||
'host.os.version': 'host.os.version', | ||
}; | ||
expect(extendMap('host', osFieldsMap)).toEqual(expected); | ||
}); | ||
|
||
test('it should extend a sample hosts record', () => { | ||
const hostMap: Record<string, string> = { | ||
'host.id': 'host.id', | ||
'host.ip': 'host.ip', | ||
'host.name': 'host.name', | ||
}; | ||
const osFieldsMap: Readonly<Record<string, string>> = { | ||
'os.platform': 'os.platform', | ||
'os.full': 'os.full', | ||
'os.family': 'os.family', | ||
'os.version': 'os.version', | ||
'os.kernel': 'os.kernel', | ||
}; | ||
const expected: Record<string, string> = { | ||
'host.id': 'host.id', | ||
'host.ip': 'host.ip', | ||
'host.name': 'host.name', | ||
'host.os.family': 'host.os.family', | ||
'host.os.full': 'host.os.full', | ||
'host.os.kernel': 'host.os.kernel', | ||
'host.os.platform': 'host.os.platform', | ||
'host.os.version': 'host.os.version', | ||
}; | ||
const output = { ...hostMap, ...extendMap('host', osFieldsMap) }; | ||
expect(output).toEqual(expected); | ||
}); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
x-pack/plugins/security_solution/common/ecs/ecs_fields/extend_map.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,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const extendMap = ( | ||
path: string, | ||
map: Readonly<Record<string, string>> | ||
): Readonly<Record<string, string>> => | ||
Object.entries(map).reduce<Record<string, string>>((accum, [key, value]) => { | ||
accum[`${path}.${key}`] = `${path}.${value}`; | ||
return accum; | ||
}, {}); |
Oops, something went wrong.