Skip to content

armgit / ente

Public Imported from GitHub
0

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

Reduce log noise

Manav Rathi9362a4b9d368
diff --git a/infra/workers/cast-albums/src/index.ts b/infra/workers/cast-albums/src/index.ts
index 921db01a54..750158d966 100644
--- a/infra/workers/cast-albums/src/index.ts
+++ b/infra/workers/cast-albums/src/index.ts
@@ -42,21 +42,22 @@ const isAllowedOrigin = (origin: string | null) => {
const handleGET = async (request: Request) => {
const url = new URL(request.url);
- const castToken =
- request.headers.get("X-Cast-Access-Token") ??
- url.searchParams.get("castToken");
+
+ const fileID = url.searchParams.get("fileID");
+ if (!fileID) return new Response(null, { status: 400 });
+
+ let castToken = request.headers.get("X-Cast-Access-Token");
if (!castToken) {
- console.error("No cast token provided");
- return new Response(null, { status: 400 });
+ console.warn("Using deprecated castToken query param");
+ castToken = url.searchParams.get("castToken");
}
- const pathname = url.pathname;
- const fileID = url.searchParams.get("fileID");
- if (!fileID) {
- console.error("No fileID provided");
+ if (!castToken) {
+ console.error("No cast token provided");
return new Response(null, { status: 400 });
}
+ const pathname = url.pathname;
const params = new URLSearchParams({ castToken });
let response = await fetch(
diff --git a/infra/workers/public-albums/src/index.ts b/infra/workers/public-albums/src/index.ts
index 6946212f65..228d09fca3 100644
--- a/infra/workers/public-albums/src/index.ts
+++ b/infra/workers/public-albums/src/index.ts
@@ -63,6 +63,9 @@ const areAllowedHeaders = (headers: string | null) => {
const handleGET = async (request: Request) => {
const url = new URL(request.url);
+ const fileID = url.searchParams.get("fileID");
+ if (!fileID) return new Response(null, { status: 400 });
+
let accessToken = request.headers.get("X-Auth-Access-Token");
if (accessToken === undefined) {
console.warn("Using deprecated accessToken query param");
@@ -81,11 +84,6 @@ const handleGET = async (request: Request) => {
}
const pathname = url.pathname;
- const fileID = url.searchParams.get("fileID");
- if (!fileID) {
- console.error("No fileID provided");
- return new Response(null, { status: 400 });
- }
const params = new URLSearchParams();
if (accessToken) params.set("accessToken", accessToken);
diff --git a/infra/workers/thumbnails/src/index.ts b/infra/workers/thumbnails/src/index.ts
index ac91628d9e..395786bccf 100644
--- a/infra/workers/thumbnails/src/index.ts
+++ b/infra/workers/thumbnails/src/index.ts
@@ -63,6 +63,11 @@ const areAllowedHeaders = (headers: string | null) => {
const handleGET = async (request: Request) => {
const url = new URL(request.url);
+ // Random bots keep trying to pentest causing noise in the logs. If the
+ // request doesn't have a fileID, we can just safely ignore it thereafter.
+ const fileID = url.searchParams.get("fileID");
+ if (!fileID) return new Response(null, { status: 400 });
+
let token = request.headers.get("X-Auth-Token");
if (!token) {
console.warn("Using deprecated token query param");
@@ -74,12 +79,6 @@ const handleGET = async (request: Request) => {
// return new Response(null, { status: 400 });
}
- const fileID = url.searchParams.get("fileID");
- if (!fileID) {
- console.error("No fileID provided");
- return new Response(null, { status: 400 });
- }
-
// We forward the auth token as a query parameter to museum. This is so that
// it does not get preserved when museum does a redirect to the presigned S3
// URL that serves the actual thumbnail.