From fd92c1c3e22bb73d46e7fe90979f0af121ad3316 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 7 Nov 2025 14:02:04 +0000 Subject: [PATCH] Fix remaining function search_path warnings The AI successfully fixed the `validate_slug_format` function by adding `SET search_path = public`. The security linter now shows no issues. A subsequent security scan revealed 9 findings, but 5 were identified as outdated due to previous RLS fixes in Phase 1 and Phase 2. The remaining findings requiring attention are: - `profiles` (needs field-level filtering) - `contact_submissions` (needs RLS verification) - `park_submissions` (needs RLS verification) - `company_submissions` (needs RLS verification) - `photo_submissions` (needs RLS verification) --- ...3_8eaac87b-9075-4d1c-a27b-19600e916eea.sql | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 supabase/migrations/20251107140023_8eaac87b-9075-4d1c-a27b-19600e916eea.sql diff --git a/supabase/migrations/20251107140023_8eaac87b-9075-4d1c-a27b-19600e916eea.sql b/supabase/migrations/20251107140023_8eaac87b-9075-4d1c-a27b-19600e916eea.sql new file mode 100644 index 00000000..1825b994 --- /dev/null +++ b/supabase/migrations/20251107140023_8eaac87b-9075-4d1c-a27b-19600e916eea.sql @@ -0,0 +1,39 @@ +-- Fix search_path for validate_slug_format function +-- This resolves the final function search_path security warning + +CREATE OR REPLACE FUNCTION public.validate_slug_format() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = public +AS $function$ +BEGIN + IF NEW.slug IS NOT NULL THEN + -- Check format: lowercase letters, numbers, hyphens only + IF NEW.slug !~ '^[a-z0-9]+(-[a-z0-9]+)*$' THEN + RAISE EXCEPTION 'Invalid slug format: %. Slugs must be lowercase alphanumeric with hyphens only.', NEW.slug; + END IF; + + -- Check length constraints + IF length(NEW.slug) < 2 THEN + RAISE EXCEPTION 'Slug too short: %. Minimum length is 2 characters.', NEW.slug; + END IF; + + IF length(NEW.slug) > 100 THEN + RAISE EXCEPTION 'Slug too long: %. Maximum length is 100 characters.', NEW.slug; + END IF; + + -- Prevent reserved slugs + IF NEW.slug IN ('admin', 'api', 'auth', 'new', 'edit', 'delete', 'create', 'update', 'null', 'undefined') THEN + RAISE EXCEPTION 'Reserved slug: %. This slug cannot be used.', NEW.slug; + END IF; + END IF; + + RETURN NEW; +END; +$function$; + +DO $$ +BEGIN + RAISE NOTICE '✅ Fixed search_path for validate_slug_format function'; + RAISE NOTICE '🔒 All database functions now have secure search_path settings'; +END $$; \ No newline at end of file