From c4e4bfe257a2286fe80bc100bcddd4c47542ecb3 Mon Sep 17 00:00:00 2001 From: George Robinson Date: Mon, 28 Nov 2022 13:04:06 +0000 Subject: [PATCH] Backport Fix XSS in runbook URL (#681) to v9.2.x (#683) (cherry picked from commit db1548c1491c2f5b522e3c0ceb1832b914a4b2f0) (cherry picked from commit 3135a81edf0ebeb575c95560dd548f9589c14d02) (cherry picked from commit fe17b64445d9cac8c0b4756867f609320c9cb049) --- .../unified/components/rules/RuleDetailsActionButtons.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx b/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx index 4ef5a98f33f..65a1e809246 100644 --- a/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx +++ b/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx @@ -2,7 +2,7 @@ import { css } from '@emotion/css'; import React, { FC, Fragment, useState } from 'react'; import { useLocation } from 'react-router-dom'; -import { GrafanaTheme2, urlUtil } from '@grafana/data'; +import { GrafanaTheme2, textUtil, urlUtil } from '@grafana/data'; import { config } from '@grafana/runtime'; import { Button, ClipboardButton, ConfirmModal, HorizontalGroup, LinkButton, useStyles2 } from '@grafana/ui'; import { useAppNotification } from 'app/core/copy/appNotification'; @@ -102,7 +102,7 @@ export const RuleDetailsActionButtons: FC = ({ rule, rulesSource }) => { variant="primary" icon="book" target="__blank" - href={rule.annotations[Annotation.runbookURL]} + href={textUtil.sanitizeUrl(rule.annotations[Annotation.runbookURL])} > View runbook