Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Restrict Sentry reporter upstream hosts

Manav Rathiad593c6f8b6a
diff --git a/infra/workers/sentry-reporter/src/index.ts b/infra/workers/sentry-reporter/src/index.ts
index f09cd6e9aa..bfe8eeef23 100644
--- a/infra/workers/sentry-reporter/src/index.ts
+++ b/infra/workers/sentry-reporter/src/index.ts
@@ -26,6 +26,7 @@ const handlePOST = async (request: Request) => {
const originalBody = await request.text();
const originalDSNString = extractDSN(originalBody);
const { body, dsn } = mapDSN(originalBody, originalDSNString);
+ if (!isEnteSentryDSN(dsn)) return new Response(null, { status: 400 });
const projectId = parseInt(dsn.pathname?.slice(1)?.split("/")[0] ?? "1");
@@ -82,6 +83,10 @@ const mapDSN = (originalBody: string, originalDSNString: string) => {
return { body, dsn };
};
+const isEnteSentryDSN = (dsn: URL) =>
+ dsn.protocol === "https:" &&
+ (dsn.hostname === "sentry.ente.com" || dsn.hostname === "sentry.ente.io");
+
const dsnMappings: Record<string, string> = {
// photos-mobile
"https://[email protected]/4":