[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74F52X45BQKFYS3EFRWEZ1H":3,"skill-same:01M74F52X45BQKFYS3EFRWEZ1H":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M74F52X45BQKFYS3EFRWEZ1H","supabase-rpc-functions",null,"Supabase RPC function security patterns -- SECURITY DEFINER with `SET search_path` discipline, `REVOKE EXECUTE FROM public` for least-privilege exposure, JSON-arg shape drift between client and server contracts. Triggers on Supabase RPC function authoring (`CREATE OR REPLACE FUNCTION`, `rpc(` client calls). OWASP ASI02 (Tool Misuse) defense -- RPCs that bypass RLS are a privileged-backdoor path.","MILTONADINA\u002FDevOPs","MILTONADINA","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106546372?v=4","01M74F3R2PP4Z04DQMMBHSQAT1","Milton Adina","01M74F3R3CHTKPXJV4RP7RR3W8",0,"MIT","https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Fskills\u002Fstack-specific\u002Fsupabase\u002Frpc-functions\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: supabase-rpc-functions\ndescription: Supabase RPC function security patterns -- SECURITY DEFINER with `SET search_path` discipline, `REVOKE EXECUTE FROM public` for least-privilege exposure, JSON-arg shape drift between client and server contracts. Triggers on Supabase RPC function authoring (`CREATE OR REPLACE FUNCTION`, `rpc(` client calls). OWASP ASI02 (Tool Misuse) defense -- RPCs that bypass RLS are a privileged-backdoor path.\n---\n\n# Supabase RPC Functions\n\n> Defends against **OWASP ASI02 (Tool Misuse)** -- specifically, the\n> case where a Supabase RPC function with `SECURITY DEFINER` privileges\n> becomes a privileged backdoor that bypasses the row-level security\n> policies the application otherwise relies on. Supabase exposes any\n> Postgres function in the `public` schema as an HTTP RPC endpoint via\n> PostgREST; that exposure surface is BROADER than most authors\n> appreciate. Without careful authoring, an RPC intended for internal\n> server-side use becomes callable by any authenticated client.\n\n**Tradeoff:** RPC functions are powerful for encapsulating multi-step\noperations as atomic Postgres transactions. The cost: every\n`SECURITY DEFINER` function is a privilege-escalation gateway whose\ninputs and authorization must be explicitly defended. RLS protects\ntables; RPCs sit outside RLS unless authored carefully.\n\n---\n\n## Why this matters\n\nPostgREST's default behavior:\n\n- Every function in the `public` schema is exposed as an HTTP endpoint.\n- Functions inherit the caller's role unless declared `SECURITY DEFINER`.\n- `SECURITY DEFINER` functions run with the function-creator's\n  privileges, which means an `auth.uid()`-aware function written by\n  a superuser-equivalent admin executes WITH ADMIN PRIVILEGES even\n  when called by an anonymous user.\n- `search_path` for `SECURITY DEFINER` functions is the calling\n  session's `search_path` by default -- a malicious client can prepend\n  a schema they control, hijacking unqualified table references inside\n  the function body.\n\nThe combination \"exposed by default + privileged execution + caller-\ncontrolled search_path\" is the canonical Postgres RPC vulnerability\nclass. The patterns below close each piece.\n\n---\n\n## Pattern 1 -- `SECURITY DEFINER` with explicit `SET search_path`\n\nWhen a function MUST run with creator privileges (typical case:\ncrossing a security boundary like updating a counter on behalf of a\nuser who can read but not directly modify the table), declare\n`SECURITY DEFINER` AND pin the `search_path`:\n\n```sql\nCREATE OR REPLACE FUNCTION public.increment_post_view_count(p_post_id uuid)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$\nBEGIN\n  -- All table references are now resolved against public + pg_temp,\n  -- regardless of what the caller's session search_path is.\n  UPDATE public.posts\n    SET view_count = view_count + 1\n    WHERE id = p_post_id;\nEND;\n$$;\n```\n\n`SET search_path = public, pg_temp` pins the schema resolution at\nfunction-definition time. `pg_temp` last is the canonical safe pattern --\ntemporary objects the caller might create can't shadow the public\nschema's tables.\n\nA function declared `SECURITY DEFINER` WITHOUT `SET search_path` is a\ncritical defect.\n\n---\n\n## Pattern 2 -- `REVOKE EXECUTE FROM public` after creating the function\n\nPostgreSQL grants `EXECUTE` on functions to `PUBLIC` (every role) by\ndefault, and Supabase's default privileges also grant `EXECUTE` on new\nfunctions in `public` directly to `anon`, `authenticated`, and\n`service_role`. Revoking from `PUBLIC` alone therefore leaves `anon`\nand `authenticated` able to call the function. Revoke from `PUBLIC`,\n`anon`, and `authenticated`, then grant back only to the role(s) that\nshould call it:\n\n```sql\n-- Create the function.\nCREATE OR REPLACE FUNCTION public.admin_grant_role(p_user_id uuid, p_role text)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$ ... $$;\n\n-- Immediately revoke the Postgres default (PUBLIC) and Supabase's direct grants.\nREVOKE EXECUTE ON FUNCTION public.admin_grant_role(uuid, text) FROM public, anon, authenticated;\n\n-- Grant only to the role(s) that should call it. An admin operation is service-role-only:\nGRANT EXECUTE ON FUNCTION public.admin_grant_role(uuid, text) TO service_role;\n\n-- A function any signed-in user may call (scoped inside by auth.uid()) would instead get:\n-- GRANT EXECUTE ON FUNCTION public.some_user_function(...) TO authenticated;\n```\n\nThe `REVOKE ... FROM public, anon, authenticated` is the load-bearing\nstep. Without it, the `anon` role (unauthenticated users) can call the\nfunction. PostgREST\nexposes the endpoint; clients hit it; the SECURITY DEFINER body runs\nwith admin privileges on behalf of an unauthenticated attacker.\n\n---\n\n## Pattern 3 -- Defensive JSON-arg parsing for RPCs accepting JSONB\n\nRPCs that accept a JSONB argument must parse the JSON defensively\ninside the function body. A client can pass any shape; the function's\nparameter type is just `jsonb`, not a struct contract.\n\n```sql\nCREATE OR REPLACE FUNCTION public.bulk_update_settings(p_settings jsonb)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$\nDECLARE\n  v_theme text;\n  v_locale text;\nBEGIN\n  -- Extract with type assertion; ->> returns text or NULL.\n  v_theme := p_settings ->> 'theme';\n  v_locale := p_settings ->> 'locale';\n\n  -- Validate inside the function body. The caller can pass any JSON\n  -- shape; the function decides what to accept.\n  IF v_theme IS NOT NULL AND v_theme NOT IN ('light', 'dark', 'auto') THEN\n    RAISE EXCEPTION 'invalid theme: %', v_theme;\n  END IF;\n  IF v_locale IS NOT NULL AND length(v_locale) > 10 THEN\n    RAISE EXCEPTION 'locale too long';\n  END IF;\n\n  -- Use auth.uid() to scope the update to the calling user. SECURITY\n  -- DEFINER runs with elevated DB privileges, but auth.uid() still\n  -- returns the JWT subject of the actual caller.\n  UPDATE public.user_settings\n    SET theme = COALESCE(v_theme, theme),\n        locale = COALESCE(v_locale, locale)\n    WHERE user_id = auth.uid();\nEND;\n$$;\n```\n\nThe COALESCE pattern handles partial updates: only fields present in\nthe JSON are updated. Critically, the scope is `WHERE user_id =\nauth.uid()` -- the SECURITY DEFINER's elevated privileges don't grant\nthe right to update OTHER users' settings; the function's own WHERE\nclause restricts that.\n\n---\n\n## Anti-patterns\n\n### Anti-pattern 1 -- `SECURITY DEFINER` without `SET search_path`\n\n```sql\n-- WRONG\nCREATE OR REPLACE FUNCTION public.grant_admin(p_user uuid)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER  -- no SET search_path!\nAS $$\nBEGIN\n  UPDATE users SET role = 'admin' WHERE id = p_user;  -- which 'users'?\nEND;\n$$;\n```\n\nA caller can `SET search_path = malicious_schema, public;` before\ninvoking the function. Inside the function body, `users` resolves to\n`malicious_schema.users` (a table the attacker controls). The\n`UPDATE` runs against the wrong table with admin privileges. Always\npin `search_path` for SECURITY DEFINER functions.\n\n### Anti-pattern 2 -- Forgetting `REVOKE EXECUTE FROM public`\n\n```sql\n-- WRONG: anon role can call this and run with admin privileges\nCREATE OR REPLACE FUNCTION public.elevated_helper(p_user uuid)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$ \u002F* does something privileged *\u002F $$;\n-- (no REVOKE)\n```\n\nThe default grants (to `PUBLIC`, and Supabase's direct grants to\n`anon` and `authenticated`) mean PostgREST exposes the function for\nanonymous callers. Test it: hit\n`https:\u002F\u002F\u003Cproject>.supabase.co\u002Frest\u002Fv1\u002Frpc\u002Felevated_helper` with only\nthe anon key. If you get a 200, the function is publicly callable. The\nREVOKE + targeted GRANT pattern is mandatory.\n\n### Anti-pattern 3 -- Trusting JSONB arg shape without validation\n\n```sql\n-- WRONG\nCREATE OR REPLACE FUNCTION public.bulk_action(p_args jsonb)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$\nBEGIN\n  EXECUTE 'UPDATE posts SET ' || (p_args ->> 'set_clause') || ' WHERE id = ' || (p_args ->> 'id');\nEND;\n$$;\n```\n\nThis is a SQL-injection RPC. The caller's JSON `set_clause` is\nconcatenated directly into the SQL string. Even a non-malicious client\nthat passes `set_clause: \"title = NULL\"` produces an unexpected\nupdate; a malicious client passes\n`set_clause: \"title = NULL; DROP TABLE users; --\"` and the EXECUTE\nruns the destructive statement.\n\nNEVER concatenate user-controlled input into dynamic SQL. Use\nparameterised queries, plpgsql's typed local variables, or the\n`format(...)` function with `%I` (identifier) \u002F `%L` (literal) format\nspecifiers if dynamic SQL is genuinely required.\n\n---\n\n## ASI\u002FAST mapping\n\nThis skill addresses **canonical OWASP ASI02 (Tool Misuse)** from\n`governance\u002Fowasp-asi-2026\u002Fthreats.md`. Supabase RPC functions ARE\ntools in the agentic sense -- they're invokable HTTP endpoints with\nside effects. A SECURITY DEFINER function callable by anonymous users\nwith an unpinned search_path is a tool whose misuse is trivial. The\npatterns above ensure RPC tools are invokable only by intended callers,\nrun in a hardened execution environment (pinned search_path), and\nvalidate their JSON input.\n\nThe complementary RLS skill\n(`stack-specific\u002Fsupabase\u002Frls-policies`) is the ASI03 (Identity &\nPrivilege Abuse) counterpart for the same Supabase integration. Both\nskills together close the database-layer authz surface; missing either\nleaves a gap.\n\n---\n\n## Testing\n\nFor every RPC function, write integration tests that exercise:\n\n```sql\n-- 1. Anon-role caller cannot invoke (after REVOKE):\nSET ROLE anon;\nSELECT public.elevated_helper('some-uuid');  -- expect permission denied\n\n-- 2. Authenticated-role caller can invoke:\nSET ROLE authenticated;\nSET request.jwt.claim.sub = 'user-a-uuid';\nSELECT public.bulk_update_settings('{\"theme\": \"dark\"}'::jsonb);  -- expect success\n\n-- 3. Malformed JSON arg is rejected:\nSELECT public.bulk_update_settings('{\"theme\": \"purple\"}'::jsonb);  -- expect raised exception\n```\n\nA test that misses any of these three is incomplete. Wire them into\nthe same pytest\u002FpgTAP harness that tests RLS policies.\n\n---\n\n## See also\n\n- `governance\u002Fowasp-asi-2026\u002Fthreats.md` -- ASI02 full text\n- Supabase RPC guide:\n  https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fdatabase\u002Ffunctions\n- `skills\u002Fstack-specific\u002Fsupabase\u002Frls-policies\u002FSKILL.md` -- the\n  ASI03 companion skill for the same Supabase integration\n- PostgreSQL SECURITY DEFINER docs:\n  https:\u002F\u002Fwww.postgresql.org\u002Fdocs\u002Fcurrent\u002Fsql-createfunction.html#SQL-CREATEFUNCTION-SECURITY\n","# Supabase RPC Functions\n\n> Defends against **OWASP ASI02 (Tool Misuse)** -- specifically, the\n> case where a Supabase RPC function with `SECURITY DEFINER` privileges\n> becomes a privileged backdoor that bypasses the row-level security\n> policies the application otherwise relies on. Supabase exposes any\n> Postgres function in the `public` schema as an HTTP RPC endpoint via\n> PostgREST; that exposure surface is BROADER than most authors\n> appreciate. Without careful authoring, an RPC intended for internal\n> server-side use becomes callable by any authenticated client.\n\n**Tradeoff:** RPC functions are powerful for encapsulating multi-step\noperations as atomic Postgres transactions. The cost: every\n`SECURITY DEFINER` function is a privilege-escalation gateway whose\ninputs and authorization must be explicitly defended. RLS protects\ntables; RPCs sit outside RLS unless authored carefully.\n\n---\n\n## Why this matters\n\nPostgREST's default behavior:\n\n- Every function in the `public` schema is exposed as an HTTP endpoint.\n- Functions inherit the caller's role unless declared `SECURITY DEFINER`.\n- `SECURITY DEFINER` functions run with the function-creator's\n  privileges, which means an `auth.uid()`-aware function written by\n  a superuser-equivalent admin executes WITH ADMIN PRIVILEGES even\n  when called by an anonymous user.\n- `search_path` for `SECURITY DEFINER` functions is the calling\n  session's `search_path` by default -- a malicious client can prepend\n  a schema they control, hijacking unqualified table references inside\n  the function body.\n\nThe combination \"exposed by default + privileged execution + caller-\ncontrolled search_path\" is the canonical Postgres RPC vulnerability\nclass. The patterns below close each piece.\n\n---\n\n## Pattern 1 -- `SECURITY DEFINER` with explicit `SET search_path`\n\nWhen a function MUST run with creator privileges (typical case:\ncrossing a security boundary like updating a counter on behalf of a\nuser who can read but not directly modify the table), declare\n`SECURITY DEFINER` AND pin the `search_path`:\n\n```sql\nCREATE OR REPLACE FUNCTION public.increment_post_view_count(p_post_id uuid)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$\nBEGIN\n  -- All table references are now resolved against public + pg_temp,\n  -- regardless of what the caller's session search_path is.\n  UPDATE public.posts\n    SET view_count = view_count + 1\n    WHERE id = p_post_id;\nEND;\n$$;\n```\n\n`SET search_path = public, pg_temp` pins the schema resolution at\nfunction-definition time. `pg_temp` last is the canonical safe pattern --\ntemporary objects the caller might create can't shadow the public\nschema's tables.\n\nA function declared `SECURITY DEFINER` WITHOUT `SET search_path` is a\ncritical defect.\n\n---\n\n## Pattern 2 -- `REVOKE EXECUTE FROM public` after creating the function\n\nPostgreSQL grants `EXECUTE` on functions to `PUBLIC` (every role) by\ndefault, and Supabase's default privileges also grant `EXECUTE` on new\nfunctions in `public` directly to `anon`, `authenticated`, and\n`service_role`. Revoking from `PUBLIC` alone therefore leaves `anon`\nand `authenticated` able to call the function. Revoke from `PUBLIC`,\n`anon`, and `authenticated`, then grant back only to the role(s) that\nshould call it:\n\n```sql\n-- Create the function.\nCREATE OR REPLACE FUNCTION public.admin_grant_role(p_user_id uuid, p_role text)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$ ... $$;\n\n-- Immediately revoke the Postgres default (PUBLIC) and Supabase's direct grants.\nREVOKE EXECUTE ON FUNCTION public.admin_grant_role(uuid, text) FROM public, anon, authenticated;\n\n-- Grant only to the role(s) that should call it. An admin operation is service-role-only:\nGRANT EXECUTE ON FUNCTION public.admin_grant_role(uuid, text) TO service_role;\n\n-- A function any signed-in user may call (scoped inside by auth.uid()) would instead get:\n-- GRANT EXECUTE ON FUNCTION public.some_user_function(...) TO authenticated;\n```\n\nThe `REVOKE ... FROM public, anon, authenticated` is the load-bearing\nstep. Without it, the `anon` role (unauthenticated users) can call the\nfunction. PostgREST\nexposes the endpoint; clients hit it; the SECURITY DEFINER body runs\nwith admin privileges on behalf of an unauthenticated attacker.\n\n---\n\n## Pattern 3 -- Defensive JSON-arg parsing for RPCs accepting JSONB\n\nRPCs that accept a JSONB argument must parse the JSON defensively\ninside the function body. A client can pass any shape; the function's\nparameter type is just `jsonb`, not a struct contract.\n\n```sql\nCREATE OR REPLACE FUNCTION public.bulk_update_settings(p_settings jsonb)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$\nDECLARE\n  v_theme text;\n  v_locale text;\nBEGIN\n  -- Extract with type assertion; ->> returns text or NULL.\n  v_theme := p_settings ->> 'theme';\n  v_locale := p_settings ->> 'locale';\n\n  -- Validate inside the function body. The caller can pass any JSON\n  -- shape; the function decides what to accept.\n  IF v_theme IS NOT NULL AND v_theme NOT IN ('light', 'dark', 'auto') THEN\n    RAISE EXCEPTION 'invalid theme: %', v_theme;\n  END IF;\n  IF v_locale IS NOT NULL AND length(v_locale) > 10 THEN\n    RAISE EXCEPTION 'locale too long';\n  END IF;\n\n  -- Use auth.uid() to scope the update to the calling user. SECURITY\n  -- DEFINER runs with elevated DB privileges, but auth.uid() still\n  -- returns the JWT subject of the actual caller.\n  UPDATE public.user_settings\n    SET theme = COALESCE(v_theme, theme),\n        locale = COALESCE(v_locale, locale)\n    WHERE user_id = auth.uid();\nEND;\n$$;\n```\n\nThe COALESCE pattern handles partial updates: only fields present in\nthe JSON are updated. Critically, the scope is `WHERE user_id =\nauth.uid()` -- the SECURITY DEFINER's elevated privileges don't grant\nthe right to update OTHER users' settings; the function's own WHERE\nclause restricts that.\n\n---\n\n## Anti-patterns\n\n### Anti-pattern 1 -- `SECURITY DEFINER` without `SET search_path`\n\n```sql\n-- WRONG\nCREATE OR REPLACE FUNCTION public.grant_admin(p_user uuid)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER  -- no SET search_path!\nAS $$\nBEGIN\n  UPDATE users SET role = 'admin' WHERE id = p_user;  -- which 'users'?\nEND;\n$$;\n```\n\nA caller can `SET search_path = malicious_schema, public;` before\ninvoking the function. Inside the function body, `users` resolves to\n`malicious_schema.users` (a table the attacker controls). The\n`UPDATE` runs against the wrong table with admin privileges. Always\npin `search_path` for SECURITY DEFINER functions.\n\n### Anti-pattern 2 -- Forgetting `REVOKE EXECUTE FROM public`\n\n```sql\n-- WRONG: anon role can call this and run with admin privileges\nCREATE OR REPLACE FUNCTION public.elevated_helper(p_user uuid)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$ \u002F* does something privileged *\u002F $$;\n-- (no REVOKE)\n```\n\nThe default grants (to `PUBLIC`, and Supabase's direct grants to\n`anon` and `authenticated`) mean PostgREST exposes the function for\nanonymous callers. Test it: hit\n`https:\u002F\u002F\u003Cproject>.supabase.co\u002Frest\u002Fv1\u002Frpc\u002Felevated_helper` with only\nthe anon key. If you get a 200, the function is publicly callable. The\nREVOKE + targeted GRANT pattern is mandatory.\n\n### Anti-pattern 3 -- Trusting JSONB arg shape without validation\n\n```sql\n-- WRONG\nCREATE OR REPLACE FUNCTION public.bulk_action(p_args jsonb)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public, pg_temp\nAS $$\nBEGIN\n  EXECUTE 'UPDATE posts SET ' || (p_args ->> 'set_clause') || ' WHERE id = ' || (p_args ->> 'id');\nEND;\n$$;\n```\n\nThis is a SQL-injection RPC. The caller's JSON `set_clause` is\nconcatenated directly into the SQL string. Even a non-malicious client\nthat passes `set_clause: \"title = NULL\"` produces an unexpected\nupdate; a malicious client passes\n`set_clause: \"title = NULL; DROP TABLE users; --\"` and the EXECUTE\nruns the destructive statement.\n\nNEVER concatenate user-controlled input into dynamic SQL. Use\nparameterised queries, plpgsql's typed local variables, or the\n`format(...)` function with `%I` (identifier) \u002F `%L` (literal) format\nspecifiers if dynamic SQL is genuinely required.\n\n---\n\n## ASI\u002FAST mapping\n\nThis skill addresses **canonical OWASP ASI02 (Tool Misuse)** from\n`governance\u002Fowasp-asi-2026\u002Fthreats.md`. Supabase RPC functions ARE\ntools in the agentic sense -- they're invokable HTTP endpoints with\nside effects. A SECURITY DEFINER function callable by anonymous users\nwith an unpinned search_path is a tool whose misuse is trivial. The\npatterns above ensure RPC tools are invokable only by intended callers,\nrun in a hardened execution environment (pinned search_path), and\nvalidate their JSON input.\n\nThe complementary RLS skill\n(`stack-specific\u002Fsupabase\u002Frls-policies`) is the ASI03 (Identity &\nPrivilege Abuse) counterpart for the same Supabase integration. Both\nskills together close the database-layer authz surface; missing either\nleaves a gap.\n\n---\n\n## Testing\n\nFor every RPC function, write integration tests that exercise:\n\n```sql\n-- 1. Anon-role caller cannot invoke (after REVOKE):\nSET ROLE anon;\nSELECT public.elevated_helper('some-uuid');  -- expect permission denied\n\n-- 2. Authenticated-role caller can invoke:\nSET ROLE authenticated;\nSET request.jwt.claim.sub = 'user-a-uuid';\nSELECT public.bulk_update_settings('{\"theme\": \"dark\"}'::jsonb);  -- expect success\n\n-- 3. Malformed JSON arg is rejected:\nSELECT public.bulk_update_settings('{\"theme\": \"purple\"}'::jsonb);  -- expect raised exception\n```\n\nA test that misses any of these three is incomplete. Wire them into\nthe same pytest\u002FpgTAP harness that tests RLS policies.\n\n---\n\n## See also\n\n- `governance\u002Fowasp-asi-2026\u002Fthreats.md` -- ASI02 full text\n- Supabase RPC guide:\n  https:\u002F\u002Fsupabase.com\u002Fdocs\u002Fguides\u002Fdatabase\u002Ffunctions\n- `skills\u002Fstack-specific\u002Fsupabase\u002Frls-policies\u002FSKILL.md` -- the\n  ASI03 companion skill for the same Supabase integration\n- PostgreSQL SECURITY DEFINER docs:\n  https:\u002F\u002Fwww.postgresql.org\u002Fdocs\u002Fcurrent\u002Fsql-createfunction.html#SQL-CREATEFUNCTION-SECURITY\n",{"name":5,"description":7},"main","5a590e92c8f62b54c96a6928215ac2145b671e03","skills\u002Fstack-specific\u002Fsupabase\u002Frpc-functions","https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs","https:\u002F\u002Fgithub.com\u002FMILTONADINA","https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fmiltonadina","CS\u002FCybersecurity SWE & former Epidemiologist. Building secure, test-driven full-stack & mobile apps (TS\u002FReact\u002FNode, Java\u002FSpring, Flutter).","2026-11-14 20:03:36",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add MILTONADINA\u002FDevOPs --skill supabase-rpc-functions",{"tool":38,"command":39},"bunx","bunx skills add MILTONADINA\u002FDevOPs --skill supabase-rpc-functions",{"tool":41,"command":42},"pnpm","pnpm dlx skills add MILTONADINA\u002FDevOPs --skill supabase-rpc-functions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Fskills\u002Fstack-specific\u002Fsupabase\u002Frpc-functions\u002FSKILL.md",true,[46],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"SKILL.md.bundle","OTHER","其他",9559,"https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Fskills\u002Fstack-specific\u002Fsupabase\u002Frpc-functions\u002FSKILL.md.bundle",[53,60,67,74,79,86],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M74F7F3HN6J7CSFHBVQAE9S5","karpathy-guidelines","Behavioral guidelines that reduce common LLM coding mistakes. Apply whenever writing, modifying, or reviewing code. Don't assume requirements, don't overcomplicate, don't refactor unrelated code, and define success criteria before implementing. Use this skill on every non-trivial coding task to avoid bloat, silent assumptions, and completion-bias.","https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fsecurity\u002Fmodified-skill\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M74F7D60N9FRWWWHCGZMMB41","unsigned-missing-sig-fixture","Test fixture (F.09) — SKILL.md without an accompanying .sig file. Default install rejects with exit 2; --allow-unsigned --rationale=\"...\" proceeds.","https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Finstall\u002Fsource-skills\u002Funsigned-missing-sig\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M74F7BKGX67Q606QPKZV7TQV","unsigned-mismatched-sig-fixture","Test fixture (F.09) — SKILL.md whose accompanying .sig signs different content. NFR-F3 hash check catches this even with --allow-unsigned.","https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Finstall\u002Fsource-skills\u002Funsigned-mismatched-sig\u002FSKILL.md",[],[],{"skillNo":75,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M74F793BYMX98EQC5XP4CDZK","https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Finstall\u002Fsource-skills\u002Fsigned\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M74F7481EBD7G5471ZC4S9YB","webhook-idempotency","Defend against double-processing of webhook events across every provider (Stripe, GitHub, Slack, Twilio, SendGrid). Idempotency-key pattern + replay-window enforcement + dedupe-storage strategy. Triggers on any webhook handler authoring (route matching \u002Fwebhook(s)?\u002F, Stripe-Signature \u002F X-Hub-Signature-256 header references). Defense against OWASP ASI02 (Tool Misuse) -- a replayed webhook that re-triggers a destructive tool is the canonical control-flow-level replay attack. Universal across providers; stack-specific signature verification lives in stack-specific skills.","https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Fskills\u002Funiversal\u002Fsecurity\u002Fwebhook-idempotency\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M74F71Q6JKRFJ66G5T98KE8H","semgrep-scan","Run Semgrep static analysis to detect insecure code patterns - SQL injection, XSS, path traversal, weak crypto, broken auth, OWASP Top 10 issues. Use on every file change touching security-sensitive code and as part of the tiered security gate. Complements gitleaks (which catches secrets) by catching insecure logic.","https:\u002F\u002Fgithub.com\u002FMILTONADINA\u002FDevOPs\u002Fblob\u002Fmain\u002Fskills\u002Funiversal\u002Fsecurity\u002Fsemgrep-scan\u002FSKILL.md",[],[]]