Proposal update to make it where Supabase rule 0029 will skip functions whose body matches a reasonable "gated" heuristic - e.g. contains a check on 'auth.uid( )', 'has_role', 'is_admin', or equivalent.
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
調査の方向性
まず、ルール 0029_authenticated_security_definer_function_executable の実装とテストを見つけます。payload には具体的なファイル名が記載されていません。ヒューリスティック、SQL コメントによるオプトアウト、config allowlist の各提案を比較し、コーディングする前に maintainers がどの方向を望んでいるかを確認します。選択した抑制動作が実装され、テストでカバーされ、実際に安全でない関数を隠していないことをもって完了とします。
索引モデルが issue の本文から書いたものです。
説明
Title
0029: allow opt-in suppression for SECURITY DEFINER functions that self-gate the caller
Body
Summary
Rule 0029_authenticated_security_definer_function_executable flags every SECURITY DEFINER function in the exposed API schema that is executable by authenticated. In codebases that legitimately rely on definer RPCs for cross-user reads, RPC-only tables, and rate-limit counters, this produces a large number of warnings that cannot be resolved without either (a) removing DEFINER and breaking the RPC's purpose, or (b) revoking EXECUTE from authenticated and moving the call off the Data API.
Both options are unattractive for the common pattern where a definer function is the gate:
CREATE OR REPLACE FUNCTION public.mp_end_room_v2(p_game_id uuid, p_reason text)
RETURNS void LANGUAGE plpgsql SECURITY DEFINER
SET search_path = 'public' AS $$
DECLARE v_uid uuid := auth.uid();
BEGIN
IF v_uid IS NULL THEN RETURN; END IF;
-- ...participant check against mp_games...
UPDATE public.mp_games SET status = 'ended' WHERE id = p_game_id
AND (host_user_id = v_uid OR guest_user_id = v_uid);
END $$;
This function needs DEFINER because it mutates the opponent's row in mp_games; it self-gates via auth.uid() and a participant check. There is no safe alternative: SECURITY INVOKER would fail RLS, and revoking EXECUTE FROM authenticated would make the game unplayable.
Concrete data point
In a game project with ~40 definer RPCs (matchmaking, chat, ranked Elo, spectator flow), rule 0029 flags 33+ functions. After a manual audit, all 33 were confirmed as intentionally-gated definers. The signal-to-noise ratio for this rule in that codebase is effectively 0%.
Proposals (any one would help)
Option A — Heuristic: Skip functions whose body references any of auth.uid(), auth.jwt(), public.has_role(, is_admin(, or RAISE EXCEPTION within the first N statements. False positives are still possible, but the rule stops firing on the common "check-then-act" pattern.
Option B — Explicit opt-out via COMMENT: Skip functions whose Postgres comment matches a marker such as lint:0029-safe. Example:
COMMENT ON FUNCTION public.mp_end_room_v2(uuid, text)
IS 'lint:0029-safe — participant check via auth.uid() inside body';
This is the same escape-hatch pattern many linters use (# noqa, // eslint-disable) and gives auditors a searchable marker in the source.
Option C — Config-driven allowlist: Support a project-level allowlist (e.g. an entry in supabase/config.toml or a magic table public._splinter_ignore) that lists function names to skip.
Option B is the least invasive and the most auditable. Option A alone would already remove most noise.
Why this matters
Right now, teams doing the right thing (definer RPCs for privileged writes, self-gated with auth.uid()) are indistinguishable in the linter output from teams that accidentally left a definer function exposed. That creates alert fatigue on 0029 and pushes teams toward either ignoring the whole rule or maintaining out-of-band allowlists. Any of the three options above would let 0029 flag only the risky definers, which is what the rule was intended to catch.
Happy to contribute a PR for option B if there's interest.
- 主要言語
- PLpgSQL
- スター
- 284
- フォーク
- 110
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
supabase/splinter のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
supabase/splinter#206 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
0002_auth_users_exposed false positive: pg_depend join lacks a refclassid filter (cross-catalog OID collision)対応中かも @tushardev-365 が 97 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 40/100
supabase/splinter#210 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
0030_autovacuum_disabled misses tables where autovacuum_enabled is set to off, 0 or no対応中かも @RaphaelFakhri が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Proposal: lint for RLS policies whose role lacks the table privilege (policy_without_privilege)対応中かも @larik15 が 29 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 1/100
メンテナーはふだん 1 日以内に返信
supabase/splinter の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
langchain-ai/langchain-redis#222 ·
メンテナーはふだん 2 日以内に返信
-
`BLMPOP` with COUNT 0 or numkeys 0 hangs対応中かも @ggyuchive が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted new check
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Area - Azure Provisioning Area - Local to Cloud Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
microsoft/vscode-mssql#23205 ·
メンテナーはふだん 1 日以内に返信