From 2d3de82ae990971f3f47e9528766287fdf951112 Mon Sep 17 00:00:00 2001 From: Esteban Beltran Date: Wed, 19 Feb 2025 17:54:25 +0100 Subject: [PATCH] Frontend sandbox: Improve signature elegibility check to avoid extra requests (#100980) * Frontend sandbox: Improve signature elegibility check to avoid extra requests * remove caching element --- .../sandbox/sandbox_plugin_loader_registry.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/public/app/features/plugins/sandbox/sandbox_plugin_loader_registry.ts b/public/app/features/plugins/sandbox/sandbox_plugin_loader_registry.ts index 0d954d4ae75..2dbef3be1e1 100644 --- a/public/app/features/plugins/sandbox/sandbox_plugin_loader_registry.ts +++ b/public/app/features/plugins/sandbox/sandbox_plugin_loader_registry.ts @@ -62,21 +62,24 @@ export async function isPluginFrontendSandboxEligible({ return false; } - // don't run grafana-signed plugins in sandbox + // grafana signature and internal plugins are not allowed in the sandbox + return isPluginSignatureEligibleForSandbox({ pluginId }); +} + +async function isPluginSignatureEligibleForSandbox({ pluginId }: SandboxEligibilityCheckParams): Promise { try { - //this can fail if gcom is not accesible - const details = await getPluginDetails(pluginId); - return details.signatureType !== PluginSignatureType.grafana && details.signature !== 'internal'; + // this can fail if we are trying to fetch settings of a non-installed plugin + const pluginMeta = await getPluginSettings(pluginId, { showErrorAlert: false }); + return pluginMeta.signatureType !== PluginSignatureType.grafana && pluginMeta.signature !== 'internal'; } catch (e) { try { - // this can fail if we are trying to fetch settings of a non-installed plugin - const pluginMeta = await getPluginSettings(pluginId, { showErrorAlert: false }); - return pluginMeta.signatureType !== PluginSignatureType.grafana && pluginMeta.signature !== 'internal'; + //this can fail if gcom is not accesible + const details = await getPluginDetails(pluginId); + return details.signatureType !== PluginSignatureType.grafana && details.signature !== 'internal'; } catch (e) { return false; } } - return true; } /**