From 7b4eb22242af5fc112e5bf6bc1fc466905de61d2 Mon Sep 17 00:00:00 2001 From: Esteban Beltran Date: Tue, 15 Apr 2025 12:52:14 +0200 Subject: [PATCH] Chore: Remove code for feature flag frontendSandboxMonitorOnly (#103982) * Chore: Remove code for feature flag frontendSandboxMonitorOnly * Fix lint issues --- .../src/types/featureToggles.gen.ts | 4 - pkg/services/featuremgmt/registry.go | 7 -- pkg/services/featuremgmt/toggles_gen.csv | 1 - pkg/services/featuremgmt/toggles_gen.go | 4 - pkg/services/featuremgmt/toggles_gen.json | 111 +++++++++--------- .../plugins/sandbox/distortion_map.ts | 41 +------ .../plugins/sandbox/document_sandbox.ts | 20 +--- public/app/features/plugins/sandbox/utils.ts | 6 +- 8 files changed, 69 insertions(+), 125 deletions(-) diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index b8a364f19a6..6bef5fe1b7e 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -178,10 +178,6 @@ export interface FeatureToggles { */ pluginsFrontendSandbox?: boolean; /** - * Enables monitor only in the plugin frontend sandbox (if enabled) - */ - frontendSandboxMonitorOnly?: boolean; - /** * Enables right panel for the plugins details page * @default true */ diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index c96090f0e2d..52dc328685e 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -283,13 +283,6 @@ var ( Stage: FeatureStagePrivatePreview, Owner: grafanaPluginsPlatformSquad, }, - { - Name: "frontendSandboxMonitorOnly", - Description: "Enables monitor only in the plugin frontend sandbox (if enabled)", - Stage: FeatureStagePrivatePreview, - FrontendOnly: true, - Owner: grafanaPluginsPlatformSquad, - }, { Name: "pluginsDetailsRightPanel", Description: "Enables right panel for the plugins details page", diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index 4f50369af09..387cea9729b 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -36,7 +36,6 @@ enableDatagridEditing,preview,@grafana/dataviz-squad,false,false,true extraThemes,experimental,@grafana/grafana-frontend-platform,false,false,true lokiPredefinedOperations,experimental,@grafana/observability-logs,false,false,true pluginsFrontendSandbox,privatePreview,@grafana/plugins-platform-backend,false,false,false -frontendSandboxMonitorOnly,privatePreview,@grafana/plugins-platform-backend,false,false,true pluginsDetailsRightPanel,GA,@grafana/plugins-platform-backend,false,false,true sqlDatasourceDatabaseSelection,preview,@grafana/oss-big-tent,false,false,true recordedQueriesMulti,GA,@grafana/observability-metrics,false,false,false diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 7fcbc519d18..e7774064927 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -155,10 +155,6 @@ const ( // Enables the plugins frontend sandbox FlagPluginsFrontendSandbox = "pluginsFrontendSandbox" - // FlagFrontendSandboxMonitorOnly - // Enables monitor only in the plugin frontend sandbox (if enabled) - FlagFrontendSandboxMonitorOnly = "frontendSandboxMonitorOnly" - // FlagPluginsDetailsRightPanel // Enables right panel for the plugins details page FlagPluginsDetailsRightPanel = "pluginsDetailsRightPanel" diff --git a/pkg/services/featuremgmt/toggles_gen.json b/pkg/services/featuremgmt/toggles_gen.json index c3cf020be00..9f2c43cc3a4 100644 --- a/pkg/services/featuremgmt/toggles_gen.json +++ b/pkg/services/featuremgmt/toggles_gen.json @@ -62,7 +62,7 @@ "metadata": { "name": "alertRuleRestore", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-05T14:15:26Z" }, "spec": { "description": "Enables the alert rule restore feature", @@ -76,7 +76,7 @@ "name": "alertStateHistoryLokiOnly", "resourceVersion": "1743693517832", "creationTimestamp": "2023-03-30T18:53:21Z", - "deletionTimestamp": "2025-04-07T14:33:12Z" + "deletionTimestamp": "2025-04-08T13:50:27Z" }, "spec": { "description": "Disable Grafana alerts from emitting annotations when a remote Loki instance is available.", @@ -89,7 +89,7 @@ "name": "alertStateHistoryLokiPrimary", "resourceVersion": "1743693517832", "creationTimestamp": "2023-03-30T18:53:21Z", - "deletionTimestamp": "2025-04-07T14:33:12Z" + "deletionTimestamp": "2025-04-08T13:50:27Z" }, "spec": { "description": "Enable a remote Loki instance as the primary source for state history reads.", @@ -102,7 +102,7 @@ "name": "alertStateHistoryLokiSecondary", "resourceVersion": "1743693517832", "creationTimestamp": "2023-03-30T18:53:21Z", - "deletionTimestamp": "2025-04-07T14:33:12Z" + "deletionTimestamp": "2025-04-08T13:50:27Z" }, "spec": { "description": "Enable Grafana to write alert state history to an external Loki instance in addition to Grafana annotations.", @@ -153,8 +153,8 @@ "metadata": { "name": "alertingConversionAPI", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z", - "deletionTimestamp": "2025-04-04T13:25:42Z" + "creationTimestamp": "2025-02-12T07:13:21Z", + "deletionTimestamp": "2025-04-05T08:27:02Z" }, "spec": { "description": "Enable the alerting conversion API", @@ -210,7 +210,7 @@ "metadata": { "name": "alertingJiraIntegration", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-02-14T12:22:04Z" }, "spec": { "description": "Enables the new Jira integration for contact points in cloud alert managers.", @@ -237,7 +237,7 @@ "metadata": { "name": "alertingMigrationUI", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-14T16:40:05Z" }, "spec": { "description": "Enables the alerting migration UI, to migrate datasource-managed rules to Grafana-managed rules", @@ -306,7 +306,7 @@ "metadata": { "name": "alertingRulePermanentlyDelete", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-04-03T11:18:25Z" }, "spec": { "description": "Enables UI functionality to permanently delete alert rules", @@ -322,7 +322,7 @@ "metadata": { "name": "alertingRuleRecoverDeleted", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-27T14:39:26Z" }, "spec": { "description": "Enables the UI functionality to recover and view deleted alert rules", @@ -338,7 +338,7 @@ "metadata": { "name": "alertingRuleVersionHistoryRestore", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-02-17T12:25:32Z" }, "spec": { "description": "Enables the alert rule version history restore feature", @@ -354,7 +354,7 @@ "metadata": { "name": "alertingSaveStateCompressed", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-01-27T17:47:33Z" }, "spec": { "description": "Enables the compressed protobuf-based alert state storage", @@ -483,7 +483,7 @@ "metadata": { "name": "assetSriChecks", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-04T10:56:35Z" }, "spec": { "description": "Enables SRI checks for Grafana JavaScript assets", @@ -561,7 +561,7 @@ "metadata": { "name": "azureMonitorLogsBuilderEditor", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-04-02T14:15:25Z" }, "spec": { "description": "Enables the logs builder mode for the Azure Monitor data source", @@ -735,7 +735,7 @@ "metadata": { "name": "dashboardDisableSchemaValidationV1", "resourceVersion": "1744303023863", - "creationTimestamp": "2025-04-10T16:37:03Z" + "creationTimestamp": "2025-04-11T16:52:46Z" }, "spec": { "description": "Disable schema validation for dashboards/v1", @@ -747,7 +747,7 @@ "metadata": { "name": "dashboardDisableSchemaValidationV2", "resourceVersion": "1744303023863", - "creationTimestamp": "2025-04-10T16:37:03Z" + "creationTimestamp": "2025-04-11T16:52:46Z" }, "spec": { "description": "Disable schema validation for dashboards/v2", @@ -814,7 +814,7 @@ "metadata": { "name": "dashboardSchemaValidationLogging", "resourceVersion": "1744303223631", - "creationTimestamp": "2025-04-10T16:40:23Z" + "creationTimestamp": "2025-04-11T16:52:46Z" }, "spec": { "description": "Log schema validation errors so they can be analyzed later", @@ -1116,7 +1116,7 @@ "name": "exploreMetrics", "resourceVersion": "1743693517832", "creationTimestamp": "2024-04-09T18:15:18Z", - "deletionTimestamp": "2025-04-11T01:41:57Z" + "deletionTimestamp": "2025-04-11T20:45:14Z" }, "spec": { "description": "Enables the new Grafana Metrics Drilldown core app", @@ -1143,8 +1143,8 @@ "metadata": { "name": "exploreMetricsUseExternalAppPlugin", "resourceVersion": "1744146547481", - "creationTimestamp": "2025-04-03T15:18:37Z", - "deletionTimestamp": "2025-04-11T01:41:57Z", + "creationTimestamp": "2025-02-03T20:46:54Z", + "deletionTimestamp": "2025-04-11T20:45:14Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-08 21:09:07.481769 +0000 UTC" } @@ -1174,7 +1174,7 @@ "metadata": { "name": "extensionSidebar", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-04-03T10:16:35Z" }, "spec": { "description": "Enables the extension sidebar", @@ -1306,7 +1306,7 @@ "metadata": { "name": "fetchRulesUsingPost", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-01-29T12:17:44Z" }, "spec": { "description": "Use a POST request to list rules by passing down the namespaces user has access to", @@ -1360,7 +1360,8 @@ "metadata": { "name": "frontendSandboxMonitorOnly", "resourceVersion": "1743693517832", - "creationTimestamp": "2023-07-05T11:48:25Z" + "creationTimestamp": "2023-07-05T11:48:25Z", + "deletionTimestamp": "2025-04-14T13:27:59Z" }, "spec": { "description": "Enables monitor only in the plugin frontend sandbox (if enabled)", @@ -1427,7 +1428,7 @@ "metadata": { "name": "grafanaManagedRecordingRulesDatasources", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-07T13:30:40Z" }, "spec": { "description": "Enables writing to data sources for Grafana-managed recording rules.", @@ -1441,7 +1442,7 @@ "metadata": { "name": "grafanaconThemes", "resourceVersion": "1744293476104", - "creationTimestamp": "2025-04-03T15:18:37Z", + "creationTimestamp": "2025-02-06T11:08:04Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-10 13:57:56.104154 +0000 UTC" } @@ -1565,7 +1566,7 @@ "metadata": { "name": "infinityRunQueriesInParallel", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-14T12:54:04Z" }, "spec": { "description": "Enables running Infinity queries in parallel", @@ -1629,7 +1630,7 @@ "metadata": { "name": "inviteUserExperimental", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-07T19:09:59Z" }, "spec": { "description": "Renders invite user button along the app", @@ -1709,7 +1710,7 @@ "metadata": { "name": "kubernetesClientDashboardsFolders", "resourceVersion": "1744337414536", - "creationTimestamp": "2025-02-18T21:15:35Z", + "creationTimestamp": "2025-02-18T23:11:26Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-11 02:10:14.536012 +0000 UTC" } @@ -1794,7 +1795,7 @@ "name": "live-service-web-worker", "resourceVersion": "1743693517832", "creationTimestamp": "2022-01-26T17:44:20Z", - "deletionTimestamp": "2025-04-07T09:56:17Z" + "deletionTimestamp": "2025-04-07T14:47:35Z" }, "spec": { "description": "This will use a webworker thread to processes events rather than the main thread", @@ -1807,7 +1808,7 @@ "metadata": { "name": "localeFormatPreference", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-31T13:59:07Z" }, "spec": { "description": "Specifies the locale so the correct format for numbers and dates can be shown", @@ -1819,7 +1820,7 @@ "metadata": { "name": "localizationForPlugins", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-31T04:38:38Z" }, "spec": { "description": "Enables localization for plugins", @@ -1928,7 +1929,7 @@ "metadata": { "name": "logsPanelControls", "resourceVersion": "1744209818391", - "creationTimestamp": "2025-04-04T13:11:29Z", + "creationTimestamp": "2025-04-07T14:38:55Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-09 14:43:38.391331 +0000 UTC" } @@ -2087,7 +2088,7 @@ "metadata": { "name": "managedDualWriter", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-02-19T14:50:39Z" }, "spec": { "description": "Pick the dual write mode from database configs", @@ -2101,7 +2102,7 @@ "metadata": { "name": "metricsFromProfiles", "resourceVersion": "1743767250962", - "creationTimestamp": "2025-04-04T11:45:44Z", + "creationTimestamp": "2025-04-09T10:55:28Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-04 11:47:30.962546 +0000 UTC" } @@ -2129,7 +2130,7 @@ "metadata": { "name": "multiTenantTempCredentials", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-04-02T20:25:50Z" }, "spec": { "description": "use multi-tenant path for awsTempCredentials", @@ -2221,7 +2222,7 @@ "metadata": { "name": "newLogsPanel", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-02-04T17:40:17Z" }, "spec": { "description": "Enables the new logs panel in Explore", @@ -2247,7 +2248,7 @@ "metadata": { "name": "newShareReportDrawer", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-02-17T19:05:46Z" }, "spec": { "description": "Enables the report creation drawer in a dashboard", @@ -2261,8 +2262,8 @@ "metadata": { "name": "noBackdropBlur", "resourceVersion": "1744057771109", - "creationTimestamp": "2025-04-03T15:18:37Z", - "deletionTimestamp": "2025-04-08T09:27:30Z", + "creationTimestamp": "2025-03-14T15:21:35Z", + "deletionTimestamp": "2025-04-08T10:58:19Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-07 20:29:31.109804663 +0000 UTC" } @@ -2280,7 +2281,7 @@ "name": "nodeGraphDotLayout", "resourceVersion": "1743693517832", "creationTimestamp": "2024-01-31T16:26:12Z", - "deletionTimestamp": "2025-04-07T10:13:50Z" + "deletionTimestamp": "2025-04-08T14:37:17Z" }, "spec": { "description": "Changed the layout algorithm for the node graph", @@ -2452,7 +2453,7 @@ "metadata": { "name": "pluginsCDNSyncLoader", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-02-07T10:07:08Z" }, "spec": { "description": "Loads plugins from CDN synchronously", @@ -2585,7 +2586,7 @@ "name": "prometheusRunQueriesInParallel", "resourceVersion": "1743693517832", "creationTimestamp": "2024-08-12T12:31:39Z", - "deletionTimestamp": "2025-04-10T18:16:18Z" + "deletionTimestamp": "2025-04-11T22:11:19Z" }, "spec": { "description": "Enables running Prometheus queries in parallel", @@ -2679,7 +2680,7 @@ "name": "queryOverLive", "resourceVersion": "1743693517832", "creationTimestamp": "2022-01-26T17:44:20Z", - "deletionTimestamp": "2025-04-07T09:56:17Z" + "deletionTimestamp": "2025-04-07T14:47:35Z" }, "spec": { "description": "Use Grafana Live WebSocket to execute backend queries", @@ -2705,7 +2706,7 @@ "metadata": { "name": "queryServiceFromExplore", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-04-02T10:00:33Z" }, "spec": { "description": "Routes explore requests to the new query service", @@ -2824,7 +2825,7 @@ "metadata": { "name": "rendererDisableAppPluginsPreload", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-02-24T14:43:06Z" }, "spec": { "description": "Disable pre-loading app plugins when the request is coming from the renderer", @@ -2905,7 +2906,7 @@ "metadata": { "name": "scopeSearchAllLevels", "resourceVersion": "1744370973814", - "creationTimestamp": "2025-04-10T12:49:09Z", + "creationTimestamp": "2025-04-14T07:42:16Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-11 11:29:33.814419 +0000 UTC" } @@ -2922,7 +2923,7 @@ "metadata": { "name": "secretsManagementAppPlatform", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-19T09:25:14Z" }, "spec": { "description": "Enable the secrets management API and services under app platform", @@ -3044,7 +3045,7 @@ "metadata": { "name": "tableNextGen", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-26T03:57:57Z" }, "spec": { "description": "Allows access to the new react-data-grid based table component.", @@ -3082,7 +3083,7 @@ "metadata": { "name": "templateVariablesUsesCombobox", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-01-31T09:53:13Z" }, "spec": { "description": "Use new **Combobox** component for template variables", @@ -3121,7 +3122,7 @@ "name": "traceQLStreaming", "resourceVersion": "1743693517832", "creationTimestamp": "2023-07-26T13:33:16Z", - "deletionTimestamp": "2025-04-08T12:39:36Z" + "deletionTimestamp": "2025-04-09T12:57:07Z" }, "spec": { "description": "Enables response streaming of TraceQL queries of the Tempo data source", @@ -3163,7 +3164,7 @@ "metadata": { "name": "unifiedNavbars", "resourceVersion": "1744174965165", - "creationTimestamp": "2025-04-05T06:53:21Z", + "creationTimestamp": "2025-04-09T12:51:22Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-09 05:02:45.165634 +0000 UTC" } @@ -3206,7 +3207,7 @@ "metadata": { "name": "unifiedStorageGrpcConnectionPool", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-21T13:24:54Z" }, "spec": { "description": "Enables the unified storage grpc connection pool", @@ -3220,7 +3221,7 @@ "metadata": { "name": "unifiedStorageHistoryPruner", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-03-17T10:36:38Z" }, "spec": { "description": "Enables the unified storage history pruner", @@ -3291,7 +3292,7 @@ "metadata": { "name": "useScopesNavigationEndpoint", "resourceVersion": "1744289349951", - "creationTimestamp": "2025-04-03T15:18:37Z", + "creationTimestamp": "2025-03-31T15:20:00Z", "annotations": { "grafana.app/updatedTimestamp": "2025-04-10 12:49:09.951013 +0000 UTC" } @@ -3334,7 +3335,7 @@ "metadata": { "name": "xrayApplicationSignals", "resourceVersion": "1743693517832", - "creationTimestamp": "2025-04-03T15:18:37Z" + "creationTimestamp": "2025-04-01T14:42:02Z" }, "spec": { "description": "Support Application Signals queries in the X-Ray datasource", diff --git a/public/app/features/plugins/sandbox/distortion_map.ts b/public/app/features/plugins/sandbox/distortion_map.ts index 1680a4cd2df..902f87afc09 100644 --- a/public/app/features/plugins/sandbox/distortion_map.ts +++ b/public/app/features/plugins/sandbox/distortion_map.ts @@ -2,7 +2,6 @@ import { ProxyTarget } from '@locker/near-membrane-shared'; import DOMPurify from 'dompurify'; import { cloneDeep, isFunction } from 'lodash'; -import { config } from '@grafana/runtime'; import { Monaco } from '@grafana/ui'; import { loadScriptIntoSandbox } from './code_loader'; @@ -68,8 +67,6 @@ type DistortionMap = Map< >; const generalDistortionMap: DistortionMap = new Map(); -const monitorOnly = Boolean(config.featureToggles.frontendSandboxMonitorOnly); - const SANDBOX_LIVE_API_PATCHED = Symbol.for('@SANDBOX_LIVE_API_PATCHED'); export function getGeneralSandboxDistortionMap() { @@ -97,9 +94,6 @@ function failToSet(originalAttrOrMethod: unknown, meta: SandboxPluginMeta) { attrOrMethod: String(originalAttrOrMethod), entity: 'window', }); - if (monitorOnly) { - return originalAttrOrMethod; - } return () => { throw new Error('Plugins are not allowed to set sandboxed properties'); }; @@ -120,10 +114,6 @@ function distortIframeAttributes(distortions: DistortionMap) { entity: 'iframe', }); - if (monitorOnly) { - return originalAttrOrMethod; - } - return () => { throw new Error('iframe.' + property + ' is not allowed in sandboxed plugins'); }; @@ -148,10 +138,6 @@ function distortConsole(distortions: DistortionMap) { if (descriptor?.value) { function getSandboxConsole(originalAttrOrMethod: unknown, meta: SandboxPluginMeta) { const pluginId = meta.id; - // we don't monitor the console because we expect a high volume of calls - if (monitorOnly) { - return originalAttrOrMethod; - } function sandboxLog(...args: unknown[]) { console.log(`[plugin ${pluginId}]`, ...args); @@ -183,10 +169,6 @@ function distortAlert(distortions: DistortionMap) { entity: 'window', }); - if (monitorOnly) { - return originalAttrOrMethod; - } - return function (...args: unknown[]) { console.log(`[plugin ${pluginId}]`, ...args); }; @@ -219,9 +201,6 @@ function distortInnerHTML(distortions: DistortionMap) { entity: 'HTMLElement', }); - if (monitorOnly) { - continue; - } throw new Error('<' + forbiddenElement + '> is not allowed in sandboxed plugins'); } } @@ -270,9 +249,7 @@ function distortCreateElement(distortions: DistortionMap) { param: arg, entity: 'document', }); - if (!monitorOnly) { - return document.createDocumentFragment(); - } + return document.createDocumentFragment(); } if (isFunction(originalMethod)) { return originalMethod.apply(this, [arg, options]); @@ -298,9 +275,7 @@ function distortInsert(distortions: DistortionMap) { param: nodeType, entity: 'HTMLElement', }); - if (!monitorOnly) { - return document.createDocumentFragment(); - } + return document.createDocumentFragment(); } if (isFunction(originalMethod)) { return originalMethod.call(this, node, ref); @@ -320,9 +295,7 @@ function distortInsert(distortions: DistortionMap) { entity: 'HTMLElement', }); - if (!monitorOnly) { - return document.createDocumentFragment(); - } + return document.createDocumentFragment(); } if (isFunction(originalMethod)) { return originalMethod.call(this, position, node); @@ -355,9 +328,7 @@ function distortAppend(distortions: DistortionMap) { return function appendDistortion(this: HTMLElement, ...args: Node[]) { let acceptedNodes = args; const filteredAcceptedNodes = args?.filter((node) => !forbiddenElements.includes(node.nodeName.toLowerCase())); - if (!monitorOnly) { - acceptedNodes = filteredAcceptedNodes; - } + acceptedNodes = filteredAcceptedNodes; if (acceptedNodes.length !== filteredAcceptedNodes.length) { logWarning(`Plugin ${pluginId} tried to append fobiddenElements`, { @@ -389,9 +360,7 @@ function distortAppend(distortions: DistortionMap) { entity: 'HTMLElement', }); - if (!monitorOnly) { - return document.createDocumentFragment(); - } + return document.createDocumentFragment(); } // if the node is a script, load it into the sandbox // this allows webpack chunks to be loaded into the sandbox diff --git a/public/app/features/plugins/sandbox/document_sandbox.ts b/public/app/features/plugins/sandbox/document_sandbox.ts index fdd4b0c9740..8d25d42625d 100644 --- a/public/app/features/plugins/sandbox/document_sandbox.ts +++ b/public/app/features/plugins/sandbox/document_sandbox.ts @@ -3,14 +3,12 @@ import { cloneDeep } from 'lodash'; import Prism from 'prismjs'; import { CustomVariableSupport, DataSourceApi } from '@grafana/data'; -import { config } from '@grafana/runtime'; import { forbiddenElements } from './constants'; import { isReactClassComponent, logWarning, unboxNearMembraneProxies } from './utils'; // IMPORTANT: NEVER export this symbol from a public (e.g `@grafana/*`) package const SANDBOX_LIVE_VALUE = Symbol.for('@@SANDBOX_LIVE_VALUE'); -const monitorOnly = Boolean(config.featureToggles.frontendSandboxMonitorOnly); export function getSafeSandboxDomElement(element: Element, pluginId: string): Element { const nodeName = Reflect.get(element, 'nodeName'); @@ -37,9 +35,7 @@ export function getSafeSandboxDomElement(element: Element, pluginId: string): El param: nodeName, }); - if (!monitorOnly) { - throw new Error('<' + nodeName + '> is not allowed in sandboxed plugins'); - } + throw new Error('<' + nodeName + '> is not allowed in sandboxed plugins'); } // allow elements inside the sandbox or the sandbox body @@ -51,15 +47,11 @@ export function getSafeSandboxDomElement(element: Element, pluginId: string): El return element; } - if (!monitorOnly) { - // any other element gets a mock - const mockElement = document.createElement(nodeName); - mockElement.dataset.grafanaPluginSandboxElement = 'true'; - // we are not logging this because a high number of warnings can be generated - return mockElement; - } else { - return element; - } + // any other element gets a mock + const mockElement = document.createElement(nodeName); + mockElement.dataset.grafanaPluginSandboxElement = 'true'; + // we are not logging this because a high number of warnings can be generated + return mockElement; } export function isDomElement(obj: unknown): obj is Element { diff --git a/public/app/features/plugins/sandbox/utils.ts b/public/app/features/plugins/sandbox/utils.ts index f122040de94..9a411a32a3e 100644 --- a/public/app/features/plugins/sandbox/utils.ts +++ b/public/app/features/plugins/sandbox/utils.ts @@ -3,12 +3,10 @@ import { cloneDeep } from 'lodash'; import * as React from 'react'; import { LogContext } from '@grafana/faro-web-sdk'; -import { config, createMonitoringLogger } from '@grafana/runtime'; +import { createMonitoringLogger } from '@grafana/runtime'; import { SandboxedPluginObject } from './types'; -const monitorOnly = Boolean(config.featureToggles.frontendSandboxMonitorOnly); - export function isSandboxedPluginObject(value: unknown): value is SandboxedPluginObject { return !!value && typeof value === 'object' && value?.hasOwnProperty('plugin'); } @@ -17,7 +15,7 @@ export function assertNever(x: never): never { throw new Error(`Unexpected object: ${x}. This should never happen.`); } -const sandboxLogger = createMonitoringLogger('sandbox', { monitorOnly: String(monitorOnly) }); +const sandboxLogger = createMonitoringLogger('sandbox'); export function isReactClassComponent(obj: unknown): obj is React.Component { return obj instanceof React.Component;