ReferenceIndividual lint rules
PostgreSQL row-level security
Check native PostgreSQL RLS flags, policy predicates, roles, and operation coverage.
Checks PostgreSQL tables and policies from available state. It models write-check fallback to USING for UPDATE and ALL policies. Use role-based integration tests to verify behavior.
Enable this opt-in rule under lint.rules.
Configuration
import { defineConfig } from '@mwillbanks/zenstack-zenlev'
export default defineConfig({
lint: {
rules: {
'zenlev/postgres/rls': [
'error',
{
tables: ['app.orders'],
force: true,
explicitUsing: true,
explicitWriteCheck: true,
noBroad: true,
roles: ['app_user'],
allowedRoles: ['app_user'],
commands: ['select', 'update'],
},
],
},
},
})Parameters
tablesselects qualified table patterns.enableddefaults totrue.force: truealso requiresFORCE ROW LEVEL SECURITY.explicitUsingrequires a writtenUSINGpredicate onSELECT,UPDATE,DELETE, andALLpolicies.explicitWriteCheckrequires a writtenWITH CHECKonINSERT,UPDATE, andALLpolicies, even when PostgreSQL would use theUSINGfallback.noBroadflags literal true predicates.allowedRoleslists permitted policy targets.roleslists roles to check for operation coverage and defaults topublic.commandsacceptsselect,insert,update, anddelete.defaultDeny: trueskips the operation coverage requirement for intentionally closed tables.
All built-in rules accept the shared selectors.
Example
Enable and force RLS on app.orders. Provide a permissive SELECT policy with USING and an UPDATE policy with both USING and WITH CHECK for app_user.