eslint-plugin-postgresql-security 3.0.4 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,97 @@
1
+ <!-- Generated by scripts/generate-plugin-agents-md.ts from package.json and the plugin exports. Do not edit by hand; run `npm run agents-md`. -->
2
+
3
+ # eslint-plugin-postgresql-security
4
+
5
+ Guide for AI coding assistants using this plugin in a project. To change the plugin's own source, read https://github.com/ofri-peretz/eslint/blob/main/AGENTS.md instead.
6
+
7
+ > ESLint Postgres security rules for the pg PostgreSQL driver — detects SQL injection, unreleased clients, floating queries, unsafe search_path, and insecure SSL.
8
+
9
+ ## Enable it
10
+
11
+ ```bash
12
+ npm install --save-dev eslint-plugin-postgresql-security
13
+ ```
14
+
15
+ Requires ESLint ^8.40.0 || ^9.0.0 || ^10.0.0 and Node >=22.13.0.
16
+
17
+ Flat config files (`eslint.config.*`) are found by ESLint 8.57 and newer; on ESLint 9 and 10 they are the default.
18
+
19
+ ```js
20
+ // eslint.config.mjs
21
+ import postgresqlSecurity from 'eslint-plugin-postgresql-security';
22
+
23
+ export default [postgresqlSecurity.configs.recommended];
24
+ ```
25
+
26
+ Each preset is one flat config object: put it in the array as an element, do not spread it. Rule ids are prefixed `postgresql-security/`. Add it to the config you already have; do not remove other plugins. TypeScript files need a TypeScript parser in the config (`typescript-eslint`).
27
+
28
+ Use it alongside `eslint-plugin-security`, not instead of it: keep that plugin if the project has it. Measured overlap and the limits of both: https://eslint.interlace.tools/docs/getting-started/with-eslint-plugin-security
29
+
30
+ ## Presets
31
+
32
+ | Preset | Rules | Errors | Warnings |
33
+ | ------------- | ----- | ------ | -------- |
34
+ | `flagship` | 1 | 1 | 0 |
35
+ | `recommended` | 13 | 7 | 6 |
36
+ | `strict` | 13 | 13 | 0 |
37
+
38
+ ### `flagship`
39
+
40
+ 1 rule:
41
+
42
+ - `no-unsafe-query` (error): Prevent SQL injection by disallowing string concatenation or unsafe template literals in queries.
43
+
44
+ ### `recommended`
45
+
46
+ 13 rules:
47
+
48
+ - `no-unsafe-query` (error): Prevent SQL injection by disallowing string concatenation or unsafe template literals in queries.
49
+ - `no-insecure-ssl` (error): Prevent the use of insecure SSL configurations (rejectUnauthorized: false).
50
+ - `no-hardcoded-credentials` (error): Detect hardcoded credentials in pg Client or Pool initialization.
51
+ - `no-unsafe-search-path` (error): Prevent unsafe SET search_path usage with dynamic values, which can lead to schema hijacking.
52
+ - `no-unsafe-copy-from` (error): Prevent unsafe COPY FROM usage with dynamic file paths, which can lead to arbitrary file read/RCE.
53
+ - `no-transaction-on-pool` (error): Prevent starting transactions directly on the Pool, which is unsafe due to lack of client affinity.
54
+ - `no-missing-client-release` (error): Ensure pg client is released after use to prevent pool exhaustion.
55
+ - `prevent-double-release` (warn): Prevent releasing a pg client multiple times.
56
+ - `no-floating-query` (warn): Ensure all queries are awaited or returned to prevent unhandled promise rejections.
57
+ - `check-query-params` (warn): Ensure the number of query parameters matches the arguments array.
58
+ - `no-select-all` (warn): Prevent using * in SELECT statements (implicit columns).
59
+ - `prefer-pool-query` (warn): Prefer pool.query() over client.query() for single-shot queries.
60
+ - `no-batch-insert-loop` (warn): Prevent executing database queries within loops (N+1 problem).
61
+
62
+ ### `strict`
63
+
64
+ Same rules as `recommended`.
65
+
66
+ ## Other Interlace plugins by dependency
67
+
68
+ If the project also depends on one of these, add the matching plugin the same way:
69
+
70
+ - `express`, `fastify`, `koa`, `@hapi/hapi`, `restify`, `hono`, `next`, `@nestjs/core`, `@nestjs/common`, `aws-lambda`, `@types/aws-lambda`, `@middy/core`, `commander`, `yargs`, `@oclif/core`, `@modelcontextprotocol/*`: `eslint-plugin-node-security`
71
+ - `express`: `eslint-plugin-express-security`
72
+ - `@nestjs/common`, `@nestjs/core`: `eslint-plugin-nestjs-security`
73
+ - `react`, `react-dom`, `preact`, `vue`, `svelte`, `@angular/core`, `solid-js`, `lit`, `next`, `nuxt`: `eslint-plugin-browser-security`
74
+ - `jsonwebtoken`, `jose`, `express-jwt`, `@nestjs/jwt`, `jwks-rsa`, `jwt-decode`: `eslint-plugin-jwt-security`
75
+ - `mysql2`, `mysql`: `eslint-plugin-mysql-security`
76
+ - `mongodb`, `mongoose`: `eslint-plugin-mongodb-security`
77
+ - `better-sqlite3`, `sqlite3`: `eslint-plugin-sqlite-security`
78
+ - `knex`: `eslint-plugin-knex-security`
79
+ - `@prisma/client`, `prisma`: `eslint-plugin-prisma-security`
80
+ - `drizzle-orm`: `eslint-plugin-drizzle-security`
81
+ - `sequelize`: `eslint-plugin-sequelize-security`
82
+ - `typeorm`: `eslint-plugin-typeorm-security`
83
+ - `@supabase/supabase-js`: `eslint-plugin-supabase-security`
84
+ - `@modelcontextprotocol/*`: `eslint-plugin-mcp-sdk-security`
85
+ - `openai`, `@openai/agents`: `eslint-plugin-openai-security`
86
+ - `@anthropic-ai/sdk`, `@anthropic-ai/claude-agent-sdk`: `eslint-plugin-anthropic-security`
87
+ - `@google/genai`: `eslint-plugin-gemini-security`
88
+ - `ai`: `eslint-plugin-vercel-ai-security`
89
+ - `aws-lambda`, `@types/aws-lambda`, `@middy/core`: `eslint-plugin-lambda-security`
90
+
91
+ The full stack-to-plugin playbook (with config rendering and a proof step) is the `security-linting` skill: https://github.com/ofri-peretz/eslint/tree/main/skills/security-linting
92
+
93
+ ## More
94
+
95
+ - Docs: https://eslint.interlace.tools/docs/security/plugin-postgresql-security
96
+ - README.md in this package: every rule with examples.
97
+ - `eslint-plugin-postgresql-security/oxlint` is an entry point for oxlint's JS plugin support; see the README.
package/README.md CHANGED
@@ -22,7 +22,28 @@
22
22
  <a href="https://scorecard.dev/viewer/?uri=github.com/ofri-peretz/eslint" target="_blank"><img src="https://api.securityscorecards.dev/projects/github.com/ofri-peretz/eslint/badge" alt="OpenSSF Scorecard" /></a>
23
23
  </p>
24
24
 
25
- > ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
25
+ ## Getting Started
26
+
27
+ - 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). 📚
28
+
29
+ <!-- AUTO-GENERATED:INSTALL:START - Do not edit manually -->
30
+
31
+ ```bash
32
+ npm install --save-dev eslint eslint-plugin-postgresql-security
33
+ ```
34
+
35
+ ```js
36
+ // eslint.config.mjs
37
+ import { configs } from 'eslint-plugin-postgresql-security';
38
+
39
+ export default [configs.recommended];
40
+ ```
41
+
42
+ `recommended` is the preset to start with. The others are listed under Configuration Presets below.
43
+
44
+ Using oxlint or Vite+? Install `oxlint-plugin-postgresql-security`: the same rules under the same `postgresql-security/<rule>` IDs, without ESLint. Its [page](https://www.npmjs.com/package/oxlint-plugin-postgresql-security) has the setup.
45
+
46
+ <!-- AUTO-GENERATED:INSTALL:END -->
26
47
 
27
48
  ## Description
28
49
 
@@ -48,40 +69,6 @@ That trade costs recall, and we measure it:
48
69
 
49
70
  <!-- AUTO-GENERATED:DOCTRINE:END -->
50
71
 
51
- ## Getting Started
52
-
53
- - 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). 📚
54
-
55
- <!-- AUTO-GENERATED:INSTALL:START - Do not edit manually -->
56
-
57
- **oxlint / Vite+** — the same rules under the same `postgresql-security/<rule>` IDs, without ESLint:
58
-
59
- ```bash
60
- npm install oxlint-plugin-postgresql-security --save-dev
61
- ```
62
-
63
- ```jsonc
64
- // .oxlintrc.json
65
- { "jsPlugins": ["oxlint-plugin-postgresql-security"] }
66
- ```
67
-
68
- ```ts
69
- // vite.config.ts
70
- import { defineConfig } from 'vite-plus';
71
-
72
- export default defineConfig({
73
- lint: { jsPlugins: ['oxlint-plugin-postgresql-security'] },
74
- });
75
- ```
76
-
77
- **ESLint:**
78
-
79
- ```bash
80
- npm install eslint-plugin-postgresql-security --save-dev
81
- ```
82
-
83
- <!-- AUTO-GENERATED:INSTALL:END -->
84
-
85
72
  ## ⚙️ Configuration Presets
86
73
  | Preset | Description |
87
74
  | :------------ | :------------------------------------------------------- |
@@ -156,12 +143,12 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
156
143
  | [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. | 🟢 | 💼 | | | | |
157
144
  | [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. | 🟢 | 💼 | | | | |
158
145
  | [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. | 🟢 | 💼 | | | | |
159
- | [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-693 | | | Discourages SELECT in favor of explicit column lists. | 🟢 | | ⚠️ | | | |
146
+ | [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. | 🟢 | | ⚠️ | | | |
160
147
  | [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). | 🟢 | 💼 | | | | |
161
148
  | [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). | 🟢 | 💼 | | | | |
162
149
  | [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 | 🟢 | 💼 | | | | |
163
150
  | [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. | 🟢 | 💼 | | | | |
164
- | [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-693 | | | Suggests using pool.query() for single-shot queries instead of manual connect/release. | 🟢 | | ⚠️ | | | |
151
+ | [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. | 🟢 | | ⚠️ | | | |
165
152
  | [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. | 🟢 | | ⚠️ | | | |
166
153
  <!-- AUTO-GENERATED:RULES_TABLE:END -->
167
154
  <!-- AUTO-GENERATED:ECOSYSTEM_TABLE:START - Do not edit manually -->
@@ -213,11 +200,10 @@ Part of the **Interlace ESLint ecosystem** — AI-native rules with LLM-optimize
213
200
  <!-- AUTO-GENERATED:ECOSYSTEM_TABLE:END -->
214
201
 
215
202
  <!-- INTERLACE:STAR_CTA:START -->
216
- ## ⭐ Support & follow
217
203
 
218
- If this plugin caught a real bug for you, **[star the repo](https://github.com/ofri-peretz/eslint)** — stars are the signal that keeps the Interlace ESLint ecosystem maintained — and **[follow the writeups on Dev.to](https://dev.to/ofri-peretz)** for the benchmarks and security research behind these rules.
204
+ ## Support
219
205
 
220
- [![GitHub stars](https://img.shields.io/github/stars/ofri-peretz/eslint?style=social)](https://github.com/ofri-peretz/eslint)
206
+ 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.
221
207
 
222
208
  <!-- INTERLACE:STAR_CTA:END -->
223
209
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-postgresql-security",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "ESLint Postgres security rules for the pg PostgreSQL driver — detects SQL injection, unreleased clients, floating queries, unsafe search_path, and insecure SSL.",
5
5
  "type": "commonjs",
6
6
  "sideEffects": false,
@@ -33,7 +33,8 @@
33
33
  "files": [
34
34
  "src/",
35
35
  "README.md",
36
- "LICENSE"
36
+ "LICENSE",
37
+ "AGENTS.md"
37
38
  ],
38
39
  "keywords": [
39
40
  "eslint",
package/src/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.rules={get"no-unsafe-query"(){return require("./rules/no-unsafe-query").noUnsafeQuery},get"no-insecure-ssl"(){return require("./rules/no-insecure-ssl").noInsecureSsl},get"no-hardcoded-credentials"(){return require("./rules/no-hardcoded-credentials").noHardcodedCredentials},get"check-query-params"(){return require("./rules/check-query-params").checkQueryParams},get"no-missing-client-release"(){return require("./rules/no-missing-client-release").noMissingClientRelease},get"no-transaction-on-pool"(){return require("./rules/no-transaction-on-pool").noTransactionOnPool},get"no-floating-query"(){return require("./rules/no-floating-query").noFloatingQuery},get"no-select-all"(){return require("./rules/no-select-all").noSelectAll},get"prefer-pool-query"(){return require("./rules/prefer-pool-query").preferPoolQuery},get"no-batch-insert-loop"(){return require("./rules/no-batch-insert-loop").noBatchInsertLoop},get"no-unsafe-search-path"(){return require("./rules/no-unsafe-search-path").noUnsafeSearchPath},get"no-unsafe-copy-from"(){return require("./rules/no-unsafe-copy-from").noUnsafeCopyFrom},get"prevent-double-release"(){return require("./rules/prevent-double-release").preventDoubleRelease}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-postgresql-security",exports.rules);exports.plugin={meta:{name:"eslint-plugin-postgresql-security",version:"3.0.4"},rules:exports.rules};exports.configs={flagship:{plugins:{"postgresql-security":exports.plugin,"pg":exports.plugin},rules:{"postgresql-security/no-unsafe-query":"error"}},recommended:{plugins:{"postgresql-security":exports.plugin,"pg":exports.plugin},rules:{"postgresql-security/no-unsafe-query":"error","postgresql-security/no-insecure-ssl":"error","postgresql-security/no-hardcoded-credentials":"error","postgresql-security/no-unsafe-search-path":"error","postgresql-security/no-unsafe-copy-from":"error","postgresql-security/no-transaction-on-pool":"error","postgresql-security/no-missing-client-release":"error","postgresql-security/prevent-double-release":"warn","postgresql-security/no-floating-query":"warn","postgresql-security/check-query-params":"warn","postgresql-security/no-select-all":"warn","postgresql-security/prefer-pool-query":"warn","postgresql-security/no-batch-insert-loop":"warn"}},strict:{plugins:{"postgresql-security":exports.plugin,"pg":exports.plugin},rules:{"postgresql-security/no-unsafe-query":"error","postgresql-security/no-insecure-ssl":"error","postgresql-security/no-hardcoded-credentials":"error","postgresql-security/no-unsafe-search-path":"error","postgresql-security/no-unsafe-copy-from":"error","postgresql-security/no-transaction-on-pool":"error","postgresql-security/no-missing-client-release":"error","postgresql-security/prevent-double-release":"error","postgresql-security/no-floating-query":"error","postgresql-security/check-query-params":"error","postgresql-security/no-select-all":"error","postgresql-security/prefer-pool-query":"error","postgresql-security/no-batch-insert-loop":"error"}}};exports.default=exports.plugin;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.rules={get"no-unsafe-query"(){return require("./rules/no-unsafe-query").noUnsafeQuery},get"no-insecure-ssl"(){return require("./rules/no-insecure-ssl").noInsecureSsl},get"no-hardcoded-credentials"(){return require("./rules/no-hardcoded-credentials").noHardcodedCredentials},get"check-query-params"(){return require("./rules/check-query-params").checkQueryParams},get"no-missing-client-release"(){return require("./rules/no-missing-client-release").noMissingClientRelease},get"no-transaction-on-pool"(){return require("./rules/no-transaction-on-pool").noTransactionOnPool},get"no-floating-query"(){return require("./rules/no-floating-query").noFloatingQuery},get"no-select-all"(){return require("./rules/no-select-all").noSelectAll},get"prefer-pool-query"(){return require("./rules/prefer-pool-query").preferPoolQuery},get"no-batch-insert-loop"(){return require("./rules/no-batch-insert-loop").noBatchInsertLoop},get"no-unsafe-search-path"(){return require("./rules/no-unsafe-search-path").noUnsafeSearchPath},get"no-unsafe-copy-from"(){return require("./rules/no-unsafe-copy-from").noUnsafeCopyFrom},get"prevent-double-release"(){return require("./rules/prevent-double-release").preventDoubleRelease}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-postgresql-security",exports.rules);exports.plugin={meta:{name:"eslint-plugin-postgresql-security",version:"3.0.6"},rules:exports.rules};exports.configs={flagship:{plugins:{"postgresql-security":exports.plugin,"pg":exports.plugin},rules:{"postgresql-security/no-unsafe-query":"error"}},recommended:{plugins:{"postgresql-security":exports.plugin,"pg":exports.plugin},rules:{"postgresql-security/no-unsafe-query":"error","postgresql-security/no-insecure-ssl":"error","postgresql-security/no-hardcoded-credentials":"error","postgresql-security/no-unsafe-search-path":"error","postgresql-security/no-unsafe-copy-from":"error","postgresql-security/no-transaction-on-pool":"error","postgresql-security/no-missing-client-release":"error","postgresql-security/prevent-double-release":"warn","postgresql-security/no-floating-query":"warn","postgresql-security/check-query-params":"warn","postgresql-security/no-select-all":"warn","postgresql-security/prefer-pool-query":"warn","postgresql-security/no-batch-insert-loop":"warn"}},strict:{plugins:{"postgresql-security":exports.plugin,"pg":exports.plugin},rules:{"postgresql-security/no-unsafe-query":"error","postgresql-security/no-insecure-ssl":"error","postgresql-security/no-hardcoded-credentials":"error","postgresql-security/no-unsafe-search-path":"error","postgresql-security/no-unsafe-copy-from":"error","postgresql-security/no-transaction-on-pool":"error","postgresql-security/no-missing-client-release":"error","postgresql-security/prevent-double-release":"error","postgresql-security/no-floating-query":"error","postgresql-security/check-query-params":"error","postgresql-security/no-select-all":"error","postgresql-security/prefer-pool-query":"error","postgresql-security/no-batch-insert-loop":"error"}}};exports.default=exports.plugin;