Skip to content

Commit

Permalink
[Entity Analytics] Remove links to legacy risk scoring docs (#187585)
Browse files Browse the repository at this point in the history
## Summary

Related to elastic/security-docs#5489. We had
a few places where we incorrectly link to the legacy
user/host risk scoring docs. 

In deleting the links I found we had two `RiskSummary` components which
components which I have renamed `RiskSummaryPanel` and
`FlyoutRiskSummary` to make life easier.

<img width="770" alt="Screenshot 2024-07-04 at 15 47 14"
src="https://github.com/elastic/kibana/assets/3315046/20e26a15-4975-4165-9c56-bb328c508bee">

---------

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
hop-dev and elasticmachine authored Jul 11, 2024
1 parent 460b520 commit 12bd8fe
Show file tree
Hide file tree
Showing 27 changed files with 106 additions and 133 deletions.
2 changes: 0 additions & 2 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,6 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D
ruleUiAdvancedParams: `${SECURITY_SOLUTION_DOCS}rules-ui-create.html#rule-ui-advanced-params`,
entityAnalytics: {
riskScorePrerequisites: `${SECURITY_SOLUTION_DOCS}ers-requirements.html`,
hostRiskScore: `${SECURITY_SOLUTION_DOCS}host-risk-score.html`,
userRiskScore: `${SECURITY_SOLUTION_DOCS}user-risk-score.html`,
entityRiskScoring: `${SECURITY_SOLUTION_DOCS}entity-risk-scoring.html`,
assetCriticality: `${SECURITY_SOLUTION_DOCS}asset-criticality.html`,
},
Expand Down
2 changes: 0 additions & 2 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ export interface DocLinks {
readonly ruleUiAdvancedParams: string;
readonly entityAnalytics: {
readonly riskScorePrerequisites: string;
readonly hostRiskScore: string;
readonly userRiskScore: string;
readonly entityRiskScoring: string;
readonly assetCriticality: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
TimelineEventsDetailsItem,
RiskSeverity,
} from '../../../../../common/search_strategy';
import { RiskSummary } from '../../../../entity_analytics/components/risk_summary';
import { RiskSummaryPanel } from '../../../../entity_analytics/components/risk_summary_panel';
import { EnrichmentSummary } from './enrichment_summary';
import { RiskScoreEntity } from '../../../../../common/search_strategy';
import { useHasSecurityCapability } from '../../../../helper_hooks';
Expand Down Expand Up @@ -137,15 +137,15 @@ const ThreatSummaryViewComponent: React.FC<{
{hasEntityAnalyticsCapability && (
<>
<EuiFlexItem grow={false}>
<RiskSummary
<RiskSummaryPanel
riskEntity={RiskScoreEntity.host}
risk={hostRisk}
originalRisk={originalHostRisk}
/>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<RiskSummary
<RiskSummaryPanel
riskEntity={RiskScoreEntity.user}
risk={userRisk}
originalRisk={originalUserRisk}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useCheckSignalIndex } from '../../../detections/containers/detection_en
import type { inputsModel } from '../../../common/store';
import { RiskScoreHeaderTitle } from '../risk_score_onboarding/risk_score_header_title';
import { HeaderSection } from '../../../common/components/header_section';
import { RiskScoreDocLink } from '../risk_score_onboarding/risk_score_doc_link';
import { EntityAnalyticsLearnMoreLink } from '../risk_score_onboarding/entity_analytics_doc_link';
import { RiskScoreEnableButton } from '../risk_score_onboarding/risk_score_enable_button';
import * as i18n from './translations';

Expand Down Expand Up @@ -55,7 +55,7 @@ const EnableRiskScoreComponent = ({
<>
{text.body}
{` `}
<RiskScoreDocLink riskScoreEntity={entityType} />
<EntityAnalyticsLearnMoreLink />
</>
}
actions={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ export const VIEW_ALL = i18n.translate(
}
);

export const LEARN_MORE = (riskEntity?: RiskScoreEntity) =>
i18n.translate('xpack.securitySolution.entityAnalytics.riskDashboard.learnMore', {
defaultMessage: 'Learn more about {riskEntity} risk',
values: {
riskEntity: getRiskEntityTranslation(riskEntity, true),
},
});

export const LAST_UPDATED = i18n.translate(
'xpack.securitySolution.entityAnalytics.riskDashboard.lastUpdatedTitle',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
CriticalityLevels,
CriticalityModifiers,
} from '../../../../common/entity_analytics/asset_criticality';
import { RiskScoreDocLink } from '../risk_score_onboarding/risk_score_doc_link';
import { EntityAnalyticsLearnMoreLink } from '../risk_score_onboarding/entity_analytics_doc_link';
import { BETA } from '../risk_score_onboarding/translations';
import { AssetCriticalityBadge } from '../asset_criticality';

Expand Down Expand Up @@ -262,14 +262,7 @@ export const RiskInformationFlyout = ({ handleOnClose }: { handleOnClose: () =>
</SpacedOrderedList>
</EuiText>
<EuiSpacer size="m" />
<RiskScoreDocLink
title={
<FormattedMessage
id="xpack.securitySolution.riskInformation.learnMore"
defaultMessage="Learn more about Entity risk"
/>
}
/>
<EntityAnalyticsLearnMoreLink />
</EuiFlyoutBody>

<EuiFlyoutFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export const RISK_SCORE_TITLE = (riskEntity: RiskScoreEntity) =>
},
});

export const RISK_SCORING_TITLE = i18n.translate(
'xpack.securitySolution.riskScore.overview.riskScoringTitle',
{
defaultMessage: 'Entity Risk Scoring',
}
);

export const ENTITY_RISK_LEVEL = (riskEntity: RiskScoreEntity) =>
i18n.translate('xpack.securitySolution.entityAnalytics.riskDashboard.riskLevelTitle', {
defaultMessage: '{riskEntity} risk level',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import React from 'react';
import { useKibana } from '../../../common/lib/kibana';

const EntityAnalyticsLearnMoreLinkComponent = ({ title }: { title?: string | React.ReactNode }) => {
const { docLinks } = useKibana().services;
const entityAnalyticsLinks = docLinks.links.securitySolution.entityAnalytics;

return (
<EuiLink
target="_blank"
rel="noopener nofollow noreferrer"
href={entityAnalyticsLinks.entityRiskScoring}
>
{title ? (
title
) : (
<FormattedMessage
id="xpack.securitySolution.entityAnalytics.learnMore"
defaultMessage="Learn more about entity risk scoring"
/>
)}
</EuiLink>
);
};

export const EntityAnalyticsLearnMoreLink = React.memo(EntityAnalyticsLearnMoreLinkComponent);

EntityAnalyticsLearnMoreLink.displayName = 'EntityAnalyticsLearnMoreLink';

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const RiskScoreEnableButtonComponent = ({
}) => {
const spaceId = useSpaceId();
const { http, dashboard, ...startServices } = useKibana().services;
const { renderDocLink, renderDashboardLink } = useRiskScoreToastContent(riskScoreEntity);
const { renderDocLink, renderDashboardLink } = useRiskScoreToastContent();
const { fetch, isLoading } = useFetch(REQUEST_NAMES.ENABLE_RISK_SCORE, installRiskScoreModule);
const isRiskEngineEnabled = useIsExperimentalFeatureEnabled('riskScoringRoutesEnabled');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const RiskScoreRestartButtonComponent = ({
);
const spaceId = useSpaceId();

const { renderDocLink } = useRiskScoreToastContent(riskScoreEntity);
const { renderDocLink } = useRiskScoreToastContent();
const { http, ...startServices } = useKibana().services;

const onClick = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ import React, { useCallback, useMemo } from 'react';
import styled from 'styled-components';
import { FormattedMessage } from '@kbn/i18n-react';

import type { RiskScoreEntity } from '../../../../common/search_strategy';
import { RiskScoreDocLink } from './risk_score_doc_link';
import { EntityAnalyticsLearnMoreLink } from './entity_analytics_doc_link';

const StyledButton = styled(EuiButton)`
float: right;
`;

export const useRiskScoreToastContent = (riskScoreEntity: RiskScoreEntity) => {
export const useRiskScoreToastContent = () => {
const renderDocLink = useCallback(
(message: string) => (
<>
{message} <RiskScoreDocLink riskScoreEntity={riskScoreEntity} />
{message} <EntityAnalyticsLearnMoreLink />
</>
),
[riskScoreEntity]
[]
);
const renderDashboardLink = useCallback(
(message: string, targetUrl: string) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import type { Story } from '@storybook/react';
import { TestProvider } from '@kbn/expandable-flyout/src/test/provider';
import { StorybookProviders } from '../../../common/mock/storybook_providers';
import { mockRiskScoreState } from '../../../timelines/components/side_panel/new_user_detail/__mocks__';
import { RiskSummary } from './risk_summary';
import { FlyoutRiskSummary } from './risk_summary';

export default {
component: RiskSummary,
title: 'Components/RiskSummary',
component: FlyoutRiskSummary,
title: 'Components/FlyoutRiskSummary',
};

export const Default: Story<void> = () => {
return (
<StorybookProviders>
<TestProvider>
<div style={{ maxWidth: '300px' }}>
<RiskSummary
<FlyoutRiskSummary
openDetailsPanel={() => {}}
riskScoreData={{ ...mockRiskScoreState, data: [] }}
queryId={'testQuery'}
Expand All @@ -39,7 +39,7 @@ export const PreviewMode: Story<void> = () => {
<StorybookProviders>
<TestProvider>
<div style={{ maxWidth: '300px' }}>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={{ ...mockRiskScoreState, data: [] }}
queryId={'testQuery'}
recalculatingScore={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { render } from '@testing-library/react';
import React from 'react';
import { TestProviders } from '../../../common/mock';
import { RiskSummary } from './risk_summary';
import { FlyoutRiskSummary } from './risk_summary';
import type {
LensAttributes,
VisualizationEmbeddableProps,
Expand All @@ -37,15 +37,15 @@ jest.mock('@kbn/kibana-react-plugin/public', () => {
};
});

describe('RiskSummary', () => {
describe('FlyoutRiskSummary', () => {
beforeEach(() => {
mockVisualizationEmbeddable.mockClear();
});

it('renders risk summary table with alerts only', () => {
const { getByTestId, queryByTestId } = render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={mockHostRiskScoreState}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('RiskSummary', () => {

const { getByTestId } = render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={mockHostRiskScoreState}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('RiskSummary', () => {
it('renders risk summary table when riskScoreData is empty', () => {
const { getByTestId } = render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={{ ...mockHostRiskScoreState, data: undefined }}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand All @@ -122,7 +122,7 @@ describe('RiskSummary', () => {
it('risk summary header does not render link when riskScoreData is loading', () => {
const { queryByTestId } = render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={{ ...mockHostRiskScoreState, data: undefined, loading: true }}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand All @@ -137,7 +137,7 @@ describe('RiskSummary', () => {
it('risk summary header does not render expand icon when in preview mode', () => {
const { queryByTestId } = render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={{ ...mockHostRiskScoreState, data: undefined, loading: true }}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand All @@ -154,7 +154,7 @@ describe('RiskSummary', () => {
it('renders visualization embeddable', () => {
const { getByTestId } = render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={mockHostRiskScoreState}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand All @@ -169,7 +169,7 @@ describe('RiskSummary', () => {
it('renders updated at', () => {
const { getByTestId } = render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={mockHostRiskScoreState}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand All @@ -184,7 +184,7 @@ describe('RiskSummary', () => {
it('builds lens attributes for host risk score', () => {
render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={mockHostRiskScoreState}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand All @@ -211,7 +211,7 @@ describe('RiskSummary', () => {
it('builds lens cases attachment metadata for host risk score', () => {
render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={mockHostRiskScoreState}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand All @@ -233,7 +233,7 @@ describe('RiskSummary', () => {
it('builds lens cases attachment metadata for user risk score', () => {
render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={mockUserRiskScoreState}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand All @@ -255,7 +255,7 @@ describe('RiskSummary', () => {
it('builds lens attributes for user risk score', () => {
render(
<TestProviders>
<RiskSummary
<FlyoutRiskSummary
riskScoreData={mockUserRiskScoreState}
queryId={'testQuery'}
openDetailsPanel={() => {}}
Expand Down
Loading

0 comments on commit 12bd8fe

Please sign in to comment.