Skip to content

The agent that grows with you

fix(desktop): preserve Electron Framework JIT entitlements

ryrenz60800e87cab8
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.py
index 05da449f17f..a4ad9940a58 100644
--- a/hermes_cli/main_desktop.py
+++ b/hermes_cli/main_desktop.py
@@ -647,8 +647,10 @@ def _desktop_macos_local_codesign(app: Path, *, desktop_dir: Path, identity: str
if p.suffix in {".framework", ".app"}:
bundles.add(p)
for bundle in sorted(bundles, key=lambda p: len(p.parts), reverse=True):
- ent = ent_inherit if bundle.suffix == ".app" and "Helper" in bundle.name else None
- sign_path(bundle, entitlements=ent, identifier=_desktop_macos_bundle_id(bundle))
+ # Every nested bundle takes the inherit plist, frameworks included: under the hardened
+ # runtime Electron Framework needs allow-jit in its own signature, and signing it with
+ # no entitlements strips what electron-builder's afterSign step applies in a real build.
+ sign_path(bundle, entitlements=ent_inherit, identifier=_desktop_macos_bundle_id(bundle))
# 3) The main bundle, with the app's own entitlements.
sign_path(app, entitlements=ent_main, identifier=_desktop_macos_bundle_id(app))
diff --git a/tests/hermes_cli/test_gui_command.py b/tests/hermes_cli/test_gui_command.py
index 8f4488879f5..f0b38153266 100644
--- a/tests/hermes_cli/test_gui_command.py
+++ b/tests/hermes_cli/test_gui_command.py
@@ -381,6 +381,9 @@ def _make_signable_app(desktop_dir: Path) -> Path:
helper = app / "Contents" / "Frameworks" / "Hermes Helper.app"
_write_info_plist(helper, "com.nousresearch.hermes.helper")
+ framework = app / "Contents" / "Frameworks" / "Electron Framework.framework"
+ _write_info_plist(framework, "com.github.Electron.framework")
+
native_dir = app / "Contents" / "Resources" / "app.asar.unpacked" / "node_modules" / "pty"
native_dir.mkdir(parents=True)
(native_dir / "pty.node").write_text("", encoding="utf-8")
@@ -420,6 +423,23 @@ def test_desktop_macos_local_codesign_signs_native_binaries(tmp_path, monkeypatc
assert str(app / "Contents" / "Frameworks" / "chrome_crashpad_handler") in signed
+def test_desktop_macos_local_codesign_preserves_framework_entitlements(tmp_path, monkeypatch):
+ """Hardened runtime frameworks must retain Electron's JIT entitlements."""
+ desktop_dir = tmp_path / "apps" / "desktop"
+ app = _make_signable_app(desktop_dir)
+ calls = _collect_codesign_calls(monkeypatch)
+
+ assert main_desktop._desktop_macos_local_codesign(app, desktop_dir=desktop_dir) is True
+
+ framework = app / "Contents" / "Frameworks" / "Electron Framework.framework"
+ framework_call = next(call for call in calls if call[-1] == str(framework))
+ assert framework_call[5:7] == ["--options", "runtime"]
+ assert framework_call[7:9] == [
+ "--entitlements",
+ str(desktop_dir / "electron" / "entitlements.mac.inherit.plist"),
+ ]
+
+
# --- desktop --setup-tcc-identity ------------------------------------------