Skip to content

feat: update pgdelta to handle user-defined policies and comments - #2142

Open
leandrocp wants to merge 1 commit into
mainfrom
feat/pgdelta-rls
Open

feat: update pgdelta to handle user-defined policies and comments#2142
leandrocp wants to merge 1 commit into
mainfrom
feat/pgdelta-rls

Conversation

@leandrocp

Copy link
Copy Markdown
Member

Ref supabase/pg-toolbelt#433

Closes REAL-997

@github-actions

Copy link
Copy Markdown
Contributor

CRAP Score Report

Summary: files=233 functions=1267 scored=1267 worst_score=15944.76

** (Mix) CRAP threshold failed: max_score=30.00
High scores: 30
  lib/extensions/postgres_cdc_rls/subscription_manager.ex Extensions.PostgresCdcRls.SubscriptionManager.handle_info/2 score=37.16
  lib/realtime/adapters/postgres/oid_database.ex Realtime.Adapters.Postgres.OidDatabase.name_for_type_id/1 score=15944.76
  lib/realtime/application.ex Realtime.Application.setup_region_mapping/0 score=47.11
  lib/realtime/nodes.ex Realtime.Nodes.default_region_mapping/1 score=157.20
  lib/realtime/operations.ex Realtime.Operations.rebalance/0 score=42.00
  lib/realtime/operations.ex Realtime.Operations.kill_connections_to_tenant_id/2 score=90.00
  lib/realtime/tenants/connect.ex Realtime.Tenants.Connect.handle_info/2 score=40.25
  lib/realtime_web/channels/realtime_channel.ex RealtimeWeb.RealtimeChannel.handle_info/2 score=60.51
  lib/realtime_web/channels/realtime_channel.ex RealtimeWeb.RealtimeChannel.handle_in/3 score=132.36
  lib/realtime_web/dashboard/feature_flags.ex RealtimeWeb.Dashboard.FeatureFlags.handle_event/3 score=112.70
  lib/realtime_web/dashboard/node_info.ex RealtimeWeb.Dashboard.NodeInfo.fetch_node_data/2 score=42.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.handle_event/3 score=552.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.handle_info/2 score=210.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.render_value/2 score=42.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.load_module_functions/1 score=42.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.parse_and_start/2 score=110.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.format_value/1 score=702.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.sort_entries/2 score=42.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.parse_module/1 score=90.00
  lib/realtime_web/dashboard/sql_inspector.ex RealtimeWeb.Dashboard.SqlInspector.handle_event/3 score=72.00
  lib/realtime_web/dashboard/sql_inspector.ex RealtimeWeb.Dashboard.SqlInspector.execute_read_only/1 score=72.00
  lib/realtime_web/dashboard/sql_inspector.ex RealtimeWeb.Dashboard.SqlInspector.mask_sensitive_columns/1 score=42.00
  lib/realtime_web/dashboard/sql_inspector.ex RealtimeWeb.Dashboard.SqlInspector.compare_cells/2 score=42.00
  lib/realtime_web/dashboard/sql_inspector.ex RealtimeWeb.Dashboard.SqlInspector.format_cell/1 score=72.00
  lib/realtime_web/dashboard/tenant_migrations.ex RealtimeWeb.Dashboard.TenantMigrations.handle_info/2 score=156.00
  lib/realtime_web/live/components.ex RealtimeWeb.Components.input/1 score=90.00
  lib/realtime_web/live/inspector_live/conn_component.ex RealtimeWeb.InspectorLive.ConnComponent.handle_event/3 score=53.83
  lib/realtime_web/live/inspector_live/event_log_component.ex RealtimeWeb.InspectorLive.EventLogComponent.category_variant/1 score=35.00
  lib/realtime_web/live/inspector_live/event_log_component.ex RealtimeWeb.InspectorLive.EventLogComponent.event_label/1 score=76.13
  lib/realtime_web/live/status_live/index.ex RealtimeWeb.StatusLive.Index.handle_event/3 score=42.00

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 90.814%feat/pgdelta-rls into main. No base build found for main.

avallete pushed a commit to supabase/pg-toolbelt that referenced this pull request Aug 29, 2026
Auth-team decision (2026-08-29): the Auth service never ships or manages
RLS policies on its own tables — every policy there is user-managed, and
the post-2024 RLS/grant list drift is deliberate. That guarantee is
schema-scoped, so the carve-out is too: any policy whose table is in the
auth schema is user intent, included in diffs and exports via a new
SUPABASE_USER_POLICY_SCHEMAS constant folded into the user-policy include
rule (and its comment-satellite companion), instead of mirroring the 16
auth entries of supautils.policy_grants.

Schema-wide beats the table list because it round-trips the
legal-but-inert case (auth.oauth_clients: grantable, RLS never enabled)
and is immune to future grant-list drift (auth.passkeys has no grant
today). The per-table SURFACES list stays for storage/realtime until
those teams give the same forward-looking guarantee. The pristine guard
and the base-init fixture pin the observable half: zero policies on auth
in the base image, RLS enabled on exactly the 16 tables of auth's
20240612123726_enable_rls_update_grants migration.

Also corrects the PR #407 round-4 triage note in the follow-ups doc (its
"CREATE POLICY requires ownership" premise is refuted by
supautils.policy_grants) and records the customer-SELECT-re-grants-on-auth
follow-up (ACLs carry a grantor, so a provenance discriminator exists;
separate PR).

RED (previous commit) on the surfaces-only branch state:

  unit:  (fail) keeps ANY policy on an auth table managed (schema-wide rule)  (Expected: false, Received: true)
         (fail) keeps comments ON allowlist policies managed (REAL-997)  (Received: undefined)
  integ: (fail) diff/apply/converge an auth.users policy (schema-wide carve-out)
         (fail) export files the auth.users policy under the table without recreating it

GREEN: unit 1381 pass / 0 fail; supabase-managed-policies 10/10 and
base-init pins 4/4 on supabase/postgres:17.6.1.135.

Refs CLI-1385 (Phase 5). Ref supabase/realtime#2142.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P4iJTUreVfKQhfAtuLfJNg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants