mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
fix(desktop): stop the packaged app from running as plain Node
Cookie encryption keeps the key in the app's Keychain item, which macOS hands to the app's signed binary. With RunAsNode and the inspector fuses on, any local process could start that binary as Node (ELECTRON_RUN_AS_NODE=1) or with --inspect and read the key. Turn RunAsNode off everywhere and the inspector off outside Beta, which keeps it for the startup benchmark's Node timings like its on-request debugging port. NODE_OPTIONS stays on: packaged Electron already drops all but two harmless options, and the fuse would also strip NODE_EXTRA_CA_CERTS from the CLI's environment.
This commit is contained in:
parent
59145a728f
commit
663c7ee045
2 changed files with 26 additions and 1 deletions
|
|
@ -80,6 +80,20 @@ test.each(channels)("channel identity for $channel", ({ channel, appId, feed })
|
|||
expect(config.deb?.fpm).not.toContain("--rpm-rpmbuild-define=_build_id_links none")
|
||||
})
|
||||
|
||||
test.each([
|
||||
{ channel: "dev", inspect: false },
|
||||
{ channel: "beta", inspect: true },
|
||||
{ channel: "prod", inspect: false },
|
||||
])("Electron fuses for $channel", ({ channel, inspect }) => {
|
||||
// Absent keys keep Electron's defaults: NODE_OPTIONS stays on, the asar and file: fuses stay as they are.
|
||||
expect(load(channel).electronFuses).toEqual({
|
||||
enableCookieEncryption: true,
|
||||
runAsNode: false,
|
||||
enableNodeCliInspectArguments: inspect,
|
||||
resetAdHocDarwinSignature: true,
|
||||
})
|
||||
})
|
||||
|
||||
test("legacy Linux launcher stays hidden", async () => {
|
||||
const desktop = await Bun.file(path.join(import.meta.dirname, "resources/linux/opencode-desktop.desktop")).text()
|
||||
expect(desktop).toContain("Exec=/opt/OpenCode/ai.opencode %U")
|
||||
|
|
|
|||
|
|
@ -113,7 +113,18 @@ const getBase = (appId: string): Configuration => {
|
|||
// https://www.electronjs.org/docs/latest/tutorial/fuses#cookieencryption
|
||||
// Flipping a fuse breaks the macOS signature. A build without a signing identity is not signed again, so re-sign it
|
||||
// ad hoc or Apple Silicon refuses to launch it. A signed build is signed again after the fuses anyway.
|
||||
electronFuses: { enableCookieEncryption: true, resetAdHocDarwinSignature: true },
|
||||
electronFuses: {
|
||||
enableCookieEncryption: true,
|
||||
// Started as plain Node (ELECTRON_RUN_AS_NODE) or with an inspector, the signed binary would run any code under
|
||||
// the app's identity, which macOS lets read the app's Keychain key and so every cookie. Nothing runs the app as
|
||||
// Node: the CLI is its own executable. Beta keeps --inspect, as it keeps its on-request debugging port, for the
|
||||
// startup benchmark's Node timings (perf/startup.bench.ts).
|
||||
runAsNode: false,
|
||||
enableNodeCliInspectArguments: resolveChannel() === "beta",
|
||||
// NODE_OPTIONS stays: a packaged app already ignores every option but --http-parser and --max-http-header-size,
|
||||
// and turning the fuse off would also strip NODE_EXTRA_CA_CERTS from the environment the CLI and its terminals get.
|
||||
resetAdHocDarwinSignature: true,
|
||||
},
|
||||
afterPack: async (context) => {
|
||||
const arch = Arch[context.arch]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue