Remove outdated checks

This commit is contained in:
nexryai
2026-01-09 12:59:51 +00:00
committed by GitHub
parent 5e0c77766b
commit 0fc87fa37f
-49
View File
@@ -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);
// 許可リストが設定されていない場合はすべて拒否