The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: Another lint update (#22682)
Ivan Vasilov1ca7cc36ce2d
diff --git a/apps/studio/components/interfaces/Reports/ReportLints.utils.tsx b/apps/studio/components/interfaces/Reports/ReportLints.utils.tsxindex b044d3148a3..bd6641455fc 100644--- a/apps/studio/components/interfaces/Reports/ReportLints.utils.tsx+++ b/apps/studio/components/interfaces/Reports/ReportLints.utils.tsx@@ -32,6 +32,8 @@ export function getHumanReadableTitle(title: LINT_TYPES) {return 'Security Definer View'case 'duplicate_index':return 'Duplicate Index'+ case 'extension_in_public':+ return 'Extension in Public'default:assertUnreachable(title)throw new Error('This case should never be reached')@@ -172,7 +174,18 @@ export const LintCTA = ({case 'security_definer_view':// we don't have a good place to send the user to check out a viewreturn <></>-+ case 'extension_in_public':+ return (+ <Button asChild type="default">+ <Link+ href={`/project/${projectRef}/database/extensions?filter=${metadata?.name}`}+ target="_blank"+ rel="noreferrer"+ >+ View extension+ </Link>+ </Button>+ )default:assertUnreachable(title)return <></>diff --git a/apps/studio/data/lint/lint-query.ts b/apps/studio/data/lint/lint-query.tsindex cd681bf8ecd..2f8e54f6eaf 100644--- a/apps/studio/data/lint/lint-query.ts+++ b/apps/studio/data/lint/lint-query.ts@@ -26,6 +26,7 @@ with foreign_keys as (index_ as (selectindrelid::regclass as table_,+ indrelid as table_oid,indexrelid::regclass as index_,string_to_array(indkey::text, ' ')::smallint[] as col_attnumsfrom@@ -58,11 +59,15 @@ fromleft join index_ idxon fk.table_ = idx.table_and fk.col_attnums = idx.col_attnums+ left join pg_catalog.pg_depend dep+ on idx.table_oid = dep.objid+ and dep.deptype = 'e'whereidx.index_ is nulland fk.schema_::text not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault')+ and dep.objid is null -- exclude tables owned by extensionsorder byfk.table_,fk.fkey_name)@@ -230,7 +235,7 @@ fromwhereis_rls_activeand schema_::text not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault')and ((@@ -276,11 +281,15 @@ fromon pgns.oid = pgc.relnamespaceleft join pg_catalog.pg_index pgion pgi.indrelid = pgc.oid+ left join pg_catalog.pg_depend dep+ on pgc.oid = dep.objid+ and dep.deptype = 'e'wherepgc.relkind = 'r' -- regular tablesand pgns.nspname not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgsodium', 'pgsodium_masks', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'storage', 'supabase_functions', 'supabase_migrations', 'vault')+ and dep.objid is null -- exclude tables owned by extensionsgroup bypgc.oid,pgns.nspname,@@ -317,12 +326,16 @@ frompg_catalog.pg_stat_user_indexes psuijoin pg_catalog.pg_index pion psui.indexrelid = pi.indexrelid+ left join pg_catalog.pg_depend dep+ on psui.relid = dep.objid+ and dep.deptype = 'e'wherepsui.idx_scan = 0and not pi.indisuniqueand not pi.indisprimary+ and dep.objid is null -- exclude tables owned by extensionsand psui.schemaname not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'))union all(@@ -354,11 +367,16 @@ select) as cache_keyfrompg_catalog.pg_policy p- join pg_catalog.pg_class c on p.polrelid = c.oid- join pg_catalog.pg_namespace n on c.relnamespace = n.oid+ join pg_catalog.pg_class c+ on p.polrelid = c.oid+ join pg_catalog.pg_namespace n+ on c.relnamespace = n.oidjoin pg_catalog.pg_roles ron p.polroles @> array[r.oid]- or p.polroles = array[0::oid],+ or p.polroles = array[0::oid]+ left join pg_catalog.pg_depend dep+ on c.oid = dep.objid+ and dep.deptype = 'e',lateral (select x.cmdfrom unnest((@@ -376,11 +394,12 @@ fromwherec.relkind = 'r' -- regular tablesand n.nspname not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault')and r.rolname not like 'pg_%'and r.rolname not like 'supabase%admin'and not r.rolbypassrls+ and dep.objid is null -- exclude tables owned by extensionsgroup byn.nspname,c.relname,@@ -418,13 +437,17 @@ fromon p.polrelid = c.oidjoin pg_catalog.pg_namespace non c.relnamespace = n.oid+ left join pg_catalog.pg_depend dep+ on c.oid = dep.objid+ and dep.deptype = 'e'wherec.relkind = 'r' -- regular tablesand n.nspname not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault')-- RLS is disabledand not c.relrowsecurity+ and dep.objid is null -- exclude tables owned by extensionsgroup byn.nspname,c.relname)@@ -457,14 +480,18 @@ fromon p.polrelid = c.oidjoin pg_catalog.pg_namespace non c.relnamespace = n.oid+ left join pg_catalog.pg_depend dep+ on c.oid = dep.objid+ and dep.deptype = 'e'wherec.relkind = 'r' -- regular tablesand n.nspname not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault')-- RLS is enabledand c.relrowsecurityand p.polname is null+ and dep.objid is null -- exclude tables owned by extensionsgroup byn.nspname,c.relname)@@ -505,11 +532,15 @@ fromjoin pg_catalog.pg_class con pi.tablename = c.relnameand n.oid = c.relnamespace+ left join pg_catalog.pg_depend dep+ on c.oid = dep.objid+ and dep.deptype = 'e'wherec.relkind in ('r', 'm') -- tables and materialized viewsand n.nspname not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault')+ and dep.objid is null -- exclude tables owned by extensionsgroup byn.nspname,c.relkind,@@ -544,9 +575,13 @@ frompg_catalog.pg_class cjoin pg_catalog.pg_namespace non n.oid = c.relnamespace+ left join pg_catalog.pg_depend dep+ on c.oid = dep.objid+ and dep.deptype = 'e'wherec.relkind = 'v'and n.nspname = 'public'+ and dep.objid is null -- exclude views owned by extensionsand not (lower(coalesce(c.reloptions::text,'{}'))::text[]&& array[@@ -562,7 +597,7 @@ select'function_search_path_mutable' as name,'WARN' as level,'EXTERNAL' as facing,- 'Detects functions with a mutable search_path parameter which could fail to execute sucessfully for some roles.' as description,+ 'Detects functions with a mutable search_path parameter which could fail to execute successfully for some roles.' as description,format('Function \`%s.%s\` has a role mutable search_path',n.nspname,@@ -584,10 +619,14 @@ frompg_catalog.pg_proc pjoin pg_catalog.pg_namespace non p.pronamespace = n.oid+ left join pg_catalog.pg_depend dep+ on p.oid = dep.objid+ and dep.deptype = 'e'wheren.nspname not in (- '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pg_catalog', 'pgbouncer', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault'+ '_timescaledb_internal', 'auth', 'cron', 'extensions', 'graphql', 'graphql_public', 'information_schema', 'net', 'pgroonga', 'pgsodium', 'pgsodium_masks', 'pgtle', 'pgbouncer', 'pg_catalog', 'pgtle', 'realtime', 'repack', 'storage', 'supabase_functions', 'supabase_migrations', 'tiger', 'topology', 'vault')+ and dep.objid is null -- exclude functions owned by extensions-- Search path not set to ''and not coalesce(p.proconfig, '{}') && array['search_path=""'])union all@@ -621,7 +660,35 @@ wherec.relkind = 'r' -- regular tablesand n.nspname = 'public'-- RLS is disabled- and not c.relrowsecurity)`.trim()+ and not c.relrowsecurity)+union all+(+select+ 'extension_in_public' as name,+ 'WARN' as level,+ 'EXTERNAL' as facing,+ 'Detects extensions installed in the \`public\` schema.' as description,+ format(+ 'Extension \`%s\` is installed in the public schema. Move it to another schema.',+ pe.extname+ ) as detail,+ 'https://supabase.com/docs/guides/database/database-linter?lint=0014_extension_in_public' as remediation,+ jsonb_build_object(+ 'schema', pe.extnamespace::regnamespace,+ 'name', pe.extname,+ 'type', 'extension'+ ) as metadata,+ format(+ 'extension_in_public_%s',+ pe.extname+ ) as cache_key+from+ pg_catalog.pg_extension pe+where+ -- plpgsql is installed by default in public and outside user control+ -- confirmed safe+ pe.extname not in ('plpgsql')+ and pe.extnamespace::regnamespace::text = 'public')`.trim()// Array of all lint rules we handle right now.export const LINT_TYPES = [@@ -637,6 +704,7 @@ export const LINT_TYPES = ['security_definer_view','function_search_path_mutable','rls_disabled_in_public',+ 'extension_in_public',] as constexport type LINT_TYPES = (typeof LINT_TYPES)[number]