safegres is a pure-Postgres row-level security (RLS) auditor that validates grants, RLS enforcement, policy coverage, and detects risky SQL policy patterns. At version 0.10.1, it offers a CLI and library interface to audit your PostgreSQL database without requiring any application framework. Unlike other Postgres auditing tools, safegres focuses specifically on RLS misconfigurations, providing actionable reports on missing policies, overly permissive grants, and unsafe pattern usage (e.g., `current_setting` in policies). It is actively maintained with monthly releases and ships TypeScript definitions.
npm install safegresNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to a Postgres database using environment variable and runs an RLS audit on the public schema.
Use 'verbose: false' or limit schemas to only those you need.
Pass a pg.Pool instance; if using a Client, wrap it in a Pool (or use runAudit with a pool).
Replace 'import { report } from 'safegres'' with 'import { audit } from 'safegres''.Ensure your Postgres server version is >= 9.5.
Access 'warning.policyName' instead of 'warning.policy' in your code.
Ensure you instantiate a pg.Pool: const pool = new pg.Pool({ connectionString: DATABASE_URL });Upgrade Postgres to >=9.5 or grant the necessary privileges.
Run 'npm install safegres' and ensure your import path is correct.
Create a Pool first: const pool = new pg.Pool({ connectionString: DATABASE_URL });