Skip to content

Commit b0e5025

Browse files
authored
[Remote-SSH Bug]: Settings missing in remote settings view (fix microsoft/vscode-remote-release#8627) (microsoft#186828)
1 parent 6b83d6d commit b0e5025

File tree

2 files changed

+50
-28
lines changed

2 files changed

+50
-28
lines changed

src/vs/workbench/browser/workbench.contribution.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
77
import { localize } from 'vs/nls';
88
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
99
import { isMacintosh, isWindows, isLinux, isWeb, isNative } from 'vs/base/common/platform';
10-
import { ConfigurationMigrationWorkbenchContribution, securityConfigurationNodeBase, workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration';
10+
import { ConfigurationMigrationWorkbenchContribution, DynamicWorkbenchConfigurationWorkbenchContribution, workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration';
1111
import { isStandalone } from 'vs/base/browser/browser';
1212
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
1313
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
@@ -20,6 +20,9 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
2020
// Migration support
2121
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ConfigurationMigrationWorkbenchContribution, LifecyclePhase.Eventually);
2222

23+
// Dynamic Configuration
24+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DynamicWorkbenchConfigurationWorkbenchContribution, LifecyclePhase.Ready);
25+
2326
// Workbench
2427
registry.registerConfiguration({
2528
...workbenchConfigurationNodeBase,
@@ -709,30 +712,4 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
709712
}
710713
}
711714
});
712-
713-
// Security
714-
registry.registerConfiguration({
715-
...securityConfigurationNodeBase,
716-
'properties': {
717-
'security.allowedUNCHosts': {
718-
'type': 'array',
719-
'items': {
720-
'type': 'string',
721-
'pattern': '^[^\\\\]+$',
722-
'patternErrorMessage': localize('security.allowedUNCHosts.patternErrorMessage', 'UNC host names must not contain backslashes.')
723-
},
724-
'default': [],
725-
'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.'),
726-
'included': isWeb ? true /* web maybe connected to a windows machine */ : isWindows,
727-
'scope': ConfigurationScope.MACHINE
728-
},
729-
'security.restrictUNCAccess': {
730-
'type': 'boolean',
731-
'default': true,
732-
'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.'),
733-
'included': isWeb ? true /* web maybe connected to a windows machine */ : isWindows,
734-
'scope': ConfigurationScope.MACHINE
735-
}
736-
}
737-
});
738715
})();

src/vs/workbench/common/configuration.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { localize } from 'vs/nls';
7-
import { ConfigurationScope, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry';
7+
import { ConfigurationScope, IConfigurationNode, IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
88
import { Registry } from 'vs/platform/registry/common/platform';
99
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
1010
import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
1111
import { ConfigurationTarget, IConfigurationOverrides, IConfigurationService, IConfigurationValue } from 'vs/platform/configuration/common/configuration';
1212
import { Disposable } from 'vs/base/common/lifecycle';
1313
import { Emitter } from 'vs/base/common/event';
14+
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
15+
import { OperatingSystem, isWindows } from 'vs/base/common/platform';
1416

1517
export const applicationConfigurationNodeBase = Object.freeze<IConfigurationNode>({
1618
'id': 'application',
@@ -118,3 +120,46 @@ export class ConfigurationMigrationWorkbenchContribution extends Disposable impl
118120
await Promise.allSettled(keyValuePairs.map(async ([key, value]) => this.configurationService.updateValue(key, value.value, overrides, target)));
119121
}
120122
}
123+
124+
export class DynamicWorkbenchConfigurationWorkbenchContribution extends Disposable implements IWorkbenchContribution {
125+
126+
constructor(
127+
@IRemoteAgentService remoteAgentService: IRemoteAgentService
128+
) {
129+
super();
130+
131+
(async () => {
132+
if (!isWindows) {
133+
const remoteEnvironment = await remoteAgentService.getEnvironment();
134+
if (remoteEnvironment?.os !== OperatingSystem.Windows) {
135+
return;
136+
}
137+
}
138+
139+
// Windows: UNC allow list security configuration
140+
const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
141+
registry.registerConfiguration({
142+
...securityConfigurationNodeBase,
143+
'properties': {
144+
'security.allowedUNCHosts': {
145+
'type': 'array',
146+
'items': {
147+
'type': 'string',
148+
'pattern': '^[^\\\\]+$',
149+
'patternErrorMessage': localize('security.allowedUNCHosts.patternErrorMessage', 'UNC host names must not contain backslashes.')
150+
},
151+
'default': [],
152+
'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.'),
153+
'scope': ConfigurationScope.MACHINE
154+
},
155+
'security.restrictUNCAccess': {
156+
'type': 'boolean',
157+
'default': true,
158+
'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.'),
159+
'scope': ConfigurationScope.MACHINE
160+
}
161+
}
162+
});
163+
})();
164+
}
165+
}

0 commit comments

Comments
 (0)