Workspace trust - extension enablement (#120028)
This commit is contained in:
parent
6aa528024b
commit
c2b5d3d471
4 changed files with 18 additions and 6 deletions
|
@ -307,6 +307,18 @@ export function isAuthenticaionProviderExtension(manifest: IExtensionManifest):
|
|||
return manifest.contributes && manifest.contributes.authentication ? manifest.contributes.authentication.length > 0 : false;
|
||||
}
|
||||
|
||||
export function getExtensionWorkspaceTrustRequirement(manifest: IExtensionManifest): ExtensionWorkspaceTrustRequirement {
|
||||
if (manifest.workspaceTrust?.required !== undefined) {
|
||||
return manifest.workspaceTrust.required;
|
||||
}
|
||||
|
||||
if (!manifest.main) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 'onStart';
|
||||
}
|
||||
|
||||
export interface IScannedExtension {
|
||||
readonly identifier: IExtensionIdentifier;
|
||||
readonly location: URI;
|
||||
|
|
|
@ -16,7 +16,7 @@ import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
|||
import { isArray } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ExtensionWorkspaceTrustRequirement } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtensionWorkspaceTrustRequirement, getExtensionWorkspaceTrustRequirement } from 'vs/platform/extensions/common/extensions';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Link } from 'vs/platform/opener/browser/link';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
@ -248,7 +248,7 @@ export class WorkspaceTrustEditor extends EditorPane {
|
|||
}
|
||||
|
||||
private async getExtensionsByTrustRequirement(extensions: IExtensionStatus[], trustRequirement: ExtensionWorkspaceTrustRequirement): Promise<IExtension[]> {
|
||||
const filtered = extensions.filter(ext => ext.local.manifest.workspaceTrust?.required === trustRequirement);
|
||||
const filtered = extensions.filter(ext => getExtensionWorkspaceTrustRequirement(ext.local.manifest) === trustRequirement);
|
||||
const ids = filtered.map(ext => ext.identifier.id);
|
||||
|
||||
return getExtensions(ids, this.extensionWorkbenchService);
|
||||
|
|
|
@ -12,7 +12,7 @@ import { areSameExtensions } from 'vs/platform/extensionManagement/common/extens
|
|||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IExtension, isAuthenticaionProviderExtension, isLanguagePackExtension } from 'vs/platform/extensions/common/extensions';
|
||||
import { getExtensionWorkspaceTrustRequirement, IExtension, isAuthenticaionProviderExtension, isLanguagePackExtension } from 'vs/platform/extensions/common/extensions';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ExtensionKindController } from 'vs/workbench/services/extensions/common/extensionsUtil';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
@ -281,7 +281,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
|
|||
private _isDisabledByTrustRequirement(extension: IExtension): boolean {
|
||||
const workspaceTrustState = this.workspaceTrustService.getWorkspaceTrustState();
|
||||
|
||||
if (extension.manifest.workspaceTrust?.required === 'onStart') {
|
||||
if (getExtensionWorkspaceTrustRequirement(extension.manifest) === 'onStart') {
|
||||
if (workspaceTrustState !== WorkspaceTrustState.Trusted) {
|
||||
this._addToWorkspaceDisabledExtensionsByTrustRequirement(extension);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
ILocalExtension, IGalleryExtension, InstallExtensionEvent, DidInstallExtensionEvent, IExtensionIdentifier, DidUninstallExtensionEvent, IReportedExtension, IGalleryMetadata, IExtensionGalleryService, InstallOptions, UninstallOptions, INSTALL_ERROR_NOT_SUPPORTED
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementServer, IExtensionManagementServerService, IWorkbenchExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionType, isLanguagePackExtension, IExtensionManifest } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtensionType, isLanguagePackExtension, IExtensionManifest, getExtensionWorkspaceTrustRequirement } from 'vs/platform/extensions/common/extensions';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
@ -361,7 +361,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
|
|||
}
|
||||
|
||||
protected async checkForWorkspaceTrust(manifest: IExtensionManifest): Promise<void> {
|
||||
if (manifest.workspaceTrust?.required === 'onStart') {
|
||||
if (getExtensionWorkspaceTrustRequirement(manifest) === 'onStart') {
|
||||
const trustState = await this.workspaceTrustService.requireWorkspaceTrust();
|
||||
return trustState === WorkspaceTrustState.Trusted ? Promise.resolve() : Promise.reject(canceled());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue