Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: validate developer app logo URLs
Richie McIlroy13b8c565b2d2
diff --git a/apps/web/__tests__/unit/agent-api.test.ts b/apps/web/__tests__/unit/agent-api.test.tsindex 11292f6a7..c0980ebd2 100644--- a/apps/web/__tests__/unit/agent-api.test.ts+++ b/apps/web/__tests__/unit/agent-api.test.ts@@ -8,6 +8,7 @@ import {decodeAgentCursor,encodeAgentCursor,escapeAgentLikePattern,+ isAgentHttpUrl,parseAgentDate,parseAgentLimit,parseAgentVtt,@@ -54,6 +55,13 @@ describe("agent API normalization", () => {expect(escapeAgentLikePattern("100%_ready!")).toBe("100!%!_ready!!");});+ it("accepts only absolute HTTP developer logo URLs", () => {+ expect(isAgentHttpUrl("https://cdn.example.com/logo.png")).toBe(true);+ expect(isAgentHttpUrl("http://localhost:3000/logo.png")).toBe(true);+ expect(isAgentHttpUrl("javascript:alert(1)")).toBe(false);+ expect(isAgentHttpUrl("/logo.png")).toBe(false);+ });+it("normalizes VTT into millisecond cues and text", () => {const cues = parseAgentVtt("WEBVTT\r\n\r\n1\r\n00:00:01.250 --> 00:00:03.500 align:start\r\nHello <b>agent</b>\r\n\r\n2\r\n00:00:04,000 --> 00:00:05,125\r\nSecond line\r\n",diff --git a/apps/web/app/api/v1/[...route]/route.ts b/apps/web/app/api/v1/[...route]/route.tsindex 1076f00ea..3a99a586e 100644--- a/apps/web/app/api/v1/[...route]/route.ts+++ b/apps/web/app/api/v1/[...route]/route.ts@@ -77,6 +77,7 @@ import {decodeAgentCursor,encodeAgentCursor,escapeAgentLikePattern,+ isAgentHttpUrl,normalizeAgentMetadata,parseAgentDate,parseAgentLimit,@@ -3733,10 +3734,14 @@ const AgentManagementHandlersLive = HttpApiBuilder.group();}const name = payload.name?.trim();+ const logoUrl =+ payload.logoUrl === null ? null : payload.logoUrl?.trim();if ((name !== undefined &&(name.length === 0 || name.length > 255)) ||- (payload.logoUrl?.length ?? 0) > 1024+ (logoUrl !== undefined &&+ logoUrl !== null &&+ (logoUrl.length > 1024 || !isAgentHttpUrl(logoUrl)))) {return yield* badRequest(requestId,@@ -3747,7 +3752,7 @@ const AgentManagementHandlersLive = HttpApiBuilder.group(principal,operation: "update_developer_app",idempotencyKey: yield* requestIdempotencyKey,- request: { path, ...payload, name },+ request: { path, ...payload, name, logoUrl },requestId,decodeReplay: decodeMutationResponse,execute: async (tx) => {@@ -3770,7 +3775,7 @@ const AgentManagementHandlersLive = HttpApiBuilder.group(.set({name,environment: payload.environment,- logoUrl: payload.logoUrl,+ logoUrl,updatedAt: now,}).where(eq(Db.developerApps.id, path.appId));diff --git a/apps/web/lib/agent-api.ts b/apps/web/lib/agent-api.tsindex 1eace33ec..f9dd23a57 100644--- a/apps/web/lib/agent-api.ts+++ b/apps/web/lib/agent-api.ts@@ -42,6 +42,18 @@ export const parseAgentLimit = (value: string | undefined) => {export const escapeAgentLikePattern = (value: string) =>value.replace(/[!%_]/g, (match) => `!${match}`);+export const isAgentHttpUrl = (value: string) => {+ try {+ const url = new URL(value);+ return (+ (url.protocol === "http:" || url.protocol === "https:") &&+ url.hostname.length > 0+ );+ } catch {+ return false;+ }+};+const parseAgentUtcDate = (value: string) => {const match = value.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,3}))?Z$/,