提交 53a2781d 编写于 作者: J Joao Moreno

add extensions control url

上级 f3ffbcf5
{
"name": "code-oss-dev",
"version": "1.20.0",
"distro": "2478cca5311e147817eef29cb81c0995a3517842",
"distro": "e14a5a3afaae557ff651b344462ed39e776435a2",
"author": {
"name": "Microsoft Corporation"
},
......@@ -129,4 +129,4 @@
"windows-mutex": "^0.2.0",
"windows-process-tree": "0.1.6"
}
}
}
\ No newline at end of file
......@@ -229,6 +229,12 @@ export enum StatisticType {
Uninstall = 'uninstall'
}
export interface IReportedExtension {
id: IExtensionIdentifier;
malicious: boolean;
slow: boolean;
}
export interface IExtensionGalleryService {
_serviceBrand: any;
isEnabled(): boolean;
......@@ -240,6 +246,7 @@ export interface IExtensionGalleryService {
getChangelog(extension: IGalleryExtension): TPromise<string>;
loadCompatibleVersion(extension: IGalleryExtension): TPromise<IGalleryExtension>;
loadAllDependencies(dependencies: IExtensionIdentifier[]): TPromise<IGalleryExtension[]>;
getExtensionsReport(): TPromise<IReportedExtension[]>;
}
export interface InstallExtensionEvent {
......
......@@ -9,7 +9,7 @@ import * as path from 'path';
import { TPromise } from 'vs/base/common/winjs.base';
import { distinct } from 'vs/base/common/arrays';
import { getErrorMessage, isPromiseCanceledError } from 'vs/base/common/errors';
import { StatisticType, IGalleryExtension, IExtensionGalleryService, IGalleryExtensionAsset, IQueryOptions, SortBy, SortOrder, IExtensionManifest, IExtensionIdentifier } from 'vs/platform/extensionManagement/common/extensionManagement';
import { StatisticType, IGalleryExtension, IExtensionGalleryService, IGalleryExtensionAsset, IQueryOptions, SortBy, SortOrder, IExtensionManifest, IExtensionIdentifier, IReportedExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { getGalleryExtensionId, getGalleryExtensionTelemetryData, adoptToGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { assign, getOrDefault } from 'vs/base/common/objects';
import { IRequestService } from 'vs/platform/request/node/request';
......@@ -23,6 +23,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { readFile } from 'vs/base/node/pfs';
import { writeFileAndFlushSync } from 'vs/base/node/extfs';
import { generateUuid, isUUID } from 'vs/base/common/uuid';
import { values } from 'vs/base/common/map';
interface IRawGalleryExtensionFile {
assetType: string;
......@@ -309,11 +310,17 @@ function toExtension(galleryExtension: IRawGalleryExtension, extensionsGalleryUr
};
}
interface IRawExtensionsReport {
malicious: string[];
slow: string[];
}
export class ExtensionGalleryService implements IExtensionGalleryService {
_serviceBrand: any;
private extensionsGalleryUrl: string;
private extensionsControlUrl: string;
private readonly commonHeadersPromise: TPromise<{ [key: string]: string; }>;
......@@ -324,6 +331,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
) {
const config = product.extensionsGallery;
this.extensionsGalleryUrl = config && config.serviceUrl;
this.extensionsControlUrl = config && config.controlUrl;
this.commonHeadersPromise = resolveMarketplaceHeaders(this.environmentService);
}
......@@ -711,6 +719,40 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
}
return false;
}
getExtensionsReport(): TPromise<IReportedExtension[]> {
if (!this.isEnabled()) {
return TPromise.wrapError(new Error('No extension gallery service configured.'));
}
if (!this.extensionsControlUrl) {
return TPromise.as([]);
}
return this.requestService.request({ type: 'GET', url: this.extensionsControlUrl }).then(context => {
if (context.res.statusCode !== 200) {
return TPromise.wrapError(new Error('Could not get extensions report.'));
}
return asJson<IRawExtensionsReport>(context).then(result => {
const map = new Map<string, IReportedExtension>();
for (const id of result.malicious) {
const ext = map.get(id) || { id: { id }, malicious: true, slow: false };
ext.malicious = true;
map.set(id, ext);
}
for (const id of result.slow) {
const ext = map.get(id) || { id: { id }, malicious: false, slow: true };
ext.slow = true;
map.set(id, ext);
}
return TPromise.as(values(map));
});
});
}
}
export function resolveMarketplaceHeaders(environmentService: IEnvironmentService): TPromise<{ [key: string]: string; }> {
......
......@@ -25,6 +25,7 @@ export interface IProductConfiguration {
extensionsGallery: {
serviceUrl: string;
itemUrl: string;
controlUrl: string;
};
extensionTips: { [id: string]: string; };
extensionImportantTips: { [id: string]: { name: string; pattern: string; }; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册