Skip to content

Commit 9d7b75c

Browse files
authoredFeb 25, 2025
feat: add test for security definer functions (#1461)
* feat: add test for security definer functions * chore: include nspname to help relate functions to schema/extensions
1 parent 6aa8c5d commit 9d7b75c

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
 

‎nix/tests/expected/security.out

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- get a list of security definer functions owned by supabase_admin
2+
-- this list should be vetted to ensure the functions are safe to use as security definer
3+
select
4+
n.nspname, p.proname
5+
from pg_catalog.pg_proc p
6+
left join pg_catalog.pg_namespace n ON n.oid = p.pronamespace
7+
where p.proowner = (select oid from pg_catalog.pg_roles where rolname = 'supabase_admin')
8+
and p.prosecdef = true
9+
order by 1,2;
10+
nspname | proname
11+
----------+--------------------------------
12+
graphql | get_schema_version
13+
graphql | increment_schema_version
14+
pgsodium | disable_security_label_trigger
15+
pgsodium | enable_security_label_trigger
16+
pgsodium | get_key_by_id
17+
pgsodium | get_key_by_name
18+
pgsodium | get_named_keys
19+
pgsodium | mask_role
20+
pgsodium | update_mask
21+
public | dblink_connect_u
22+
public | dblink_connect_u
23+
public | pgaudit_ddl_command_end
24+
public | pgaudit_sql_drop
25+
public | st_estimatedextent
26+
public | st_estimatedextent
27+
public | st_estimatedextent
28+
repack | repack_trigger
29+
(17 rows)
30+

‎nix/tests/sql/security.sql

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- get a list of security definer functions owned by supabase_admin
2+
-- this list should be vetted to ensure the functions are safe to use as security definer
3+
select
4+
n.nspname, p.proname
5+
from pg_catalog.pg_proc p
6+
left join pg_catalog.pg_namespace n ON n.oid = p.pronamespace
7+
where p.proowner = (select oid from pg_catalog.pg_roles where rolname = 'supabase_admin')
8+
and p.prosecdef = true
9+
order by 1,2;

0 commit comments

Comments
 (0)
Failed to load comments.