@codingame/monaco-vscode-api 1.82.1 → 1.82.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/missing-services.js +17 -0
- package/monaco-editor-treemending.patch +551 -551
- package/package.json +1 -1
- package/service-override/quickaccess.js +1 -1
- package/service-override/tools/editor.d.ts +1 -1
- package/service-override/views.js +10 -0
- package/service-override/workspaceTrust.d.ts +5 -0
- package/service-override/workspaceTrust.js +13 -0
- package/services.d.ts +3 -0
- package/services.js +3 -0
- package/vscode/src/vs/base/common/htmlContent.d.ts +23 -2
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagementUtil.js +16 -1
- package/vscode/src/vs/platform/opener/browser/link.d.ts +8 -0
- package/vscode/src/vs/platform/workspace/common/workspaceTrust.d.ts +34 -1
- package/vscode/src/vs/workbench/browser/parts/banner/bannerPart.js +228 -0
- package/vscode/src/vs/workbench/browser/parts/banner/media/bannerpart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/panel/panelActions.js +21 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/commandCenterControl.js +134 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/titlebarPart.js +365 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/windowTitle.js +216 -0
- package/vscode/src/vs/workbench/common/contextkeys.js +2 -1
- package/vscode/src/vs/workbench/common/theme.js +6 -6
- package/vscode/src/vs/workbench/contrib/extensions/common/extensions.js +2 -1
- package/vscode/src/vs/workbench/contrib/preferences/browser/preferences.contribution.js +108 -4
- package/vscode/src/vs/workbench/contrib/workspace/browser/media/workspaceTrustEditor.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/workspace/browser/workspace.contribution.js +842 -0
- package/vscode/src/vs/workbench/contrib/workspace/browser/workspaceTrustEditor.js +1047 -0
- package/vscode/src/vs/workbench/contrib/workspace/common/workspace.js +14 -0
- package/vscode/src/vs/workbench/services/banner/browser/bannerService.d.ts +25 -0
- package/vscode/src/vs/workbench/services/banner/browser/bannerService.js +3 -0
- package/vscode/src/vs/workbench/services/title/common/titleService.d.ts +31 -0
- package/vscode/src/vs/workbench/services/title/common/titleService.js +3 -0
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.js +3 -1
- package/vscode/src/vs/workbench/services/workspaces/browser/workspaceTrustEditorInput.js +27 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceTrust.js +649 -1
|
@@ -0,0 +1,842 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import './media/workspaceTrustEditor.css.js';
|
|
3
|
+
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
4
|
+
import { Disposable, MutableDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
5
|
+
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
6
|
+
import { registerAction2, Action2 } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
7
|
+
import { Extensions as Extensions$1 } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
8
|
+
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
9
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
10
|
+
import { Severity } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
11
|
+
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
12
|
+
import { workspaceTrustToString, IWorkspaceTrustEnablementService, IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from 'monaco-editor/esm/vs/platform/workspace/common/workspaceTrust.js';
|
|
13
|
+
import { Extensions } from '../../../common/contributions.js';
|
|
14
|
+
import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
15
|
+
import { IEditorService } from '../../../services/editor/common/editorService.js';
|
|
16
|
+
import { ContextKeyExpr, IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
17
|
+
import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
18
|
+
import { IStatusbarService } from '../../../services/statusbar/browser/statusbar.js';
|
|
19
|
+
import { EditorPaneDescriptor } from '../../../browser/editor.js';
|
|
20
|
+
import { WorkspaceTrustEditor, shieldIcon } from './workspaceTrustEditor.js';
|
|
21
|
+
import { WorkspaceTrustEditorInput } from '../../../services/workspaces/browser/workspaceTrustEditorInput.js';
|
|
22
|
+
import { WORKSPACE_TRUST_ENABLED, WORKSPACE_TRUST_STARTUP_PROMPT, WORKSPACE_TRUST_BANNER, WORKSPACE_TRUST_UNTRUSTED_FILES, WORKSPACE_TRUST_EMPTY_WINDOW } from '../../../services/workspaces/common/workspaceTrust.js';
|
|
23
|
+
import { EditorExtensions } from '../../../common/editor.js';
|
|
24
|
+
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
25
|
+
import { isSingleFolderWorkspaceIdentifier, toWorkspaceIdentifier, isEmptyWorkspaceIdentifier, IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
26
|
+
import { resolve, dirname as dirname$1 } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
27
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
28
|
+
import { MarkdownString } from 'monaco-editor/esm/vs/base/common/htmlContent.js';
|
|
29
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
30
|
+
import { IHostService } from '../../../services/host/browser/host.js';
|
|
31
|
+
import { IBannerService } from '../../../services/banner/browser/bannerService.js';
|
|
32
|
+
import { isVirtualWorkspace } from '../../../../platform/workspace/common/virtualWorkspace.js';
|
|
33
|
+
import { LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID } from '../../extensions/common/extensions.js';
|
|
34
|
+
import { IWorkbenchEnvironmentService } from '../../../services/environment/common/environmentService.js';
|
|
35
|
+
import { WORKSPACE_TRUST_SETTING_TAG } from '../../preferences/common/preferences.js';
|
|
36
|
+
import { IPreferencesService } from '../../../services/preferences/common/preferences.js';
|
|
37
|
+
import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
|
|
38
|
+
import { IProductService } from 'monaco-editor/esm/vs/platform/product/common/productService.js';
|
|
39
|
+
import { WorkspaceTrustContext, MANAGE_TRUST_COMMAND_ID } from '../common/workspace.js';
|
|
40
|
+
import { isWeb } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
41
|
+
import { IRemoteAgentService } from '../../../services/remote/common/remoteAgentService.js';
|
|
42
|
+
import { securityConfigurationNodeBase } from '../../../common/configuration.js';
|
|
43
|
+
import { basename, dirname } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
44
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
45
|
+
import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
|
|
46
|
+
import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
|
|
47
|
+
import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
|
|
48
|
+
const BANNER_RESTRICTED_MODE = 'workbench.banner.restrictedMode';
|
|
49
|
+
const STARTUP_PROMPT_SHOWN_KEY = 'workspace.trust.startupPrompt.shown';
|
|
50
|
+
const BANNER_RESTRICTED_MODE_DISMISSED_KEY = 'workbench.banner.restrictedMode.dismissed';
|
|
51
|
+
let WorkspaceTrustContextKeys = class WorkspaceTrustContextKeys extends Disposable {
|
|
52
|
+
constructor(contextKeyService, workspaceTrustEnablementService, workspaceTrustManagementService) {
|
|
53
|
+
super();
|
|
54
|
+
this._ctxWorkspaceTrustEnabled = WorkspaceTrustContext.IsEnabled.bindTo(contextKeyService);
|
|
55
|
+
this._ctxWorkspaceTrustEnabled.set(workspaceTrustEnablementService.isWorkspaceTrustEnabled());
|
|
56
|
+
this._ctxWorkspaceTrustState = WorkspaceTrustContext.IsTrusted.bindTo(contextKeyService);
|
|
57
|
+
this._ctxWorkspaceTrustState.set(workspaceTrustManagementService.isWorkspaceTrusted());
|
|
58
|
+
this._register(workspaceTrustManagementService.onDidChangeTrust(trusted => this._ctxWorkspaceTrustState.set(trusted)));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
WorkspaceTrustContextKeys = ( __decorate([
|
|
62
|
+
( __param(0, IContextKeyService)),
|
|
63
|
+
( __param(1, IWorkspaceTrustEnablementService)),
|
|
64
|
+
( __param(2, IWorkspaceTrustManagementService))
|
|
65
|
+
], WorkspaceTrustContextKeys));
|
|
66
|
+
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(WorkspaceTrustContextKeys, 3 );
|
|
67
|
+
let WorkspaceTrustRequestHandler = class WorkspaceTrustRequestHandler extends Disposable {
|
|
68
|
+
constructor(dialogService, commandService, workspaceContextService, workspaceTrustManagementService, workspaceTrustRequestService) {
|
|
69
|
+
super();
|
|
70
|
+
this.dialogService = dialogService;
|
|
71
|
+
this.commandService = commandService;
|
|
72
|
+
this.workspaceContextService = workspaceContextService;
|
|
73
|
+
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
74
|
+
this.workspaceTrustRequestService = workspaceTrustRequestService;
|
|
75
|
+
this.registerListeners();
|
|
76
|
+
}
|
|
77
|
+
get useWorkspaceLanguage() {
|
|
78
|
+
return !isSingleFolderWorkspaceIdentifier(toWorkspaceIdentifier(this.workspaceContextService.getWorkspace()));
|
|
79
|
+
}
|
|
80
|
+
async registerListeners() {
|
|
81
|
+
await this.workspaceTrustManagementService.workspaceResolved;
|
|
82
|
+
this._register(this.workspaceTrustRequestService.onDidInitiateOpenFilesTrustRequest(async () => {
|
|
83
|
+
const markdownDetails = [
|
|
84
|
+
this.workspaceContextService.getWorkbenchState() !== 1 ?
|
|
85
|
+
( localize(
|
|
86
|
+
'openLooseFileWorkspaceDetails',
|
|
87
|
+
"You are trying to open untrusted files in a workspace which is trusted."
|
|
88
|
+
)) :
|
|
89
|
+
( localize(
|
|
90
|
+
'openLooseFileWindowDetails',
|
|
91
|
+
"You are trying to open untrusted files in a window which is trusted."
|
|
92
|
+
)),
|
|
93
|
+
( localize(
|
|
94
|
+
'openLooseFileLearnMore',
|
|
95
|
+
"If you don't want to open untrusted files, we recommend to open them in Restricted Mode in a new window as the files may be malicious. See [our docs](https://aka.ms/vscode-workspace-trust) to learn more."
|
|
96
|
+
))
|
|
97
|
+
];
|
|
98
|
+
await this.dialogService.prompt({
|
|
99
|
+
type: Severity.Info,
|
|
100
|
+
message: this.workspaceContextService.getWorkbenchState() !== 1 ?
|
|
101
|
+
( localize(
|
|
102
|
+
'openLooseFileWorkspaceMesssage',
|
|
103
|
+
"Do you want to allow untrusted files in this workspace?"
|
|
104
|
+
)) :
|
|
105
|
+
( localize(
|
|
106
|
+
'openLooseFileWindowMesssage',
|
|
107
|
+
"Do you want to allow untrusted files in this window?"
|
|
108
|
+
)),
|
|
109
|
+
buttons: [
|
|
110
|
+
{
|
|
111
|
+
label: ( localize({ key: 'open', comment: ['&& denotes a mnemonic'] }, "&&Open")),
|
|
112
|
+
run: ({ checkboxChecked }) => this.workspaceTrustRequestService.completeOpenFilesTrustRequest(1 , !!checkboxChecked)
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: ( localize(
|
|
116
|
+
{ key: 'newWindow', comment: ['&& denotes a mnemonic'] },
|
|
117
|
+
"Open in &&Restricted Mode"
|
|
118
|
+
)),
|
|
119
|
+
run: ({ checkboxChecked }) => this.workspaceTrustRequestService.completeOpenFilesTrustRequest(2 , !!checkboxChecked)
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
cancelButton: {
|
|
123
|
+
run: () => this.workspaceTrustRequestService.completeOpenFilesTrustRequest(3 )
|
|
124
|
+
},
|
|
125
|
+
checkbox: {
|
|
126
|
+
label: ( localize(
|
|
127
|
+
'openLooseFileWorkspaceCheckbox',
|
|
128
|
+
"Remember my decision for all workspaces"
|
|
129
|
+
)),
|
|
130
|
+
checked: false
|
|
131
|
+
},
|
|
132
|
+
custom: {
|
|
133
|
+
icon: Codicon.shield,
|
|
134
|
+
markdownDetails: ( markdownDetails.map(md => { return { markdown: ( new MarkdownString(md)) }; }))
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}));
|
|
138
|
+
this._register(this.workspaceTrustRequestService.onDidInitiateWorkspaceTrustRequest(async (requestOptions) => {
|
|
139
|
+
const message = this.useWorkspaceLanguage ?
|
|
140
|
+
( localize(
|
|
141
|
+
'workspaceTrust',
|
|
142
|
+
"Do you trust the authors of the files in this workspace?"
|
|
143
|
+
)) :
|
|
144
|
+
( localize('folderTrust', "Do you trust the authors of the files in this folder?"));
|
|
145
|
+
const defaultDetails = ( localize(
|
|
146
|
+
'immediateTrustRequestMessage',
|
|
147
|
+
"A feature you are trying to use may be a security risk if you do not trust the source of the files or folders you currently have open."
|
|
148
|
+
));
|
|
149
|
+
const details = requestOptions?.message ?? defaultDetails;
|
|
150
|
+
const buttons = requestOptions?.buttons ?? [
|
|
151
|
+
{ label: this.useWorkspaceLanguage ? ( localize(
|
|
152
|
+
{ key: 'grantWorkspaceTrustButton', comment: ['&& denotes a mnemonic'] },
|
|
153
|
+
"&&Trust Workspace & Continue"
|
|
154
|
+
)) : ( localize(
|
|
155
|
+
{ key: 'grantFolderTrustButton', comment: ['&& denotes a mnemonic'] },
|
|
156
|
+
"&&Trust Folder & Continue"
|
|
157
|
+
)), type: 'ContinueWithTrust' },
|
|
158
|
+
{ label: ( localize(
|
|
159
|
+
{ key: 'manageWorkspaceTrustButton', comment: ['&& denotes a mnemonic'] },
|
|
160
|
+
"&&Manage"
|
|
161
|
+
)), type: 'Manage' }
|
|
162
|
+
];
|
|
163
|
+
if (!( buttons.some(b => b.type === 'Cancel'))) {
|
|
164
|
+
buttons.push({ label: ( localize('cancelWorkspaceTrustButton', "Cancel")), type: 'Cancel' });
|
|
165
|
+
}
|
|
166
|
+
const { result } = await this.dialogService.prompt({
|
|
167
|
+
type: Severity.Info,
|
|
168
|
+
message,
|
|
169
|
+
custom: {
|
|
170
|
+
icon: Codicon.shield,
|
|
171
|
+
markdownDetails: [
|
|
172
|
+
{ markdown: ( new MarkdownString(details)) },
|
|
173
|
+
{ markdown: ( new MarkdownString(( localize(
|
|
174
|
+
'immediateTrustRequestLearnMore',
|
|
175
|
+
"If you don't trust the authors of these files, we do not recommend continuing as the files may be malicious. See [our docs](https://aka.ms/vscode-workspace-trust) to learn more."
|
|
176
|
+
)))) }
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
buttons: ( buttons.filter(b => b.type !== 'Cancel').map(button => {
|
|
180
|
+
return {
|
|
181
|
+
label: button.label,
|
|
182
|
+
run: () => button.type
|
|
183
|
+
};
|
|
184
|
+
})),
|
|
185
|
+
cancelButton: (() => {
|
|
186
|
+
const cancelButton = buttons.find(b => b.type === 'Cancel');
|
|
187
|
+
if (!cancelButton) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
label: cancelButton.label,
|
|
192
|
+
run: () => cancelButton.type
|
|
193
|
+
};
|
|
194
|
+
})()
|
|
195
|
+
});
|
|
196
|
+
switch (result) {
|
|
197
|
+
case 'ContinueWithTrust':
|
|
198
|
+
await this.workspaceTrustRequestService.completeWorkspaceTrustRequest(true);
|
|
199
|
+
break;
|
|
200
|
+
case 'ContinueWithoutTrust':
|
|
201
|
+
await this.workspaceTrustRequestService.completeWorkspaceTrustRequest(undefined);
|
|
202
|
+
break;
|
|
203
|
+
case 'Manage':
|
|
204
|
+
this.workspaceTrustRequestService.cancelWorkspaceTrustRequest();
|
|
205
|
+
await this.commandService.executeCommand(MANAGE_TRUST_COMMAND_ID);
|
|
206
|
+
break;
|
|
207
|
+
case 'Cancel':
|
|
208
|
+
this.workspaceTrustRequestService.cancelWorkspaceTrustRequest();
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
WorkspaceTrustRequestHandler = ( __decorate([
|
|
215
|
+
( __param(0, IDialogService)),
|
|
216
|
+
( __param(1, ICommandService)),
|
|
217
|
+
( __param(2, IWorkspaceContextService)),
|
|
218
|
+
( __param(3, IWorkspaceTrustManagementService)),
|
|
219
|
+
( __param(4, IWorkspaceTrustRequestService))
|
|
220
|
+
], WorkspaceTrustRequestHandler));
|
|
221
|
+
let WorkspaceTrustUXHandler = class WorkspaceTrustUXHandler extends Disposable {
|
|
222
|
+
constructor(dialogService, workspaceContextService, workspaceTrustEnablementService, workspaceTrustManagementService, configurationService, statusbarService, storageService, workspaceTrustRequestService, bannerService, labelService, hostService, productService, remoteAgentService, environmentService, fileService) {
|
|
223
|
+
super();
|
|
224
|
+
this.dialogService = dialogService;
|
|
225
|
+
this.workspaceContextService = workspaceContextService;
|
|
226
|
+
this.workspaceTrustEnablementService = workspaceTrustEnablementService;
|
|
227
|
+
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
228
|
+
this.configurationService = configurationService;
|
|
229
|
+
this.statusbarService = statusbarService;
|
|
230
|
+
this.storageService = storageService;
|
|
231
|
+
this.workspaceTrustRequestService = workspaceTrustRequestService;
|
|
232
|
+
this.bannerService = bannerService;
|
|
233
|
+
this.labelService = labelService;
|
|
234
|
+
this.hostService = hostService;
|
|
235
|
+
this.productService = productService;
|
|
236
|
+
this.remoteAgentService = remoteAgentService;
|
|
237
|
+
this.environmentService = environmentService;
|
|
238
|
+
this.fileService = fileService;
|
|
239
|
+
this.entryId = `status.workspaceTrust.${this.workspaceContextService.getWorkspace().id}`;
|
|
240
|
+
this.statusbarEntryAccessor = this._register(( new MutableDisposable()));
|
|
241
|
+
(async () => {
|
|
242
|
+
await this.workspaceTrustManagementService.workspaceTrustInitialized;
|
|
243
|
+
if (this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
|
|
244
|
+
this.registerListeners();
|
|
245
|
+
this.createStatusbarEntry();
|
|
246
|
+
if (this.hostService.hasFocus) {
|
|
247
|
+
this.showModalOnStart();
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
const focusDisposable = this.hostService.onDidChangeFocus(focused => {
|
|
251
|
+
if (focused) {
|
|
252
|
+
focusDisposable.dispose();
|
|
253
|
+
this.showModalOnStart();
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
})();
|
|
259
|
+
}
|
|
260
|
+
registerListeners() {
|
|
261
|
+
this._register(this.workspaceContextService.onWillChangeWorkspaceFolders(e => {
|
|
262
|
+
if (e.fromCache) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const addWorkspaceFolder = async (e) => {
|
|
269
|
+
const trusted = this.workspaceTrustManagementService.isWorkspaceTrusted();
|
|
270
|
+
if (trusted && (e.changes.added.length || e.changes.changed.length)) {
|
|
271
|
+
const addedFoldersTrustInfo = await Promise.all(( e.changes.added.map(folder => this.workspaceTrustManagementService.getUriTrustInfo(folder.uri))));
|
|
272
|
+
if (!( addedFoldersTrustInfo.map(info => info.trusted)).every(trusted => trusted)) {
|
|
273
|
+
const { confirmed } = await this.dialogService.confirm({
|
|
274
|
+
type: Severity.Info,
|
|
275
|
+
message: ( localize(
|
|
276
|
+
'addWorkspaceFolderMessage',
|
|
277
|
+
"Do you trust the authors of the files in this folder?"
|
|
278
|
+
)),
|
|
279
|
+
detail: ( localize(
|
|
280
|
+
'addWorkspaceFolderDetail',
|
|
281
|
+
"You are adding files that are not currently trusted to a trusted workspace. Do you trust the authors of these new files?"
|
|
282
|
+
)),
|
|
283
|
+
cancelButton: ( localize('no', 'No')),
|
|
284
|
+
custom: { icon: Codicon.shield }
|
|
285
|
+
});
|
|
286
|
+
await this.workspaceTrustManagementService.setUrisTrust(( addedFoldersTrustInfo.map(i => i.uri)), confirmed);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
return e.join(addWorkspaceFolder(e));
|
|
291
|
+
}));
|
|
292
|
+
this._register(this.workspaceTrustManagementService.onDidChangeTrust(trusted => {
|
|
293
|
+
this.updateWorkbenchIndicators(trusted);
|
|
294
|
+
}));
|
|
295
|
+
this._register(this.workspaceTrustRequestService.onDidInitiateWorkspaceTrustRequestOnStartup(async () => {
|
|
296
|
+
let titleString;
|
|
297
|
+
let learnMoreString;
|
|
298
|
+
let trustOption;
|
|
299
|
+
let dontTrustOption;
|
|
300
|
+
const isAiGeneratedWorkspace = await this.isAiGeneratedWorkspace();
|
|
301
|
+
if (isAiGeneratedWorkspace && this.productService.aiGeneratedWorkspaceTrust) {
|
|
302
|
+
titleString = this.productService.aiGeneratedWorkspaceTrust.title;
|
|
303
|
+
learnMoreString = this.productService.aiGeneratedWorkspaceTrust.startupTrustRequestLearnMore;
|
|
304
|
+
trustOption = this.productService.aiGeneratedWorkspaceTrust.trustOption;
|
|
305
|
+
dontTrustOption = this.productService.aiGeneratedWorkspaceTrust.dontTrustOption;
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
console.warn('AI generated workspace trust dialog contents not available.');
|
|
309
|
+
}
|
|
310
|
+
const title = titleString ?? (this.useWorkspaceLanguage ?
|
|
311
|
+
( localize(
|
|
312
|
+
'workspaceTrust',
|
|
313
|
+
"Do you trust the authors of the files in this workspace?"
|
|
314
|
+
)) :
|
|
315
|
+
( localize('folderTrust', "Do you trust the authors of the files in this folder?")));
|
|
316
|
+
let checkboxText;
|
|
317
|
+
const workspaceIdentifier = toWorkspaceIdentifier(this.workspaceContextService.getWorkspace());
|
|
318
|
+
const isSingleFolderWorkspace = isSingleFolderWorkspaceIdentifier(workspaceIdentifier);
|
|
319
|
+
const isEmptyWindow = isEmptyWorkspaceIdentifier(workspaceIdentifier);
|
|
320
|
+
if (!isAiGeneratedWorkspace && this.workspaceTrustManagementService.canSetParentFolderTrust()) {
|
|
321
|
+
const name = basename(dirname(workspaceIdentifier.uri));
|
|
322
|
+
checkboxText = ( localize(
|
|
323
|
+
'checkboxString',
|
|
324
|
+
"Trust the authors of all files in the parent folder '{0}'",
|
|
325
|
+
name
|
|
326
|
+
));
|
|
327
|
+
}
|
|
328
|
+
this.doShowModal(title, { label: trustOption ?? ( localize(
|
|
329
|
+
{ key: 'trustOption', comment: ['&& denotes a mnemonic'] },
|
|
330
|
+
"&&Yes, I trust the authors"
|
|
331
|
+
)), sublabel: isSingleFolderWorkspace ? ( localize('trustFolderOptionDescription', "Trust folder and enable all features")) : ( localize(
|
|
332
|
+
'trustWorkspaceOptionDescription',
|
|
333
|
+
"Trust workspace and enable all features"
|
|
334
|
+
)) }, { label: dontTrustOption ?? ( localize(
|
|
335
|
+
{ key: 'dontTrustOption', comment: ['&& denotes a mnemonic'] },
|
|
336
|
+
"&&No, I don't trust the authors"
|
|
337
|
+
)), sublabel: isSingleFolderWorkspace ? ( localize('dontTrustFolderOptionDescription', "Browse folder in restricted mode")) : ( localize(
|
|
338
|
+
'dontTrustWorkspaceOptionDescription',
|
|
339
|
+
"Browse workspace in restricted mode"
|
|
340
|
+
)) }, [
|
|
341
|
+
!isSingleFolderWorkspace ?
|
|
342
|
+
( localize(
|
|
343
|
+
'workspaceStartupTrustDetails',
|
|
344
|
+
"{0} provides features that may automatically execute files in this workspace.",
|
|
345
|
+
this.productService.nameShort
|
|
346
|
+
)) :
|
|
347
|
+
( localize(
|
|
348
|
+
'folderStartupTrustDetails',
|
|
349
|
+
"{0} provides features that may automatically execute files in this folder.",
|
|
350
|
+
this.productService.nameShort
|
|
351
|
+
)),
|
|
352
|
+
learnMoreString ?? ( localize(
|
|
353
|
+
'startupTrustRequestLearnMore',
|
|
354
|
+
"If you don't trust the authors of these files, we recommend to continue in restricted mode as the files may be malicious. See [our docs](https://aka.ms/vscode-workspace-trust) to learn more."
|
|
355
|
+
)),
|
|
356
|
+
!isEmptyWindow ?
|
|
357
|
+
`\`${this.labelService.getWorkspaceLabel(workspaceIdentifier, { verbose: 2 })}\`` : '',
|
|
358
|
+
], checkboxText);
|
|
359
|
+
}));
|
|
360
|
+
}
|
|
361
|
+
updateWorkbenchIndicators(trusted) {
|
|
362
|
+
const bannerItem = this.getBannerItem(!trusted);
|
|
363
|
+
this.updateStatusbarEntry(trusted);
|
|
364
|
+
if (bannerItem) {
|
|
365
|
+
if (!trusted) {
|
|
366
|
+
this.bannerService.show(bannerItem);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
this.bannerService.hide(BANNER_RESTRICTED_MODE);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async doShowModal(question, trustedOption, untrustedOption, markdownStrings, trustParentString) {
|
|
374
|
+
await this.dialogService.prompt({
|
|
375
|
+
type: Severity.Info,
|
|
376
|
+
message: question,
|
|
377
|
+
checkbox: trustParentString ? {
|
|
378
|
+
label: trustParentString
|
|
379
|
+
} : undefined,
|
|
380
|
+
buttons: [
|
|
381
|
+
{
|
|
382
|
+
label: trustedOption.label,
|
|
383
|
+
run: async ({ checkboxChecked }) => {
|
|
384
|
+
if (checkboxChecked) {
|
|
385
|
+
await this.workspaceTrustManagementService.setParentFolderTrust(true);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
await this.workspaceTrustRequestService.completeWorkspaceTrustRequest(true);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
label: untrustedOption.label,
|
|
394
|
+
run: () => {
|
|
395
|
+
this.updateWorkbenchIndicators(false);
|
|
396
|
+
this.workspaceTrustRequestService.cancelWorkspaceTrustRequest();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
],
|
|
400
|
+
custom: {
|
|
401
|
+
buttonDetails: [
|
|
402
|
+
trustedOption.sublabel,
|
|
403
|
+
untrustedOption.sublabel
|
|
404
|
+
],
|
|
405
|
+
disableCloseAction: true,
|
|
406
|
+
icon: Codicon.shield,
|
|
407
|
+
markdownDetails: ( markdownStrings.map(md => { return { markdown: ( new MarkdownString(md)) }; }))
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
this.storageService.store(STARTUP_PROMPT_SHOWN_KEY, true, 1 , 1 );
|
|
411
|
+
}
|
|
412
|
+
async showModalOnStart() {
|
|
413
|
+
if (this.workspaceTrustManagementService.isWorkspaceTrusted()) {
|
|
414
|
+
this.updateWorkbenchIndicators(true);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (!(this.workspaceTrustManagementService.canSetWorkspaceTrust())) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
if (isVirtualWorkspace(this.workspaceContextService.getWorkspace())) {
|
|
421
|
+
this.updateWorkbenchIndicators(false);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (this.workspaceContextService.getWorkbenchState() === 1 ) {
|
|
425
|
+
this.updateWorkbenchIndicators(false);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (this.startupPromptSetting === 'never') {
|
|
429
|
+
this.updateWorkbenchIndicators(false);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (this.startupPromptSetting === 'once' && this.storageService.getBoolean(STARTUP_PROMPT_SHOWN_KEY, 1 , false)) {
|
|
433
|
+
this.updateWorkbenchIndicators(false);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
this.workspaceTrustRequestService.requestWorkspaceTrustOnStartup();
|
|
437
|
+
}
|
|
438
|
+
get startupPromptSetting() {
|
|
439
|
+
return this.configurationService.getValue(WORKSPACE_TRUST_STARTUP_PROMPT);
|
|
440
|
+
}
|
|
441
|
+
get useWorkspaceLanguage() {
|
|
442
|
+
return !isSingleFolderWorkspaceIdentifier(toWorkspaceIdentifier(this.workspaceContextService.getWorkspace()));
|
|
443
|
+
}
|
|
444
|
+
async isAiGeneratedWorkspace() {
|
|
445
|
+
const aiGeneratedWorkspaces = URI.joinPath(this.environmentService.workspaceStorageHome, 'aiGeneratedWorkspaces.json');
|
|
446
|
+
return await this.fileService.exists(aiGeneratedWorkspaces).then(async (result) => {
|
|
447
|
+
if (result) {
|
|
448
|
+
try {
|
|
449
|
+
const content = await this.fileService.readFile(aiGeneratedWorkspaces);
|
|
450
|
+
const workspaces = JSON.parse(( content.value.toString()));
|
|
451
|
+
if (workspaces.indexOf(( this.workspaceContextService.getWorkspace().folders[0].uri.toString())) > -1) {
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
catch (e) {
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return false;
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
getBannerItem(restrictedMode) {
|
|
462
|
+
const dismissedRestricted = this.storageService.getBoolean(BANNER_RESTRICTED_MODE_DISMISSED_KEY, 1 , false);
|
|
463
|
+
if (this.bannerSetting === 'never') {
|
|
464
|
+
return undefined;
|
|
465
|
+
}
|
|
466
|
+
if (this.bannerSetting === 'untilDismissed' && dismissedRestricted) {
|
|
467
|
+
return undefined;
|
|
468
|
+
}
|
|
469
|
+
const actions = [
|
|
470
|
+
{
|
|
471
|
+
label: ( localize('restrictedModeBannerManage', "Manage")),
|
|
472
|
+
href: 'command:' + MANAGE_TRUST_COMMAND_ID
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
label: ( localize('restrictedModeBannerLearnMore', "Learn More")),
|
|
476
|
+
href: 'https://aka.ms/vscode-workspace-trust'
|
|
477
|
+
}
|
|
478
|
+
];
|
|
479
|
+
return {
|
|
480
|
+
id: BANNER_RESTRICTED_MODE,
|
|
481
|
+
icon: shieldIcon,
|
|
482
|
+
ariaLabel: this.getBannerItemAriaLabels(),
|
|
483
|
+
message: this.getBannerItemMessages(),
|
|
484
|
+
actions,
|
|
485
|
+
onClose: () => {
|
|
486
|
+
if (restrictedMode) {
|
|
487
|
+
this.storageService.store(BANNER_RESTRICTED_MODE_DISMISSED_KEY, true, 1 , 1 );
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
getBannerItemAriaLabels() {
|
|
493
|
+
switch (this.workspaceContextService.getWorkbenchState()) {
|
|
494
|
+
case 1 :
|
|
495
|
+
return ( localize(
|
|
496
|
+
'restrictedModeBannerAriaLabelWindow',
|
|
497
|
+
"Restricted Mode is intended for safe code browsing. Trust this window to enable all features. Use navigation keys to access banner actions."
|
|
498
|
+
));
|
|
499
|
+
case 2 :
|
|
500
|
+
return ( localize(
|
|
501
|
+
'restrictedModeBannerAriaLabelFolder',
|
|
502
|
+
"Restricted Mode is intended for safe code browsing. Trust this folder to enable all features. Use navigation keys to access banner actions."
|
|
503
|
+
));
|
|
504
|
+
case 3 :
|
|
505
|
+
return ( localize(
|
|
506
|
+
'restrictedModeBannerAriaLabelWorkspace',
|
|
507
|
+
"Restricted Mode is intended for safe code browsing. Trust this workspace to enable all features. Use navigation keys to access banner actions."
|
|
508
|
+
));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
getBannerItemMessages() {
|
|
512
|
+
switch (this.workspaceContextService.getWorkbenchState()) {
|
|
513
|
+
case 1 :
|
|
514
|
+
return ( localize(
|
|
515
|
+
'restrictedModeBannerMessageWindow',
|
|
516
|
+
"Restricted Mode is intended for safe code browsing. Trust this window to enable all features."
|
|
517
|
+
));
|
|
518
|
+
case 2 :
|
|
519
|
+
return ( localize(
|
|
520
|
+
'restrictedModeBannerMessageFolder',
|
|
521
|
+
"Restricted Mode is intended for safe code browsing. Trust this folder to enable all features."
|
|
522
|
+
));
|
|
523
|
+
case 3 :
|
|
524
|
+
return ( localize(
|
|
525
|
+
'restrictedModeBannerMessageWorkspace',
|
|
526
|
+
"Restricted Mode is intended for safe code browsing. Trust this workspace to enable all features."
|
|
527
|
+
));
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
get bannerSetting() {
|
|
531
|
+
const result = this.configurationService.getValue(WORKSPACE_TRUST_BANNER);
|
|
532
|
+
if (result !== 'always' && isWeb && !this.remoteAgentService.getConnection()?.remoteAuthority) {
|
|
533
|
+
return 'never';
|
|
534
|
+
}
|
|
535
|
+
return result;
|
|
536
|
+
}
|
|
537
|
+
createStatusbarEntry() {
|
|
538
|
+
const entry = this.getStatusbarEntry(this.workspaceTrustManagementService.isWorkspaceTrusted());
|
|
539
|
+
this.statusbarEntryAccessor.value = this.statusbarService.addEntry(entry, this.entryId, 0 , 0.99 * Number.MAX_VALUE );
|
|
540
|
+
this.statusbarService.updateEntryVisibility(this.entryId, false);
|
|
541
|
+
}
|
|
542
|
+
getStatusbarEntry(trusted) {
|
|
543
|
+
const text = workspaceTrustToString(trusted);
|
|
544
|
+
let ariaLabel = '';
|
|
545
|
+
let toolTip;
|
|
546
|
+
switch (this.workspaceContextService.getWorkbenchState()) {
|
|
547
|
+
case 1 : {
|
|
548
|
+
ariaLabel = trusted ? ( localize('status.ariaTrustedWindow', "This window is trusted.")) :
|
|
549
|
+
( localize(
|
|
550
|
+
'status.ariaUntrustedWindow',
|
|
551
|
+
"Restricted Mode: Some features are disabled because this window is not trusted."
|
|
552
|
+
));
|
|
553
|
+
toolTip = trusted ? ariaLabel : {
|
|
554
|
+
value: ( localize(
|
|
555
|
+
{ key: 'status.tooltipUntrustedWindow2', comment: ['[abc]({n}) are links. Only translate `features are disabled` and `window is not trusted`. Do not change brackets and parentheses or {n}'] },
|
|
556
|
+
"Running in Restricted Mode\n\nSome [features are disabled]({0}) because this [window is not trusted]({1}).",
|
|
557
|
+
`command:${LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID}`,
|
|
558
|
+
`command:${MANAGE_TRUST_COMMAND_ID}`
|
|
559
|
+
)),
|
|
560
|
+
isTrusted: true,
|
|
561
|
+
supportThemeIcons: true
|
|
562
|
+
};
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
case 2 : {
|
|
566
|
+
ariaLabel = trusted ? ( localize('status.ariaTrustedFolder', "This folder is trusted.")) :
|
|
567
|
+
( localize(
|
|
568
|
+
'status.ariaUntrustedFolder',
|
|
569
|
+
"Restricted Mode: Some features are disabled because this folder is not trusted."
|
|
570
|
+
));
|
|
571
|
+
toolTip = trusted ? ariaLabel : {
|
|
572
|
+
value: ( localize(
|
|
573
|
+
{ key: 'status.tooltipUntrustedFolder2', comment: ['[abc]({n}) are links. Only translate `features are disabled` and `folder is not trusted`. Do not change brackets and parentheses or {n}'] },
|
|
574
|
+
"Running in Restricted Mode\n\nSome [features are disabled]({0}) because this [folder is not trusted]({1}).",
|
|
575
|
+
`command:${LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID}`,
|
|
576
|
+
`command:${MANAGE_TRUST_COMMAND_ID}`
|
|
577
|
+
)),
|
|
578
|
+
isTrusted: true,
|
|
579
|
+
supportThemeIcons: true
|
|
580
|
+
};
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
case 3 : {
|
|
584
|
+
ariaLabel = trusted ? ( localize('status.ariaTrustedWorkspace', "This workspace is trusted.")) :
|
|
585
|
+
( localize(
|
|
586
|
+
'status.ariaUntrustedWorkspace',
|
|
587
|
+
"Restricted Mode: Some features are disabled because this workspace is not trusted."
|
|
588
|
+
));
|
|
589
|
+
toolTip = trusted ? ariaLabel : {
|
|
590
|
+
value: ( localize(
|
|
591
|
+
{ key: 'status.tooltipUntrustedWorkspace2', comment: ['[abc]({n}) are links. Only translate `features are disabled` and `workspace is not trusted`. Do not change brackets and parentheses or {n}'] },
|
|
592
|
+
"Running in Restricted Mode\n\nSome [features are disabled]({0}) because this [workspace is not trusted]({1}).",
|
|
593
|
+
`command:${LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID}`,
|
|
594
|
+
`command:${MANAGE_TRUST_COMMAND_ID}`
|
|
595
|
+
)),
|
|
596
|
+
isTrusted: true,
|
|
597
|
+
supportThemeIcons: true
|
|
598
|
+
};
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
name: ( localize('status.WorkspaceTrust', "Workspace Trust")),
|
|
604
|
+
text: trusted ? `$(shield)` : `$(shield) ${text}`,
|
|
605
|
+
ariaLabel: ariaLabel,
|
|
606
|
+
tooltip: toolTip,
|
|
607
|
+
command: MANAGE_TRUST_COMMAND_ID,
|
|
608
|
+
kind: 'prominent'
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
updateStatusbarEntry(trusted) {
|
|
612
|
+
this.statusbarEntryAccessor.value?.update(this.getStatusbarEntry(trusted));
|
|
613
|
+
this.statusbarService.updateEntryVisibility(this.entryId, !trusted);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
WorkspaceTrustUXHandler = ( __decorate([
|
|
617
|
+
( __param(0, IDialogService)),
|
|
618
|
+
( __param(1, IWorkspaceContextService)),
|
|
619
|
+
( __param(2, IWorkspaceTrustEnablementService)),
|
|
620
|
+
( __param(3, IWorkspaceTrustManagementService)),
|
|
621
|
+
( __param(4, IConfigurationService)),
|
|
622
|
+
( __param(5, IStatusbarService)),
|
|
623
|
+
( __param(6, IStorageService)),
|
|
624
|
+
( __param(7, IWorkspaceTrustRequestService)),
|
|
625
|
+
( __param(8, IBannerService)),
|
|
626
|
+
( __param(9, ILabelService)),
|
|
627
|
+
( __param(10, IHostService)),
|
|
628
|
+
( __param(11, IProductService)),
|
|
629
|
+
( __param(12, IRemoteAgentService)),
|
|
630
|
+
( __param(13, IEnvironmentService)),
|
|
631
|
+
( __param(14, IFileService))
|
|
632
|
+
], WorkspaceTrustUXHandler));
|
|
633
|
+
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(WorkspaceTrustRequestHandler, 2 );
|
|
634
|
+
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(WorkspaceTrustUXHandler, 3 );
|
|
635
|
+
( Registry.as(EditorExtensions.EditorPane)).registerEditorPane(EditorPaneDescriptor.create(WorkspaceTrustEditor, WorkspaceTrustEditor.ID, ( localize('workspaceTrustEditor', "Workspace Trust Editor"))), [
|
|
636
|
+
( new SyncDescriptor(WorkspaceTrustEditorInput))
|
|
637
|
+
]);
|
|
638
|
+
const CONFIGURE_TRUST_COMMAND_ID = 'workbench.trust.configure';
|
|
639
|
+
const WORKSPACES_CATEGORY = { value: ( localize('workspacesCategory', "Workspaces")), original: 'Workspaces' };
|
|
640
|
+
registerAction2(class extends Action2 {
|
|
641
|
+
constructor() {
|
|
642
|
+
super({
|
|
643
|
+
id: CONFIGURE_TRUST_COMMAND_ID,
|
|
644
|
+
title: { original: 'Configure Workspace Trust Settings', value: ( localize('configureWorkspaceTrustSettings', "Configure Workspace Trust Settings")) },
|
|
645
|
+
precondition: ( ContextKeyExpr.and(WorkspaceTrustContext.IsEnabled, ( ContextKeyExpr.equals(`config.${WORKSPACE_TRUST_ENABLED}`, true)))),
|
|
646
|
+
category: WORKSPACES_CATEGORY,
|
|
647
|
+
f1: true
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
run(accessor) {
|
|
651
|
+
accessor.get(IPreferencesService).openUserSettings({ jsonEditor: false, query: `@tag:${WORKSPACE_TRUST_SETTING_TAG}` });
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
registerAction2(class extends Action2 {
|
|
655
|
+
constructor() {
|
|
656
|
+
super({
|
|
657
|
+
id: MANAGE_TRUST_COMMAND_ID,
|
|
658
|
+
title: { original: 'Manage Workspace Trust', value: ( localize('manageWorkspaceTrust', "Manage Workspace Trust")) },
|
|
659
|
+
precondition: ( ContextKeyExpr.and(WorkspaceTrustContext.IsEnabled, ( ContextKeyExpr.equals(`config.${WORKSPACE_TRUST_ENABLED}`, true)))),
|
|
660
|
+
category: WORKSPACES_CATEGORY,
|
|
661
|
+
f1: true,
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
run(accessor) {
|
|
665
|
+
const editorService = accessor.get(IEditorService);
|
|
666
|
+
const instantiationService = accessor.get(IInstantiationService);
|
|
667
|
+
const input = instantiationService.createInstance(WorkspaceTrustEditorInput);
|
|
668
|
+
editorService.openEditor(input, { pinned: true });
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
( Registry.as(Extensions$1.Configuration))
|
|
673
|
+
.registerConfiguration({
|
|
674
|
+
...securityConfigurationNodeBase,
|
|
675
|
+
properties: {
|
|
676
|
+
[WORKSPACE_TRUST_ENABLED]: {
|
|
677
|
+
type: 'boolean',
|
|
678
|
+
default: true,
|
|
679
|
+
description: ( localize(
|
|
680
|
+
'workspace.trust.description',
|
|
681
|
+
"Controls whether or not Workspace Trust is enabled within VS Code."
|
|
682
|
+
)),
|
|
683
|
+
tags: [WORKSPACE_TRUST_SETTING_TAG],
|
|
684
|
+
scope: 1 ,
|
|
685
|
+
},
|
|
686
|
+
[WORKSPACE_TRUST_STARTUP_PROMPT]: {
|
|
687
|
+
type: 'string',
|
|
688
|
+
default: 'once',
|
|
689
|
+
description: ( localize(
|
|
690
|
+
'workspace.trust.startupPrompt.description',
|
|
691
|
+
"Controls when the startup prompt to trust a workspace is shown."
|
|
692
|
+
)),
|
|
693
|
+
tags: [WORKSPACE_TRUST_SETTING_TAG],
|
|
694
|
+
scope: 1 ,
|
|
695
|
+
enum: ['always', 'once', 'never'],
|
|
696
|
+
enumDescriptions: [
|
|
697
|
+
( localize(
|
|
698
|
+
'workspace.trust.startupPrompt.always',
|
|
699
|
+
"Ask for trust every time an untrusted workspace is opened."
|
|
700
|
+
)),
|
|
701
|
+
( localize(
|
|
702
|
+
'workspace.trust.startupPrompt.once',
|
|
703
|
+
"Ask for trust the first time an untrusted workspace is opened."
|
|
704
|
+
)),
|
|
705
|
+
( localize(
|
|
706
|
+
'workspace.trust.startupPrompt.never',
|
|
707
|
+
"Do not ask for trust when an untrusted workspace is opened."
|
|
708
|
+
)),
|
|
709
|
+
]
|
|
710
|
+
},
|
|
711
|
+
[WORKSPACE_TRUST_BANNER]: {
|
|
712
|
+
type: 'string',
|
|
713
|
+
default: 'untilDismissed',
|
|
714
|
+
description: ( localize(
|
|
715
|
+
'workspace.trust.banner.description',
|
|
716
|
+
"Controls when the restricted mode banner is shown."
|
|
717
|
+
)),
|
|
718
|
+
tags: [WORKSPACE_TRUST_SETTING_TAG],
|
|
719
|
+
scope: 1 ,
|
|
720
|
+
enum: ['always', 'untilDismissed', 'never'],
|
|
721
|
+
enumDescriptions: [
|
|
722
|
+
( localize(
|
|
723
|
+
'workspace.trust.banner.always',
|
|
724
|
+
"Show the banner every time an untrusted workspace is open."
|
|
725
|
+
)),
|
|
726
|
+
( localize(
|
|
727
|
+
'workspace.trust.banner.untilDismissed',
|
|
728
|
+
"Show the banner when an untrusted workspace is opened until dismissed."
|
|
729
|
+
)),
|
|
730
|
+
( localize(
|
|
731
|
+
'workspace.trust.banner.never',
|
|
732
|
+
"Do not show the banner when an untrusted workspace is open."
|
|
733
|
+
)),
|
|
734
|
+
]
|
|
735
|
+
},
|
|
736
|
+
[WORKSPACE_TRUST_UNTRUSTED_FILES]: {
|
|
737
|
+
type: 'string',
|
|
738
|
+
default: 'prompt',
|
|
739
|
+
markdownDescription: ( localize(
|
|
740
|
+
'workspace.trust.untrustedFiles.description',
|
|
741
|
+
"Controls how to handle opening untrusted files in a trusted workspace. This setting also applies to opening files in an empty window which is trusted via `#{0}#`.",
|
|
742
|
+
WORKSPACE_TRUST_EMPTY_WINDOW
|
|
743
|
+
)),
|
|
744
|
+
tags: [WORKSPACE_TRUST_SETTING_TAG],
|
|
745
|
+
scope: 1 ,
|
|
746
|
+
enum: ['prompt', 'open', 'newWindow'],
|
|
747
|
+
enumDescriptions: [
|
|
748
|
+
( localize(
|
|
749
|
+
'workspace.trust.untrustedFiles.prompt',
|
|
750
|
+
"Ask how to handle untrusted files for each workspace. Once untrusted files are introduced to a trusted workspace, you will not be prompted again."
|
|
751
|
+
)),
|
|
752
|
+
( localize(
|
|
753
|
+
'workspace.trust.untrustedFiles.open',
|
|
754
|
+
"Always allow untrusted files to be introduced to a trusted workspace without prompting."
|
|
755
|
+
)),
|
|
756
|
+
( localize(
|
|
757
|
+
'workspace.trust.untrustedFiles.newWindow',
|
|
758
|
+
"Always open untrusted files in a separate window in restricted mode without prompting."
|
|
759
|
+
)),
|
|
760
|
+
]
|
|
761
|
+
},
|
|
762
|
+
[WORKSPACE_TRUST_EMPTY_WINDOW]: {
|
|
763
|
+
type: 'boolean',
|
|
764
|
+
default: true,
|
|
765
|
+
markdownDescription: ( localize(
|
|
766
|
+
'workspace.trust.emptyWindow.description',
|
|
767
|
+
"Controls whether or not the empty window is trusted by default within VS Code. When used with `#{0}#`, you can enable the full functionality of VS Code without prompting in an empty window.",
|
|
768
|
+
WORKSPACE_TRUST_UNTRUSTED_FILES
|
|
769
|
+
)),
|
|
770
|
+
tags: [WORKSPACE_TRUST_SETTING_TAG],
|
|
771
|
+
scope: 1
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
let WorkspaceTrustTelemetryContribution = class WorkspaceTrustTelemetryContribution extends Disposable {
|
|
776
|
+
constructor(environmentService, telemetryService, workspaceContextService, workspaceTrustEnablementService, workspaceTrustManagementService) {
|
|
777
|
+
super();
|
|
778
|
+
this.environmentService = environmentService;
|
|
779
|
+
this.telemetryService = telemetryService;
|
|
780
|
+
this.workspaceContextService = workspaceContextService;
|
|
781
|
+
this.workspaceTrustEnablementService = workspaceTrustEnablementService;
|
|
782
|
+
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
783
|
+
this.workspaceTrustManagementService.workspaceTrustInitialized
|
|
784
|
+
.then(() => {
|
|
785
|
+
this.logInitialWorkspaceTrustInfo();
|
|
786
|
+
this.logWorkspaceTrust(this.workspaceTrustManagementService.isWorkspaceTrusted());
|
|
787
|
+
this._register(this.workspaceTrustManagementService.onDidChangeTrust(isTrusted => this.logWorkspaceTrust(isTrusted)));
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
logInitialWorkspaceTrustInfo() {
|
|
791
|
+
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
|
|
792
|
+
const disabledByCliFlag = this.environmentService.disableWorkspaceTrust;
|
|
793
|
+
this.telemetryService.publicLog2('workspaceTrustDisabled', {
|
|
794
|
+
reason: disabledByCliFlag ? 'cli' : 'setting'
|
|
795
|
+
});
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
this.telemetryService.publicLog2('workspaceTrustFolderCounts', {
|
|
799
|
+
trustedFoldersCount: this.workspaceTrustManagementService.getTrustedUris().length,
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
async logWorkspaceTrust(isTrusted) {
|
|
803
|
+
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
this.telemetryService.publicLog2('workspaceTrustStateChanged', {
|
|
807
|
+
workspaceId: this.workspaceContextService.getWorkspace().id,
|
|
808
|
+
isTrusted: isTrusted
|
|
809
|
+
});
|
|
810
|
+
if (isTrusted) {
|
|
811
|
+
const getDepth = (folder) => {
|
|
812
|
+
let resolvedPath = resolve(folder);
|
|
813
|
+
let depth = 0;
|
|
814
|
+
while (dirname$1(resolvedPath) !== resolvedPath && depth < 100) {
|
|
815
|
+
resolvedPath = dirname$1(resolvedPath);
|
|
816
|
+
depth++;
|
|
817
|
+
}
|
|
818
|
+
return depth;
|
|
819
|
+
};
|
|
820
|
+
for (const folder of this.workspaceContextService.getWorkspace().folders) {
|
|
821
|
+
const { trusted, uri } = await this.workspaceTrustManagementService.getUriTrustInfo(folder.uri);
|
|
822
|
+
if (!trusted) {
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
const workspaceFolderDepth = getDepth(folder.uri.fsPath);
|
|
826
|
+
const trustedFolderDepth = getDepth(uri.fsPath);
|
|
827
|
+
const delta = workspaceFolderDepth - trustedFolderDepth;
|
|
828
|
+
this.telemetryService.publicLog2('workspaceFolderDepthBelowTrustedFolder', { workspaceFolderDepth, trustedFolderDepth, delta });
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
WorkspaceTrustTelemetryContribution = ( __decorate([
|
|
834
|
+
( __param(0, IWorkbenchEnvironmentService)),
|
|
835
|
+
( __param(1, ITelemetryService)),
|
|
836
|
+
( __param(2, IWorkspaceContextService)),
|
|
837
|
+
( __param(3, IWorkspaceTrustEnablementService)),
|
|
838
|
+
( __param(4, IWorkspaceTrustManagementService))
|
|
839
|
+
], WorkspaceTrustTelemetryContribution));
|
|
840
|
+
( Registry.as(Extensions.Workbench))
|
|
841
|
+
.registerWorkbenchContribution(WorkspaceTrustTelemetryContribution, 3 );
|
|
842
|
+
export { WorkspaceTrustContextKeys, WorkspaceTrustRequestHandler, WorkspaceTrustUXHandler };
|