From 0e964f07b3666f0498ebc1588be84af20dac139d Mon Sep 17 00:00:00 2001 From: Johannes Klein Agents Date: Thu, 26 Nov 2026 11:33:12 +0100 Subject: [PATCH] Set Electron Fuses in the packaged app (#373) electron-builder sets six fuses through build.electronFuses: no RunAsNode, no NODE_OPTIONS, no Node inspect flags, cookie encryption on, and the app loads only from an asar that passes integrity validation. A pack test asserts the exact block. Co-Authored-By: Claude Opus 5.5 --- package.json | 8 ++++++++ src/pack.test.ts | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0150b7f6..20d1a9d1 100644 --- a/package.json +++ b/package.json @@ -120,6 +120,14 @@ "appId": "org.jtklein.raxmlGUI2", "productName": "raxmlGUI", "afterSign": "./scripts/notarize.js", + "electronFuses": { + "runAsNode": false, + "enableCookieEncryption": true, + "enableNodeOptionsEnvironmentVariable": false, + "enableNodeCliInspectArguments": false, + "enableEmbeddedAsarIntegrityValidation": true, + "onlyLoadAppFromAsar": true + }, "extends": null, "directories": { "buildResources": "public", diff --git a/src/pack.test.ts b/src/pack.test.ts index b77fee50..e645655c 100644 --- a/src/pack.test.ts +++ b/src/pack.test.ts @@ -4,7 +4,7 @@ import path from 'path'; import { getConfig } from 'app-builder-lib/out/util/config/config'; import type { FileSet } from 'app-builder-lib'; -import { scripts } from '../package.json'; +import { build, scripts } from '../package.json'; // electron-builder does not declare its pack matchers, so they load untyped. const { getMainFileMatchers, getNodeModuleFileMatcher } = require( 'app-builder-lib/out/fileMatcher' ); @@ -101,6 +101,17 @@ it( 'packs the built shell and the production dependencies', async () => { ] ); } ); +it( 'sets the Electron Fuses of the packaged app', () => { + expect( build.electronFuses ).toEqual( { + runAsNode: false, + enableCookieEncryption: true, + enableNodeOptionsEnvironmentVariable: false, + enableNodeCliInspectArguments: false, + enableEmbeddedAsarIntegrityValidation: true, + onlyLoadAppFromAsar: true, + } ); +} ); + it( 'pack scripts build the shell, then run electron-builder', () => { expect( scripts.build ).toBe( 'electron-vite build' );