Interlace    PostgreSQL    oxlint    ESLint

Security rules for PostgreSQL interaction in Node.js (SQL injection prevention).

NPM Version NPM Downloads Install Size Package License Codecov Since Dec 2025 OpenSSF Scorecard

## Getting Started - To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-postgresql-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security). ๐Ÿ“š ```bash npm install --save-dev eslint eslint-plugin-postgresql-security ``` ```js // eslint.config.mjs import { configs } from 'eslint-plugin-postgresql-security'; export default [configs.recommended]; ``` `recommended` is the preset to start with. The others are listed under Configuration Presets below. Using oxlint or Vite+? Install `oxlint-plugin-postgresql-security`: the same rules under the same `postgresql-security/` IDs, without ESLint. Its [page](https://www.npmjs.com/package/oxlint-plugin-postgresql-security) has the setup. ## Description This plugin provides Security rules for PostgreSQL interaction in Node.js (SQL injection prevention). ## Why pg-specific? A generic SQL injection linter can flag string concatenation wherever it appears, but it cannot know the parameterization convention for each database client. The `pg` (node-postgres) driver uses `$1, $2, โ€ฆ` positional placeholders with a second-argument array โ€” a pattern no generic rule encodes. `eslint-plugin-postgresql-security` knows this contract: it only fires on `.query()` calls, it stays silent when a second argument (the values array) is present, and it tracks variable taint across assignment statements so that a split-line pattern like `const sql = "SELECT..." + id; client.query(sql)` is flagged even though the concatenation and the query call are on separate lines. The result is a rule with near-zero false positives on legitimate parameterized queries and reliable detection on the patterns that actually lead to SQL injection. - **Why** โ€” a linter nobody reads protects nothing. We would rather miss a finding than spend your attention on one that was never real. - **How** โ€” evidence, not names. A rule fires on what the code *does*, resolved through the AST and ESLint's own scope analysis. - **What** โ€” every finding carries its fix, in prose for a human and as structured JSON for an agent. Security rules add a CWE mapping and, where assigned, a CVSS score. That trade costs recall, and we measure it: [methodology](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-METHODOLOGY.md) ยท [results](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-RESULTS.md) ยท [a false positive is a bug](https://github.com/ofri-peretz/eslint/issues). ## โš™๏ธ Configuration Presets | Preset | Description | | :------------ | :------------------------------------------------------- | | `recommended` | Recommended preset - balanced security for most projects | | `strict` | Strict preset - all rules as errors | ## ๐Ÿ“š Supported Libraries | Library | npm | Downloads | Detection | | -------------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------- | | `pg` (node-postgres) | [![npm](https://img.shields.io/npm/v/pg.svg?style=flat-square)](https://www.npmjs.com/package/pg) | [![downloads](https://img.shields.io/npm/dt/pg.svg?style=flat-square)](https://www.npmjs.com/package/pg) | SQL Injection, Connection Leaks | ### Custom Configuration ```javascript import pg from 'eslint-plugin-postgresql-security'; export default [ { plugins: { pg }, rules: { 'pg/no-unsafe-query': 'error', 'pg/no-select-all': 'off', // Disable if needed }, }, ]; ``` ## ๐Ÿ’ก What You Get - **PostgreSQL-specific rules:** Catches pg driver anti-patterns that generic linters miss - **LLM-optimized messages:** Structured 2-line errors with CWE + fixes that AI assistants can apply - **Connection safety:** Prevents leaks, double releases, and transaction race conditions - **SQL security:** SQL injection, search_path hijacking, file access via COPY - **Performance patterns:** N+1 queries, SELECT \*, bulk operation suggestions Every rule produces a **structured error message**: ```bash src/db.ts 42:15 error ๐Ÿ”’ CWE-89 OWASP:A03-Injection CVSS:9.8 | Unsafe query detected | CRITICAL Fix: Use parameterized query: client.query('SELECT * FROM users WHERE id = $1', [userId]) ``` ## ๐Ÿ“ฆ Compatibility | Package | Version | | :--- | :--- | | ESLint | `^8.40.0 \|\| ^9.0.0 \|\| ^10.0.0` | | Node.js | `>=22.13.0` | See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) โ€” current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10. ## Rules **Legend** | Icon | Description | | :---: | :--- | | ๐Ÿ’ผ | **Recommended**: Included in the recommended preset. | | โš ๏ธ | **Warns**: Set to warn in recommended preset. | | ๐Ÿ”ง | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. | | ๐Ÿ’ก | **Suggestions**: Providing code suggestions in IDE. | | ๐Ÿšซ | **Deprecated**: This rule is deprecated. | | ๐ŸŸข | **Type-unaware**: AST-only, runs in oxlint JS-plugin tier. | | ๐ŸŸก | **Type-aware (refining)**: pure-AST primary path; types refine precision. | | ๐ŸŸ  | **Type-aware (graceful)**: requires TS program; silent without it. | | Rule | CWE | OWASP | CVSS | Description | ๐Ÿง  | ๐Ÿ’ผ | โš ๏ธ | ๐Ÿ”ง | ๐Ÿ’ก | ๐Ÿšซ | | :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: | | [check-query-params](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/check-query-params?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-89 | | | Ensures the number of placeholders in SQL queries matches the provided parameters. | ๐ŸŸข | | โš ๏ธ | | | | | [no-batch-insert-loop](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-batch-insert-loop?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-400 | | | Prevents INSERT/UPDATE/DELETE queries inside loops (N+1 query anti-pattern). | ๐ŸŸข | | โš ๏ธ | | | | | [no-floating-query](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-floating-query?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-252 | | | Ensures query promises are awaited or handled. | ๐ŸŸข | | โš ๏ธ | | | | | [no-hardcoded-credentials](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-hardcoded-credentials?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-798 | | | Prevents hardcoded passwords and connection strings in PostgreSQL client initialization. | ๐ŸŸข | ๐Ÿ’ผ | | | | | | [no-insecure-ssl](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-insecure-ssl?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-295 | | | Prevents disabling SSL certificate validation in PostgreSQL connections. | ๐ŸŸข | ๐Ÿ’ผ | | | | | | [no-missing-client-release](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-missing-client-release?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-772 | | | Ensures acquired pool clients are released back to the pool. | ๐ŸŸข | ๐Ÿ’ผ | | | | | | [no-select-all](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-select-all?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-1049 | | | Discourages SELECT in favor of explicit column lists. | ๐ŸŸข | | โš ๏ธ | | | | | [no-transaction-on-pool](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-transaction-on-pool?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-362 | | | Prevents running transaction commands directly on pool (must use dedicated client). | ๐ŸŸข | ๐Ÿ’ผ | | | | | | [no-unsafe-copy-from](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-unsafe-copy-from?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-73 | A03:2021 | | Prevents COPY FROM with file paths (should use STDIN for safe client-side data loading). | ๐ŸŸข | ๐Ÿ’ผ | | | | | | [no-unsafe-query](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-unsafe-query?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-89 | | | SQL injection is one of the most critical security vulnerabilities | ๐ŸŸข | ๐Ÿ’ผ | | | | | | [no-unsafe-search-path](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/no-unsafe-search-path?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-426 | | | Prevents dynamic SET searchpath queries that could enable schema hijacking. | ๐ŸŸข | ๐Ÿ’ผ | | | | | | [prefer-pool-query](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/prefer-pool-query?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-400 | | | Suggests using pool.query() for single-shot queries instead of manual connect/release. | ๐ŸŸข | | โš ๏ธ | | | | | [prevent-double-release](https://eslint.interlace.tools/docs/security/plugin-postgresql-security/rules/prevent-double-release?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security) | CWE-415 | | | Prevents calling client.release() multiple times on the same client. | ๐ŸŸข | | โš ๏ธ | | | | ## ๐Ÿ”— Related ESLint Plugins Part of the **Interlace ESLint ecosystem** โ€” AI-native rules with LLM-optimized error messages: **Security** | Plugin | Downloads | Description | | :--- | :---: | :--- | | [`eslint-plugin-anthropic-security`](https://www.npmjs.com/package/eslint-plugin-anthropic-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-anthropic-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-anthropic-security) | Anthropic SDK security. | | [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-browser-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-browser-security) | XSS, DOM security. | | [`eslint-plugin-drizzle-security`](https://www.npmjs.com/package/eslint-plugin-drizzle-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-drizzle-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-drizzle-security) | Drizzle security. | | [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-express-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-express-security) | Express middleware hardening. | | [`eslint-plugin-gemini-security`](https://www.npmjs.com/package/eslint-plugin-gemini-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-gemini-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-gemini-security) | Google Gemini SDK security. | | [`eslint-plugin-jwt-security`](https://www.npmjs.com/package/eslint-plugin-jwt-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-jwt-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-jwt-security) | Token security. | | [`eslint-plugin-knex-security`](https://www.npmjs.com/package/eslint-plugin-knex-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-knex-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-knex-security) | Knex security. | | [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-lambda-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda hardening. | | [`eslint-plugin-mcp-sdk-security`](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-mcp-sdk-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security) | MCP SDK security. | | [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-mongodb-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | MongoDB injection. | | [`eslint-plugin-mysql-security`](https://www.npmjs.com/package/eslint-plugin-mysql-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-mysql-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-mysql-security) | MySQL security. | | [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-nestjs-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS framework hardening. | | [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-node-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-node-security) | Server-side patterns. | | [`eslint-plugin-openai-security`](https://www.npmjs.com/package/eslint-plugin-openai-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-openai-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-openai-security) | OpenAI SDK security. | | [`eslint-plugin-prisma-security`](https://www.npmjs.com/package/eslint-plugin-prisma-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-prisma-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-prisma-security) | Prisma security. | | [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-secure-coding.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-secure-coding) | Injection prevention. | | [`eslint-plugin-sequelize-security`](https://www.npmjs.com/package/eslint-plugin-sequelize-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-sequelize-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-sequelize-security) | Sequelize ORM security. | | [`eslint-plugin-sqlite-security`](https://www.npmjs.com/package/eslint-plugin-sqlite-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-sqlite-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-sqlite-security) | SQLite security. | | [`eslint-plugin-supabase-security`](https://www.npmjs.com/package/eslint-plugin-supabase-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-supabase-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-supabase-security) | Supabase security. | | [`eslint-plugin-typeorm-security`](https://www.npmjs.com/package/eslint-plugin-typeorm-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-typeorm-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-typeorm-security) | TypeORM security. | | [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-vercel-ai-security.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | AI SDK security. | **Code quality** | Plugin | Downloads | Description | | :--- | :---: | :--- | | [`eslint-plugin-conventions`](https://www.npmjs.com/package/eslint-plugin-conventions) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-conventions.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-conventions) | Team-specific habits and styles. | | [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-import-next.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-import-next) | Fast cycle + import-graph analysis. | | [`eslint-plugin-maintainability`](https://www.npmjs.com/package/eslint-plugin-maintainability) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-maintainability.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-maintainability) | Cognitive load and clean-code patterns. | | [`eslint-plugin-modernization`](https://www.npmjs.com/package/eslint-plugin-modernization) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-modernization.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-modernization) | ESNext migration + syntax evolution. | | [`eslint-plugin-modularity`](https://www.npmjs.com/package/eslint-plugin-modularity) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-modularity.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-modularity) | Structural integrity and DDD patterns. | | [`eslint-plugin-operability`](https://www.npmjs.com/package/eslint-plugin-operability) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-operability.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-operability) | Production readiness and resource health. | | [`eslint-plugin-react-a11y`](https://www.npmjs.com/package/eslint-plugin-react-a11y) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-react-a11y.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-react-a11y) | React accessibility / WCAG. | | [`eslint-plugin-react-features`](https://www.npmjs.com/package/eslint-plugin-react-features) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-react-features.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-react-features) | React best practices and optimization. | | [`eslint-plugin-reliability`](https://www.npmjs.com/package/eslint-plugin-reliability) | [![downloads](https://img.shields.io/npm/dt/eslint-plugin-reliability.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-reliability) | Runtime stability and error safety. | ## Support Found a false positive? [Open an issue](https://github.com/ofri-peretz/eslint/issues): that is a bug. If the plugin helped, a star on [ofri-peretz/eslint](https://github.com/ofri-peretz/eslint) helps others find it. ## ๐Ÿ“„ License MIT ยฉ [Ofri Peretz](https://github.com/ofri-peretz)

ESLint Interlace Plugin

Interlace