From c447095d667463c51ff11db3abd1151f07c450f5 Mon Sep 17 00:00:00 2001 From: Mark Hopkin Date: Wed, 29 Nov 2023 14:07:55 +0000 Subject: [PATCH 1/2] [Entity Analytics] Use docLinks service for documentation links --- packages/kbn-doc-links/src/get_doc_links.ts | 3 ++ packages/kbn-doc-links/src/types.ts | 3 ++ .../security_solution/common/constants.ts | 7 ---- .../risk_score_doc_link.tsx | 32 ++++++++++--------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/packages/kbn-doc-links/src/get_doc_links.ts b/packages/kbn-doc-links/src/get_doc_links.ts index 8234daa4b445..72cb74639feb 100644 --- a/packages/kbn-doc-links/src/get_doc_links.ts +++ b/packages/kbn-doc-links/src/get_doc_links.ts @@ -460,6 +460,9 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => { createEsqlRuleType: `${SECURITY_SOLUTION_DOCS}rules-ui-create.html#create-esql-rule`, entityAnalytics: { riskScorePrerequisites: `${SECURITY_SOLUTION_DOCS}ers-requirements.html`, + hostRiskScore: 'host-risk-score.html', + userRiskScore: 'user-risk-score.html', + entityRiskScoring: 'advanced-entity-analytics-overview.html#entity-risk-scoring', }, }, query: { diff --git a/packages/kbn-doc-links/src/types.ts b/packages/kbn-doc-links/src/types.ts index b2298eecd3e1..85d540cb70ca 100644 --- a/packages/kbn-doc-links/src/types.ts +++ b/packages/kbn-doc-links/src/types.ts @@ -351,6 +351,9 @@ export interface DocLinks { readonly createEsqlRuleType: string; readonly entityAnalytics: { readonly riskScorePrerequisites: string; + readonly hostRiskScore: string; + readonly userRiskScore: string; + readonly entityRiskScoring: string; }; }; readonly query: { diff --git a/x-pack/plugins/security_solution/common/constants.ts b/x-pack/plugins/security_solution/common/constants.ts index 48ae1a940f61..efa4c683da0d 100644 --- a/x-pack/plugins/security_solution/common/constants.ts +++ b/x-pack/plugins/security_solution/common/constants.ts @@ -450,13 +450,6 @@ export enum BulkActionsDryRunErrCode { ESQL_INDEX_PATTERN = 'ESQL_INDEX_PATTERN', } -export const RISKY_HOSTS_DOC_LINK = - 'https://www.elastic.co/guide/en/security/current/host-risk-score.html'; -export const RISKY_USERS_DOC_LINK = - 'https://www.elastic.co/guide/en/security/current/user-risk-score.html'; -export const RISKY_ENTITY_SCORE_DOC_LINK = - 'https://www.elastic.co/guide/en/security/current/advanced-entity-analytics-overview.html#entity-risk-scoring'; - export const MAX_NUMBER_OF_NEW_TERMS_FIELDS = 3; export const BULK_ADD_TO_TIMELINE_LIMIT = 2000; diff --git a/x-pack/plugins/security_solution/public/explore/components/risk_score/risk_score_onboarding/risk_score_doc_link.tsx b/x-pack/plugins/security_solution/public/explore/components/risk_score/risk_score_onboarding/risk_score_doc_link.tsx index dbe56fd74931..a54bb9e62762 100644 --- a/x-pack/plugins/security_solution/public/explore/components/risk_score/risk_score_onboarding/risk_score_doc_link.tsx +++ b/x-pack/plugins/security_solution/public/explore/components/risk_score/risk_score_onboarding/risk_score_doc_link.tsx @@ -8,12 +8,22 @@ import { EuiLink } from '@elastic/eui'; import React, { useMemo } from 'react'; import { RiskScoreEntity } from '../../../../../common/search_strategy'; -import { - RISKY_HOSTS_DOC_LINK, - RISKY_USERS_DOC_LINK, - RISKY_ENTITY_SCORE_DOC_LINK, -} from '../../../../../common/constants'; import { LEARN_MORE } from '../../../../overview/components/entity_analytics/risk_score/translations'; +import { useKibana } from '../../../../common/lib/kibana'; + +const useLearnMoreLinkForEntity = (riskScoreEntity?: RiskScoreEntity) => { + const { docLinks } = useKibana().services; + const entityAnalyticsLinks = docLinks.links.securitySolution.entityAnalytics; + return useMemo(() => { + if (!riskScoreEntity) { + return entityAnalyticsLinks.entityRiskScoring; + } + if (riskScoreEntity === RiskScoreEntity.user) { + return entityAnalyticsLinks.userRiskScore; + } + return entityAnalyticsLinks.hostRiskScore; + }, [riskScoreEntity, entityAnalyticsLinks]); +}; const RiskScoreDocLinkComponent = ({ riskScoreEntity, @@ -22,18 +32,10 @@ const RiskScoreDocLinkComponent = ({ riskScoreEntity?: RiskScoreEntity; title?: string | React.ReactNode; }) => { - const docLink = useMemo(() => { - if (!riskScoreEntity) { - return RISKY_ENTITY_SCORE_DOC_LINK; - } - if (riskScoreEntity === RiskScoreEntity.user) { - return RISKY_USERS_DOC_LINK; - } - return RISKY_HOSTS_DOC_LINK; - }, [riskScoreEntity]); + const learnMoreLink = useLearnMoreLinkForEntity(riskScoreEntity); return ( - + {title ? title : LEARN_MORE(riskScoreEntity)} ); From 4b07190bfe33ea79228773b1ba71314238137ec0 Mon Sep 17 00:00:00 2001 From: Mark Hopkin Date: Thu, 30 Nov 2023 14:27:45 +0000 Subject: [PATCH 2/2] prefix doc URLs --- packages/kbn-doc-links/src/get_doc_links.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/kbn-doc-links/src/get_doc_links.ts b/packages/kbn-doc-links/src/get_doc_links.ts index 72cb74639feb..d115958fe320 100644 --- a/packages/kbn-doc-links/src/get_doc_links.ts +++ b/packages/kbn-doc-links/src/get_doc_links.ts @@ -460,9 +460,9 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => { createEsqlRuleType: `${SECURITY_SOLUTION_DOCS}rules-ui-create.html#create-esql-rule`, entityAnalytics: { riskScorePrerequisites: `${SECURITY_SOLUTION_DOCS}ers-requirements.html`, - hostRiskScore: 'host-risk-score.html', - userRiskScore: 'user-risk-score.html', - entityRiskScoring: 'advanced-entity-analytics-overview.html#entity-risk-scoring', + hostRiskScore: `${SECURITY_SOLUTION_DOCS}host-risk-score.html`, + userRiskScore: `${SECURITY_SOLUTION_DOCS}user-risk-score.html`, + entityRiskScoring: `${SECURITY_SOLUTION_DOCS}advanced-entity-analytics-overview.html#entity-risk-scoring`, }, }, query: {