Fix #122477

上级 05658fe9
......@@ -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;
}
}
......
......@@ -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
......
......@@ -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
}
}
};
......
......@@ -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']
}
......
......@@ -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;
......
......@@ -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
}
}
});
......
......@@ -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']
}
}
......
......@@ -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]);
......
......@@ -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]);
}
......
......@@ -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> {
......
......@@ -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);
}
}
......
......@@ -59,7 +59,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: false
},
'terminal.integrated.automationShell.linux': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: localize({
......@@ -70,7 +70,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: null
},
'terminal.integrated.automationShell.osx': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: localize({
......@@ -81,7 +81,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: null
},
'terminal.integrated.automationShell.windows': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: localize({
......@@ -92,7 +92,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: null
},
'terminal.integrated.shellArgs.linux': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
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)."),
......@@ -104,7 +104,7 @@ export const terminalConfiguration: IConfigurationNode = {
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.linux#` instead'
},
'terminal.integrated.shellArgs.osx': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
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)."),
......@@ -119,7 +119,7 @@ export const terminalConfiguration: IConfigurationNode = {
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.osx#` instead'
},
'terminal.integrated.shellArgs.windows': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
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)."),
......@@ -140,7 +140,7 @@ export const terminalConfiguration: IConfigurationNode = {
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.windows#` instead'
},
'terminal.integrated.profiles.windows': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: localize(
......@@ -202,7 +202,7 @@ export const terminalConfiguration: IConfigurationNode = {
}
},
'terminal.integrated.profiles.osx': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: localize(
......@@ -241,7 +241,7 @@ export const terminalConfiguration: IConfigurationNode = {
}
},
'terminal.integrated.profiles.linux': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: localize(
......@@ -530,7 +530,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: true
},
'terminal.integrated.env.osx': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
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."),
......@@ -541,7 +541,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: {}
},
'terminal.integrated.env.linux': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
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."),
......@@ -552,7 +552,7 @@ export const terminalConfiguration: IConfigurationNode = {
default: {}
},
'terminal.integrated.env.windows': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
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."),
......@@ -676,7 +676,7 @@ function getTerminalShellConfigurationStub(linux: string, osx: string, windows:
type: 'object',
properties: {
'terminal.integrated.shell.linux': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: linux,
......@@ -685,7 +685,7 @@ function getTerminalShellConfigurationStub(linux: string, osx: string, windows:
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.linux#` instead'
},
'terminal.integrated.shell.osx': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: osx,
......@@ -694,7 +694,7 @@ function getTerminalShellConfigurationStub(linux: string, osx: string, windows:
markdownDeprecationMessage: 'This is deprecated, use `#terminal.integrated.defaultProfile.osx#` instead'
},
'terminal.integrated.shell.windows': {
requireTrust: true,
restricted: true,
// TODO: Remove when workspace trust is enabled by default
scope: ConfigurationScope.APPLICATION,
markdownDescription: windows,
......
......@@ -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);
......
......@@ -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> {
......
......@@ -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;
}
});
......
......@@ -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.
......
......@@ -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 {
......
......@@ -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[];
......
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册