Skip to content

Commit

Permalink
take all profiles for populating trusted publishers (#238638)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 authored Jan 24, 2025
1 parent b17af07 commit 6655b2c
Showing 1 changed file with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import { ProgressLocation } from '../../../../platform/progress/common/progress.
import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js';
import { IConfigurationMigrationRegistry, Extensions as ConfigurationMigrationExtensions } from '../../../common/configuration.js';
import { IProductService } from '../../../../platform/product/common/productService.js';
import { IUserDataProfilesService } from '../../../../platform/userDataProfile/common/userDataProfile.js';

// Singletons
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService, InstantiationType.Eager /* Auto updates extensions */);
Expand Down Expand Up @@ -1932,31 +1933,34 @@ class ExtensionStorageCleaner implements IWorkbenchContribution {
class TrustedPublishersInitializer implements IWorkbenchContribution {
constructor(
@IExtensionManagementService extensionManagementService: IExtensionManagementService,
@IUserDataProfilesService userDataProfilesService: IUserDataProfilesService,
@IAllowedExtensionsService allowedExtensionsService: IAllowedExtensionsService,
@IProductService productService: IProductService,
@IStorageService storageService: IStorageService,
) {
const trustedPublishersInitStatusKey = 'trusted-publishers-initialized';
if (!storageService.get(trustedPublishersInitStatusKey, StorageScope.APPLICATION)) {
extensionManagementService.getInstalled(ExtensionType.User)
.then(async extensions => {
const trustedPublishers = new Set<string>();
for (const extension of extensions) {
if (!extension.publisherId) {
continue;
for (const profile of userDataProfilesService.profiles) {
extensionManagementService.getInstalled(ExtensionType.User, profile.extensionsResource)
.then(async extensions => {
const trustedPublishers = new Set<string>();
for (const extension of extensions) {
if (!extension.publisherId) {
continue;
}
const publisher = extension.manifest.publisher.toLowerCase();
if (productService.trustedExtensionPublishers?.includes(publisher)
|| (extension.publisherDisplayName && productService.trustedExtensionPublishers?.includes(extension.publisherDisplayName.toLowerCase()))) {
continue;
}
trustedPublishers.add(publisher);
}
const publisher = extension.manifest.publisher.toLowerCase();
if (productService.trustedExtensionPublishers?.includes(publisher)
|| (extension.publisherDisplayName && productService.trustedExtensionPublishers?.includes(extension.publisherDisplayName.toLowerCase()))) {
continue;
if (trustedPublishers.size) {
await allowedExtensionsService.trustPublishers(...trustedPublishers);
}
trustedPublishers.add(publisher);
}
if (trustedPublishers.size) {
await allowedExtensionsService.trustPublishers(...trustedPublishers);
}
storageService.store(trustedPublishersInitStatusKey, 'true', StorageScope.APPLICATION, StorageTarget.MACHINE);
});
storageService.store(trustedPublishersInitStatusKey, 'true', StorageScope.APPLICATION, StorageTarget.MACHINE);
});
}
}
}
}
Expand Down

0 comments on commit 6655b2c

Please sign in to comment.