From 4adafbbd6ba2b91799d03d2627166a776944f829 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 | 4 +-- .../RuleContentViewer/RuleContentViewer.tsx | 28 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cypress-workflow.yml b/.github/workflows/cypress-workflow.yml index cdef2caa7..7c32bfba7 100644 --- a/.github/workflows/cypress-workflow.yml +++ b/.github/workflows/cypress-workflow.yml @@ -7,8 +7,8 @@ on: branches: - "*" env: - OPENSEARCH_DASHBOARDS_VERSION: '2.9' - SECURITY_ANALYTICS_BRANCH: '2.x' + OPENSEARCH_DASHBOARDS_VERSION: '2.9.0' + SECURITY_ANALYTICS_BRANCH: '2.9' jobs: tests: name: Run Cypress E2E tests 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}