Security hardening: enable RLS, sanitize errors, validate URLs, gate devtools#29
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
Security hardening: enable RLS, sanitize errors, validate URLs, gate devtools#29devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
- Add Supabase migration enabling RLS on all tables with authenticated-only policies - Validate repo_url protocol (http/https) before rendering as clickable link - Gate Zustand devtools middleware behind import.meta.env.DEV - Sanitize Supabase error messages in production via userFacingError helper - Hide ErrorBoundary stack traces in production builds Co-Authored-By: alecvdpoel <alecvdpoel@pm.me>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
The app uses the Supabase anon key without any authentication flow. Policies now grant access to both anon and authenticated roles so the app continues to work. Comment notes these should be tightened once an auth flow is added. Co-Authored-By: alecvdpoel <alecvdpoel@pm.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security audit and hardening pass across the codebase. The changes fall into five categories:
Enable Supabase Row-Level Security — New migration (
20260415_enable_rls_all_tables.sql) enables RLS on all 5 tables and creates CRUD policies for both theanonandauthenticatedroles. Since the app currently has no authentication flow and uses the anon key exclusively, both roles are granted access. The migration includes comments noting these should be tightened toauthenticated-only (or row-owner checks likeauth.uid() = owner_id) once an auth flow is added.Validate
repo_urlbefore rendering as link —ProjectDetail.tsxnow checks thatrepo_urlstarts withhttp://orhttps://before rendering it in an<a href>. Non-HTTP URLs (e.g.javascript:) are rendered as plain text instead.Gate Zustand devtools to dev-only — All 4 stores (
projects,tools,sessions,ui) now passenabled: import.meta.env.DEVso Redux DevTools integration is stripped from production builds.Sanitize Supabase error messages — New
src/lib/errors.tshelper (userFacingError) returns a generic message in production to avoid leaking internal table/column names. Applied to all error paths in projects, tools, and sessions stores.Hide ErrorBoundary stack traces in production — The
<pre>block inErrorBoundary.tsxis now gated behindimport.meta.env.DEV.Review & Testing Checklist for Human
anonandauthenticatedroles — this is a deliberate stepping stone since the app has no auth flow yet. Verify this matches your intent. When you add authentication later, tighten these policies toauthenticated-only or add row-owner checks.repo_urldisplay: Verify that projects with validhttps://URLs still render as clickable links, and that a hypotheticaljavascript:or malformed URL renders as plain text.npm run buildand confirm the app works — devtools should not appear, error toasts should show "Something went wrong", and the ErrorBoundary should not show stack traces.Notes
npm auditreports 0 vulnerabilities — no dependency changes in this PR.userFacingErrorhelper intentionally shows a single generic message in production. If you want more granularity (e.g., network vs. validation errors), the helper can be extended later.userFacingErrorhelper or the URL validation regex — consider adding these if you'd like coverage on these paths.Link to Devin session: https://app.devin.ai/sessions/460394d6b50548f194e1cd70a5a2e843
Requested by: @alecvdp