Skip to content

Build an SQL test harness for chat RLS and storage policies, and run it in CI #583

Closed

Description

@HMarzban

Goal

Run the chat and storage policies against a real database, so a policy regression fails a test.

Facts

  • No SQL test harness exists. The guards today are static text checks plus one-shot deploy-time asserts in migrations.
  • Two storage regressions shipped before: ed92aaad9 and 63641764e.
  • No test runs these policies: author-only message writes, the block on client rows with type = 'notification', and the chat-media policies on storage.objects.

What to build

  1. A harness against local Supabase that runs SQL as anon and as authenticated with set claims.
  2. Cases for author-only message writes.
  3. Cases for the refusal of client rows with type = 'notification'.
  4. Cases for chat-media storage SELECT, INSERT and DELETE, as a member, a non-member and anon. Include the rule from Let non-members read only chat media that a live message uses #432 that a non-member reads only media that a live message names.
  5. The post-erase case from Stop an erased account from writing back its profile, preferences and push devices #579, once that lands.
  6. A CI job that starts Supabase and runs the harness. It adds run time, so plan it with [Tracking] Faster, change-aware CI/CD pipeline #554.

Acceptance criteria

  • Each case fails when its policy is loosened locally, and passes when it is restored.
  • The CI job runs on the triggers ruled below.

Decisions

  1. When does the CI job run? Recommended: on pull requests that touch packages/supabase/**, and on the weekly cron. Most runs then pay nothing, which fits [Tracking] Faster, change-aware CI/CD pipeline #554 ruling 9. Owner: the maintainer, with [Tracking] Faster, change-aware CI/CD pipeline #554.

Effort and order

Effort L. Start after set C of #554, so the job can use its change-aware gating. Related: #554, #570, #553.


Parent: #575. Source: the 2026-10-23 test coverage review, refined on 2026-10-24.

Activity

  1. added this to the v2.3.0 milestone on Oct 24, 2026
  2. added
    enhancement
    Security
    on Oct 24, 2026
  3. HMarzban commented on Oct 24, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-10-24

    When does the CI job run? The recommended answer: on pull requests that touch packages/supabase/**, and on the weekly cron. Most runs then pay nothing, which fits #554 ruling 9.

    This decision is made. The harness still lands after #554 set C (#562, #563).

  4. HMarzban commented on Oct 24, 2026

    @HMarzban
    CollaboratorAuthor

    Related, 2026-10-24

  5. HMarzban commented on Oct 26, 2026

    @HMarzban
    CollaboratorAuthor

    Built and committed on local main. Awaits the maintainer's final push.

    Remaining gate: the push, then the first CI run of the new supabase-policies job on a packages/supabase pull request and on the weekly cron. Locally: 4 files, 36 tests pass.

  6. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-03. The pgTAP harness (4 files, 36 tests) and supabase-policies.yml shipped in 60ad50001, pushed on 2026-11-03. The job has not run on GitHub yet, because the push touched no pull request. Left:

    • maintainer: start Supabase Policy Tests once by hand (workflow_dispatch), or wait for the Sunday cron, and confirm it passes.
  7. modified the milestones: v2.3.0, v2.3.6 on Nov 9, 2026
  8. HMarzban commented on Nov 10, 2026

    @HMarzban
    CollaboratorAuthor

    Done, 2026-11-10. Maintainer ruling, 2026-11-10: "close".

    The last item is met. Supabase Policy Tests ran on the weekly cron on 2026-11-08, and its job passed (run 42444903359). The pgTAP harness (4 files, 36 tests) and supabase-policies.yml shipped in 60ad50001.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DevOpsSecurityenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions