feat: Implement security fix plan

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 15:50:07 +00:00
parent a86da6e833
commit fdfe141f31
6 changed files with 988 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
import { validateEntityData, validateEntityDataStrict } from "./validation.ts";
import { createErrorResponse } from "../_shared/errorSanitizer.ts";
import { edgeLogger, startRequest, endRequest } from "../_shared/logger.ts";
import { rateLimiters, withRateLimit } from "../_shared/rateLimiter.ts";
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
@@ -46,7 +47,10 @@ const RIDE_MODEL_FIELDS = [
'card_image_url', 'card_image_id'
];
serve(async (req) => {
// Apply per-user rate limiting for moderators (10 approvals/minute per moderator)
const approvalRateLimiter = rateLimiters.perUser(10);
serve(withRateLimit(async (req) => {
const tracking = startRequest(); // Start request tracking
if (req.method === 'OPTIONS') {
@@ -764,7 +768,7 @@ serve(async (req) => {
'process-selective-approval'
);
}
});
}, approvalRateLimiter, corsHeaders));
// Helper functions
function topologicalSort(items: any[]): any[] {