<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rodrigo Tari Carderera</title>
    <description>The latest articles on DEV Community by Rodrigo Tari Carderera (@rodrigotari1).</description>
    <link>https://dev.to/rodrigotari1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3571013%2Fb0ceefa7-2712-4e71-a6ec-8cce8d95ab50.jpeg</url>
      <title>DEV Community: Rodrigo Tari Carderera</title>
      <link>https://dev.to/rodrigotari1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rodrigotari1"/>
    <language>en</language>
    <item>
      <title>I Built a CLI to Test Supabase RLS Policies</title>
      <dc:creator>Rodrigo Tari Carderera</dc:creator>
      <pubDate>Fri, 17 Oct 2025 13:28:30 +0000</pubDate>
      <link>https://dev.to/rodrigotari1/i-built-a-cli-to-test-supabase-rls-policies-30aa</link>
      <guid>https://dev.to/rodrigotari1/i-built-a-cli-to-test-supabase-rls-policies-30aa</guid>
      <description>&lt;h1&gt;
  
  
  The Problem
&lt;/h1&gt;

&lt;p&gt;RLS policies are a pain to test and the consequences of getting them wrong are serious.&lt;/p&gt;

&lt;p&gt;Recently, a Lovable app leaked 13k users' data due to broken RLS policies. This isn't uncommon. &lt;/p&gt;

&lt;p&gt;With the rise of vibe coded apps, many developers are shipping to production without proper security testing.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Solution
&lt;/h1&gt;

&lt;p&gt;I built &lt;strong&gt;SupaShield&lt;/strong&gt; a CLI tool that tests your Supabase RLS policies before they hit production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Introspects your DB schema&lt;/strong&gt; automatically&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simulates different roles&lt;/strong&gt; (anon, authenticated, custom JWT claims)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests CRUD operations&lt;/strong&gt; on every RLS enabled table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wraps everything in transactions&lt;/strong&gt; with ROLLBACK (no data changes)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generates snapshots&lt;/strong&gt; you can diff in CI&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; supashield
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Quick Start
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Set your database URL&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;SUPASHIELD_DATABASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"postgresql://..."&lt;/span&gt;

&lt;span class="c"&gt;# Generate tests and run them&lt;/span&gt;
supashield init                        &lt;span class="c"&gt;# discover tables and generate tests&lt;/span&gt;
supashield &lt;span class="nb"&gt;test&lt;/span&gt;                        &lt;span class="c"&gt;# test all RLS policies&lt;/span&gt;
supashield &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--table&lt;/span&gt; public.users   &lt;span class="c"&gt;# test specific table&lt;/span&gt;
supashield &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--as-user&lt;/span&gt; admin@company.com  &lt;span class="c"&gt;# test with real user&lt;/span&gt;
supashield &lt;span class="nb"&gt;users&lt;/span&gt;                       &lt;span class="c"&gt;# list users from auth.users for testing&lt;/span&gt;
supashield export-pgtap &lt;span class="nt"&gt;-o&lt;/span&gt; tests.sql   &lt;span class="c"&gt;# export tests to pgTap format&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example Output
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Testing public.users:
  anonymous_user:
    SELECT: ALLOW (expected DENY) - MISMATCH!
    INSERT: DENY (expected DENY) - PASS
  authenticated_user:
    SELECT: ALLOW (expected ALLOW) - PASS
    INSERT: DENY (expected ALLOW) - MISMATCH!

Results: 2 passed, 2 failed
2 policy mismatches detected!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's not a substitute for proper security reviews as attackers will always find crafty exploits. &lt;/p&gt;

&lt;p&gt;But it catches the obvious mistakes before they leak user data.&lt;/p&gt;

&lt;h1&gt;
  
  
  Try It Out
&lt;/h1&gt;

&lt;p&gt;The tool is open source (MIT licensed) and available on GitHub: &lt;a href="https://github.com/Rodrigotari1/supashield" rel="noopener noreferrer"&gt;https://github.com/Rodrigotari1/supashield&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open to feedback!&lt;/p&gt;

</description>
      <category>database</category>
      <category>security</category>
      <category>vibecoding</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
