Merge branch 'main' into tyriar/122104

This commit is contained in:
Daniel Imms 2021-04-28 06:56:20 -07:00 committed by GitHub
commit b3292e6fff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 268 additions and 233 deletions

View file

@ -216,14 +216,14 @@ export class DefaultConfigurationModel extends ConfigurationModel {
export interface ConfigurationParseOptions {
scopes: ConfigurationScope[] | undefined;
isUntrusted?: boolean;
skipRestricted?: boolean;
}
export class ConfigurationModelParser {
private _raw: any = null;
private _configurationModel: ConfigurationModel | null = null;
private _untrustedConfigurations: string[] = [];
private _restrictedConfigurations: string[] = [];
private _parseErrors: any[] = [];
constructor(protected readonly _name: string) { }
@ -232,8 +232,8 @@ export class ConfigurationModelParser {
return this._configurationModel || new ConfigurationModel();
}
get untrustedConfigurations(): string[] {
return this._untrustedConfigurations;
get restrictedConfigurations(): string[] {
return this._restrictedConfigurations;
}
get errors(): any[] {
@ -255,9 +255,9 @@ export class ConfigurationModelParser {
public parseRaw(raw: any, options?: ConfigurationParseOptions): void {
this._raw = raw;
const { contents, keys, overrides, untrusted } = this.doParseRaw(raw, options);
const { contents, keys, overrides, restricted } = this.doParseRaw(raw, options);
this._configurationModel = new ConfigurationModel(contents, keys, overrides);
this._untrustedConfigurations = untrusted || [];
this._restrictedConfigurations = restricted || [];
}
private doParseContent(content: string): any {
@ -317,41 +317,42 @@ export class ConfigurationModelParser {
return raw;
}
protected doParseRaw(raw: any, options?: ConfigurationParseOptions): IConfigurationModel & { untrusted?: string[] } {
protected doParseRaw(raw: any, options?: ConfigurationParseOptions): IConfigurationModel & { restricted?: string[] } {
const configurationProperties = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties();
const filtered = this.filter(raw, configurationProperties, true, options);
raw = filtered.raw;
const contents = toValuesTree(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
const keys = Object.keys(raw);
const overrides: IOverrides[] = toOverrides(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
return { contents, keys, overrides, untrusted: filtered.untrusted };
return { contents, keys, overrides, restricted: filtered.restricted };
}
private filter(properties: any, configurationProperties: { [qualifiedKey: string]: IConfigurationPropertySchema | undefined }, filterOverriddenProperties: boolean, options?: ConfigurationParseOptions): { raw: {}, untrusted: string[] } {
if (!options?.scopes && !options?.isUntrusted) {
return { raw: properties, untrusted: [] };
private filter(properties: any, configurationProperties: { [qualifiedKey: string]: IConfigurationPropertySchema | undefined }, filterOverriddenProperties: boolean, options?: ConfigurationParseOptions): { raw: {}, restricted: string[] } {
if (!options?.scopes && !options?.skipRestricted) {
return { raw: properties, restricted: [] };
}
const raw: any = {};
const untrusted: string[] = [];
const restricted: string[] = [];
for (let key in properties) {
if (OVERRIDE_PROPERTY_PATTERN.test(key) && filterOverriddenProperties) {
const result = this.filter(properties[key], configurationProperties, false, options);
raw[key] = result.raw;
untrusted.push(...result.untrusted);
restricted.push(...result.restricted);
} else {
const propertySchema = configurationProperties[key];
const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : ConfigurationScope.WINDOW : undefined;
if (propertySchema?.restricted) {
restricted.push(key);
}
// Load unregistered configurations always.
if (scope === undefined || options.scopes === undefined || options.scopes.includes(scope)) {
if (options.isUntrusted && propertySchema?.requireTrust) {
untrusted.push(key);
} else {
if (!(options.skipRestricted && propertySchema?.restricted)) {
raw[key] = properties[key];
}
}
}
}
return { raw, untrusted };
return { raw, restricted };
}
}
@ -393,8 +394,8 @@ export class UserSettings extends Disposable {
return this.parser.configurationModel;
}
getUntrustedSettings(): string[] {
return this.parser.untrustedConfigurations;
getRestrictedSettings(): string[] {
return this.parser.restrictedConfigurations;
}
}

View file

@ -113,10 +113,10 @@ export interface IConfigurationPropertySchema extends IJSONSchema {
scope?: ConfigurationScope;
/**
* When enabled, value of this configuration will be read only from trusted sources.
* When restricted, value of this configuration will be read only from trusted sources.
* For eg., If the workspace is not trusted, then the value of this configuration is not read from workspace settings file.
*/
requireTrust?: boolean;
restricted?: boolean;
included?: boolean;
@ -137,7 +137,7 @@ export interface IConfigurationPropertySchema extends IJSONSchema {
export interface IConfigurationExtensionInfo {
id: string;
requireTrustForConfigurations?: string[];
restrictedConfigurations?: string[];
}
export interface IConfigurationNode {
@ -329,7 +329,7 @@ class ConfigurationRegistry implements IConfigurationRegistry {
property.scope = undefined; // No scope for overridable properties `[${identifier}]`
} else {
property.scope = types.isUndefinedOrNull(property.scope) ? scope : property.scope;
property.requireTrust = types.isUndefinedOrNull(property.requireTrust) ? !!extensionInfo?.requireTrustForConfigurations?.includes(key) : property.requireTrust;
property.restricted = types.isUndefinedOrNull(property.restricted) ? !!extensionInfo?.restrictedConfigurations?.includes(key) : property.restricted;
}
// Add to properties maps

View file

@ -87,19 +87,19 @@ function registerProxyConfigurations(scope: ConfigurationScope): void {
type: 'string',
pattern: '^https?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$',
markdownDescription: localize('proxy', "The proxy setting to use. If not set, will be inherited from the `http_proxy` and `https_proxy` environment variables."),
requireTrust: true
restricted: true
},
'http.proxyStrictSSL': {
type: 'boolean',
default: true,
description: localize('strictSSL', "Controls whether the proxy server certificate should be verified against the list of supplied CAs."),
requireTrust: true
restricted: true
},
'http.proxyAuthorization': {
type: ['null', 'string'],
default: null,
markdownDescription: localize('proxyAuthorization', "The value to send as the `Proxy-Authorization` header for every network request."),
requireTrust: true
restricted: true
},
'http.proxySupport': {
type: 'string',
@ -112,13 +112,13 @@ function registerProxyConfigurations(scope: ConfigurationScope): void {
],
default: 'override',
description: localize('proxySupport', "Use the proxy support for extensions."),
requireTrust: true
restricted: true
},
'http.systemCertificates': {
type: 'boolean',
default: true,
description: localize('systemCertificates', "Controls whether CA certificates should be loaded from the OS. (On Windows and macOS, a reload of the window is required after turning this off.)"),
requireTrust: true
restricted: true
}
}
};

View file

@ -223,7 +223,7 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfigurat
localize('telemetry.enableTelemetry', "Enable usage data and errors to be sent to a Microsoft online service.") :
localize('telemetry.enableTelemetryMd', "Enable usage data and errors to be sent to a Microsoft online service. Read our privacy statement [here]({0}).", product.privacyStatementUrl),
'default': true,
'requireTrust': true,
'restricted': true,
'scope': ConfigurationScope.APPLICATION,
'tags': ['usesOnlineServices']
}

View file

@ -16,7 +16,6 @@ import { ExtHostContext, ExtHostDocumentsShape, IExtHostContext, MainThreadDocum
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { toLocalResource, extUri, IExtUri } from 'vs/base/common/resources';
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { Emitter } from 'vs/base/common/event';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
@ -126,7 +125,6 @@ export class MainThreadDocuments extends Disposable implements MainThreadDocumen
@ITextModelService textModelResolverService: ITextModelService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IUriIdentityService uriIdentityService: IUriIdentityService,
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
@IPathService private readonly _pathService: IPathService
) {
super();
@ -156,12 +154,12 @@ export class MainThreadDocuments extends Disposable implements MainThreadDocumen
}
}));
this._register(workingCopyFileService.onDidRunWorkingCopyFileOperation(e => {
if (e.operation === FileOperation.MOVE || e.operation === FileOperation.DELETE) {
for (const { source } of e.files) {
if (source) {
this._modelReferenceCollection.remove(source);
}
this._register(fileService.onDidRunOperation(e => {
const isMove = e.isOperation(FileOperation.MOVE);
if (isMove || e.isOperation(FileOperation.DELETE)) {
const removed = isMove ? e.target?.resource : e.resource;
if (removed) {
this._modelReferenceCollection.remove(removed);
}
}
}));

View file

@ -26,7 +26,6 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
@ -298,14 +297,13 @@ export class MainThreadDocumentsAndEditors {
@IBulkEditService bulkEditService: IBulkEditService,
@IPanelService panelService: IPanelService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
@IUriIdentityService uriIdentityService: IUriIdentityService,
@IClipboardService private readonly _clipboardService: IClipboardService,
@IPathService pathService: IPathService
) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDocumentsAndEditors);
this._mainThreadDocuments = this._toDispose.add(new MainThreadDocuments(this, extHostContext, this._modelService, this._textFileService, fileService, textModelResolverService, environmentService, uriIdentityService, workingCopyFileService, pathService));
this._mainThreadDocuments = this._toDispose.add(new MainThreadDocuments(this, extHostContext, this._modelService, this._textFileService, fileService, textModelResolverService, environmentService, uriIdentityService, pathService));
extHostContext.set(MainContext.MainThreadDocuments, this._mainThreadDocuments);
const mainThreadTextEditors = this._toDispose.add(new MainThreadTextEditors(this, extHostContext, codeEditorService, bulkEditService, this._editorService, this._editorGroupService));

View file

@ -170,7 +170,7 @@ configurationExtPoint.setHandler((extensions, { added, removed }) => {
validateProperties(configuration, extension);
configuration.id = node.id || extension.description.identifier.value;
configuration.extensionInfo = { id: extension.description.identifier.value, requireTrustForConfigurations: extension.description.capabilities?.untrustedWorkspaces?.supported === 'limited' ? extension.description.capabilities?.untrustedWorkspaces.restrictedConfigurations : undefined };
configuration.extensionInfo = { id: extension.description.identifier.value, restrictedConfigurations: extension.description.capabilities?.untrustedWorkspaces?.supported === 'limited' ? extension.description.capabilities?.untrustedWorkspaces.restrictedConfigurations : undefined };
configuration.title = configuration.title || extension.description.displayName || extension.description.identifier.value;
configurations.push(configuration);
return configurations;

View file

@ -24,7 +24,7 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
enum: ['neverOpen', 'openOnSessionStart', 'openOnSessionStartWithComments'],
default: 'openOnSessionStartWithComments',
description: nls.localize('openComments', "Controls when the comments panel should open."),
requireTrust: false
restricted: false
}
}
});

View file

@ -28,7 +28,7 @@ registry.registerConfiguration({
'description': localize('workbench.enableExperiments', "Fetches experiments to run from a Microsoft online service."),
'default': true,
'scope': ConfigurationScope.APPLICATION,
'requireTrust': true,
'restricted': true,
'tags': ['usesOnlineServices']
}
}

View file

@ -595,7 +595,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
this.registerExtensionAction({
id: 'workbench.extensions.action.disableAutoUpdate',
title: { value: localize('disableAutoUpdate', "Disable Auto Updating Extensions"), original: 'Disable Auto Updating Extensions' },
title: { value: localize('disableAutoUpdate', "Disable Auto Update for all extensions"), original: 'Disable Auto Update for all extensions' },
category: ExtensionsLocalizedLabel,
f1: true,
run: (accessor: ServicesAccessor) => accessor.get(IConfigurationService).updateValue(AutoUpdateConfigurationKey, false)
@ -603,7 +603,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
this.registerExtensionAction({
id: 'workbench.extensions.action.enableAutoUpdate',
title: { value: localize('enableAutoUpdate', "Enable Auto Updating All Extensions"), original: 'Enable Auto Updating All Extensions' },
title: { value: localize('enableAutoUpdate', "Enable Auto Update for all extensions"), original: 'Enable Auto Update for all extensions' },
category: ExtensionsLocalizedLabel,
f1: true,
run: (accessor: ServicesAccessor) => accessor.get(IConfigurationService).updateValue(AutoUpdateConfigurationKey, true)

View file

@ -1059,7 +1059,7 @@ class UnsupportedSettingsRenderer extends Disposable implements modes.CodeAction
markerData.push(this.generateUnsupportedMachineSettingMarker(setting));
}
if (!this.workspaceTrustManagementService.isWorkpaceTrusted() && configuration.requireTrust) {
if (!this.workspaceTrustManagementService.isWorkpaceTrusted() && configuration.restricted) {
const marker = this.generateUntrustedSettingMarker(setting);
markerData.push(marker);
const codeActions = this.generateUntrustedSettingCodeActions([marker]);
@ -1085,7 +1085,7 @@ class UnsupportedSettingsRenderer extends Disposable implements modes.CodeAction
});
}
if (!this.workspaceTrustManagementService.isWorkpaceTrusted() && configuration.requireTrust) {
if (!this.workspaceTrustManagementService.isWorkpaceTrusted() && configuration.restricted) {
const marker = this.generateUntrustedSettingMarker(setting);
markerData.push(marker);
const codeActions = this.generateUntrustedSettingCodeActions([marker]);
@ -1115,7 +1115,7 @@ class UnsupportedSettingsRenderer extends Disposable implements modes.CodeAction
return {
severity: MarkerSeverity.Warning,
...setting.range,
message: nls.localize('untrustedSetting', "This setting can be applied only in the trusted workspace.")
message: nls.localize('untrustedSetting', "This setting can only be applied in a trusted workspace.")
};
}

View file

@ -217,7 +217,7 @@ export class SettingsEditor2 extends EditorPane {
this.renderTree();
}));
this._register(configurationService.onDidChangeUntrustdSettings(e => {
this._register(configurationService.onDidChangeRestrictedSettings(e => {
if (e.default.length) {
this.updateElementsByKey([...e.default]);
}

View file

@ -285,7 +285,7 @@ export function resolveSettingsTree(tocData: ITOCEntry<string>, coreSettingsGrou
export function resolveConfiguredUntrustedSettings(groups: ISettingsGroup[], target: SettingsTarget, configurationService: IWorkbenchConfigurationService): ISetting[] {
const allSettings = getFlatSettings(groups);
return [...allSettings].filter(setting => setting.requireTrust && inspectSetting(setting.key, target, configurationService).isConfigured);
return [...allSettings].filter(setting => setting.restricted && inspectSetting(setting.key, target, configurationService).isConfigured);
}
export function resolveExtensionsSettings(groups: ISettingsGroup[]): ITOCEntry<ISetting> {
@ -1541,7 +1541,7 @@ export class SettingUntrustedRenderer extends AbstractSettingRenderer implements
untrustedWorkspaceIcon.style.setProperty('--workspace-trust-state-untrusted-color', colors.untrustedForegroundColor?.toString() || '');
}));
const element = DOM.append(trustLabelElement, $('span'));
element.textContent = localize('trustLabel', "This setting can be applied only in the trusted workspace.");
element.textContent = localize('trustLabel', "This setting can only be applied in a trusted workspace");
const linkElement: HTMLAnchorElement = DOM.append(trustLabelElement, $('a'));
linkElement.textContent = manageWorkspaceTrustLabel;
linkElement.setAttribute('tabindex', '0');

View file

@ -176,7 +176,7 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
switch (targetSelector) {
case 'workspaceFolderValue':
case 'workspaceValue':
this.isUntrusted = !!this.setting.requireTrust && !isWorkspaceTrusted;
this.isUntrusted = !!this.setting.restricted && !isWorkspaceTrusted;
break;
}
@ -199,7 +199,7 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
this.defaultValue = inspected.defaultValue;
this.isConfigured = isConfigured;
if (isConfigured || this.setting.tags || this.tags || this.isUntrusted) {
if (isConfigured || this.setting.tags || this.tags || this.setting.restricted) {
// Don't create an empty Set for all 1000 settings, only if needed
this.tags = new Set<string>();
if (isConfigured) {
@ -210,7 +210,7 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
this.setting.tags.forEach(tag => this.tags!.add(tag));
}
if (this.isUntrusted) {
if (this.setting.restricted) {
this.tags.add(REQUIRE_TRUSTED_WORKSPACE_SETTING_TAG);
}
}
@ -476,13 +476,13 @@ export function inspectSetting(key: string, target: SettingsTarget, configuratio
let isConfigured = typeof inspected[targetSelector] !== 'undefined';
if (!isConfigured) {
if (target === ConfigurationTarget.USER_LOCAL) {
isConfigured = !!configurationService.unTrustedSettings.userLocal?.includes(key);
isConfigured = !!configurationService.restrictedSettings.userLocal?.includes(key);
} else if (target === ConfigurationTarget.USER_REMOTE) {
isConfigured = !!configurationService.unTrustedSettings.userRemote?.includes(key);
isConfigured = !!configurationService.restrictedSettings.userRemote?.includes(key);
} else if (target === ConfigurationTarget.WORKSPACE) {
isConfigured = !!configurationService.unTrustedSettings.workspace?.includes(key);
isConfigured = !!configurationService.restrictedSettings.workspace?.includes(key);
} else if (target instanceof URI) {
isConfigured = !!configurationService.unTrustedSettings.workspaceFolder?.get(target)?.includes(key);
isConfigured = !!configurationService.restrictedSettings.workspaceFolder?.get(target)?.includes(key);
}
}

View file

@ -137,6 +137,11 @@ interface TaskCustomizationTelemetryEvent {
properties: string[];
}
interface CommandUpgrade {
command?: string;
args?: string[];
}
class TaskMap {
private _store: Map<string, Task[]> = new Map();
@ -3166,7 +3171,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
return undefined;
}
private upgradeTask(task: Task): TaskConfig.CustomTask | TaskConfig.ConfiguringTask | undefined {
private upgradeTask(task: Task, suppressTaskName: boolean, globalConfig: { windows?: CommandUpgrade, osx?: CommandUpgrade, linux?: CommandUpgrade }): TaskConfig.CustomTask | TaskConfig.ConfiguringTask | undefined {
if (!CustomTask.is(task)) {
return;
}
@ -3181,11 +3186,17 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
if (task.command.runtime === RuntimeType.Shell) {
configElement.type = RuntimeType.toString(RuntimeType.Shell);
}
if (task.command.name) {
if (task.command.name && !suppressTaskName && !globalConfig.windows?.command && !globalConfig.osx?.command && !globalConfig.linux?.command) {
configElement.command = task.command.name;
} else if (suppressTaskName) {
configElement.command = task._source.config.element.command;
}
if (task.command.args && (!Types.isArray(task.command.args) || (task.command.args.length > 0))) {
configElement.args = task.command.args;
if (!globalConfig.windows?.args && !globalConfig.osx?.args && !globalConfig.linux?.args) {
configElement.args = task.command.args;
} else {
configElement.args = task._source.config.element.args;
}
}
}
@ -3216,6 +3227,10 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
return;
}
if (!(await this.trust())) {
return;
}
const tasks = await this.getGroupedTasks();
const fileDiffs: [URI, URI][] = [];
for (const folder of this.workspaceFolders) {
@ -3228,8 +3243,14 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
const configTasks: (TaskConfig.CustomTask | TaskConfig.ConfiguringTask)[] = [];
const suppressTaskName = !!this.configurationService.getValue('tasks.suppressTaskName', { resource: folder.uri });
const globalConfig = {
windows: <CommandUpgrade>this.configurationService.getValue('tasks.windows', { resource: folder.uri }),
osx: <CommandUpgrade>this.configurationService.getValue('tasks.osx', { resource: folder.uri }),
linux: <CommandUpgrade>this.configurationService.getValue('tasks.linux', { resource: folder.uri })
};
tasks.get(folder).forEach(task => {
const configTask = this.upgradeTask(task);
const configTask = this.upgradeTask(task, suppressTaskName, globalConfig);
if (configTask) {
configTasks.push(configTask);
}

View file

@ -59,7 +59,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: false
},
'terminal.integrated.automationShell.linux': {
requireTrust: true,
restricted: true,
markdownDescription: localize({
key: 'terminal.integrated.automationShell.linux',
comment: ['{0} and {1} are the `shell` and `shellArgs` settings keys']
@ -68,7 +68,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: null
},
'terminal.integrated.automationShell.osx': {
requireTrust: true,
restricted: true,
markdownDescription: localize({
key: 'terminal.integrated.automationShell.osx',
comment: ['{0} and {1} are the `shell` and `shellArgs` settings keys']
@ -77,7 +77,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: null
},
'terminal.integrated.automationShell.windows': {
requireTrust: true,
restricted: true,
markdownDescription: localize({
key: 'terminal.integrated.automationShell.windows',
comment: ['{0} and {1} are the `shell` and `shellArgs` settings keys']
@ -86,7 +86,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: null
},
'terminal.integrated.shellArgs.linux': {
requireTrust: true,
restricted: true,
markdownDescription: localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
type: 'array',
items: {
@ -96,7 +96,7 @@ export const terminalConfiguration: IConfigurationNode = {
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.linux#` instead'
},
'terminal.integrated.shellArgs.osx': {
requireTrust: true,
restricted: true,
markdownDescription: localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the macOS terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
type: 'array',
items: {
@ -109,7 +109,7 @@ export const terminalConfiguration: IConfigurationNode = {
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.osx#` instead'
},
'terminal.integrated.shellArgs.windows': {
requireTrust: true,
restricted: true,
markdownDescription: localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
'anyOf': [
{
@ -128,7 +128,7 @@ export const terminalConfiguration: IConfigurationNode = {
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.windows#` instead'
},
'terminal.integrated.profiles.windows': {
requireTrust: true,
restricted: true,
markdownDescription: localize(
{
key: 'terminal.integrated.profiles.windows',
@ -188,7 +188,7 @@ export const terminalConfiguration: IConfigurationNode = {
}
},
'terminal.integrated.profiles.osx': {
requireTrust: true,
restricted: true,
markdownDescription: localize(
{
key: 'terminal.integrated.profile.osx',
@ -225,7 +225,7 @@ export const terminalConfiguration: IConfigurationNode = {
}
},
'terminal.integrated.profiles.linux': {
requireTrust: true,
restricted: true,
markdownDescription: localize(
{
key: 'terminal.integrated.profile.linux',
@ -513,7 +513,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: true
},
'terminal.integrated.env.osx': {
requireTrust: true,
restricted: true,
markdownDescription: localize('terminal.integrated.env.osx', "Object with environment variables that will be added to the VS Code process to be used by the terminal on macOS. Set to `null` to delete the environment variable."),
type: 'object',
additionalProperties: {
@ -522,7 +522,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: {}
},
'terminal.integrated.env.linux': {
requireTrust: true,
restricted: true,
markdownDescription: localize('terminal.integrated.env.linux', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Linux. Set to `null` to delete the environment variable."),
type: 'object',
additionalProperties: {
@ -531,7 +531,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: {}
},
'terminal.integrated.env.windows': {
requireTrust: true,
restricted: true,
markdownDescription: localize('terminal.integrated.env.windows', "Object with environment variables that will be added to the VS Code process to be used by the terminal on Windows. Set to `null` to delete the environment variable."),
type: 'object',
additionalProperties: {
@ -659,21 +659,21 @@ function getTerminalShellConfigurationStub(linux: string, osx: string, windows:
type: 'object',
properties: {
'terminal.integrated.shell.linux': {
requireTrust: true,
restricted: true,
markdownDescription: linux,
type: ['string', 'null'],
default: null,
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.linux#` instead'
},
'terminal.integrated.shell.osx': {
requireTrust: true,
restricted: true,
markdownDescription: osx,
type: ['string', 'null'],
default: null,
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.osx#` instead'
},
'terminal.integrated.shell.windows': {
requireTrust: true,
restricted: true,
markdownDescription: windows,
type: ['string', 'null'],
default: null,

View file

@ -131,7 +131,7 @@ export class WorkspaceTrustEditor extends EditorPane {
private registerListeners(): void {
this._register(this.extensionWorkbenchService.onChange(() => this.render()));
this._register(this.configurationService.onDidChangeUntrustdSettings(() => this.render()));
this._register(this.configurationService.onDidChangeRestrictedSettings(() => this.render()));
this._register(this.workspaceTrustManagementService.onDidChangeTrust(() => this.render()));
this._register(this.workspaceTrustManagementService.onDidChangeTrustedFolders(() => this.render()));
}
@ -206,7 +206,7 @@ export class WorkspaceTrustEditor extends EditorPane {
this.headerContainer.className = this.getHeaderContainerClass(isWorkspaceTrusted);
// Settings
const settingsRequiringTrustedWorkspaceCount = filterSettingsRequireWorkspaceTrust(this.configurationService.unTrustedSettings.default).length;
const settingsRequiringTrustedWorkspaceCount = filterSettingsRequireWorkspaceTrust(this.configurationService.restrictedSettings.default).length;
// Features List
const installedExtensions = await this.instantiationService.invokeFunction(getInstalledExtensions);
@ -316,7 +316,6 @@ export class WorkspaceTrustEditor extends EditorPane {
if (this.workspaceTrustManagementService.canSetParentFolderTrust()) {
const { parentPath } = splitName(workspaceIdentifier.uri.fsPath);
const parentIsTrusted = this.workspaceTrustManagementService.getFolderTrustInfo(URI.file(parentPath)).trusted;
console.log(`Parent (${parentPath}) is trusted: ${parentIsTrusted}`);
if (parentIsTrusted) {
return false;
}

View file

@ -44,7 +44,7 @@ export class UserConfiguration extends Disposable {
private readonly logService: ILogService,
) {
super();
this.configurationParseOptions = { scopes, isUntrusted: false };
this.configurationParseOptions = { scopes, skipRestricted: false };
this.userConfiguration.value = new UserSettings(this.userSettingsResource, scopes, uriIdentityService.extUri, this.fileService);
this._register(this.userConfiguration.value.onDidChange(() => this.reloadConfigurationScheduler.schedule()));
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this.reload().then(configurationModel => this._onDidChangeConfiguration.fire(configurationModel)), 50));
@ -77,8 +77,8 @@ export class UserConfiguration extends Disposable {
return this.userConfiguration.value!.reparse(this.configurationParseOptions);
}
getUntrustedSettings(): string[] {
return this.userConfiguration.value!.getUntrustedSettings();
getRestrictedSettings(): string[] {
return this.userConfiguration.value!.getRestrictedSettings();
}
}
@ -174,8 +174,8 @@ class FileServiceBasedConfiguration extends Disposable {
return this._cache;
}
getUntrustedSettings(): string[] {
return this._folderSettingsModelParser.untrustedConfigurations;
getRestrictedSettings(): string[] {
return this._folderSettingsModelParser.restrictedConfigurations;
}
reparse(configurationParseOptions: ConfigurationParseOptions): ConfigurationModel {
@ -267,8 +267,8 @@ export class RemoteUserConfiguration extends Disposable {
return this._userConfiguration.reparse({ scopes: REMOTE_MACHINE_SCOPES });
}
getUntrustedSettings(): string[] {
return this._userConfiguration.getUntrustedSettings();
getRestrictedSettings(): string[] {
return this._userConfiguration.getRestrictedSettings();
}
private onDidUserConfigurationChange(configurationModel: ConfigurationModel): void {
@ -367,8 +367,8 @@ class FileServiceBasedRemoteUserConfiguration extends Disposable {
return this.parser.configurationModel;
}
getUntrustedSettings(): string[] {
return this.parser.untrustedConfigurations;
getRestrictedSettings(): string[] {
return this.parser.restrictedConfigurations;
}
private async handleFileEvents(event: FileChangesEvent): Promise<void> {
@ -436,8 +436,8 @@ class CachedRemoteUserConfiguration extends Disposable {
return this.configurationModel;
}
getUntrustedSettings(): string[] {
return this.parser.untrustedConfigurations;
getRestrictedSettings(): string[] {
return this.parser.restrictedConfigurations;
}
async reload(): Promise<ConfigurationModel> {
@ -500,7 +500,7 @@ export class WorkspaceConfiguration extends Disposable {
async reload(): Promise<void> {
if (this._workspaceIdentifier) {
await this._workspaceConfiguration.load(this._workspaceIdentifier, { scopes: WORKSPACE_SCOPES, isUntrusted: this.isUntrusted() });
await this._workspaceConfiguration.load(this._workspaceIdentifier, { scopes: WORKSPACE_SCOPES, skipRestricted: this.isUntrusted() });
}
}
@ -526,19 +526,19 @@ export class WorkspaceConfiguration extends Disposable {
}
reparseWorkspaceSettings(): ConfigurationModel {
this._workspaceConfiguration.reparseWorkspaceSettings({ scopes: WORKSPACE_SCOPES, isUntrusted: this.isUntrusted() });
this._workspaceConfiguration.reparseWorkspaceSettings({ scopes: WORKSPACE_SCOPES, skipRestricted: this.isUntrusted() });
return this.getConfiguration();
}
getUntrustedSettings(): string[] {
return this._workspaceConfiguration.getUntrustedSettings();
getRestrictedSettings(): string[] {
return this._workspaceConfiguration.getRestrictedSettings();
}
private async waitAndInitialize(workspaceIdentifier: IWorkspaceIdentifier): Promise<void> {
await whenProviderRegistered(workspaceIdentifier.configPath, this._fileService);
if (!(this._workspaceConfiguration instanceof FileServiceBasedWorkspaceConfiguration)) {
const fileServiceBasedWorkspaceConfiguration = this._register(new FileServiceBasedWorkspaceConfiguration(this._fileService));
await fileServiceBasedWorkspaceConfiguration.load(workspaceIdentifier, { scopes: WORKSPACE_SCOPES, isUntrusted: this.isUntrusted() });
await fileServiceBasedWorkspaceConfiguration.load(workspaceIdentifier, { scopes: WORKSPACE_SCOPES, skipRestricted: this.isUntrusted() });
this.doInitialize(fileServiceBasedWorkspaceConfiguration);
this.onDidWorkspaceConfigurationChange(false, true);
}
@ -640,8 +640,8 @@ class FileServiceBasedWorkspaceConfiguration extends Disposable {
return this.getWorkspaceSettings();
}
getUntrustedSettings(): string[] {
return this.workspaceConfigurationModelParser.getUntrustedWorkspaceSettings();
getRestrictedSettings(): string[] {
return this.workspaceConfigurationModelParser.getRestrictedWorkspaceSettings();
}
private consolidate(): void {
@ -711,8 +711,8 @@ class CachedWorkspaceConfiguration {
return this.getWorkspaceSettings();
}
getUntrustedSettings(): string[] {
return this.workspaceConfigurationModelParser.getUntrustedWorkspaceSettings();
getRestrictedSettings(): string[] {
return this.workspaceConfigurationModelParser.getRestrictedWorkspaceSettings();
}
private consolidate(): void {
@ -800,8 +800,8 @@ class CachedFolderConfiguration {
}
}
getUntrustedSettings(): string[] {
return this._folderSettingsModelParser.untrustedConfigurations;
getRestrictedSettings(): string[] {
return this._folderSettingsModelParser.restrictedConfigurations;
}
reparse(configurationParseOptions: ConfigurationParseOptions): ConfigurationModel {
@ -844,7 +844,7 @@ export class FolderConfiguration extends Disposable {
this.scopes = WorkbenchState.WORKSPACE === this.workbenchState ? FOLDER_SCOPES : WORKSPACE_SCOPES;
this.configurationFolder = uriIdentityService.extUri.joinPath(workspaceFolder.uri, configFolderRelativePath);
this.cachedFolderConfiguration = new CachedFolderConfiguration(workspaceFolder.uri, configFolderRelativePath, { scopes: this.scopes, isUntrusted: this.isUntrusted() }, configurationCache);
this.cachedFolderConfiguration = new CachedFolderConfiguration(workspaceFolder.uri, configFolderRelativePath, { scopes: this.scopes, skipRestricted: this.isUntrusted() }, configurationCache);
if (this.configurationCache.needsCaching(workspaceFolder.uri)) {
this.folderConfiguration = this.cachedFolderConfiguration;
whenProviderRegistered(workspaceFolder.uri, fileService)
@ -869,13 +869,13 @@ export class FolderConfiguration extends Disposable {
}
reparse(): ConfigurationModel {
const configurationModel = this.folderConfiguration.reparse({ scopes: this.scopes, isUntrusted: this.isUntrusted() });
const configurationModel = this.folderConfiguration.reparse({ scopes: this.scopes, skipRestricted: this.isUntrusted() });
this.updateCache();
return configurationModel;
}
getUntrustedSettings(): string[] {
return this.folderConfiguration.getUntrustedSettings();
getRestrictedSettings(): string[] {
return this.folderConfiguration.getRestrictedSettings();
}
private isUntrusted(): boolean {
@ -890,7 +890,7 @@ export class FolderConfiguration extends Disposable {
private createFileServiceBasedConfiguration(fileService: IFileService, uriIdentityService: IUriIdentityService, logService: ILogService) {
const settingsResource = uriIdentityService.extUri.joinPath(this.configurationFolder, `${FOLDER_SETTINGS_NAME}.json`);
const standAloneConfigurationResources: [string, URI][] = [TASKS_CONFIGURATION_KEY, LAUNCH_CONFIGURATION_KEY].map(name => ([name, uriIdentityService.extUri.joinPath(this.configurationFolder, `${name}.json`)]));
return new FileServiceBasedConfiguration(this.configurationFolder.toString(), settingsResource, standAloneConfigurationResources, { scopes: this.scopes, isUntrusted: this.isUntrusted() }, fileService, uriIdentityService, logService);
return new FileServiceBasedConfiguration(this.configurationFolder.toString(), settingsResource, standAloneConfigurationResources, { scopes: this.scopes, skipRestricted: this.isUntrusted() }, fileService, uriIdentityService, logService);
}
private async updateCache(): Promise<void> {

View file

@ -14,7 +14,7 @@ import { IWorkspaceContextService, Workspace as BaseWorkspace, WorkbenchState, I
import { ConfigurationModel, DefaultConfigurationModel, ConfigurationChangeEvent, AllKeysConfigurationChangeEvent, mergeChanges } from 'vs/platform/configuration/common/configurationModels';
import { IConfigurationChangeEvent, ConfigurationTarget, IConfigurationOverrides, keyFromOverrideIdentifier, isConfigurationOverrides, IConfigurationData, IConfigurationValue, IConfigurationChange, ConfigurationTargetToString } from 'vs/platform/configuration/common/configuration';
import { Configuration } from 'vs/workbench/services/configuration/common/configurationModels';
import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, machineSettingsSchemaId, LOCAL_MACHINE_SCOPES, IWorkbenchConfigurationService, UntrustedSettings } from 'vs/workbench/services/configuration/common/configuration';
import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, machineSettingsSchemaId, LOCAL_MACHINE_SCOPES, IWorkbenchConfigurationService, RestrictedSettings } from 'vs/workbench/services/configuration/common/configuration';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions, allSettings, windowSettings, resourceSettings, applicationSettings, machineSettings, machineOverridableSettings, ConfigurationScope, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
import { IWorkspaceIdentifier, isWorkspaceIdentifier, IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, IWorkspaceInitializationPayload, IEmptyWorkspaceIdentifier, useSlashForPath, getStoredWorkspaceFolder, isSingleFolderWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, toWorkspaceFolders } from 'vs/platform/workspaces/common/workspaces';
@ -76,12 +76,12 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
private readonly _onDidChangeWorkbenchState: Emitter<WorkbenchState> = this._register(new Emitter<WorkbenchState>());
public readonly onDidChangeWorkbenchState: Event<WorkbenchState> = this._onDidChangeWorkbenchState.event;
private readonly _onDidChangeUntrustedSettings = this._register(new Emitter<UntrustedSettings>());
public readonly onDidChangeUntrustdSettings = this._onDidChangeUntrustedSettings.event;
private isWorkspaceTrusted: boolean = true;
private _unTrustedSettings: UntrustedSettings = { default: [] };
get unTrustedSettings() { return this._unTrustedSettings; }
private _restrictedSettings: RestrictedSettings = { default: [] };
get restrictedSettings() { return this._restrictedSettings; }
private readonly _onDidChangeRestrictedSettings = this._register(new Emitter<RestrictedSettings>());
public readonly onDidChangeRestrictedSettings = this._onDidChangeRestrictedSettings.event;
private readonly configurationRegistry: IConfigurationRegistry;
@ -423,7 +423,22 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
} else {
this._configuration.updateWorkspaceConfiguration(this.workspaceConfiguration.updateWorkspaceTrust(this.isWorkspaceTrusted));
}
const keys = this.updateUntrustedSettings();
this.updateRestrictedSettings();
let keys: string[] = [];
if (this.restrictedSettings.userLocal) {
keys.push(...this.restrictedSettings.userLocal);
}
if (this.restrictedSettings.userRemote) {
keys.push(...this.restrictedSettings.userRemote);
}
if (this.restrictedSettings.workspace) {
keys.push(...this.restrictedSettings.workspace);
}
if (this.restrictedSettings.workspaceFolder) {
this.restrictedSettings.workspaceFolder.forEach((value) => keys.push(...value));
}
keys = distinct(keys);
if (keys.length) {
this.triggerConfigurationChange({ keys, overrides: [] }, { data, workspace: this.workspace }, ConfigurationTarget.WORKSPACE);
}
@ -612,7 +627,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
this.initialized = true;
}
this.updateUntrustedSettings();
this.updateRestrictedSettings();
}
private getWorkspaceConfigurationModel(folderConfigurations: ConfigurationModel[]): ConfigurationModel {
@ -651,7 +666,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
}
}
this.triggerConfigurationChange(change, { data: previousData, workspace: this.workspace }, ConfigurationTarget.DEFAULT);
this.updateUntrustedSettings();
this.updateRestrictedSettings();
}
}
@ -689,51 +704,49 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
}
}
private updateUntrustedSettings(): string[] {
private updateRestrictedSettings(): void {
const changed: string[] = [];
const allProperties = this.configurationRegistry.getConfigurationProperties();
const defaultUntrustedSettings: string[] = this.isWorkspaceTrusted ? [] : Object.keys(allProperties).filter(key => allProperties[key].requireTrust).sort((a, b) => a.localeCompare(b));
const defaultDelta = delta(defaultUntrustedSettings, this._unTrustedSettings.default, (a, b) => a.localeCompare(b));
const defaultRestrictedSettings: string[] = Object.keys(allProperties).filter(key => allProperties[key].restricted).sort((a, b) => a.localeCompare(b));
const defaultDelta = delta(defaultRestrictedSettings, this._restrictedSettings.default, (a, b) => a.localeCompare(b));
changed.push(...defaultDelta.added, ...defaultDelta.removed);
const userLocal = this.localUserConfiguration.getUntrustedSettings().sort((a, b) => a.localeCompare(b));
const userLocalDelta = delta(userLocal, this._unTrustedSettings.userLocal || [], (a, b) => a.localeCompare(b));
const userLocal = this.localUserConfiguration.getRestrictedSettings().sort((a, b) => a.localeCompare(b));
const userLocalDelta = delta(userLocal, this._restrictedSettings.userLocal || [], (a, b) => a.localeCompare(b));
changed.push(...userLocalDelta.added, ...userLocalDelta.removed);
const userRemote = (this.remoteUserConfiguration?.getUntrustedSettings() || []).sort((a, b) => a.localeCompare(b));
const userRemoteDelta = delta(userRemote, this._unTrustedSettings.userRemote || [], (a, b) => a.localeCompare(b));
const userRemote = (this.remoteUserConfiguration?.getRestrictedSettings() || []).sort((a, b) => a.localeCompare(b));
const userRemoteDelta = delta(userRemote, this._restrictedSettings.userRemote || [], (a, b) => a.localeCompare(b));
changed.push(...userRemoteDelta.added, ...userRemoteDelta.removed);
const workspaceFolderMap = new ResourceMap<ReadonlyArray<string>>();
for (const workspaceFolder of this.workspace.folders) {
const cachedFolderConfig = this.cachedFolderConfigs.get(workspaceFolder.uri);
const folderUntrustedSettings = (cachedFolderConfig?.getUntrustedSettings() || []).sort((a, b) => a.localeCompare(b));
if (folderUntrustedSettings.length) {
workspaceFolderMap.set(workspaceFolder.uri, folderUntrustedSettings);
const folderRestrictedSettings = (cachedFolderConfig?.getRestrictedSettings() || []).sort((a, b) => a.localeCompare(b));
if (folderRestrictedSettings.length) {
workspaceFolderMap.set(workspaceFolder.uri, folderRestrictedSettings);
}
const previous = this._unTrustedSettings.workspaceFolder?.get(workspaceFolder.uri) || [];
const workspaceFolderDelta = delta(folderUntrustedSettings, previous, (a, b) => a.localeCompare(b));
const previous = this._restrictedSettings.workspaceFolder?.get(workspaceFolder.uri) || [];
const workspaceFolderDelta = delta(folderRestrictedSettings, previous, (a, b) => a.localeCompare(b));
changed.push(...workspaceFolderDelta.added, ...workspaceFolderDelta.removed);
}
const workspace = this.getWorkbenchState() === WorkbenchState.WORKSPACE ? this.workspaceConfiguration.getUntrustedSettings().sort((a, b) => a.localeCompare(b))
const workspace = this.getWorkbenchState() === WorkbenchState.WORKSPACE ? this.workspaceConfiguration.getRestrictedSettings().sort((a, b) => a.localeCompare(b))
: this.workspace.folders[0] ? (workspaceFolderMap.get(this.workspace.folders[0].uri) || []) : [];
const workspaceDelta = delta(workspace, this._unTrustedSettings.workspace || [], (a, b) => a.localeCompare(b));
const workspaceDelta = delta(workspace, this._restrictedSettings.workspace || [], (a, b) => a.localeCompare(b));
changed.push(...workspaceDelta.added, ...workspaceDelta.removed);
if (changed.length) {
this._unTrustedSettings = {
default: defaultUntrustedSettings,
this._restrictedSettings = {
default: defaultRestrictedSettings,
userLocal: userLocal.length ? userLocal : undefined,
userRemote: userRemote.length ? userRemote : undefined,
workspace: workspace.length ? workspace : undefined,
workspaceFolder: workspaceFolderMap.size ? workspaceFolderMap : undefined,
};
this._onDidChangeUntrustedSettings.fire(this.unTrustedSettings);
this._onDidChangeRestrictedSettings.fire(this.restrictedSettings);
}
return distinct(changed);
}
private async updateWorkspaceConfiguration(workspaceFolders: WorkspaceFolder[], configuration: ConfigurationModel, fromCache: boolean): Promise<void> {
@ -749,7 +762,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
} else {
this.triggerConfigurationChange(change, previous, ConfigurationTarget.WORKSPACE);
}
this.updateUntrustedSettings();
this.updateRestrictedSettings();
}
private async handleWillChangeWorkspaceFolders(changes: IWorkspaceFoldersChangeEvent, fromCache: boolean): Promise<void> {
@ -774,7 +787,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
} else {
this.triggerConfigurationChange(folderConfiguraitonChange, previous, ConfigurationTarget.WORKSPACE_FOLDER);
}
this.updateUntrustedSettings();
this.updateRestrictedSettings();
}
private async onFoldersChanged(): Promise<IConfigurationChange> {
@ -1067,7 +1080,7 @@ class RegisterConfigurationSchemasContribution extends Disposable implements IWo
const result: IStringDictionary<IConfigurationPropertySchema> = {};
forEach(properties, ({ key, value }) => {
if (!value.requireTrust) {
if (!value.restricted) {
result[key] = value;
}
});

View file

@ -52,11 +52,11 @@ export function filterSettingsRequireWorkspaceTrust(settings: ReadonlyArray<stri
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
return settings.filter(key => {
const property = configurationRegistry.getConfigurationProperties()[key];
return property.requireTrust && property.scope !== ConfigurationScope.APPLICATION && property.scope !== ConfigurationScope.MACHINE;
return property.restricted && property.scope !== ConfigurationScope.APPLICATION && property.scope !== ConfigurationScope.MACHINE;
});
}
export type UntrustedSettings = {
export type RestrictedSettings = {
default: ReadonlyArray<string>;
userLocal?: ReadonlyArray<string>;
userRemote?: ReadonlyArray<string>;
@ -67,14 +67,14 @@ export type UntrustedSettings = {
export const IWorkbenchConfigurationService = refineServiceDecorator<IConfigurationService, IWorkbenchConfigurationService>(IConfigurationService);
export interface IWorkbenchConfigurationService extends IConfigurationService {
/**
* List of untrusted settings
* Restricted settings defined in each configuraiton target
*/
readonly unTrustedSettings: UntrustedSettings;
readonly restrictedSettings: RestrictedSettings;
/**
* Event that triggers when the list of untrusted settings changes
* Event that triggers when the restricted settings changes
*/
readonly onDidChangeUntrustdSettings: Event<UntrustedSettings>;
readonly onDidChangeRestrictedSettings: Event<RestrictedSettings>;
/**
* A promise that resolves when the remote configuration is loaded in a remote window.

View file

@ -46,8 +46,8 @@ export class WorkspaceConfigurationModelParser extends ConfigurationModelParser
this._settingsModelParser.reparse(configurationParseOptions);
}
getUntrustedWorkspaceSettings(): string[] {
return this._settingsModelParser.untrustedConfigurations;
getRestrictedWorkspaceSettings(): string[] {
return this._settingsModelParser.restrictedConfigurations;
}
protected override doParseRaw(raw: any, configurationParseOptions?: ConfigurationParseOptions): IConfigurationModel {

View file

@ -660,10 +660,10 @@ suite('WorkspaceConfigurationService - Folder', () => {
'default': 'isSet',
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE
},
'configurationService.folder.untrustedSetting': {
'configurationService.folder.restrictedSetting': {
'type': 'string',
'default': 'isSet',
requireTrust: true
restricted: true
},
}
});
@ -699,7 +699,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
teardown(() => disposables.clear());
test('defaults', () => {
assert.deepStrictEqual(testObject.getValue('configurationService'), { 'folder': { 'applicationSetting': 'isSet', 'machineSetting': 'isSet', 'machineOverridableSetting': 'isSet', 'testSetting': 'isSet', 'languageSetting': 'isSet', 'untrustedSetting': 'isSet' } });
assert.deepStrictEqual(testObject.getValue('configurationService'), { 'folder': { 'applicationSetting': 'isSet', 'machineSetting': 'isSet', 'machineOverridableSetting': 'isSet', 'testSetting': 'isSet', 'languageSetting': 'isSet', 'restrictedSetting': 'isSet' } });
});
test('globals override defaults', async () => {
@ -1122,108 +1122,110 @@ suite('WorkspaceConfigurationService - Folder', () => {
assert.strictEqual(testObject.getValue('configurationService.folder.testSetting'), 'userValue');
});
test('untrusted setting is read from workspace when workspace is trusted', async () => {
test('restricted setting is read from workspace when workspace is trusted', async () => {
testObject.updateWorkspaceTrust(true);
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "workspaceValue" }'));
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "workspaceValue" }'));
await testObject.reloadConfiguration();
assert.strictEqual(testObject.getValue('configurationService.folder.untrustedSetting', { resource: workspaceService.getWorkspace().folders[0].uri }), 'workspaceValue');
assert.deepStrictEqual(testObject.unTrustedSettings.default, []);
assert.strictEqual(testObject.unTrustedSettings.userLocal, undefined);
assert.strictEqual(testObject.unTrustedSettings.userRemote, undefined);
assert.strictEqual(testObject.unTrustedSettings.workspace, undefined);
assert.strictEqual(testObject.unTrustedSettings.workspaceFolder, undefined);
assert.strictEqual(testObject.getValue('configurationService.folder.restrictedSetting', { resource: workspaceService.getWorkspace().folders[0].uri }), 'workspaceValue');
assert.ok(testObject.restrictedSettings.default.includes('configurationService.folder.restrictedSetting'));
assert.strictEqual(testObject.restrictedSettings.userLocal, undefined);
assert.strictEqual(testObject.restrictedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.restrictedSettings.workspace, ['configurationService.folder.restrictedSetting']);
assert.strictEqual(testObject.restrictedSettings.workspaceFolder?.size, 1);
assert.deepStrictEqual(testObject.restrictedSettings.workspaceFolder?.get(workspaceService.getWorkspace().folders[0].uri), ['configurationService.folder.restrictedSetting']);
});
test('untrusted setting is not read from workspace when workspace is changed to trusted', async () => {
test('restricted setting is not read from workspace when workspace is changed to trusted', async () => {
testObject.updateWorkspaceTrust(true);
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "workspaceValue" }'));
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "workspaceValue" }'));
await testObject.reloadConfiguration();
testObject.updateWorkspaceTrust(false);
assert.strictEqual(testObject.getValue('configurationService.folder.untrustedSetting', { resource: workspaceService.getWorkspace().folders[0].uri }), 'userValue');
assert.ok(testObject.unTrustedSettings.default.includes('configurationService.folder.untrustedSetting'));
assert.strictEqual(testObject.unTrustedSettings.userLocal, undefined);
assert.strictEqual(testObject.unTrustedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.unTrustedSettings.workspace, ['configurationService.folder.untrustedSetting']);
assert.strictEqual(testObject.unTrustedSettings.workspaceFolder?.size, 1);
assert.deepStrictEqual(testObject.unTrustedSettings.workspaceFolder?.get(workspaceService.getWorkspace().folders[0].uri), ['configurationService.folder.untrustedSetting']);
assert.strictEqual(testObject.getValue('configurationService.folder.restrictedSetting', { resource: workspaceService.getWorkspace().folders[0].uri }), 'userValue');
assert.ok(testObject.restrictedSettings.default.includes('configurationService.folder.restrictedSetting'));
assert.strictEqual(testObject.restrictedSettings.userLocal, undefined);
assert.strictEqual(testObject.restrictedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.restrictedSettings.workspace, ['configurationService.folder.restrictedSetting']);
assert.strictEqual(testObject.restrictedSettings.workspaceFolder?.size, 1);
assert.deepStrictEqual(testObject.restrictedSettings.workspaceFolder?.get(workspaceService.getWorkspace().folders[0].uri), ['configurationService.folder.restrictedSetting']);
});
test('change event is triggered when workspace is changed to untrusted', async () => {
testObject.updateWorkspaceTrust(true);
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "workspaceValue" }'));
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "workspaceValue" }'));
await testObject.reloadConfiguration();
const promise = Event.toPromise(testObject.onDidChangeConfiguration);
testObject.updateWorkspaceTrust(false);
const event = await promise;
assert.ok(event.affectedKeys.includes('configurationService.folder.untrustedSetting'));
assert.ok(event.affectsConfiguration('configurationService.folder.untrustedSetting'));
assert.ok(event.affectedKeys.includes('configurationService.folder.restrictedSetting'));
assert.ok(event.affectsConfiguration('configurationService.folder.restrictedSetting'));
});
test('untrusted setting is not read from workspace when workspace is not trusted', async () => {
test('restricted setting is not read from workspace when workspace is not trusted', async () => {
testObject.updateWorkspaceTrust(false);
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "workspaceValue" }'));
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "workspaceValue" }'));
await testObject.reloadConfiguration();
assert.strictEqual(testObject.getValue('configurationService.folder.untrustedSetting', { resource: workspaceService.getWorkspace().folders[0].uri }), 'userValue');
assert.ok(testObject.unTrustedSettings.default.includes('configurationService.folder.untrustedSetting'));
assert.strictEqual(testObject.unTrustedSettings.userLocal, undefined);
assert.strictEqual(testObject.unTrustedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.unTrustedSettings.workspace, ['configurationService.folder.untrustedSetting']);
assert.strictEqual(testObject.unTrustedSettings.workspaceFolder?.size, 1);
assert.deepStrictEqual(testObject.unTrustedSettings.workspaceFolder?.get(workspaceService.getWorkspace().folders[0].uri), ['configurationService.folder.untrustedSetting']);
assert.strictEqual(testObject.getValue('configurationService.folder.restrictedSetting', { resource: workspaceService.getWorkspace().folders[0].uri }), 'userValue');
assert.ok(testObject.restrictedSettings.default.includes('configurationService.folder.restrictedSetting'));
assert.strictEqual(testObject.restrictedSettings.userLocal, undefined);
assert.strictEqual(testObject.restrictedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.restrictedSettings.workspace, ['configurationService.folder.restrictedSetting']);
assert.strictEqual(testObject.restrictedSettings.workspaceFolder?.size, 1);
assert.deepStrictEqual(testObject.restrictedSettings.workspaceFolder?.get(workspaceService.getWorkspace().folders[0].uri), ['configurationService.folder.restrictedSetting']);
});
test('untrusted setting is read when workspace is changed to trusted', async () => {
test('restricted setting is read when workspace is changed to trusted', async () => {
testObject.updateWorkspaceTrust(false);
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "workspaceValue" }'));
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "workspaceValue" }'));
await testObject.reloadConfiguration();
testObject.updateWorkspaceTrust(true);
assert.strictEqual(testObject.getValue('configurationService.folder.untrustedSetting', { resource: workspaceService.getWorkspace().folders[0].uri }), 'workspaceValue');
assert.deepStrictEqual(testObject.unTrustedSettings.default, []);
assert.strictEqual(testObject.unTrustedSettings.userLocal, undefined);
assert.strictEqual(testObject.unTrustedSettings.userRemote, undefined);
assert.strictEqual(testObject.unTrustedSettings.workspace, undefined);
assert.strictEqual(testObject.unTrustedSettings.workspaceFolder, undefined);
assert.strictEqual(testObject.getValue('configurationService.folder.restrictedSetting', { resource: workspaceService.getWorkspace().folders[0].uri }), 'workspaceValue');
assert.ok(testObject.restrictedSettings.default.includes('configurationService.folder.restrictedSetting'));
assert.strictEqual(testObject.restrictedSettings.userLocal, undefined);
assert.strictEqual(testObject.restrictedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.restrictedSettings.workspace, ['configurationService.folder.restrictedSetting']);
assert.strictEqual(testObject.restrictedSettings.workspaceFolder?.size, 1);
assert.deepStrictEqual(testObject.restrictedSettings.workspaceFolder?.get(workspaceService.getWorkspace().folders[0].uri), ['configurationService.folder.restrictedSetting']);
});
test('change event is triggered when workspace is changed to trusted', async () => {
testObject.updateWorkspaceTrust(false);
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "workspaceValue" }'));
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "userValue" }'));
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "workspaceValue" }'));
await testObject.reloadConfiguration();
const promise = Event.toPromise(testObject.onDidChangeConfiguration);
testObject.updateWorkspaceTrust(true);
const event = await promise;
assert.ok(event.affectedKeys.includes('configurationService.folder.untrustedSetting'));
assert.ok(event.affectsConfiguration('configurationService.folder.untrustedSetting'));
assert.ok(event.affectedKeys.includes('configurationService.folder.restrictedSetting'));
assert.ok(event.affectsConfiguration('configurationService.folder.restrictedSetting'));
});
test('adding an untrusted setting triggers change event', async () => {
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "userValue" }'));
test('adding an restricted setting triggers change event', async () => {
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "userValue" }'));
testObject.updateWorkspaceTrust(false);
const promise = Event.toPromise(testObject.onDidChangeUntrustdSettings);
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.untrustedSetting": "workspaceValue" }'));
const promise = Event.toPromise(testObject.onDidChangeRestrictedSettings);
await fileService.writeFile(joinPath(workspaceService.getWorkspace().folders[0].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.folder.restrictedSetting": "workspaceValue" }'));
return promise;
});
@ -1269,16 +1271,16 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
'default': 'isSet',
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE
},
'configurationService.workspace.testUntrustedSetting1': {
'configurationService.workspace.testRestrictedSetting1': {
'type': 'string',
'default': 'isSet',
requireTrust: true,
restricted: true,
scope: ConfigurationScope.RESOURCE
},
'configurationService.workspace.testUntrustedSetting2': {
'configurationService.workspace.testRestrictedSetting2': {
'type': 'string',
'default': 'isSet',
requireTrust: true,
restricted: true,
scope: ConfigurationScope.RESOURCE
}
}
@ -1841,41 +1843,44 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
});
});
test('untrusted setting is read from workspace folders when workspace is trusted', async () => {
test('restricted setting is read from workspace folders when workspace is trusted', async () => {
testObject.updateWorkspaceTrust(true);
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.workspace.testUntrustedSetting1": "userValue", "configurationService.workspace.testUntrustedSetting2": "userValue" }'));
await jsonEditingServce.write((workspaceContextService.getWorkspace().configuration!), [{ path: ['settings'], value: { 'configurationService.workspace.testUntrustedSetting1': 'workspaceValue' } }], true);
await fileService.writeFile(joinPath(testObject.getWorkspace().folders[1].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.workspace.testUntrustedSetting2": "workspaceFolder2Value" }'));
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.workspace.testRestrictedSetting1": "userValue", "configurationService.workspace.testRestrictedSetting2": "userValue" }'));
await jsonEditingServce.write((workspaceContextService.getWorkspace().configuration!), [{ path: ['settings'], value: { 'configurationService.workspace.testRestrictedSetting1': 'workspaceValue' } }], true);
await fileService.writeFile(joinPath(testObject.getWorkspace().folders[1].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.workspace.testRestrictedSetting2": "workspaceFolder2Value" }'));
await testObject.reloadConfiguration();
assert.strictEqual(testObject.getValue('configurationService.workspace.testUntrustedSetting1', { resource: testObject.getWorkspace().folders[0].uri }), 'workspaceValue');
assert.strictEqual(testObject.getValue('configurationService.workspace.testUntrustedSetting2', { resource: testObject.getWorkspace().folders[1].uri }), 'workspaceFolder2Value');
assert.deepStrictEqual(testObject.unTrustedSettings.default, []);
assert.strictEqual(testObject.unTrustedSettings.userLocal, undefined);
assert.strictEqual(testObject.unTrustedSettings.userRemote, undefined);
assert.strictEqual(testObject.unTrustedSettings.workspace, undefined);
assert.strictEqual(testObject.unTrustedSettings.workspaceFolder, undefined);
assert.strictEqual(testObject.getValue('configurationService.workspace.testRestrictedSetting1', { resource: testObject.getWorkspace().folders[0].uri }), 'workspaceValue');
assert.strictEqual(testObject.getValue('configurationService.workspace.testRestrictedSetting2', { resource: testObject.getWorkspace().folders[1].uri }), 'workspaceFolder2Value');
assert.ok(testObject.restrictedSettings.default.includes('configurationService.workspace.testRestrictedSetting1'));
assert.ok(testObject.restrictedSettings.default.includes('configurationService.workspace.testRestrictedSetting2'));
assert.strictEqual(testObject.restrictedSettings.userLocal, undefined);
assert.strictEqual(testObject.restrictedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.restrictedSettings.workspace, ['configurationService.workspace.testRestrictedSetting1']);
assert.strictEqual(testObject.restrictedSettings.workspaceFolder?.size, 1);
assert.strictEqual(testObject.restrictedSettings.workspaceFolder?.get(testObject.getWorkspace().folders[0].uri), undefined);
assert.deepStrictEqual(testObject.restrictedSettings.workspaceFolder?.get(testObject.getWorkspace().folders[1].uri), ['configurationService.workspace.testRestrictedSetting2']);
});
test('untrusted setting is not read from workspace when workspace is not trusted', async () => {
test('restricted setting is not read from workspace when workspace is not trusted', async () => {
testObject.updateWorkspaceTrust(false);
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.workspace.testUntrustedSetting1": "userValue", "configurationService.workspace.testUntrustedSetting2": "userValue" }'));
await jsonEditingServce.write((workspaceContextService.getWorkspace().configuration!), [{ path: ['settings'], value: { 'configurationService.workspace.testUntrustedSetting1': 'workspaceValue' } }], true);
await fileService.writeFile(joinPath(testObject.getWorkspace().folders[1].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.workspace.testUntrustedSetting2": "workspaceFolder2Value" }'));
await fileService.writeFile(environmentService.settingsResource, VSBuffer.fromString('{ "configurationService.workspace.testRestrictedSetting1": "userValue", "configurationService.workspace.testRestrictedSetting2": "userValue" }'));
await jsonEditingServce.write((workspaceContextService.getWorkspace().configuration!), [{ path: ['settings'], value: { 'configurationService.workspace.testRestrictedSetting1': 'workspaceValue' } }], true);
await fileService.writeFile(joinPath(testObject.getWorkspace().folders[1].uri, '.vscode', 'settings.json'), VSBuffer.fromString('{ "configurationService.workspace.testRestrictedSetting2": "workspaceFolder2Value" }'));
await testObject.reloadConfiguration();
assert.strictEqual(testObject.getValue('configurationService.workspace.testUntrustedSetting1', { resource: testObject.getWorkspace().folders[0].uri }), 'userValue');
assert.strictEqual(testObject.getValue('configurationService.workspace.testUntrustedSetting2', { resource: testObject.getWorkspace().folders[1].uri }), 'userValue');
assert.ok(testObject.unTrustedSettings.default.includes('configurationService.workspace.testUntrustedSetting1'));
assert.ok(testObject.unTrustedSettings.default.includes('configurationService.workspace.testUntrustedSetting2'));
assert.strictEqual(testObject.unTrustedSettings.userLocal, undefined);
assert.strictEqual(testObject.unTrustedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.unTrustedSettings.workspace, ['configurationService.workspace.testUntrustedSetting1']);
assert.strictEqual(testObject.unTrustedSettings.workspaceFolder?.size, 1);
assert.strictEqual(testObject.unTrustedSettings.workspaceFolder?.get(testObject.getWorkspace().folders[0].uri), undefined);
assert.deepStrictEqual(testObject.unTrustedSettings.workspaceFolder?.get(testObject.getWorkspace().folders[1].uri), ['configurationService.workspace.testUntrustedSetting2']);
assert.strictEqual(testObject.getValue('configurationService.workspace.testRestrictedSetting1', { resource: testObject.getWorkspace().folders[0].uri }), 'userValue');
assert.strictEqual(testObject.getValue('configurationService.workspace.testRestrictedSetting2', { resource: testObject.getWorkspace().folders[1].uri }), 'userValue');
assert.ok(testObject.restrictedSettings.default.includes('configurationService.workspace.testRestrictedSetting1'));
assert.ok(testObject.restrictedSettings.default.includes('configurationService.workspace.testRestrictedSetting2'));
assert.strictEqual(testObject.restrictedSettings.userLocal, undefined);
assert.strictEqual(testObject.restrictedSettings.userRemote, undefined);
assert.deepStrictEqual(testObject.restrictedSettings.workspace, ['configurationService.workspace.testRestrictedSetting1']);
assert.strictEqual(testObject.restrictedSettings.workspaceFolder?.size, 1);
assert.strictEqual(testObject.restrictedSettings.workspaceFolder?.get(testObject.getWorkspace().folders[0].uri), undefined);
assert.deepStrictEqual(testObject.restrictedSettings.workspaceFolder?.get(testObject.getWorkspace().folders[1].uri), ['configurationService.workspace.testRestrictedSetting2']);
});
});

View file

@ -77,7 +77,7 @@ export interface ISetting {
enumDescriptionsAreMarkdown?: boolean;
tags?: string[];
disallowSyncIgnore?: boolean;
requireTrust?: boolean;
restricted?: boolean;
extensionInfo?: IConfigurationExtensionInfo;
validator?: (value: any) => string | null;
enumItemLabels?: string[];

View file

@ -643,7 +643,7 @@ export class DefaultSettings extends Disposable {
enumDescriptionsAreMarkdown: !prop.enumDescriptions,
tags: prop.tags,
disallowSyncIgnore: prop.disallowSyncIgnore,
requireTrust: prop.requireTrust,
restricted: prop.restricted,
extensionInfo: extensionInfo,
deprecationMessage: prop.markdownDeprecationMessage || prop.deprecationMessage,
deprecationMessageIsMarkdown: !!prop.markdownDeprecationMessage,

View file

@ -78,6 +78,8 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
if (changeEvent.key === this.storageKey) {
this._trustStateInfo = this.loadTrustInfo();
this.currentTrustState = this.calculateWorkspaceTrust();
this._onDidChangeTrustedFolders.fire();
}
}));
}
@ -110,7 +112,6 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
private saveTrustInfo(): void {
this.storageService.store(this.storageKey, JSON.stringify(this._trustStateInfo), StorageScope.GLOBAL, StorageTarget.MACHINE);
this._onDidChangeTrustedFolders.fire();
}
private calculateWorkspaceTrust(): boolean {

View file

@ -25,7 +25,7 @@ import { NullLogService } from 'vs/platform/log/common/log';
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import { TestTextResourcePropertiesService, TestWorkingCopyFileService } from 'vs/workbench/test/common/workbenchTestServices';
import { TestTextResourcePropertiesService } from 'vs/workbench/test/common/workbenchTestServices';
import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
@ -93,7 +93,6 @@ suite('MainThreadDocumentsAndEditors', () => {
}
},
TestEnvironmentService,
new TestWorkingCopyFileService(),
new UriIdentityService(fileService),
new class extends mock<IClipboardService>() {
override readText() {