From c26b693341c582e57a1f07eebe6c676b3b90ec3d Mon Sep 17 00:00:00 2001 From: Amardeepsingh Siglani Date: Tue, 5 Sep 2023 11:28:16 -0700 Subject: [PATCH] Make tags hyperlinks to mitre attack web pages in detection rules (#692) * made rule tags links to mitre attack webpage Signed-off-by: Amardeepsingh Siglani * updated workflow file Signed-off-by: Amardeepsingh Siglani --------- Signed-off-by: Amardeepsingh Siglani --- .github/workflows/cypress-workflow.yml | 2 +- .../RuleContentViewer/RuleContentViewer.tsx | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cypress-workflow.yml b/.github/workflows/cypress-workflow.yml index 5df3d7107..3b6bc009d 100644 --- a/.github/workflows/cypress-workflow.yml +++ b/.github/workflows/cypress-workflow.yml @@ -9,7 +9,7 @@ on: env: OPENSEARCH_DASHBOARDS_VERSION: '2.9.0' OPENSEARCH_VERSION: '2.9.0-SNAPSHOT' - SECURITY_ANALYTICS_BRANCH: '2.x' + SECURITY_ANALYTICS_BRANCH: '2.9' GRADLE_VERSION: '7.6.1' # If this variable is not empty, the package.json, opensearch_dashboards.json, and yarn.lock files will be replaced diff --git a/public/pages/Rules/components/RuleContentViewer/RuleContentViewer.tsx b/public/pages/Rules/components/RuleContentViewer/RuleContentViewer.tsx index 9c5c83afb..193ebfa39 100644 --- a/public/pages/Rules/components/RuleContentViewer/RuleContentViewer.tsx +++ b/public/pages/Rules/components/RuleContentViewer/RuleContentViewer.tsx @@ -129,11 +129,29 @@ export const RuleContentViewer: React.FC = ({ gutterSize="s" data-test-subj={'rule_flyout_rule_tags'} > - {ruleData.tags.map((tag: any, i: number) => ( - - {tag.value} - - ))} + {ruleData.tags.map((tag: { value: string }, i: number) => { + const isLinkable = !!tag.value.match(/attack\.t[0-9]+/); + let tagComponent: React.ReactNode = tag.value; + + if (isLinkable) { + const link = `https://attack.mitre.org/techniques/${tag.value + .split('.') + .slice(1) + .join('/') + .toUpperCase()}`; + tagComponent = ( + + {tag.value} + + ); + } + + return ( + + {tagComponent} + + ); + })} ) : (
{DEFAULT_EMPTY_DATA}