fix(desktop): harden Electron Windows runtime#152
Conversation
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 2 minutes and 38 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (23)
📝 WalkthroughWalkthroughThe PR introduces a custom Changes
Sequence DiagramsequenceDiagram
participant App as Electron App
participant Main as Main Process
participant Store as Store (Lazy)
participant IPC as IPC Handlers
participant Preload as Preload
participant Renderer as Renderer
participant StartupState as Startup State
App->>Main: app.whenReady()
Main->>IPC: registerIpcHandlers(deps)
Main->>Main: registerRendererProtocol()
Main->>Main: createMainWindow()
Main->>Preload: Window created with preload
Renderer->>StartupState: initialize()
StartupState->>Preload: window.api.getWindowConfig()
Preload->>IPC: ipcRenderer.invoke("get-window-config")
IPC->>Store: deps.getWindowConfig()
Store-->>IPC: { updaterEnabled, wslEnabled }
IPC-->>Preload: config
Preload-->>StartupState: config
par Deep Links Fetch
StartupState->>Preload: window.api.consumeInitialDeepLinks()
Preload->>IPC: ipcRenderer.invoke("consume-initial-deep-links")
IPC->>Main: deps.consumeInitialDeepLinks()
Main-->>IPC: string[]
IPC-->>Preload: deep links
Preload-->>StartupState: deep links
end
StartupState->>StartupState: ready.resolve()
Renderer->>StartupState: await ready
Renderer->>Renderer: render() with startupState
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
582352d to
d290e88
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/desktop-electron/src/main/renderer-protocol.test.ts`:
- Around line 20-30: Add a test in renderer-protocol.test.ts that passes
malformed/invalid URL inputs to resolveRendererFile and asserts it returns null
(not throwing); specifically call resolveRendererFile(root, "not-a-url") and
maybe other bad inputs like an empty string or a truncated scheme (e.g.,
"pawwork-renderer:/bad") and assert toBeNull for each, ensuring
resolveRendererFile handles URL parsing failures gracefully.
In `@packages/desktop-electron/src/main/renderer-protocol.ts`:
- Around line 11-27: In resolveRendererFile, after decoding the pathname with
decodeURIComponent(url.pathname) add an explicit null-byte check (e.g., if
(path.includes('\0')) return null) to reject inputs containing %00 before any
fs/path operations; update or add unit tests that call resolveRendererFile with
null-byte attempts (for example "pawwork-renderer://renderer/index.html%00.js")
to assert it returns null.
In `@packages/desktop-electron/src/main/store.test.ts`:
- Around line 27-34: The failing assertion is caused by shared cached
default-store state; update the test to use a test-unique store name when
calling getStore so constructorCalls is isolated per test (e.g., generate a
unique string and pass it into getStore instead of relying on the default), then
assert constructorCalls transitions 0 -> 1 accordingly; locate and modify the
test invoking getStore and the constructorCalls assertions in store.test.ts to
supply a unique name for each run.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4b692009-d89b-454a-9c9f-9a1b7a42537a
📒 Files selected for processing (22)
packages/desktop-electron/electron.vite.config.tspackages/desktop-electron/src/main/index.tspackages/desktop-electron/src/main/ipc-window-config.test.tspackages/desktop-electron/src/main/ipc.tspackages/desktop-electron/src/main/renderer-protocol.test.tspackages/desktop-electron/src/main/renderer-protocol.tspackages/desktop-electron/src/main/server-store.test.tspackages/desktop-electron/src/main/server.test.tspackages/desktop-electron/src/main/server.tspackages/desktop-electron/src/main/store.test.tspackages/desktop-electron/src/main/store.tspackages/desktop-electron/src/main/windows-protocol.test.tspackages/desktop-electron/src/main/windows-security.test.tspackages/desktop-electron/src/main/windows.tspackages/desktop-electron/src/preload/index.tspackages/desktop-electron/src/preload/types.tspackages/desktop-electron/src/renderer/env.d.tspackages/desktop-electron/src/renderer/html.test.tspackages/desktop-electron/src/renderer/index.tsxpackages/desktop-electron/src/renderer/startup-state.test.tspackages/desktop-electron/src/renderer/startup-state.tspackages/desktop-electron/src/renderer/updater.ts
💤 Files with no reviewable changes (2)
- packages/desktop-electron/src/main/store.ts
- packages/desktop-electron/src/renderer/env.d.ts
Astro-Han
left a comment
There was a problem hiding this comment.
Nits only; the three-commit slice is well scoped and the threat model is coherent. Findings below are mostly defensive-hardening gaps and test-strength nitpicks.
366455c to
c7e7496
Compare
c7e7496 to
d85e2c7
Compare
Summary
electron-storeso settings storage is not constructed during main-process module import.pawwork-renderer://rendererorigin and narrow sidecar CORS to that origin.Why
This is direction 2 from #141: Electron/process-layer Windows hardening. It keeps the PR scoped to upstream candidates #23373, #23523, and #23516. It does not include #23633, #23396, Windows ARM64, or the opencode-layer work already covered by #148.
Related Issue
Closes #141. PR #148 already covered the opencode-layer Windows compatibility track; this PR covers the remaining Electron/process-layer Windows hardening track.
How To Verify
cd packages/desktop-electron && bun testcd packages/desktop-electron && bun run typecheckcd packages/desktop-electron && bun run buildScreenshots/Recordings
N/A, desktop runtime hardening only.
Checklist
Summary by CodeRabbit
New Features
Improvements