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

take all profiles for populating trusted publishers #238638

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading