electron-updater 4.3.8 → 4.3.9
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/LICENSE +22 -0
- package/out/AppAdapter.js +19 -28
- package/out/AppAdapter.js.map +1 -1
- package/out/AppImageUpdater.js +103 -195
- package/out/AppImageUpdater.js.map +1 -1
- package/out/AppUpdater.d.ts +1 -1
- package/out/AppUpdater.js +517 -771
- package/out/AppUpdater.js.map +1 -1
- package/out/BaseUpdater.js +79 -103
- package/out/BaseUpdater.js.map +1 -1
- package/out/DownloadedUpdateHelper.js +150 -223
- package/out/DownloadedUpdateHelper.js.map +1 -1
- package/out/ElectronAppAdapter.js +35 -63
- package/out/ElectronAppAdapter.js.map +1 -1
- package/out/MacUpdater.js +132 -201
- package/out/MacUpdater.js.map +1 -1
- package/out/NoOpLogger.d.ts +6 -0
- package/out/NoOpLogger.js +19 -0
- package/out/NoOpLogger.js.map +1 -0
- package/out/NsisUpdater.js +199 -345
- package/out/NsisUpdater.js.map +1 -1
- package/out/differentialDownloader/DataSplitter.js +180 -252
- package/out/differentialDownloader/DataSplitter.js.map +1 -1
- package/out/differentialDownloader/DifferentialDownloader.d.ts +1 -1
- package/out/differentialDownloader/DifferentialDownloader.js +242 -355
- package/out/differentialDownloader/DifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js +29 -65
- package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/GenericDifferentialDownloader.js +7 -21
- package/out/differentialDownloader/GenericDifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js +79 -107
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js.map +1 -1
- package/out/differentialDownloader/downloadPlanBuilder.js +99 -123
- package/out/differentialDownloader/downloadPlanBuilder.js.map +1 -1
- package/out/differentialDownloader/multipleRangeDownloader.js +99 -148
- package/out/differentialDownloader/multipleRangeDownloader.js.map +1 -1
- package/out/electronHttpExecutor.js +73 -106
- package/out/electronHttpExecutor.js.map +1 -1
- package/out/event.d.ts +35 -0
- package/out/event.js +39 -0
- package/out/event.js.map +1 -0
- package/out/log.d.ts +11 -0
- package/out/log.js +19 -0
- package/out/log.js.map +1 -0
- package/out/main.d.ts +1 -3
- package/out/main.js +60 -196
- package/out/main.js.map +1 -1
- package/out/providerFactory.js +49 -105
- package/out/providerFactory.js.map +1 -1
- package/out/providers/BintrayProvider.d.ts +2 -2
- package/out/providers/BintrayProvider.js +40 -95
- package/out/providers/BintrayProvider.js.map +1 -1
- package/out/providers/GenericProvider.d.ts +2 -2
- package/out/providers/GenericProvider.js +46 -80
- package/out/providers/GenericProvider.js.map +1 -1
- package/out/providers/GitHubProvider.d.ts +2 -2
- package/out/providers/GitHubProvider.js +122 -201
- package/out/providers/GitHubProvider.js.map +1 -1
- package/out/providers/PrivateGitHubProvider.js +87 -165
- package/out/providers/PrivateGitHubProvider.js.map +1 -1
- package/out/providers/Provider.js +122 -173
- package/out/providers/Provider.js.map +1 -1
- package/out/util.d.ts +5 -0
- package/out/util.js +42 -0
- package/out/util.js.map +1 -0
- package/out/windowsExecutableCodeSignatureVerifier.js +99 -139
- package/out/windowsExecutableCodeSignatureVerifier.js.map +1 -1
- package/package.json +33 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/Provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/providers/Provider.ts"],"names":[],"mappings":";;;AAAA,+DAAuK;AAEvK,qCAA8B;AAG9B,kCAAwC;AAWxC,MAAsB,QAAQ;IAI5B,YAAuC,cAAsC;QAAtC,mBAAc,GAAd,cAAc,CAAwB;QAHrE,mBAAc,GAA+B,IAAI,CAAA;QAIvD,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAA;IACzC,CAAC;IAED,I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;YAC7D,MAAM,+BAAQ,CAAC,mEAAmE,wCAAiB,CAAC,QAAQ,CAAC,EAAE,EAAE,yBAAyB,CAAC,CAAA;SAC5I;QACD,OAAO;YACL,GAAG,EAAE,qBAAc,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;YAC3D,IAAI,EAAE,QAAQ;SACf,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAI,UAAgC,CAAC,QAAQ,CAAA;IAC3D,MAAM,WAAW,GAAG,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAA;IACrF,IAAI,WAAW,IAAI,IAAI,EAAE;QACvB,CAAC;QAAC,MAAM,CAAC,CAAC,CAAS,CAAC,WAAW,GAAG;YAChC,GAAG,WAAW;YACd,IAAI,EAAE,qBAAc,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI;SACtE,CAAA;KACF;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AArBD,oCAqBC","sourcesContent":["import { CancellationToken, HttpExecutor, newError, safeStringifyJson, UpdateFileInfo, UpdateInfo, WindowsUpdateInfo, configureRequestUrl } from \"builder-util-runtime\"\nimport { OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { load } from \"js-yaml\"\nimport { URL } from \"url\"\nimport { ResolvedUpdateFileInfo } from \"../main\"\nimport { newUrlFromBase } from \"../util\"\n\nexport type ProviderPlatform = \"darwin\" | \"linux\" | \"win32\"\n\nexport interface ProviderRuntimeOptions {\n isUseMultipleRangeRequest: boolean\n platform: ProviderPlatform\n\n executor: HttpExecutor<any>\n}\n\nexport abstract class Provider<T extends UpdateInfo> {\n private requestHeaders: OutgoingHttpHeaders | null = null\n protected readonly executor: HttpExecutor<any>\n\n protected constructor(private readonly runtimeOptions: ProviderRuntimeOptions) {\n this.executor = runtimeOptions.executor\n }\n\n get isUseMultipleRangeRequest(): boolean {\n return this.runtimeOptions.isUseMultipleRangeRequest !== false\n }\n\n private getChannelFilePrefix(): string {\n if (this.runtimeOptions.platform === \"linux\") {\n const arch = process.env.TEST_UPDATER_ARCH || process.arch\n const archSuffix = arch === \"x64\" ? \"\" : `-${arch}`\n return \"-linux\" + archSuffix\n } else {\n return this.runtimeOptions.platform === \"darwin\" ? \"-mac\" : \"\"\n }\n }\n\n // due to historical reasons for windows we use channel name without platform specifier\n protected getDefaultChannelName(): string {\n return this.getCustomChannelName(\"latest\")\n }\n\n protected getCustomChannelName(channel: string): string {\n return `${channel}${this.getChannelFilePrefix()}`\n }\n\n get fileExtraDownloadHeaders(): OutgoingHttpHeaders | null {\n return null\n }\n\n setRequestHeaders(value: OutgoingHttpHeaders | null): void {\n this.requestHeaders = value\n }\n\n abstract getLatestVersion(): Promise<T>\n\n abstract resolveFiles(updateInfo: UpdateInfo): Array<ResolvedUpdateFileInfo>\n\n /**\n * Method to perform API request only to resolve update info, but not to download update.\n */\n protected httpRequest(url: URL, headers?: OutgoingHttpHeaders | null, cancellationToken?: CancellationToken): Promise<string | null> {\n return this.executor.request(this.createRequestOptions(url, headers), cancellationToken)\n }\n\n protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions {\n const result: RequestOptions = {}\n if (this.requestHeaders == null) {\n if (headers != null) {\n result.headers = headers\n }\n } else {\n result.headers = headers == null ? this.requestHeaders : { ...this.requestHeaders, ...headers }\n }\n\n configureRequestUrl(url, result)\n return result\n }\n}\n\nexport function findFile(files: Array<ResolvedUpdateFileInfo>, extension: string, not?: Array<string>): ResolvedUpdateFileInfo | null | undefined {\n if (files.length === 0) {\n throw newError(\"No files provided\", \"ERR_UPDATER_NO_FILES_PROVIDED\")\n }\n\n const result = files.find(it => it.url.pathname.toLowerCase().endsWith(`.${extension}`))\n if (result != null) {\n return result\n } else if (not == null) {\n return files[0]\n } else {\n return files.find(fileInfo => !not.some(ext => fileInfo.url.pathname.toLowerCase().endsWith(`.${ext}`)))\n }\n}\n\nexport function parseUpdateInfo(rawData: string | null, channelFile: string, channelFileUrl: URL): UpdateInfo {\n if (rawData == null) {\n throw newError(`Cannot parse update info from ${channelFile} in the latest release artifacts (${channelFileUrl}): rawData: null`, \"ERR_UPDATER_INVALID_UPDATE_INFO\")\n }\n\n let result: UpdateInfo\n try {\n result = load(rawData) as UpdateInfo\n } catch (e) {\n throw newError(\n `Cannot parse update info from ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}, rawData: ${rawData}`,\n \"ERR_UPDATER_INVALID_UPDATE_INFO\"\n )\n }\n return result\n}\n\nexport function getFileList(updateInfo: UpdateInfo): Array<UpdateFileInfo> {\n const files = updateInfo.files\n if (files != null && files.length > 0) {\n return files\n }\n\n // noinspection JSDeprecatedSymbols\n if (updateInfo.path != null) {\n // noinspection JSDeprecatedSymbols\n return [\n {\n url: updateInfo.path,\n sha2: (updateInfo as any).sha2,\n sha512: updateInfo.sha512,\n } as any,\n ]\n } else {\n throw newError(`No files provided: ${safeStringifyJson(updateInfo)}`, \"ERR_UPDATER_NO_FILES_PROVIDED\")\n }\n}\n\nexport function resolveFiles(updateInfo: UpdateInfo, baseUrl: URL, pathTransformer: (p: string) => string = (p: string): string => p): Array<ResolvedUpdateFileInfo> {\n const files = getFileList(updateInfo)\n const result: Array<ResolvedUpdateFileInfo> = files.map(fileInfo => {\n if ((fileInfo as any).sha2 == null && fileInfo.sha512 == null) {\n throw newError(`Update info doesn't contain nor sha256 neither sha512 checksum: ${safeStringifyJson(fileInfo)}`, \"ERR_UPDATER_NO_CHECKSUM\")\n }\n return {\n url: newUrlFromBase(pathTransformer(fileInfo.url), baseUrl),\n info: fileInfo,\n }\n })\n\n const packages = (updateInfo as WindowsUpdateInfo).packages\n const packageInfo = packages == null ? null : packages[process.arch] || packages.ia32\n if (packageInfo != null) {\n ;(result[0] as any).packageInfo = {\n ...packageInfo,\n path: newUrlFromBase(pathTransformer(packageInfo.path), baseUrl).href,\n }\n }\n return result\n}\n"]}
|
package/out/util.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { URL } from "url";
|
|
3
|
+
export declare function newUrlFromBase(pathname: string, baseUrl: URL, addRandomQueryToAvoidCaching?: boolean): URL;
|
|
4
|
+
export declare function getChannelFilename(channel: string): string;
|
|
5
|
+
export declare function blockmapFiles(baseUrl: URL, oldVersion: string, newVersion: string): URL[];
|
package/out/util.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blockmapFiles = exports.getChannelFilename = exports.newUrlFromBase = exports.newBaseUrl = void 0;
|
|
4
|
+
// if baseUrl path doesn't ends with /, this path will be not prepended to passed pathname for new URL(input, base)
|
|
5
|
+
const url_1 = require("url");
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
const escapeRegExp = require("lodash.escaperegexp");
|
|
8
|
+
/** @internal */
|
|
9
|
+
function newBaseUrl(url) {
|
|
10
|
+
const result = new url_1.URL(url);
|
|
11
|
+
if (!result.pathname.endsWith("/")) {
|
|
12
|
+
result.pathname += "/";
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
exports.newBaseUrl = newBaseUrl;
|
|
17
|
+
// addRandomQueryToAvoidCaching is false by default because in most cases URL already contains version number,
|
|
18
|
+
// so, it makes sense only for Generic Provider for channel files
|
|
19
|
+
function newUrlFromBase(pathname, baseUrl, addRandomQueryToAvoidCaching = false) {
|
|
20
|
+
const result = new url_1.URL(pathname, baseUrl);
|
|
21
|
+
// search is not propagated (search is an empty string if not specified)
|
|
22
|
+
const search = baseUrl.search;
|
|
23
|
+
if (search != null && search.length !== 0) {
|
|
24
|
+
result.search = search;
|
|
25
|
+
}
|
|
26
|
+
else if (addRandomQueryToAvoidCaching) {
|
|
27
|
+
result.search = `noCache=${Date.now().toString(32)}`;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
exports.newUrlFromBase = newUrlFromBase;
|
|
32
|
+
function getChannelFilename(channel) {
|
|
33
|
+
return `${channel}.yml`;
|
|
34
|
+
}
|
|
35
|
+
exports.getChannelFilename = getChannelFilename;
|
|
36
|
+
function blockmapFiles(baseUrl, oldVersion, newVersion) {
|
|
37
|
+
const newBlockMapUrl = newUrlFromBase(`${baseUrl.pathname}.blockmap`, baseUrl);
|
|
38
|
+
const oldBlockMapUrl = newUrlFromBase(`${baseUrl.pathname.replace(new RegExp(escapeRegExp(newVersion), "g"), oldVersion)}.blockmap`, baseUrl);
|
|
39
|
+
return [oldBlockMapUrl, newBlockMapUrl];
|
|
40
|
+
}
|
|
41
|
+
exports.blockmapFiles = blockmapFiles;
|
|
42
|
+
//# sourceMappingURL=util.js.map
|
package/out/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,mHAAmH;AACnH,6BAAyB;AACzB,aAAa;AACb,oDAAmD;AAEnD,gBAAgB;AAChB,SAAgB,UAAU,CAAC,GAAW;IACpC,MAAM,MAAM,GAAG,IAAI,SAAG,CAAC,GAAG,CAAC,CAAA;IAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAClC,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAA;KACvB;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAND,gCAMC;AAED,8GAA8G;AAC9G,iEAAiE;AACjE,SAAgB,cAAc,CAAC,QAAgB,EAAE,OAAY,EAAE,4BAA4B,GAAG,KAAK;IACjG,MAAM,MAAM,GAAG,IAAI,SAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACzC,wEAAwE;IACxE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC7B,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACzC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;KACvB;SAAM,IAAI,4BAA4B,EAAE;QACvC,MAAM,CAAC,MAAM,GAAG,WAAW,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAA;KACrD;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAVD,wCAUC;AAED,SAAgB,kBAAkB,CAAC,OAAe;IAChD,OAAO,GAAG,OAAO,MAAM,CAAA;AACzB,CAAC;AAFD,gDAEC;AAED,SAAgB,aAAa,CAAC,OAAY,EAAE,UAAkB,EAAE,UAAkB;IAChF,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,OAAO,CAAC,QAAQ,WAAW,EAAE,OAAO,CAAC,CAAA;IAC9E,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;IAC7I,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;AACzC,CAAC;AAJD,sCAIC","sourcesContent":["// if baseUrl path doesn't ends with /, this path will be not prepended to passed pathname for new URL(input, base)\nimport { URL } from \"url\"\n// @ts-ignore\nimport * as escapeRegExp from \"lodash.escaperegexp\"\n\n/** @internal */\nexport function newBaseUrl(url: string): URL {\n const result = new URL(url)\n if (!result.pathname.endsWith(\"/\")) {\n result.pathname += \"/\"\n }\n return result\n}\n\n// addRandomQueryToAvoidCaching is false by default because in most cases URL already contains version number,\n// so, it makes sense only for Generic Provider for channel files\nexport function newUrlFromBase(pathname: string, baseUrl: URL, addRandomQueryToAvoidCaching = false): URL {\n const result = new URL(pathname, baseUrl)\n // search is not propagated (search is an empty string if not specified)\n const search = baseUrl.search\n if (search != null && search.length !== 0) {\n result.search = search\n } else if (addRandomQueryToAvoidCaching) {\n result.search = `noCache=${Date.now().toString(32)}`\n }\n return result\n}\n\nexport function getChannelFilename(channel: string): string {\n return `${channel}.yml`\n}\n\nexport function blockmapFiles(baseUrl: URL, oldVersion: string, newVersion: string): URL[] {\n const newBlockMapUrl = newUrlFromBase(`${baseUrl.pathname}.blockmap`, baseUrl)\n const oldBlockMapUrl = newUrlFromBase(`${baseUrl.pathname.replace(new RegExp(escapeRegExp(newVersion), \"g\"), oldVersion)}.blockmap`, baseUrl)\n return [oldBlockMapUrl, newBlockMapUrl]\n}\n"]}
|
|
@@ -1,152 +1,112 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function _builderUtilRuntime() {
|
|
9
|
-
const data = require("builder-util-runtime");
|
|
10
|
-
|
|
11
|
-
_builderUtilRuntime = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _child_process() {
|
|
19
|
-
const data = require("child_process");
|
|
20
|
-
|
|
21
|
-
_child_process = function () {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function os() {
|
|
29
|
-
const data = _interopRequireWildcard(require("os"));
|
|
30
|
-
|
|
31
|
-
os = function () {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
39
|
-
|
|
40
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifySignature = void 0;
|
|
4
|
+
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const os = require("os");
|
|
42
7
|
// $certificateInfo = (Get-AuthenticodeSignature 'xxx\yyy.exe'
|
|
43
8
|
// | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains("CN=siemens.com")})
|
|
44
9
|
// | Out-String ; if ($certificateInfo) { exit 0 } else { exit 1 }
|
|
45
10
|
function verifySignature(publisherNames, unescapedTempUpdateFile, logger) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
11
|
+
return new Promise(resolve => {
|
|
12
|
+
// Escape quotes and backticks in filenames to prevent user from breaking the
|
|
13
|
+
// arguments and perform a remote command injection.
|
|
14
|
+
//
|
|
15
|
+
// Consider example powershell command:
|
|
16
|
+
// ```powershell
|
|
17
|
+
// Get-AuthenticodeSignature 'C:\\path\\my-bad-';calc;'filename.exe'
|
|
18
|
+
// ```
|
|
19
|
+
// The above would work expected and find the file name, however, it will also execute `;calc;`
|
|
20
|
+
// command and start the calculator app.
|
|
21
|
+
//
|
|
22
|
+
// From Powershell quoting rules:
|
|
23
|
+
// https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7
|
|
24
|
+
// * Double quotes `"` are treated literally within single-quoted strings;
|
|
25
|
+
// * Single quotes can be escaped by doubling them: 'don''t' -> don't;
|
|
26
|
+
// * Backticks can be escaped by doubling them: 'A backtick (``) character';
|
|
27
|
+
//
|
|
28
|
+
// Also note that at this point the file has already been written to the disk, thus we are
|
|
29
|
+
// guaranteed that the path will not contains any illegal characters like <>:"/\|?*
|
|
30
|
+
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
|
31
|
+
const tempUpdateFile = unescapedTempUpdateFile.replace(/'/g, "''").replace(/`/g, "``");
|
|
32
|
+
// https://github.com/electron-userland/electron-builder/issues/2421
|
|
33
|
+
// https://github.com/electron-userland/electron-builder/issues/2535
|
|
34
|
+
child_process_1.execFile("powershell.exe", [
|
|
35
|
+
"-NoProfile",
|
|
36
|
+
"-NonInteractive",
|
|
37
|
+
"-InputFormat",
|
|
38
|
+
"None",
|
|
39
|
+
"-Command",
|
|
40
|
+
`Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress | ForEach-Object { [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($_)) }`,
|
|
41
|
+
], {
|
|
42
|
+
timeout: 20 * 1000,
|
|
43
|
+
}, (error, stdout, stderr) => {
|
|
44
|
+
try {
|
|
45
|
+
if (error != null || stderr) {
|
|
46
|
+
handleError(logger, error, stderr);
|
|
47
|
+
resolve(null);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const data = parseOut(Buffer.from(stdout, "base64").toString("utf-8"));
|
|
51
|
+
if (data.Status === 0) {
|
|
52
|
+
const name = builder_util_runtime_1.parseDn(data.SignerCertificate.Subject).get("CN");
|
|
53
|
+
if (publisherNames.includes(name)) {
|
|
54
|
+
resolve(null);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const result = `publisherNames: ${publisherNames.join(" | ")}, raw info: ` + JSON.stringify(data, (name, value) => (name === "RawData" ? undefined : value), 2);
|
|
59
|
+
logger.warn(`Sign verification failed, installer signed with incorrect certificate: ${result}`);
|
|
60
|
+
resolve(result);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
logger.warn(`Cannot execute Get-AuthenticodeSignature: ${error}. Ignoring signature validation due to unknown error.`);
|
|
64
|
+
resolve(null);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
98
68
|
});
|
|
99
|
-
});
|
|
100
69
|
}
|
|
101
|
-
|
|
70
|
+
exports.verifySignature = verifySignature;
|
|
102
71
|
function parseOut(out) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
delete data.Path;
|
|
119
|
-
return data;
|
|
72
|
+
const data = JSON.parse(out);
|
|
73
|
+
delete data.PrivateKey;
|
|
74
|
+
delete data.IsOSBinary;
|
|
75
|
+
delete data.SignatureType;
|
|
76
|
+
const signerCertificate = data.SignerCertificate;
|
|
77
|
+
if (signerCertificate != null) {
|
|
78
|
+
delete signerCertificate.Archived;
|
|
79
|
+
delete signerCertificate.Extensions;
|
|
80
|
+
delete signerCertificate.Handle;
|
|
81
|
+
delete signerCertificate.HasPrivateKey;
|
|
82
|
+
// duplicates data.SignerCertificate (contains RawData)
|
|
83
|
+
delete signerCertificate.SubjectName;
|
|
84
|
+
}
|
|
85
|
+
delete data.Path;
|
|
86
|
+
return data;
|
|
120
87
|
}
|
|
121
|
-
|
|
122
88
|
function handleError(logger, error, stderr) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (stderr) {
|
|
142
|
-
logger.warn(`Cannot execute Get-AuthenticodeSignature, stderr: ${stderr}. Ignoring signature validation due to unknown stderr.`);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
89
|
+
if (isOldWin6()) {
|
|
90
|
+
logger.warn(`Cannot execute Get-AuthenticodeSignature: ${error || stderr}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
child_process_1.execFileSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "ConvertTo-Json test"], { timeout: 10 * 1000 });
|
|
95
|
+
}
|
|
96
|
+
catch (testError) {
|
|
97
|
+
logger.warn(`Cannot execute ConvertTo-Json: ${testError.message}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (error != null) {
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
if (stderr) {
|
|
104
|
+
logger.warn(`Cannot execute Get-AuthenticodeSignature, stderr: ${stderr}. Ignoring signature validation due to unknown stderr.`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
145
107
|
}
|
|
146
|
-
|
|
147
108
|
function isOldWin6() {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
// __ts-babel@6.0.4
|
|
109
|
+
const winVersion = os.release();
|
|
110
|
+
return winVersion.startsWith("6.") && !winVersion.startsWith("6.3");
|
|
111
|
+
}
|
|
152
112
|
//# sourceMappingURL=windowsExecutableCodeSignatureVerifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/windowsExecutableCodeSignatureVerifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"windowsExecutableCodeSignatureVerifier.js","sourceRoot":"","sources":["../src/windowsExecutableCodeSignatureVerifier.ts"],"names":[],"mappings":";;;AAAA,+DAA8C;AAC9C,iDAAsD;AACtD,yBAAwB;AAGxB,8DAA8D;AAC9D,kJAAkJ;AAClJ,kEAAkE;AAClE,SAAgB,eAAe,CAAC,cAA6B,EAAE,uBAA+B,EAAE,MAAc;IAC5G,OAAO,IAAI,OAAO,CAAgB,OAAO,CAAC,EAAE;QAC1C,6EAA6E;QAC7E,oDAAoD;QACpD,EAAE;QACF,uCAAuC;QACvC,gBAAgB;QAChB,oEAAoE;QACpE,MAAM;QACN,+FAA+F;QAC/F,wCAAwC;QACxC,EAAE;QACF,iCAAiC;QACjC,2HAA2H;QAC3H,0EAA0E;QAC1E,sEAAsE;QACtE,4EAA4E;QAC5E,EAAE;QACF,0FAA0F;QAC1F,mFAAmF;QACnF,sEAAsE;QACtE,MAAM,cAAc,GAAG,uBAAuB,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAEtF,oEAAoE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AED,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,MAAM,KAAK,CAAA;KACZ;IAED,IAAI,MAAM,EAAE;QACV,MAAM,CAAC,IAAI,CAAC,qDAAqD,MAAM,wDAAwD,CAAC,CAAA;QAChI,OAAM;KACP;AACH,CAAC;AAED,SAAS,SAAS;IAChB,MAAM,UAAU,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;IAC/B,OAAO,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AACrE,CAAC","sourcesContent":["import { parseDn } from \"builder-util-runtime\"\nimport { execFile, execFileSync } from \"child_process\"\nimport * as os from \"os\"\nimport { Logger } from \"./main\"\n\n// $certificateInfo = (Get-AuthenticodeSignature 'xxx\\yyy.exe'\n// | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains(\"CN=siemens.com\")})\n// | Out-String ; if ($certificateInfo) { exit 0 } else { exit 1 }\nexport function verifySignature(publisherNames: Array<string>, unescapedTempUpdateFile: string, logger: Logger): Promise<string | null> {\n return new Promise<string | null>(resolve => {\n // Escape quotes and backticks in filenames to prevent user from breaking the\n // arguments and perform a remote command injection.\n //\n // Consider example powershell command:\n // ```powershell\n // Get-AuthenticodeSignature 'C:\\\\path\\\\my-bad-';calc;'filename.exe'\n // ```\n // The above would work expected and find the file name, however, it will also execute `;calc;`\n // command and start the calculator app.\n //\n // From Powershell quoting rules:\n // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7\n // * Double quotes `\"` are treated literally within single-quoted strings;\n // * Single quotes can be escaped by doubling them: 'don''t' -> don't;\n // * Backticks can be escaped by doubling them: 'A backtick (``) character';\n //\n // Also note that at this point the file has already been written to the disk, thus we are\n // guaranteed that the path will not contains any illegal characters like <>:\"/\\|?*\n // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file\n const tempUpdateFile = unescapedTempUpdateFile.replace(/'/g, \"''\").replace(/`/g, \"``\")\n\n // https://github.com/electron-userland/electron-builder/issues/2421\n // https://github.com/electron-userland/electron-builder/issues/2535\n execFile(\n \"powershell.exe\",\n [\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-InputFormat\",\n \"None\",\n \"-Command\",\n `Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress | ForEach-Object { [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($_)) }`,\n ],\n {\n timeout: 20 * 1000,\n },\n (error, stdout, stderr) => {\n try {\n if (error != null || stderr) {\n handleError(logger, error, stderr)\n resolve(null)\n return\n }\n\n const data = parseOut(Buffer.from(stdout, \"base64\").toString(\"utf-8\"))\n if (data.Status === 0) {\n const name = parseDn(data.SignerCertificate.Subject).get(\"CN\")!\n if (publisherNames.includes(name)) {\n resolve(null)\n return\n }\n }\n\n const result = `publisherNames: ${publisherNames.join(\" | \")}, raw info: ` + JSON.stringify(data, (name, value) => (name === \"RawData\" ? undefined : value), 2)\n logger.warn(`Sign verification failed, installer signed with incorrect certificate: ${result}`)\n resolve(result)\n } catch (e) {\n logger.warn(`Cannot execute Get-AuthenticodeSignature: ${error}. Ignoring signature validation due to unknown error.`)\n resolve(null)\n return\n }\n }\n )\n })\n}\n\nfunction parseOut(out: string): any {\n const data = JSON.parse(out)\n delete data.PrivateKey\n delete data.IsOSBinary\n delete data.SignatureType\n const signerCertificate = data.SignerCertificate\n if (signerCertificate != null) {\n delete signerCertificate.Archived\n delete signerCertificate.Extensions\n delete signerCertificate.Handle\n delete signerCertificate.HasPrivateKey\n // duplicates data.SignerCertificate (contains RawData)\n delete signerCertificate.SubjectName\n }\n delete data.Path\n return data\n}\n\nfunction handleError(logger: Logger, error: Error | null, stderr: string | null): void {\n if (isOldWin6()) {\n logger.warn(\n `Cannot execute Get-AuthenticodeSignature: ${error || stderr}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`\n )\n return\n }\n\n try {\n execFileSync(\"powershell.exe\", [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"ConvertTo-Json test\"], { timeout: 10 * 1000 })\n } catch (testError) {\n logger.warn(\n `Cannot execute ConvertTo-Json: ${testError.message}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`\n )\n return\n }\n\n if (error != null) {\n throw error\n }\n\n if (stderr) {\n logger.warn(`Cannot execute Get-AuthenticodeSignature, stderr: ${stderr}. Ignoring signature validation due to unknown stderr.`)\n return\n }\n}\n\nfunction isOldWin6(): boolean {\n const winVersion = os.release()\n return winVersion.startsWith(\"6.\") && !winVersion.startsWith(\"6.3\")\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
2
|
+
"name": "electron-updater",
|
|
3
|
+
"version": "4.3.9",
|
|
4
|
+
"description": "Cross platform updater for electron applications",
|
|
5
|
+
"main": "out/main.js",
|
|
6
|
+
"author": "Vladimir Krivosheev",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": "electron-userland/electron-builder",
|
|
9
|
+
"bugs": "https://github.com/electron-userland/electron-builder/issues",
|
|
10
|
+
"homepage": "https://github.com/electron-userland/electron-builder",
|
|
11
|
+
"files": [
|
|
12
|
+
"out"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@types/semver": "^7.3.5",
|
|
16
|
+
"builder-util-runtime": "8.7.5",
|
|
17
|
+
"fs-extra": "^10.0.0",
|
|
18
|
+
"js-yaml": "^4.1.0",
|
|
19
|
+
"lazy-val": "^1.0.4",
|
|
20
|
+
"lodash.escaperegexp": "^4.1.2",
|
|
21
|
+
"lodash.isequal": "^4.5.0",
|
|
22
|
+
"semver": "^7.3.5"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/fs-extra": "^9.0.11",
|
|
26
|
+
"@types/js-yaml": "^4.0.1",
|
|
27
|
+
"@types/lodash.escaperegexp": "^4.1.6",
|
|
28
|
+
"@types/lodash.isequal": "^4.5.5"
|
|
29
|
+
},
|
|
30
|
+
"typings": "./out/main.d.ts",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"tag": "next"
|
|
33
|
+
}
|
|
34
|
+
}
|