From f890cb23b816e8d91baba8d7aed34a426da13d88 Mon Sep 17 00:00:00 2001 From: Esteban Beltran Date: Wed, 27 Sep 2023 16:50:23 +0200 Subject: [PATCH] Sandbox: use same trusted types default policy than grafana main realm (#75539) --- public/app/core/trustedTypePolicies.ts | 36 ++++++++++--------- .../plugins/sandbox/sandbox_plugin_loader.ts | 7 ++-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/public/app/core/trustedTypePolicies.ts b/public/app/core/trustedTypePolicies.ts index 997e4215194..6dedb7f68e8 100644 --- a/public/app/core/trustedTypePolicies.ts +++ b/public/app/core/trustedTypePolicies.ts @@ -3,27 +3,29 @@ import { config } from '@grafana/runtime'; const CSP_REPORT_ONLY_ENABLED = config.bootData.settings.cspReportOnlyEnabled; +export const defaultTrustedTypesPolicy = { + createHTML: (string: string, source: string, sink: string) => { + if (!CSP_REPORT_ONLY_ENABLED) { + return string.replace(/