📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Fix invalid URL parsing in origin check and constrain AI tool period values
Blue Mouse9998827b4a0f
diff --git a/backend/apps/cloud/src/ai/ai.service.ts b/backend/apps/cloud/src/ai/ai.service.tsindex 9f04ae0fc..3f7093ee9 100644--- a/backend/apps/cloud/src/ai/ai.service.ts+++ b/backend/apps/cloud/src/ai/ai.service.ts@@ -300,7 +300,20 @@ Available columns for filters:.string().optional().describe('Specific goal ID, or omit to get all goals'),- period: z.string().optional().describe('Time period (default: 7d)'),+ period: z+ .enum([+ '1h',+ 'today',+ 'yesterday',+ '1d',+ '7d',+ '4w',+ '3M',+ '12M',+ '24M',+ ])+ .optional()+ .describe('Time period (default: 7d)'),from: z.string().optional()@@ -337,7 +350,20 @@ Available columns for filters:'Get funnel analysis data showing step-by-step conversions',inputSchema: z.object({funnelId: z.string().describe('Funnel ID to query'),- period: z.string().optional().describe('Time period (default: 7d)'),+ period: z+ .enum([+ '1h',+ 'today',+ 'yesterday',+ '1d',+ '7d',+ '4w',+ '3M',+ '12M',+ '24M',+ ])+ .optional()+ .describe('Time period (default: 7d)'),from: z.string().optional()diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.tsindex 7e53b16f0..7f2b10e1b 100644--- a/backend/apps/cloud/src/analytics/analytics.service.ts+++ b/backend/apps/cloud/src/analytics/analytics.service.ts@@ -400,7 +400,19 @@ export class AnalyticsService {)}} else {- const { hostname } = new URL(origin)+ const urlString = /^https?:\/\//i.test(origin)+ ? origin+ : `https://${origin}`++ let hostname: string++ try {+ hostname = new URL(urlString).hostname+ } catch {+ throw new BadRequestException(+ "This origin is prohibited by the project's origins policy",+ )+ }if (!isValidOrigin(origins, hostname)) {throw new BadRequestException(diff --git a/backend/apps/community/src/analytics/analytics.service.ts b/backend/apps/community/src/analytics/analytics.service.tsindex 606aee5b5..6fe1074c8 100644--- a/backend/apps/community/src/analytics/analytics.service.ts+++ b/backend/apps/community/src/analytics/analytics.service.ts@@ -381,7 +381,20 @@ export class AnalyticsService {)}} else {- const { hostname } = new URL(origin)+ const urlString = /^https?:\/\//i.test(origin)+ ? origin+ : `https://${origin}`++ let hostname: string++ try {+ hostname = new URL(urlString).hostname+ } catch {+ throw new BadRequestException(+ "This origin is prohibited by the project's origins policy",+ )+ }+if (!isValidOrigin(origins, hostname)) {throw new BadRequestException("This origin is prohibited by the project's origins policy",