Skip to content

Commit

Permalink
[8.13] [SecuritySolution] Fix Entity risk score visualization display…
Browse files Browse the repository at this point in the history
…s 'N/A' instead of score (elastic#177448) (elastic#177553)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[SecuritySolution] Fix Entity risk score visualization displays
'N/A' instead of score
(elastic#177448)](elastic#177448)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Pablo
Machado","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-02-22T08:35:08Z","message":"[SecuritySolution]
Fix Entity risk score visualization displays 'N/A' instead of score
(elastic#177448)\n\n## Summary\r\n\r\nAdd a new property to the
`LensVisualization` that prevents the table\r\nand tab filters from
being applied.\r\n\r\n###
BEFORE\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/1490444/e13deb8f-d023-404d-9cea-e749b8ee2694\"\r\nwidth=\"500\"
/>\r\n\r\n###
AFTER\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/1490444/ad12325d-fe4f-40cd-83a8-45d755707061\"\r\nwidth=\"500\"
/>\r\n\r\n\r\n### How to test it?\r\n* Open the User flyout on the
host's page / Events\r\n* The risk score visualization should not be
filtered by *exists\r\nhost.name\"\r\n\r\n### Checklist\r\n\r\nDelete
any items that are not applicable to this PR.\r\n\r\n\r\n- [X] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"45ce4c3f3111dd07ed51d6f62d9b1d77887ada34","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.13.0","v8.14.0"],"title":"[SecuritySolution]
Fix Entity risk score visualization displays 'N/A' instead of
score","number":177448,"url":"https://github.com/elastic/kibana/pull/177448","mergeCommit":{"message":"[SecuritySolution]
Fix Entity risk score visualization displays 'N/A' instead of score
(elastic#177448)\n\n## Summary\r\n\r\nAdd a new property to the
`LensVisualization` that prevents the table\r\nand tab filters from
being applied.\r\n\r\n###
BEFORE\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/1490444/e13deb8f-d023-404d-9cea-e749b8ee2694\"\r\nwidth=\"500\"
/>\r\n\r\n###
AFTER\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/1490444/ad12325d-fe4f-40cd-83a8-45d755707061\"\r\nwidth=\"500\"
/>\r\n\r\n\r\n### How to test it?\r\n* Open the User flyout on the
host's page / Events\r\n* The risk score visualization should not be
filtered by *exists\r\nhost.name\"\r\n\r\n### Checklist\r\n\r\nDelete
any items that are not applicable to this PR.\r\n\r\n\r\n- [X] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"45ce4c3f3111dd07ed51d6f62d9b1d77887ada34"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/177448","number":177448,"mergeCommit":{"message":"[SecuritySolution]
Fix Entity risk score visualization displays 'N/A' instead of score
(elastic#177448)\n\n## Summary\r\n\r\nAdd a new property to the
`LensVisualization` that prevents the table\r\nand tab filters from
being applied.\r\n\r\n###
BEFORE\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/1490444/e13deb8f-d023-404d-9cea-e749b8ee2694\"\r\nwidth=\"500\"
/>\r\n\r\n###
AFTER\r\n<img\r\nsrc=\"https://github.com/elastic/kibana/assets/1490444/ad12325d-fe4f-40cd-83a8-45d755707061\"\r\nwidth=\"500\"
/>\r\n\r\n\r\n### How to test it?\r\n* Open the User flyout on the
host's page / Events\r\n* The risk score visualization should not be
filtered by *exists\r\nhost.name\"\r\n\r\n### Checklist\r\n\r\nDelete
any items that are not applicable to this PR.\r\n\r\n\r\n- [X] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"45ce4c3f3111dd07ed51d6f62d9b1d77887ada34"}}]}]
BACKPORT-->

Co-authored-by: Pablo Machado <[email protected]>
  • Loading branch information
kibanamachine and machadoum authored Feb 22, 2024
1 parent f91e5cb commit 5946741
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const LensComponentWrapper = styled.div<{

const LensEmbeddableComponent: React.FC<LensEmbeddableComponentProps> = ({
applyGlobalQueriesAndFilters = true,
applyPageAndTabsFilters = true,
extraActions,
extraOptions,
getLensAttributes,
Expand Down Expand Up @@ -99,6 +100,7 @@ const LensEmbeddableComponent: React.FC<LensEmbeddableComponentProps> = ({
const { searchSessionId } = useVisualizationResponse({ visualizationId: id });
const attributes = useLensAttributes({
applyGlobalQueriesAndFilters,
applyPageAndTabsFilters,
extraOptions,
getLensAttributes,
lensAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type GetLensAttributes = (

export interface UseLensAttributesProps {
applyGlobalQueriesAndFilters?: boolean;
applyPageAndTabsFilters?: boolean;
extraOptions?: ExtraOptions;
getLensAttributes?: GetLensAttributes;
lensAttributes?: LensAttributes | null;
Expand Down Expand Up @@ -83,6 +84,7 @@ export enum VisualizationContextMenuDefaultActionName {

export interface LensEmbeddableComponentProps {
applyGlobalQueriesAndFilters?: boolean;
applyPageAndTabsFilters?: boolean;
extraActions?: Action[];
extraOptions?: ExtraOptions;
getLensAttributes?: GetLensAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,31 @@ describe('useLensAttributes', () => {
]);
});

it('should not apply tabs and pages when applyPageAndTabsFilters = false', () => {
(useRouteSpy as jest.Mock).mockReturnValue([
{
detailName: 'elastic',
pageName: 'user',
tabName: 'events',
},
]);
const { result } = renderHook(
() =>
useLensAttributes({
applyPageAndTabsFilters: false,
getLensAttributes: getExternalAlertLensAttributes,
stackByField: 'event.dataset',
}),
{ wrapper }
);

expect(result?.current?.state.filters).toEqual([
...getExternalAlertLensAttributes().state.filters,
...getIndexFilters(['auditbeat-*']),
...filterFromSearchBar,
]);
});

it('should add data view id to references', () => {
const { result } = renderHook(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {

export const useLensAttributes = ({
applyGlobalQueriesAndFilters = true,
applyPageAndTabsFilters = true,
extraOptions,
getLensAttributes,
lensAttributes,
Expand Down Expand Up @@ -95,8 +96,8 @@ export const useLensAttributes = ({
...(applyGlobalQueriesAndFilters ? { query } : {}),
filters: [
...attrs.state.filters,
...pageFilters,
...tabsFilters,
...(applyPageAndTabsFilters ? pageFilters : []),
...(applyPageAndTabsFilters ? tabsFilters : []),
...indexFilters,
...(applyGlobalQueriesAndFilters ? filters : []),
],
Expand All @@ -108,6 +109,7 @@ export const useLensAttributes = ({
} as LensAttributes;
}, [
applyGlobalQueriesAndFilters,
applyPageAndTabsFilters,
attrs,
dataViewId,
filters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const RiskSummaryComponent = <T extends RiskScoreEntity>({
{riskData && (
<VisualizationEmbeddable
applyGlobalQueriesAndFilters={false}
applyPageAndTabsFilters={false}
lensAttributes={lensAttributes}
id={`RiskSummary-risk_score_metric`}
timerange={timerange}
Expand Down

0 comments on commit 5946741

Please sign in to comment.