ESLint InterlaceESLint Interlace
Plugin: pg

Overview

PostgreSQL security and best practices for the pg driver

Live from GitHub

This content is fetched directly from README.md on GitHub and cached for 1 hour.

AI-Optimized Security

Every rule includes CWE, OWASP, and CVSS metadata for AI assistants to provide precise, context-aware fixes.


ESLint Interlace Logo

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

NPM VersionNPM DownloadsPackage LicenseCodecovSince Dec 2025

Description

This plugin provides Security rules for PostgreSQL interaction in Node.js (SQL injection prevention). By using this plugin, you can proactively identify and mitigate security risks across your entire codebase.

Philosophy

Interlace fosters strength through integration. Instead of stacking isolated rules, we interlace security directly into your workflow to create a resilient fabric of code. We believe tools should guide rather than gatekeep, providing educational feedback that strengthens the developer with every interaction.

Getting Started

npm install eslint-plugin-pg --save-dev

๐Ÿ’ก 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:

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])

โš™๏ธ Configuration Presets

PresetDescription
recommendedRecommended preset - balanced security for most projects
strictStrict preset - all rules as errors

๐Ÿ“š Supported Libraries

LibrarynpmDownloadsDetection
pg (node-postgres)SQL Injection, Connection Leaks

Custom Configuration

import pg from 'eslint-plugin-pg';

export default [
  {
    plugins: { pg },
    rules: {
      'pg/no-unsafe-query': 'error',
      'pg/no-select-all': 'off', // Disable if needed
    },
  },
];

Rules

Legend

IconDescription
๐Ÿ’ผRecommended: Included in the recommended preset.
โš ๏ธWarns: Set towarn in recommended preset.
๐Ÿ”งAuto-fixable: Automatically fixable by the --fix CLI option.
๐Ÿ’กSuggestions: Providing code suggestions in IDE.
๐ŸšซDeprecated: This rule is deprecated.
RuleCWEOWASPCVSSDescription๐Ÿ’ผโš ๏ธ๐Ÿ”ง๐Ÿ’ก๐Ÿšซ
check-query-paramsCWE-20A06:2025ESLint rule documentation for check-query-params๐Ÿ’ผโš ๏ธ๐Ÿ’ก
no-batch-insert-loopCWE-400A04:2025ESLint rule documentation for no-batch-insert-loop๐Ÿ’ผโš ๏ธ๐Ÿ’ก
no-floating-queryCWE-252A06:2025ESLint rule documentation for no-floating-query๐Ÿ’ผ๐Ÿ’ก
no-hardcoded-credentialsCWE-798A05:2025ESLint rule documentation for no-hardcoded-credentials๐Ÿ’ผ๐Ÿ’ก
no-insecure-sslCWE-295A05:2025ESLint rule documentation for no-insecure-ssl๐Ÿ’ผ๐Ÿ’ก
no-missing-client-releaseCWE-772A09:2025ESLint rule documentation for no-missing-client-release๐Ÿ’ผ๐Ÿ’ก
no-select-allCWE-400A04:2025ESLint rule documentation for no-select-all๐Ÿ’ผโš ๏ธ๐Ÿ’ก
no-transaction-on-poolCWE-362A04:2025ESLint rule documentation for no-transaction-on-pool๐Ÿ’ผ๐Ÿ’ก
no-unsafe-copy-fromCWE-22A03:2025ESLint rule documentation for no-unsafe-copy-from๐Ÿ’ผ๐Ÿ’ก
no-unsafe-queryCWE-89A03:2025ESLint rule documentation for no-unsafe-query๐Ÿ’ผ๐Ÿ’ก
no-unsafe-search-pathCWE-426A01:2025ESLint rule documentation for no-unsafe-search-path๐Ÿ’ผ๐Ÿ’ก
prefer-pool-queryCWE-404A04:2025ESLint rule documentation for prefer-pool-query๐Ÿ’ผโš ๏ธ๐Ÿ’ก
prevent-double-releaseCWE-415A04:2025ESLint rule documentation for prevent-double-release๐Ÿ’ผ๐Ÿ’ก

Part of the Interlace ESLint Ecosystem โ€” AI-native security plugins with LLM-optimized error messages:

PluginDownloadsDescription
eslint-plugin-secure-codingGeneral security rules & OWASP guidelines.
eslint-plugin-pgPostgreSQL security & best practices.
eslint-plugin-cryptoNodeJS Cryptography security rules.
eslint-plugin-jwtJWT security & best practices.
eslint-plugin-browser-securityBrowser-specific security & XSS prevention.
eslint-plugin-express-securityExpress.js security hardening rules.
eslint-plugin-lambda-securityAWS Lambda security best practices.
eslint-plugin-nestjs-securityNestJS security rules & patterns.
eslint-plugin-mongodb-securityMongoDB security best practices.
eslint-plugin-vercel-ai-securityVercel AI SDK security hardening.
eslint-plugin-import-nextNext-gen import sorting & architecture.

๐Ÿ“„ License

MIT ยฉ Ofri Peretz

ESLint Interlace Plugin

View README.md on GitHub โ†’

On this page

No Headings