From e9cb2a313ecc5a8e3cfeca7d2b7df2878802096e Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 28 Nov 2022 15:16:58 +0200 Subject: [PATCH] [v9.3.x] Fix XSS in runbook URL (#684) Fix XSS in runbook URL (#681) (cherry picked from commit db1548c1491c2f5b522e3c0ceb1832b914a4b2f0) Co-authored-by: George Robinson --- .../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 00439bb23bd..cd66f5547fd 100644 --- a/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx +++ b/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx @@ -1,7 +1,7 @@ import { css } from '@emotion/css'; import React, { FC, Fragment } from 'react'; -import { GrafanaTheme2 } from '@grafana/data'; +import { GrafanaTheme2, textUtil } from '@grafana/data'; import { Button, HorizontalGroup, LinkButton, useStyles2 } from '@grafana/ui'; import { contextSrv } from 'app/core/services/context_srv'; import { AccessControlAction } from 'app/types'; @@ -61,7 +61,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