Skip to content

feat: add test for security definer functions #1461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions nix/tests/expected/security.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- get a list of security definer functions owned by supabase_admin
-- this list should be vetted to ensure the functions are safe to use as security definer
select
n.nspname, p.proname
from pg_catalog.pg_proc p
left join pg_catalog.pg_namespace n ON n.oid = p.pronamespace
where p.proowner = (select oid from pg_catalog.pg_roles where rolname = 'supabase_admin')
and p.prosecdef = true
order by 1,2;
nspname | proname
----------+--------------------------------
graphql | get_schema_version
graphql | increment_schema_version
pgsodium | disable_security_label_trigger
pgsodium | enable_security_label_trigger
pgsodium | get_key_by_id
pgsodium | get_key_by_name
pgsodium | get_named_keys
pgsodium | mask_role
pgsodium | update_mask
public | dblink_connect_u
public | dblink_connect_u
public | pgaudit_ddl_command_end
public | pgaudit_sql_drop
public | st_estimatedextent
public | st_estimatedextent
public | st_estimatedextent
repack | repack_trigger
(17 rows)

9 changes: 9 additions & 0 deletions nix/tests/sql/security.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- get a list of security definer functions owned by supabase_admin
-- this list should be vetted to ensure the functions are safe to use as security definer
select
n.nspname, p.proname
from pg_catalog.pg_proc p
left join pg_catalog.pg_namespace n ON n.oid = p.pronamespace
where p.proowner = (select oid from pg_catalog.pg_roles where rolname = 'supabase_admin')
and p.prosecdef = true
order by 1,2;