Restrict plan max RPC to authorized org callers#1754
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a SECURITY DEFINER PostgreSQL function Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant DB as DB Function: get_current_plan_max_org
participant Identity as get_identity_org_allowed
participant Rights as check_min_rights
participant Data as orgs/stripe_info/plans
Client->>DB: CALL get_current_plan_max_org(orgid)
DB->>Identity: derive requesting_user(orgid)
Identity-->>DB: requesting_user / allowed_orgs
DB->>Rights: check_min_rights(requesting_user, orgid, 'org.read')
Rights-->>DB: allowed / denied
alt allowed
DB->>Data: query orgs JOIN stripe_info JOIN plans
Data-->>DB: plan metrics
DB-->>Client: return rows (mau, bandwidth, storage, build_time_unit)
else denied
DB-->>Client: return 0 rows (log deny)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
c088165 to
5d036d0
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
supabase/tests/08_plan_functions.sql (1)
53-53: Minor: Consider explicit type cast for count comparison.
count(*)returnsbigint, while0is an integer literal. While PostgreSQL handles this implicitly, an explicit cast improves type clarity.Proposed fix
- 0, + 0::bigint,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@supabase/tests/08_plan_functions.sql` at line 53, The test compares count(*) (which yields bigint) to the literal 0; change the literal to an explicit bigint cast (e.g., use 0::bigint or CAST(0 AS bigint)) wherever the literal appears in the assertion in the 08_plan_functions.sql test so the types match the count(*) result and avoid implicit coercion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@supabase/tests/08_plan_functions.sql`:
- Line 53: The test compares count(*) (which yields bigint) to the literal 0;
change the literal to an explicit bigint cast (e.g., use 0::bigint or CAST(0 AS
bigint)) wherever the literal appears in the assertion in the
08_plan_functions.sql test so the types match the count(*) result and avoid
implicit coercion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fa50bd7a-72cb-4bbe-a04d-1af93d365ec8
📒 Files selected for processing (2)
supabase/migrations/20260308203334_fix_get_current_plan_max_org_access_cli.sqlsupabase/tests/08_plan_functions.sql
|



Summary (AI generated)
public.get_current_plan_max_org(uuid).get_identity_org_allowedandcheck_min_rights('read', ...)so callers must be authorized for the requested org.authenticatedandservice_role.Test plan (AI generated)
bun lint.origin/main.Screenshots (AI generated)
Checklist (AI generated)
bun lint.Summary by CodeRabbit