Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): ignore invalid app protocol links

Josué5a9fa8cc96d2
diff --git a/desktop-app/src/__tests__/sandboxUiProtocolWindowPolicy.test.ts b/desktop-app/src/__tests__/sandboxUiProtocolWindowPolicy.test.ts
new file mode 100644
index 000000000..920d1e818
--- /dev/null
+++ b/desktop-app/src/__tests__/sandboxUiProtocolWindowPolicy.test.ts
@@ -0,0 +1,23 @@
+import { describe, expect, it } from 'vitest'
+import { shouldAcceptSandboxUiProtocolLink } from '../sandboxUiProtocolWindowPolicy.js'
+
+describe('sandbox UI protocol window policy', () => {
+ it('accepts valid app protocol links for window handoff', () => {
+ expect(
+ shouldAcceptSandboxUiProtocolLink(
+ 'evenfire://app/sandbox-recipes/task-board?path=%2Ftasks&team=team-1'
+ )
+ ).toBe(true)
+ })
+
+ it('rejects malformed app protocol links before a desktop window is requested', () => {
+ for (const rawUrl of [
+ 'evenfire://app/sandbox-recipes/task-board/',
+ 'evenfire://app/sandbox-recipes/task-board?path=%2Fsafe%2F..%2Fadmin',
+ 'evenfire://app/sandbox-recipes/task-board?team=other%2Fteam',
+ 'evenfire://app:444/sandbox-recipes/task-board',
+ ]) {
+ expect(shouldAcceptSandboxUiProtocolLink(rawUrl)).toBe(false)
+ }
+ })
+})
diff --git a/desktop-app/src/main.ts b/desktop-app/src/main.ts
index 63a067cc3..747221e4e 100644
--- a/desktop-app/src/main.ts
+++ b/desktop-app/src/main.ts
@@ -13,6 +13,7 @@ import {
SANDBOX_UI_DEEP_LINK_PROTOCOL,
parseSandboxUiDeepLink,
} from './sandboxUiDeepLinks.js'
+import { shouldAcceptSandboxUiProtocolLink } from './sandboxUiProtocolWindowPolicy.js'
import { installAdaptiveSystemIcon, resolveSystemIconPath } from './systemIcon.js'
const EVENFIRE_APP_NAME = 'Evenfire'
@@ -197,7 +198,8 @@ function handleEvenfireUrl(rawUrl: string): void {
const hostname = parsed.hostname.toLowerCase()
if (hostname === SANDBOX_UI_DEEP_LINK_HOST) {
- if (!handleSandboxUiDeepLink(rawUrl)) requestMainWindow()
+ if (!shouldAcceptSandboxUiProtocolLink(rawUrl)) return
+ handleSandboxUiDeepLink(rawUrl)
return
}
diff --git a/desktop-app/src/sandboxUiProtocolWindowPolicy.ts b/desktop-app/src/sandboxUiProtocolWindowPolicy.ts
new file mode 100644
index 000000000..434a6f776
--- /dev/null
+++ b/desktop-app/src/sandboxUiProtocolWindowPolicy.ts
@@ -0,0 +1,5 @@
+import { parseSandboxUiDeepLink } from './sandboxUiDeepLinks.js'
+
+export function shouldAcceptSandboxUiProtocolLink(rawUrl: string): boolean {
+ return parseSandboxUiDeepLink(rawUrl) !== null
+}