Conversation
📝 WalkthroughWalkthroughAdds RBAC-gated authorization for app-version checks via new SECURITY DEFINER functions, removes a deprecated API-key RPC and its CLI/type usages, updates DB tests to cover API-key scoping, and pins test fixture package version to 6.45.10. Changesexist_app_versions RBAC + cleanup
sequenceDiagram
participant Client as Caller
participant Rpc as exist_app_versions()
participant RBAC as rbac_check_permission_direct
participant Apps as public.apps / public.app_versions
Client->>Rpc: call exist_app_versions(appid, name_version[, apikey])
Rpc->>Apps: resolve owning org (apps)
alt not found
Rpc-->>Client: return false
else found
Rpc->>RBAC: check permission (bundle-read) using user or apikey context
alt allowed
Rpc->>Apps: query app_versions for (org, appid, name_version)
Rpc-->>Client: return exists? (true/false)
else denied
Rpc-->>Client: return false
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 SQLFluff (4.1.0)supabase/tests/05_app_functions.sqlUser Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects: supabase/migrations/20260507091347_secure_exist_app_versions_rpc.sqlUser Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects: supabase/tests/33_test_rbac_phase1.sqlUser Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects: Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0114d48268
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
0114d48 to
5ec1de6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cli/test/fixtures/setup-test-projects.sh`:
- Line 10: The PACKAGE_VERSION variable in setup-test-projects.sh is set to a
non-existent npm version ("6.45.10") which will cause installs to fail under set
-e; update the PACKAGE_VERSION value to an existing published version (for
example "6.43.5") or coordinate/release 6.45.10 before merging so that the
install commands that reference PACKAGE_VERSION succeed; locate and edit the
PACKAGE_VERSION="6.45.10" assignment in setup-test-projects.sh to the chosen
valid version.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e13d7fd8-7583-457b-b354-b3d8b1cfbb62
📒 Files selected for processing (8)
cli/src/types/supabase.types.tscli/src/utils.tscli/test/fixtures/setup-test-projects.shsrc/types/supabase.types.tssupabase/functions/_backend/utils/supabase.types.tssupabase/migrations/20260507091347_secure_exist_app_versions_rpc.sqlsupabase/tests/05_app_functions.sqlsupabase/tests/33_test_rbac_phase1.sql
💤 Files with no reviewable changes (4)
- cli/src/utils.ts
- cli/src/types/supabase.types.ts
- src/types/supabase.types.ts
- supabase/functions/_backend/utils/supabase.types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- supabase/migrations/20260507091347_secure_exist_app_versions_rpc.sql
|



Summary (AI generated)
exist_app_versionsRPC overloads with service-role bypass plus RBAC/API-key authorization before returning bundle existence.check_min_rightsso directappsRLS respects explicit API-key RBAC bindings instead of falling back to broader owner-user permissions.getAccessibleAppsForApiKeyhelper and dropsget_accessible_apps_for_apikey_v2; the CLI now relies on the correctedappsRLS path.Motivation (AI generated)
exist_app_versionswas an unauthenticated oracle for release-history enumeration. While reviewing the CLI app-list path, the API-key RBAC restriction belonged incheck_min_rightsitself so direct table RLS stays correct and no app-list wrapper RPC is needed.Business Impact (AI generated)
This protects customer release timelines and security-fix history from public enumeration, and keeps restricted API keys restricted consistently across CLI and direct table access.
Test Plan (AI generated)
bun lintbun typecheckbun run cli:checkbun scripts/supabase-worktree.ts test db supabase/tests/00-supabase_test_helpers.sql supabase/tests/05_app_functions.sql supabase/tests/33_test_rbac_phase1.sqlcapgkeyreturnsfalsecapgkeyreturnstrueGenerated with AI
Summary by CodeRabbit
Chores
Bug Fixes
Tests