Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remote-SSH Bug]: Settings missing in remote settings view (fix microsoft/vscode-remote-release#8627) #186828

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 4 additions & 27 deletions src/vs/workbench/browser/workbench.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { localize } from 'vs/nls';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { isMacintosh, isWindows, isLinux, isWeb, isNative } from 'vs/base/common/platform';
import { ConfigurationMigrationWorkbenchContribution, securityConfigurationNodeBase, workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration';
import { ConfigurationMigrationWorkbenchContribution, DynamicWorkbenchConfigurationWorkbenchContribution, workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration';
import { isStandalone } from 'vs/base/browser/browser';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
Expand All @@ -20,6 +20,9 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
// Migration support
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ConfigurationMigrationWorkbenchContribution, LifecyclePhase.Eventually);

// Dynamic Configuration
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DynamicWorkbenchConfigurationWorkbenchContribution, LifecyclePhase.Ready);

// Workbench
registry.registerConfiguration({
...workbenchConfigurationNodeBase,
Expand Down Expand Up @@ -709,30 +712,4 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
}
}
});

// Security
registry.registerConfiguration({
...securityConfigurationNodeBase,
'properties': {
'security.allowedUNCHosts': {
'type': 'array',
'items': {
'type': 'string',
'pattern': '^[^\\\\]+$',
'patternErrorMessage': localize('security.allowedUNCHosts.patternErrorMessage', 'UNC host names must not contain backslashes.')
},
'default': [],
'markdownDescription': localize('security.allowedUNCHosts', 'A set of UNC host names (without leading or trailing backslash, for example `192.168.0.1` or `my-server`) to allow without user confirmation. If a UNC host is being accessed that is not allowed via this setting or has not been acknowledged via user confirmation, an error will occur and the operation stopped. A restart is required when changing this setting. Find out more about this setting at https://aka.ms/vscode-windows-unc.'),
'included': isWeb ? true /* web maybe connected to a windows machine */ : isWindows,
'scope': ConfigurationScope.MACHINE
},
'security.restrictUNCAccess': {
'type': 'boolean',
'default': true,
'markdownDescription': localize('security.restrictUNCAccess', 'If enabled, only allows access to UNC host names that are allowed by the `#security.allowedUNCHosts#` setting or after user confirmation. Find out more about this setting at https://aka.ms/vscode-windows-unc.'),
'included': isWeb ? true /* web maybe connected to a windows machine */ : isWindows,
'scope': ConfigurationScope.MACHINE
}
}
});
})();
47 changes: 46 additions & 1 deletion src/vs/workbench/common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
*--------------------------------------------------------------------------------------------*/

import { localize } from 'vs/nls';
import { ConfigurationScope, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry';
import { ConfigurationScope, IConfigurationNode, IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { ConfigurationTarget, IConfigurationOverrides, IConfigurationService, IConfigurationValue } from 'vs/platform/configuration/common/configuration';
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { OperatingSystem, isWindows } from 'vs/base/common/platform';

export const applicationConfigurationNodeBase = Object.freeze<IConfigurationNode>({
'id': 'application',
Expand Down Expand Up @@ -118,3 +120,46 @@ export class ConfigurationMigrationWorkbenchContribution extends Disposable impl
await Promise.allSettled(keyValuePairs.map(async ([key, value]) => this.configurationService.updateValue(key, value.value, overrides, target)));
}
}

export class DynamicWorkbenchConfigurationWorkbenchContribution extends Disposable implements IWorkbenchContribution {

constructor(
@IRemoteAgentService remoteAgentService: IRemoteAgentService
) {
super();

(async () => {
if (!isWindows) {
const remoteEnvironment = await remoteAgentService.getEnvironment();
if (remoteEnvironment?.os !== OperatingSystem.Windows) {
return;
}
}

// Windows: UNC allow list security configuration
const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
registry.registerConfiguration({
...securityConfigurationNodeBase,
'properties': {
'security.allowedUNCHosts': {
'type': 'array',
'items': {
'type': 'string',
'pattern': '^[^\\\\]+$',
'patternErrorMessage': localize('security.allowedUNCHosts.patternErrorMessage', 'UNC host names must not contain backslashes.')
},
'default': [],
'markdownDescription': localize('security.allowedUNCHosts', 'A set of UNC host names (without leading or trailing backslash, for example `192.168.0.1` or `my-server`) to allow without user confirmation. If a UNC host is being accessed that is not allowed via this setting or has not been acknowledged via user confirmation, an error will occur and the operation stopped. A restart is required when changing this setting. Find out more about this setting at https://aka.ms/vscode-windows-unc.'),
'scope': ConfigurationScope.MACHINE
},
'security.restrictUNCAccess': {
'type': 'boolean',
'default': true,
'markdownDescription': localize('security.restrictUNCAccess', 'If enabled, only allows access to UNC host names that are allowed by the `#security.allowedUNCHosts#` setting or after user confirmation. Find out more about this setting at https://aka.ms/vscode-windows-unc.'),
'scope': ConfigurationScope.MACHINE
}
}
});
})();
}
}