Frontend Sandbox: Do not consider internal plugins as elegible (#96325)

This commit is contained in:
Esteban Beltran 2024-11-13 09:28:19 +01:00 committed by GitHub
parent f83f7332a1
commit acf57aa556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import {
shouldLoadPluginInFrontendSandbox,
setSandboxEnabledCheck,
isPluginFrontendSandboxEnabled,
isPluginFrontendSandboxEligible,
} from './sandbox_plugin_loader_registry';
jest.mock('@grafana/runtime', () => ({
@ -89,4 +90,11 @@ describe('Sandbox eligibility checks', () => {
expect(customCheck).toHaveBeenCalledWith({ pluginId: 'test-plugin' });
expect(result).toBe(false);
});
test('isPluginFrontendSandboxEligible returns false for plugins with internal signature', async () => {
//@ts-expect-error We don't publicly export the internal signature
getPluginSettingsMock.mockResolvedValue({ ...fakePlugin, signature: 'internal' });
const result = await isPluginFrontendSandboxEligible({ pluginId: 'test-plugin' });
expect(result).toBe(false);
});
});

View File

@ -64,7 +64,7 @@ export async function isPluginFrontendSandboxEligible({
try {
// don't run grafana-signed plugins in sandbox
const pluginMeta = await getPluginSettings(pluginId, { showErrorAlert: false });
if (pluginMeta.signatureType === PluginSignatureType.grafana) {
if (pluginMeta.signatureType === PluginSignatureType.grafana || pluginMeta.signature === 'internal') {
return false;
}
} catch (e) {