mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:51:13 -05:00
Fix JSONB filter and admin guard
- Implement helper filter_jsonb_array_nulls and apply it in analyze_data_completeness to replace jsonb - 'null' usage - Add search_path public in helper function for security - Ensure useDataCompleteness runs only on admin pages by enabling query conditionally
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
-- Fix search_path security issue for filter_jsonb_array_nulls function
|
||||||
|
CREATE OR REPLACE FUNCTION filter_jsonb_array_nulls(arr JSONB)
|
||||||
|
RETURNS JSONB
|
||||||
|
LANGUAGE SQL
|
||||||
|
IMMUTABLE
|
||||||
|
SET search_path = public
|
||||||
|
AS $$
|
||||||
|
SELECT COALESCE(
|
||||||
|
jsonb_agg(element),
|
||||||
|
'[]'::jsonb
|
||||||
|
)
|
||||||
|
FROM jsonb_array_elements_text(arr) element
|
||||||
|
WHERE element != 'null'
|
||||||
|
$$;
|
||||||
Reference in New Issue
Block a user