Skip to content

lf security

Database security audit commands. Queries the Supabase backend for RLS coverage gaps and SECURITY DEFINER hygiene issues. Designed to gate CI pipelines: exits 1 when violations are found.

lf security rls-audit

Audit Row Level Security (RLS) coverage and SECURITY DEFINER function hygiene. Prints a violation report and exits 1 if any issues are found.

FlagTypeRequiredDefaultDescription
--jsonbooleannofalseOutput raw JSON instead of formatted tables

Examples

bash
# Run the audit and print a human-readable report
lf security rls-audit

# Machine-readable output for CI pipelines
lf security rls-audit --json

Successful output

✔ All sensitive tables have RLS enabled.
✔ All SECURITY DEFINER functions have SET search_path configured.
✔ RLS audit PASSED.

Failure output

✖ 2 table(s) missing RLS:
schema  table
public  widgets
public  drafts

✖ 1 SECURITY DEFINER function(s) missing SET search_path:
schema  function          signature
public  fn_admin_helper   fn_admin_helper()

✖ RLS audit FAILED. Fix violations before deploying.

Exit codes

CodeMeaning
0Audit passed — no violations
1Violations found
2Script error (missing config, unreachable backend)

Errors

ErrorCauseFix
UnauthorizedNot logged inRun lf auth login
RPC error fn_rls_unprotected_tablesMigration not appliedRun lf dev and apply pending migrations

Environment Variables

VariableRequiredDescription
SUPABASE_URLyesSupabase project URL
SUPABASE_ANON_KEYyesSupabase anon key