feat: add Socket Firewall integration for secure package installation#1880
feat: add Socket Firewall integration for secure package installation#1880MarshallOfSound wants to merge 4 commits intomainfrom
Conversation
Integrates Socket Firewall (https://github.com/SocketDev/sfw-free) to protect against supply chain attacks when installing npm dependencies from Fiddle gists. Changes: - Add `sfw` as a dependency for wrapping npm/yarn commands - Add `isUsingSocketFirewall` setting (enabled by default) - Modify `addModules` to use sfw when enabled and available - Add IPC handler `NPM_IS_SFW_INSTALLED` to check sfw availability - Add settings toggle in Execution settings panel - Add comprehensive tests for sfw integration When enabled, Fiddle runs `sfw npm install` instead of `npm install`, which scans packages during installation and blocks malicious ones. Falls back to direct npm/yarn if sfw is not installed on the system. https://claude.ai/code/session_01K6g5VZoNQRGLr4stRvHEVw
The sfw npm wrapper is MIT licensed, but the sfw-free binary it downloads at runtime is under the PolyForm Shield License 1.0.0. Include the full license text to satisfy the Notices provision. https://claude.ai/code/session_01K6g5VZoNQRGLr4stRvHEVw
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Bundle the sfw CLI script (node_modules/sfw/dist/sfw.mjs) into the webpack output via CopyPlugin so it ships with the packaged Electron app. At runtime, resolve the embedded path and run it via the system Node.js (`node sfw.mjs npm install ...`) rather than relying on a globally installed `sfw` binary. This means Socket Firewall works out of the box — users no longer need to `npm install -g sfw`. https://claude.ai/code/session_01K6g5VZoNQRGLr4stRvHEVw
sfw.mjs reads ../package.json at runtime to populate its version string, so the bundled layout must mirror node_modules/sfw/ (dist/sfw.mjs plus a sibling package.json) — copying just sfw.mjs leaves it looking for package.json one directory too high and crashes with ENOENT. In packaged builds, sfw.mjs also has to live outside the asar archive because system Node can't read asar. Mark .webpack/sfw/** as unpacked and translate app.asar -> app.asar.unpacked when resolving the path. The glob needs the explicit .webpack segment because minimatch's globstar skips dot-prefixed directories by default. Also update the settings copy now that sfw ships with the app.
Summary
Integrates Socket Firewall into Electron Fiddle to protect against supply chain attacks when installing npm dependencies from fiddle gists. The
sfwCLI is embedded with the app — no global install required.When enabled (the default), package installations are routed through sfw, which scans packages during installation and blocks malicious dependencies before they can execute (e.g.,
node sfw.mjs npm installinstead ofnpm install).Slack thread: https://electronhq.slack.com/archives/C3ANJ97H6/p1775171094186889?thread_ts=1775164754.105949&cid=C3ANJ97H6
Key Changes
sfwnpm package's bundled script (sfw.mjs) is copied into the webpack output via CopyPlugin, so it ships with the packaged appgetSfwPath()insrc/main/npm.ts— resolves the embedded script path relative to__dirnameand verifies it exists withfs.existsSyncnode sfw.mjs npm install ...using the systemnode(notprocess.execPath, which is the Electron binary)isUsingSocketFirewallpersisted to localStorage (defaults totrue)NPM_IS_SFW_INSTALLEDevent,useSocketFirewallflag threaded throughPMOperationOptionsand the module installation pipelineTHIRD_PARTY_NOTICES.mdwith the full PolyForm Shield License 1.0.0 text (for the sfw-free binary downloaded at runtime by the sfw wrapper)getSfwPath(),getIsSfwInstalled(), andaddModules()with sfw enabled/disabled/missing scenariosTest plan
yarn test— all npm.spec.ts tests passhttps://claude.ai/code/session_01K6g5VZoNQRGLr4stRvHEVw