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] Add Host/User flyout in One Discover. (elastic#19…
…9279) ## Summary Handles elastic#191998 Follow up work: - elastic/security-team#11112 - elastic#196667 This PR add below entity flyouts for below entities in One Discover: - host.name - user.name - source.ip - destination.ip In this PR we re-use the security solution code by making use of below model based on `discover-shared` plugin. ```mermaid flowchart TD discoverShared["Discover Shared"] securitySolution["Security Solution"] discover["Discover"] securitySolution -- "registers Features" --> discoverShared discover -- "consume Features" --> discoverShared ``` ## How to Test >[!Note] >This PR adds `security-root-profile` in One discover which is currently in `experimental mode`. All changes below can only be tested when profile is activated. Profile can activated by adding below lines in `config/kibana.dev.yml` > ```yaml > discover.experimental.enabledProfiles: > - security-root-profile > ``` > 1. As mentioned above, adding above experimental flag in `kibana.dev.yml`. 2. Spin up Security Serverless project and add some alert Data. 3. Navigate to Discover and add columns `host.name` and `user.name` in table. Now `host` and `user` flyouts should be available on clicking `host.name`, `user.name`, `source.ip` & `destination.ip`. 4. Flyout should work without any error. 5. Below things are not working and will be tackled in followup PR : - Security Hover actions - Actions such as `Add to Timeline` or `Add to Case` ### 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: kibanamachine <[email protected]>
- Loading branch information
1 parent
cb7e47d
commit a16b11d
Showing
41 changed files
with
728 additions
and
81 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
17 changes: 17 additions & 0 deletions
17
...lic/context_awareness/profile_providers/security/accessors/create_app_wrapper_accessor.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,17 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import type { SecuritySolutionAppWrapperFeature } from '@kbn/discover-shared-plugin/public'; | ||
|
||
export const createAppWrapperAccessor = async ( | ||
appWrapperFeature?: SecuritySolutionAppWrapperFeature | ||
) => { | ||
if (!appWrapperFeature) return undefined; | ||
return appWrapperFeature.getWrapper(); | ||
}; |
57 changes: 57 additions & 0 deletions
57
...ontext_awareness/profile_providers/security/accessors/get_cell_renderer_accessor.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,57 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { SecuritySolutionCellRendererFeature } from '@kbn/discover-shared-plugin/public'; | ||
import { DataGridCellValueElementProps } from '@kbn/unified-data-table'; | ||
import { createCellRendererAccessor } from './get_cell_renderer_accessor'; | ||
import { render } from '@testing-library/react'; | ||
|
||
const cellRendererFeature: SecuritySolutionCellRendererFeature = { | ||
id: 'security-solution-cell-renderer', | ||
getRenderer: async () => (fieldName: string) => { | ||
if (fieldName === 'host.name') { | ||
return (props: DataGridCellValueElementProps) => { | ||
return <div data-test-subj="cell-render-feature">{props.columnId}</div>; | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
const mockCellProps = { | ||
columnId: 'host.name', | ||
row: { | ||
id: '1', | ||
raw: {}, | ||
flattened: {}, | ||
}, | ||
} as DataGridCellValueElementProps; | ||
|
||
describe('getCellRendererAccessort', () => { | ||
it('should return a cell renderer', async () => { | ||
const getCellRenderer = await createCellRendererAccessor(cellRendererFeature); | ||
expect(getCellRenderer).toBeDefined(); | ||
const CellRenderer = getCellRenderer?.('host.name') as React.FC<DataGridCellValueElementProps>; | ||
expect(CellRenderer).toBeDefined(); | ||
const { getByTestId } = render(<CellRenderer {...mockCellProps} />); | ||
expect(getByTestId('cell-render-feature')).toBeVisible(); | ||
expect(getByTestId('cell-render-feature')).toHaveTextContent('host.name'); | ||
}); | ||
|
||
it('should return undefined if cellRendererFeature is not defined', async () => { | ||
const getCellRenderer = await createCellRendererAccessor(); | ||
expect(getCellRenderer).toBeUndefined(); | ||
}); | ||
|
||
it('should return undefined if cellRendererGetter returns undefined', async () => { | ||
const getCellRenderer = await createCellRendererAccessor(cellRendererFeature); | ||
const cellRenderer = getCellRenderer?.('user.name'); | ||
expect(cellRenderer).toBeUndefined(); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
...lic/context_awareness/profile_providers/security/accessors/get_cell_renderer_accessor.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,28 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { SecuritySolutionCellRendererFeature } from '@kbn/discover-shared-plugin/public'; | ||
import { DataGridCellValueElementProps } from '@kbn/unified-data-table'; | ||
|
||
export const createCellRendererAccessor = async ( | ||
cellRendererFeature?: SecuritySolutionCellRendererFeature | ||
) => { | ||
if (!cellRendererFeature) return undefined; | ||
const cellRendererGetter = await cellRendererFeature.getRenderer(); | ||
function getCellRenderer(fieldName: string) { | ||
const CellRenderer = cellRendererGetter(fieldName); | ||
if (!CellRenderer) return undefined; | ||
return React.memo(function SecuritySolutionCellRenderer(props: DataGridCellValueElementProps) { | ||
return <CellRenderer {...props} />; | ||
}); | ||
} | ||
|
||
return getCellRenderer; | ||
}; |
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
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 |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
"kbn_references": [ | ||
"@kbn/discover-utils", | ||
"@kbn/core", | ||
"@kbn/unified-data-table", | ||
] | ||
} |
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.