Use fuses to disable ELECTRON_RUN_AS_NODE

This commit is contained in:
Fedor Indutny 2021-05-07 11:04:38 -07:00 committed by GitHub
parent 470eab8352
commit dc695732bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View file

@ -12,7 +12,7 @@
},
"main": "main.js",
"scripts": {
"postinstall": "yarn build:acknowledgments && snyk protect && patch-package && electron-builder install-app-deps && rimraf node_modules/dtrace-provider",
"postinstall": "yarn build:acknowledgments && yarn build:fuses && snyk protect && patch-package && electron-builder install-app-deps && rimraf node_modules/dtrace-provider",
"postuninstall": "yarn build:acknowledgments",
"start": "electron .",
"grunt": "grunt",
@ -47,7 +47,7 @@
"dev:typed-scss": "yarn build:typed-scss -w",
"dev:storybook": "cross-env SIGNAL_ENV=storybook start-storybook -p 6006 -s ./",
"storybook:axe": "build-storybook && axe-storybook",
"build": "run-s --print-label build:grunt build:typed-scss build:webpack build:release build:zip",
"build": "run-s --print-label build:grunt build:typed-scss build:webpack build:fuses build:release build:zip",
"build:acknowledgments": "node scripts/generate-acknowledgments.js",
"build:dev": "run-s --print-label build:grunt build:typed-scss build:webpack",
"build:grunt": "yarn grunt",
@ -58,6 +58,7 @@
"build:webpack:sql-worker": "cross-env NODE_ENV=production webpack -c webpack-sql-worker.config.ts",
"build:electron": "electron-builder --config.extraMetadata.environment=$SIGNAL_ENV",
"build:release": "cross-env SIGNAL_ENV=production yarn build:electron -- --config.directories.output=release",
"build:fuses": "node scripts/fuse-electron.js",
"build:zip": "node scripts/zip-macos-release.js",
"preverify:ts": "yarn build:typed-scss",
"verify": "run-p --print-label verify:*",
@ -171,6 +172,7 @@
"@babel/preset-react": "7.7.4",
"@babel/preset-typescript": "7.7.7",
"@chanzuckerberg/axe-storybook-testing": "3.0.2",
"@electron/fuses": "1.0.1",
"@storybook/addon-actions": "5.1.11",
"@storybook/addon-knobs": "5.1.11",
"@storybook/addons": "5.1.11",

13
scripts/fuse-electron.js Normal file
View file

@ -0,0 +1,13 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-console */
const { flipFuses, FuseVersion, FuseV1Options } = require('@electron/fuses');
flipFuses(require('electron'), {
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false, // Disables ELECTRON_RUN_AS_NODE
}).catch(error => {
console.error(error.stack);
process.exit(1);
});

View file

@ -1185,6 +1185,13 @@
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz#8f03a22a04de437254e8ce8cc84ba39689288752"
integrity sha512-HyYEUDeIj5rRQU2Hk5HTB2uHsbRQpF70nvMhVzi+VJR0X+xNEhjPui4/kBf3VeH/wqD28PT4sVOm8qqLjBrSZg==
"@electron/fuses@1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@electron/fuses/-/fuses-1.0.1.tgz#b8115682aca2a81e3cbdc95121f5abb1b35f2bb5"
integrity sha512-UNfNOhNRzoxwrfV+4oUify8ajDgGMymzgjvyFnPIMv4ItLPi1O8aTG/VbBJVopIt3l4fjl0TeP63BBP3+u/ZOw==
dependencies:
fs-extra "^9.0.1"
"@electron/get@^1.0.1":
version "1.7.6"
resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.7.6.tgz#f1c8e87cbef0bce78644159b72340821d52066b3"