Configure Safegres Presets and SQL Lint Rules
Dan Lynch
Write a team preset
Save this as safegres-preset.json beside your project config to share two team conventions:
json{ "rules": { "C1": "high", "C3": "low" } }
In safegres.config.js, set extends: ['safegres:recommended', './safegres-preset.json']. Keep your exposure settings. If you already use a stack preset, keep it first. Verify the rules and exposure:
bashpnpm exec safegres print-config --explain pnpm exec safegres audit --verbose
Later layers win: objects merge, ordinary arrays replace, and table overrides accumulate. To share via npm, point the package's main at the JSON and use its package name in extends. Other built-in postures include strict, multi-tenant, oltp, and minimal. Keep exceptions narrow and document why they're safe.
Choose a search_path policy
A privileged function must not resolve names from schemas writable by untrusted users. See CVE-2018-1058 and PostgreSQL's SECURITY DEFINER guidance.
safegres:recommended disables C-series checks; safegres:constructive enables them. Keep C1 off if your policy requires a pinned path. Conversely, CF1 can still flag a no-SET function. C3 checks relation names, not every function, type, operator, or dynamic reference.
Safegres reports C1 against the live database. To block unwanted path settings in migration files, use the companion source linter:
bashpnpm add -Dw @pgsql/lint pnpm exec pgsql-lint --no-config --rules C1 packages/audit-demo/deploy
safegres lint is an alias for the live audit, not the file linter. Other source checks cover #variable_conflict (C2), unqualified relations (C3), and dynamic SQL (C4).
To enforce your own conventions, use defineRule and createLinter in a separate source check. The SQL linting course shows how to require a schema in every function definition.

