Skip to content

Commit 48cbb12

Browse files
authored
fix: replace update-notifier with simple-update notifier due to dependency vulnerability (#7078)
1 parent f205998 commit 48cbb12

File tree

4 files changed

+51
-392
lines changed

4 files changed

+51
-392
lines changed

.changeset/fluffy-cobras-beg.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"electron-builder": patch
3+
---
4+
5+
fix: replace update-notifier with simple-update-notifier due to security alert

packages/electron-builder/package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@
6060
"is-ci": "^3.0.0",
6161
"lazy-val": "^1.0.5",
6262
"read-config-file": "6.2.0",
63-
"update-notifier": "^5.1.0",
64-
"yargs": "^17.0.1"
63+
"simple-update-notifier": "^1.0.7",
64+
"yargs": "^17.5.1"
6565
},
6666
"devDependencies": {
6767
"@types/fs-extra": "9.0.13",
68-
"@types/is-ci": "3.0.0",
69-
"@types/update-notifier": "5.1.0"
68+
"@types/is-ci": "3.0.0"
7069
},
7170
"typings": "./out/index.d.ts",
7271
"publishConfig": {

packages/electron-builder/src/cli/cli.ts

+9-22
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import { InvalidConfigurationError, log } from "builder-util"
44
import * as chalk from "chalk"
55
import { getElectronVersion } from "app-builder-lib/out/electron/electronVersion"
6-
import { pathExists, readJson } from "fs-extra"
6+
import { readJson } from "fs-extra"
77
import * as isCi from "is-ci"
88
import * as path from "path"
99
import { loadEnv } from "read-config-file"
10-
import * as updateNotifier from "update-notifier"
1110
import { ExecError } from "builder-util/out/util"
1211
import { build, configureBuildCommand, createYargs } from "../builder"
1312
import { createSelfSignedCert } from "./create-self-signed-cert"
@@ -47,7 +46,7 @@ void createYargs()
4746

4847
function wrap(task: (args: any) => Promise<any>) {
4948
return (args: any) => {
50-
checkIsOutdated()
49+
checkIsOutdated().catch(e => log.warn({ error: e }, "cannot check updates"))
5150
loadEnv(path.join(process.cwd(), "electron-builder.env"))
5251
.then(() => task(args))
5352
.catch(error => {
@@ -63,29 +62,17 @@ function wrap(task: (args: any) => Promise<any>) {
6362
}
6463
}
6564

66-
function checkIsOutdated() {
65+
async function checkIsOutdated() {
6766
if (isCi || process.env.NO_UPDATE_NOTIFIER != null) {
6867
return
6968
}
7069

71-
readJson(path.join(__dirname, "..", "..", "package.json"))
72-
.then(async it => {
73-
if (it.version === "0.0.0-semantic-release") {
74-
return
75-
}
76-
77-
const packageManager = (await pathExists(path.join(__dirname, "..", "..", "package-lock.json"))) ? "npm" : "yarn"
78-
79-
const notifier = updateNotifier({ pkg: it })
80-
if (notifier.update != null) {
81-
notifier.notify({
82-
message: `Update available ${chalk.dim(notifier.update.current)}${chalk.reset(" → ")}${chalk.green(notifier.update.latest)} \nRun ${chalk.cyan(
83-
`${packageManager} upgrade electron-builder`
84-
)} to update`,
85-
})
86-
}
87-
})
88-
.catch(e => log.warn({ error: e }, "cannot check updates"))
70+
const pkg = await readJson(path.join(__dirname, "..", "..", "package.json"))
71+
if (pkg.version === "0.0.0-semantic-release") {
72+
return
73+
}
74+
const UpdateNotifier = require("simple-update-notifier")
75+
await UpdateNotifier({ pkg })
8976
}
9077

9178
async function rebuildAppNativeCode(args: any) {

0 commit comments

Comments
 (0)