mirror of
https://github.com/Nezumi-2711/google-drive-s3.git
synced 2026-09-22 13:38:30 +00:00
Remove outdated checks
This commit is contained in:
@@ -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);
|
||||
// 許可リストが設定されていない場合はすべて拒否
|
||||
|
||||
Reference in New Issue
Block a user