eslint-plugin-postgresql-security 3.0.4 → 3.0.5

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/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.5",
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.5"},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;