Skip to content

fix(policy_eval): fall back on database setups the snapshot doesn't model - #2701

Open
PragTob wants to merge 1 commit into
mainfrom
tobipfeiffer/real-1345-policy-eval-loader-checks
Open

PragTob wants to merge 1 commit into
mainfrom
tobipfeiffer/real-1345-policy-eval-loader-checks

Conversation

@PragTob

@PragTob PragTob commented Dec 4, 2026

Copy link
Copy Markdown
Member

The library lists limits the caller must cover. Realtime's loader now checks the two that a project's owner can create without a superuser, and reports what it finds through a new optional snapshot input, unmodelled_setup.

Any entry makes every decision fall back with {:unmodelled_setup, kind}, category :setup:

  • role_membership: a role the library decides for is a member of another role a policy can name
  • triggers: a trigger on realtime.messages or a partition that isn't disabled. `realtime.authorize`` inserts probe rows, so a trigger can change or fail the check

The other limits (a setting default, the search_path, revoked privileges on the known functions, the database encoding) are not checked - users can't set them and didn't want to overload the code with things that shouldn't happen.

…odel

The library lists limits the caller must cover. Realtime's loader now checks
the two that a project's owner can create without a superuser, and reports
what it finds through a new optional snapshot input, unmodelled_setup.

Any entry makes every decision fall back with {:unmodelled_setup, kind},
category :setup:

- role_membership: a role the library decides for is a member of another
role a policy can name
- triggers: a trigger on realtime.messages or a partition that isn't
disabled. `realtime.authorize`` inserts probe rows, so a trigger can
change or fail the check

The other limits (a setting default, the search_path, revoked privileges
on the known functions, the database encoding) are not checked - users
can't set them and didn't want to overload the code with things that
shouldn't happen.
@PragTob
PragTob requested a review from edgurgel December 4, 2026 16:04
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

CRAP Score Report

Summary: files=284 functions=1713 scored=1713 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=36.73
  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=129.85
  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=42.56
  lib/realtime_web/channels/auth/jwt_verification.ex RealtimeWeb.JwtVerification.generate_signer/3 score=30.78
  lib/realtime_web/channels/realtime_channel.ex RealtimeWeb.RealtimeChannel.handle_info/2 score=52.33
  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=552.00
  lib/realtime_web/dashboard/recon_trace.ex RealtimeWeb.Dashboard.ReconTrace.sort_entries/2 score=42.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=51.43
  lib/realtime_web/live/inspector_live/index.ex RealtimeWeb.InspectorLive.Index.handle_event/3 score=30.84
  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 93.367% — tobipfeiffer/real-1345-policy-eval-loader-checks into main. No base build found for main.

This branch has not been deployed

No deployments
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