mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Move extension settings for workspace trust
This commit is contained in:
parent
fa0da8322c
commit
118c41150c
|
@ -40,7 +40,7 @@ export function provideWorkspaceTrustExtensionProposals(existing: string[], rang
|
|||
if (extensionProposals.length) {
|
||||
return extensionProposals.map(e => {
|
||||
const item = new vscode.CompletionItem(e.id);
|
||||
const insertText = `"${e.id}": {\n\t"request": "onStart",\n\t"version": "${e.packageJSON.version}"\n}`;
|
||||
const insertText = `"${e.id}": {\n\t"supported": false,\n\t"version": "${e.packageJSON.version}"\n}`;
|
||||
item.kind = vscode.CompletionItemKind.Value;
|
||||
item.insertText = insertText;
|
||||
item.range = range;
|
||||
|
@ -49,7 +49,7 @@ export function provideWorkspaceTrustExtensionProposals(existing: string[], rang
|
|||
});
|
||||
} else {
|
||||
const example = new vscode.CompletionItem(localize('exampleExtension', "Example"));
|
||||
example.insertText = '"vscode.csharp: {\n\t"request": "onStart",\n\t"version": "0.0.0"\n}`;"';
|
||||
example.insertText = '"vscode.csharp: {\n\t"supported": false,\n\t"version": "0.0.0"\n}`;"';
|
||||
example.kind = vscode.CompletionItemKind.Value;
|
||||
example.range = range;
|
||||
return [example];
|
||||
|
|
|
@ -60,11 +60,11 @@ export class SettingsDocument {
|
|||
return provideInstalledExtensionProposals(alreadyConfigured, `: [\n\t"ui"\n]`, range, true);
|
||||
}
|
||||
|
||||
// security.workspace.trust.extensionUntrustedSupport
|
||||
if (location.path[0] === 'security.workspace.trust.extensionUntrustedSupport' && location.path.length === 2 && location.isAtPropertyKey) {
|
||||
// extensions.supportUntrustedWorkspaces
|
||||
if (location.path[0] === 'extensions.supportUntrustedWorkspaces' && location.path.length === 2 && location.isAtPropertyKey) {
|
||||
let alreadyConfigured: string[] = [];
|
||||
try {
|
||||
alreadyConfigured = Object.keys(parse(this.document.getText())['security.workspace.trust.extensionUntrustedSupport']);
|
||||
alreadyConfigured = Object.keys(parse(this.document.getText())['extensions.supportUntrustedWorkspaces']);
|
||||
} catch (e) {/* ignore error */ }
|
||||
return provideWorkspaceTrustExtensionProposals(alreadyConfigured, range);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ import { mnemonicButtonLabel } from 'vs/base/common/labels';
|
|||
import { Query } from 'vs/workbench/contrib/extensions/common/extensionQuery';
|
||||
import { Promises } from 'vs/base/common/async';
|
||||
import { EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { WORKSPACE_TRUST_EXTENSION_SUPPORT } from 'vs/workbench/services/workspaces/common/workspaceTrust';
|
||||
|
||||
// Singletons
|
||||
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService);
|
||||
|
@ -178,7 +179,7 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
|
|||
},
|
||||
'extensions.supportVirtualWorkspaces': {
|
||||
type: 'object',
|
||||
markdownDescription: localize('extensions.supportVirtualWorkspaces', "Override the virtual workspaces support of an extension"),
|
||||
markdownDescription: localize('extensions.supportVirtualWorkspaces', "Override the virtual workspaces support of an extension."),
|
||||
patternProperties: {
|
||||
'([a-z0-9A-Z][a-z0-9\-A-Z]*)\\.([a-z0-9A-Z][a-z0-9\-A-Z]*)$': {
|
||||
type: 'boolean',
|
||||
|
@ -188,6 +189,31 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
|
|||
default: {
|
||||
'pub.name': false
|
||||
}
|
||||
},
|
||||
[WORKSPACE_TRUST_EXTENSION_SUPPORT]: {
|
||||
type: 'object',
|
||||
markdownDescription: localize('extensions.supportUntrustedWorkspaces', "Override the untrusted workpace support of an extension. Extensions using `true` will always be enabled. Extensions using `limited` will always be enabled, and the extension will hide functionality that requires trust. Extensions using `false` will only be enabled only when the workspace is trusted."),
|
||||
patternProperties: {
|
||||
'([a-z0-9A-Z][a-z0-9\-A-Z]*)\\.([a-z0-9A-Z][a-z0-9\-A-Z]*)$': {
|
||||
type: 'object',
|
||||
properties: {
|
||||
'supported': {
|
||||
type: ['boolean', 'string'],
|
||||
enum: [true, false, 'limited'],
|
||||
enumDescriptions: [
|
||||
localize('extensions.supportUntrustedWorkspaces.true', "Extension will always be enabled."),
|
||||
localize('extensions.supportUntrustedWorkspaces.false', "Extension will only be enabled only when the workspace is trusted."),
|
||||
localize('extensions.supportUntrustedWorkspaces.limited', "Extension will always be enabled, and the extension will hide functionality requiring trust."),
|
||||
],
|
||||
description: localize('extensions.supportUntrustedWorkspaces.supported', "Defines the untrusted workspace support setting for the extension."),
|
||||
},
|
||||
'version': {
|
||||
type: 'string',
|
||||
description: localize('extensions.supportUntrustedWorkspaces.version', "Defines the version of the extension for which the override should be applied. If not specified, the override will be applied independent of the extension version."),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -27,7 +27,7 @@ import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, StatusbarA
|
|||
import { IEditorRegistry, EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { WorkspaceTrustEditor } from 'vs/workbench/contrib/workspace/browser/workspaceTrustEditor';
|
||||
import { WorkspaceTrustEditorInput } from 'vs/workbench/services/workspaces/browser/workspaceTrustEditorInput';
|
||||
import { isWorkspaceTrustEnabled, WorkspaceTrustContext, WORKSPACE_TRUST_ENABLED, WORKSPACE_TRUST_EXTENSION_UNTRUSTED_SUPPORT } from 'vs/workbench/services/workspaces/common/workspaceTrust';
|
||||
import { isWorkspaceTrustEnabled, WorkspaceTrustContext, WORKSPACE_TRUST_ENABLED } from 'vs/workbench/services/workspaces/common/workspaceTrust';
|
||||
import { EditorInput, Extensions as EditorInputExtensions, IEditorInputSerializer, IEditorInputFactoryRegistry, EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
|
@ -402,31 +402,6 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
|
|||
default: false,
|
||||
included: !isWeb,
|
||||
description: localize('workspace.trust.description', "Controls whether or not workspace trust is enabled within VS Code."),
|
||||
},
|
||||
[WORKSPACE_TRUST_EXTENSION_UNTRUSTED_SUPPORT]: {
|
||||
type: 'object',
|
||||
markdownDescription: localize('security.workspace.trust.extensionUntrustedSupport', "Override the untrusted workpace support of an extension. Extensions using `true` will always be enabled. Extensions using `limited` will always be enabled, and the extension will hide functionality that requires trust. Extensions using `false` will only be enabled only when the workspace is trusted."),
|
||||
patternProperties: {
|
||||
'([a-z0-9A-Z][a-z0-9\-A-Z]*)\\.([a-z0-9A-Z][a-z0-9\-A-Z]*)$': {
|
||||
type: 'object',
|
||||
properties: {
|
||||
'request': {
|
||||
type: 'string',
|
||||
enum: ['never', 'onDemand', 'onStart'],
|
||||
enumDescriptions: [
|
||||
localize('security.workspace.trust.extensionUntrustedSupport.supported.true', "Extension will always be enabled."),
|
||||
localize('security.workspace.trust.extensionUntrustedSupport.supported.limited', "Extension will always be enabled, and the extension will hide functionality requiring trust."),
|
||||
localize('security.workspace.trust.extensionUntrustedSupport.supported.false', "Extension will only be enabled only when the workspace is trusted."),
|
||||
],
|
||||
description: localize('security.workspace.trust.extensionUntrustedSupport.supported', "Defines the untrusted workspace support setting for the extension."),
|
||||
},
|
||||
'version': {
|
||||
type: 'string',
|
||||
description: localize('security.workspace.trust.extensionUntrustedSupport.version', "Defines the version of the extension for which the override should be applied. If not specified, the override will be applied independent of the extension version."),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
|||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { ExtensionUntrustedWorkspaceSupport } from 'vs/base/common/product';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { isWorkspaceTrustEnabled, WORKSPACE_TRUST_EXTENSION_UNTRUSTED_SUPPORT } from 'vs/workbench/services/workspaces/common/workspaceTrust';
|
||||
import { isWorkspaceTrustEnabled, WORKSPACE_TRUST_EXTENSION_SUPPORT } from 'vs/workbench/services/workspaces/common/workspaceTrust';
|
||||
|
||||
export const IExtensionManifestPropertiesService = createDecorator<IExtensionManifestPropertiesService>('extensionManifestPropertiesService');
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class ExtensionManifestPropertiesService extends Disposable implements IE
|
|||
private _productVirtualWorkspaceSupportMap: Map<string, { default?: boolean, override?: boolean }> | null = null;
|
||||
private _configuredVirtualWorkspaceSupportMap: Map<string, boolean> | null = null;
|
||||
|
||||
private readonly _configuredExtensionWorkspaceTrustRequestMap: Map<string, { request: ExtensionUntrustedWorkpaceSupportType, version?: string }>;
|
||||
private readonly _configuredExtensionWorkspaceTrustRequestMap: Map<string, { supported: ExtensionUntrustedWorkpaceSupportType, version?: string }>;
|
||||
private readonly _productExtensionWorkspaceTrustRequestMap: Map<string, ExtensionUntrustedWorkspaceSupport>;
|
||||
|
||||
constructor(
|
||||
|
@ -54,8 +54,8 @@ export class ExtensionManifestPropertiesService extends Disposable implements IE
|
|||
super();
|
||||
|
||||
// Workspace trust request type (settings.json)
|
||||
this._configuredExtensionWorkspaceTrustRequestMap = new Map<string, { request: ExtensionUntrustedWorkpaceSupportType, version?: string }>();
|
||||
const configuredExtensionWorkspaceTrustRequests = configurationService.inspect<{ [key: string]: { request: ExtensionUntrustedWorkpaceSupportType, version?: string } }>(WORKSPACE_TRUST_EXTENSION_UNTRUSTED_SUPPORT).userValue || {};
|
||||
this._configuredExtensionWorkspaceTrustRequestMap = new Map<string, { supported: ExtensionUntrustedWorkpaceSupportType, version?: string }>();
|
||||
const configuredExtensionWorkspaceTrustRequests = configurationService.inspect<{ [key: string]: { supported: ExtensionUntrustedWorkpaceSupportType, version?: string } }>(WORKSPACE_TRUST_EXTENSION_SUPPORT).userValue || {};
|
||||
for (const id of Object.keys(configuredExtensionWorkspaceTrustRequests)) {
|
||||
this._configuredExtensionWorkspaceTrustRequestMap.set(ExtensionIdentifier.toKey(id), configuredExtensionWorkspaceTrustRequests[id]);
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ export class ExtensionManifestPropertiesService extends Disposable implements IE
|
|||
const extensionWorkspaceTrustRequest = this._configuredExtensionWorkspaceTrustRequestMap.get(ExtensionIdentifier.toKey(extensionId));
|
||||
|
||||
if (extensionWorkspaceTrustRequest && (extensionWorkspaceTrustRequest.version === undefined || extensionWorkspaceTrustRequest.version === manifest.version)) {
|
||||
return extensionWorkspaceTrustRequest.request;
|
||||
return extensionWorkspaceTrustRequest.supported;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
|
|
@ -48,7 +48,7 @@ suite('ExtensionManifestPropertiesService - ExtensionKind', () => {
|
|||
});
|
||||
});
|
||||
|
||||
suite('ExtensionManifestPropertiesService - ExtensionWorkspaceTrustType', () => {
|
||||
suite('ExtensionManifestPropertiesService - ExtensionUntrustedWorkpaceSupportType', () => {
|
||||
let testObject: ExtensionManifestPropertiesService;
|
||||
let instantiationService: TestInstantiationService;
|
||||
let testConfigurationService: TestConfigurationService;
|
||||
|
|
|
@ -19,7 +19,7 @@ import { isSingleFolderWorkspaceIdentifier, toWorkspaceIdentifier } from 'vs/pla
|
|||
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
|
||||
|
||||
export const WORKSPACE_TRUST_ENABLED = 'security.workspace.trust.enabled';
|
||||
export const WORKSPACE_TRUST_EXTENSION_UNTRUSTED_SUPPORT = 'security.workspace.trust.extensionUntrustedSupport';
|
||||
export const WORKSPACE_TRUST_EXTENSION_SUPPORT = 'extensions.supportUntrustedWorkspaces';
|
||||
export const WORKSPACE_TRUST_STORAGE_KEY = 'content.trust.model.key';
|
||||
|
||||
export const WorkspaceTrustContext = {
|
||||
|
|
Loading…
Reference in a new issue