Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Expandable flyout - update risk classification ui in entities overview #165022

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID,
ENTITIES_HOST_OVERVIEW_LINK_TEST_ID,
ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID,
TECHNICAL_PREVIEW_ICON_TEST_ID,
} from './test_ids';
import { RightPanelContext } from '../context';
import { mockContextValue } from '../mocks/mock_right_panel_context';
Expand Down Expand Up @@ -82,6 +83,7 @@ describe('<HostEntityContent />', () => {

expect(getByTestId(ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID)).toHaveTextContent(osFamily);
expect(getByTestId(ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('Medium');
expect(getByTestId(TECHNICAL_PREVIEW_ICON_TEST_ID)).toBeInTheDocument();
});

it('should render correctly if returned data is null', () => {
Expand All @@ -96,7 +98,8 @@ describe('<HostEntityContent />', () => {
</TestProviders>
);
expect(getByTestId(ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID)).toHaveTextContent('—');
expect(getByTestId(ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('Unknown');
expect(getByTestId(ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('—');
expect(getByTestId(TECHNICAL_PREVIEW_ICON_TEST_ID)).toBeInTheDocument();
});
});

Expand All @@ -117,6 +120,7 @@ describe('<HostEntityContent />', () => {
expect(getByTestId(ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID)).toHaveTextContent(osFamily);
expect(getByTestId(ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID)).toHaveTextContent(lastSeenText);
expect(queryByTestId(ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID)).not.toBeInTheDocument();
expect(queryByTestId(TECHNICAL_PREVIEW_ICON_TEST_ID)).not.toBeInTheDocument();
});

it('should render correctly if returned data is null', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EuiIcon,
useEuiTheme,
useEuiFontSize,
EuiBetaBadge,
} from '@elastic/eui';
import { css } from '@emotion/css';
import { getOr } from 'lodash/fp';
Expand All @@ -23,11 +24,8 @@ import {
FirstLastSeen,
FirstLastSeenType,
} from '../../../common/components/first_last_seen/first_last_seen';
import {
buildHostNamesFilter,
RiskScoreEntity,
RiskSeverity,
} from '../../../../common/search_strategy';
import { buildHostNamesFilter, RiskScoreEntity } from '../../../../common/search_strategy';
import { getEmptyTagValue } from '../../../common/components/empty_value';
import { DefaultFieldRenderer } from '../../../timelines/components/field_renderers/field_renderers';
import { DescriptionListStyled } from '../../../common/components/page';
import { OverviewDescriptionList } from '../../../common/components/overview_description_list';
Expand All @@ -44,7 +42,9 @@ import {
ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID,
ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID,
ENTITIES_HOST_OVERVIEW_LINK_TEST_ID,
TECHNICAL_PREVIEW_ICON_TEST_ID,
} from './test_ids';
import { TECHNICAL_PREVIEW_TITLE, TECHNICAL_PREVIEW_MESSAGE } from './translations';
import { LeftPanelInsightsTab, LeftPanelKey } from '../../left';

const HOST_ICON = 'storage';
Expand Down Expand Up @@ -146,19 +146,35 @@ export const HostEntityOverview: React.FC<HostEntityOverviewProps> = ({ hostName
const hostRiskData = hostRisk && hostRisk.length > 0 ? hostRisk[0] : undefined;
return [
{
title: i18n.HOST_RISK_CLASSIFICATION,
title: (
<>
{i18n.HOST_RISK_CLASSIFICATION}
<EuiBetaBadge
css={css`
margin-left: ${euiTheme.size.xs};
`}
label={TECHNICAL_PREVIEW_TITLE}
size="s"
alignment="baseline"
iconType="beaker"
tooltipContent={TECHNICAL_PREVIEW_MESSAGE}
tooltipPosition="bottom"
data-test-subj={TECHNICAL_PREVIEW_ICON_TEST_ID}
/>
</>
),
description: (
<>
{hostRiskData ? (
<RiskScore severity={hostRiskData.host.risk.calculated_level} />
) : (
<RiskScore severity={RiskSeverity.unknown} />
getEmptyTagValue()
)}
</>
),
},
];
}, [hostRisk]);
}, [hostRisk, euiTheme.size.xs]);

return (
<EuiFlexGroup direction="column" gutterSize="s" data-test-subj={ENTITIES_HOST_OVERVIEW_TEST_ID}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export const ENTITIES_HOST_OVERVIEW_LINK_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TES
export const ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TEST_ID}OsFamily`;
export const ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TEST_ID}LastSeen`;
export const ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TEST_ID}RiskLevel`;
export const TECHNICAL_PREVIEW_ICON_TEST_ID =
'securitySolutionDocumentDetailsFlyoutTechnicalPreviewIcon';

/* Insights Threat Intelligence */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ export const RESPONSE_EMPTY = i18n.translate('xpack.securitySolution.flyout.resp
defaultMessage: 'There are no response actions defined for this event.',
});

export const TECHNICAL_PREVIEW_TITLE = i18n.translate(
'xpack.securitySolution.flyout.documentDetails.technicalPreviewTitle',
{ defaultMessage: 'Technical preview' }
);

export const TECHNICAL_PREVIEW_MESSAGE = i18n.translate(
'xpack.securitySolution.flyout.documentDetails.technicalPreviewMessage',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ENTITIES_USER_OVERVIEW_LAST_SEEN_TEST_ID,
ENTITIES_USER_OVERVIEW_LINK_TEST_ID,
ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID,
TECHNICAL_PREVIEW_ICON_TEST_ID,
} from './test_ids';
import { useObservedUserDetails } from '../../../explore/users/containers/users/observed_details';
import { mockContextValue } from '../mocks/mock_right_panel_context';
Expand Down Expand Up @@ -82,6 +83,7 @@ describe('<UserEntityOverview />', () => {

expect(getByTestId(ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID)).toHaveTextContent(domain);
expect(getByTestId(ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('Medium');
expect(getByTestId(TECHNICAL_PREVIEW_ICON_TEST_ID)).toBeInTheDocument();
});

it('should render correctly if returned data is null', () => {
Expand All @@ -96,7 +98,8 @@ describe('<UserEntityOverview />', () => {
</TestProviders>
);
expect(getByTestId(ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID)).toHaveTextContent('—');
expect(getByTestId(ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('Unknown');
expect(getByTestId(ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('—');
expect(getByTestId(TECHNICAL_PREVIEW_ICON_TEST_ID)).toBeInTheDocument();
});
});

Expand All @@ -117,6 +120,7 @@ describe('<UserEntityOverview />', () => {
expect(getByTestId(ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID)).toHaveTextContent(domain);
expect(getByTestId(ENTITIES_USER_OVERVIEW_LAST_SEEN_TEST_ID)).toHaveTextContent(lastSeenText);
expect(queryByTestId(ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID)).not.toBeInTheDocument();
expect(queryByTestId(TECHNICAL_PREVIEW_ICON_TEST_ID)).not.toBeInTheDocument();
});

it('should render correctly if returned data is null', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EuiLink,
useEuiTheme,
useEuiFontSize,
EuiBetaBadge,
} from '@elastic/eui';
import { css } from '@emotion/css';
import { getOr } from 'lodash/fp';
Expand All @@ -25,11 +26,8 @@ import {
FirstLastSeen,
FirstLastSeenType,
} from '../../../common/components/first_last_seen/first_last_seen';
import {
buildUserNamesFilter,
RiskScoreEntity,
RiskSeverity,
} from '../../../../common/search_strategy';
import { buildUserNamesFilter, RiskScoreEntity } from '../../../../common/search_strategy';
import { getEmptyTagValue } from '../../../common/components/empty_value';
import { DefaultFieldRenderer } from '../../../timelines/components/field_renderers/field_renderers';
import { DescriptionListStyled } from '../../../common/components/page';
import { OverviewDescriptionList } from '../../../common/components/overview_description_list';
Expand All @@ -44,7 +42,9 @@ import {
ENTITIES_USER_OVERVIEW_LAST_SEEN_TEST_ID,
ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID,
ENTITIES_USER_OVERVIEW_LINK_TEST_ID,
TECHNICAL_PREVIEW_ICON_TEST_ID,
} from './test_ids';
import { TECHNICAL_PREVIEW_TITLE, TECHNICAL_PREVIEW_MESSAGE } from './translations';
import { useObservedUserDetails } from '../../../explore/users/containers/users/observed_details';

const USER_ICON = 'user';
Expand Down Expand Up @@ -145,19 +145,34 @@ export const UserEntityOverview: React.FC<UserEntityOverviewProps> = ({ userName

return [
{
title: i18n.USER_RISK_CLASSIFICATION,
title: (
<>
{i18n.USER_RISK_CLASSIFICATION}
<EuiBetaBadge
css={css`
margin-left: ${euiTheme.size.xs};
`}
label={TECHNICAL_PREVIEW_TITLE}
size="s"
iconType="beaker"
tooltipContent={TECHNICAL_PREVIEW_MESSAGE}
tooltipPosition="bottom"
data-test-subj={TECHNICAL_PREVIEW_ICON_TEST_ID}
/>
</>
),
description: (
<>
{userRiskData ? (
<RiskScore severity={userRiskData.user.risk.calculated_level} />
) : (
<RiskScore severity={RiskSeverity.unknown} />
getEmptyTagValue()
)}
</>
),
},
];
}, [userRisk]);
}, [userRisk, euiTheme.size.xs]);

return (
<EuiFlexGroup direction="column" gutterSize="s" data-test-subj={ENTITIES_USER_OVERVIEW_TEST_ID}>
Expand Down