From 0fc87fa37ff46dd7f7cd86dc5834578858d238fd Mon Sep 17 00:00:00 2001 From: nexryai <61890205+nexryai@users.noreply.github.com> Date: Fri, 9 Jan 2026 12:59:51 +0000 Subject: [PATCH] Remove outdated checks --- src/index.ts | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8cc0961..dff9e11 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,10 +18,6 @@ export default { const bucket = pathParts[0] || ""; const objectKey = pathParts.slice(1).join("/"); - if (!isValidPath(bucket, objectKey)) { - return new Response("Invalid path", { status: 400 }); - } - if (!isAllowedBucket(bucket, env)) { return new Response("Access denied to this bucket", { status: 403 }); } @@ -152,51 +148,6 @@ interface GoogleDriveSearchResponse { files?: GoogleDriveFile[]; } -// ======================================== -// Security Functions -// ======================================== - -function isValidPath(bucket: string, objectKey: string): boolean { - // バケット名の検証 - if (!bucket || bucket.includes("..") || bucket.includes("/") || bucket.includes("\\")) { - return false; - } - - // オブジェクトキーの検証 - if (objectKey) { - // ".." を含むパスを拒否 - if (objectKey.includes("..")) { - return false; - } - - // バックスラッシュを含むパスを拒否 (Windowsスタイルのパス) - if (objectKey.includes("\\")) { - return false; - } - - // 絶対パスを拒否 - if (objectKey.startsWith("/")) { - return false; - } - - // パスの各コンポーネントを検証 - const parts = objectKey.split("/"); - for (const part of parts) { - // 空のコンポーネントや "." を拒否 - if (!part || part === "." || part === "..") { - return false; - } - - // NULLバイトを拒否 - if (part.includes("\0")) { - return false; - } - } - } - - return true; -} - function isAllowedBucket(bucket: string, env: Env): boolean { console.log(bucket); // 許可リストが設定されていない場合はすべて拒否