eslint-plugin-postgresql-security 1.5.0 → 1.5.2

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.
Files changed (113) hide show
  1. package/README.md +5 -5
  2. package/package.json +9 -23
  3. package/src/constants.js +1 -0
  4. package/src/index.d.ts +17 -0
  5. package/src/index.js +1 -0
  6. package/src/oxlint.d.ts +17 -0
  7. package/src/oxlint.js +1 -0
  8. package/src/rules/check-query-params/index.js +1 -0
  9. package/src/rules/no-batch-insert-loop/index.js +1 -0
  10. package/src/rules/no-floating-query/index.js +1 -0
  11. package/src/rules/no-hardcoded-credentials/index.js +1 -0
  12. package/src/rules/no-insecure-ssl/index.js +1 -0
  13. package/src/rules/no-missing-client-release/index.js +1 -0
  14. package/src/rules/no-select-all/index.js +1 -0
  15. package/src/rules/no-transaction-on-pool/index.js +1 -0
  16. package/src/rules/no-unsafe-copy-from/index.js +1 -0
  17. package/src/rules/no-unsafe-query/index.js +1 -0
  18. package/src/rules/no-unsafe-search-path/index.js +1 -0
  19. package/src/rules/prefer-pool-query/index.js +1 -0
  20. package/src/rules/prevent-double-release/index.js +1 -0
  21. package/src/types/index.js +1 -0
  22. package/CHANGELOG.md +0 -150
  23. package/dist/AGENTS.md +0 -118
  24. package/dist/CHANGELOG.md +0 -150
  25. package/dist/LICENSE +0 -23
  26. package/dist/README.md +0 -169
  27. package/dist/package.json +0 -99
  28. package/dist/src/constants.d.ts +0 -6
  29. package/dist/src/constants.js +0 -13
  30. package/dist/src/index.d.ts +0 -26
  31. package/dist/src/index.js +0 -116
  32. package/dist/src/oxlint.d.ts +0 -20
  33. package/dist/src/oxlint.js +0 -21
  34. package/dist/src/rules/check-query-params/index.d.ts +0 -8
  35. package/dist/src/rules/check-query-params/index.js +0 -90
  36. package/dist/src/rules/no-batch-insert-loop/index.d.ts +0 -8
  37. package/dist/src/rules/no-batch-insert-loop/index.js +0 -90
  38. package/dist/src/rules/no-floating-query/index.d.ts +0 -8
  39. package/dist/src/rules/no-floating-query/index.js +0 -74
  40. package/dist/src/rules/no-hardcoded-credentials/index.d.ts +0 -8
  41. package/dist/src/rules/no-hardcoded-credentials/index.js +0 -86
  42. package/dist/src/rules/no-insecure-ssl/index.d.ts +0 -8
  43. package/dist/src/rules/no-insecure-ssl/index.js +0 -66
  44. package/dist/src/rules/no-missing-client-release/index.d.ts +0 -8
  45. package/dist/src/rules/no-missing-client-release/index.js +0 -85
  46. package/dist/src/rules/no-select-all/index.d.ts +0 -8
  47. package/dist/src/rules/no-select-all/index.js +0 -79
  48. package/dist/src/rules/no-transaction-on-pool/index.d.ts +0 -8
  49. package/dist/src/rules/no-transaction-on-pool/index.js +0 -71
  50. package/dist/src/rules/no-unsafe-copy-from/index.d.ts +0 -10
  51. package/dist/src/rules/no-unsafe-copy-from/index.js +0 -205
  52. package/dist/src/rules/no-unsafe-query/index.d.ts +0 -8
  53. package/dist/src/rules/no-unsafe-query/index.js +0 -132
  54. package/dist/src/rules/no-unsafe-search-path/index.d.ts +0 -8
  55. package/dist/src/rules/no-unsafe-search-path/index.js +0 -144
  56. package/dist/src/rules/prefer-pool-query/index.d.ts +0 -8
  57. package/dist/src/rules/prefer-pool-query/index.js +0 -104
  58. package/dist/src/rules/prevent-double-release/index.d.ts +0 -8
  59. package/dist/src/rules/prevent-double-release/index.js +0 -456
  60. package/dist/src/types/index.js +0 -7
  61. package/src/__compatibility__/pg-interface.spec.ts +0 -495
  62. package/src/constants.ts +0 -11
  63. package/src/index.spec.ts +0 -14
  64. package/src/index.test.ts +0 -59
  65. package/src/index.ts +0 -130
  66. package/src/oxlint.spec.ts +0 -70
  67. package/src/oxlint.ts +0 -23
  68. package/src/rules/check-query-params/check-query-params.test.ts +0 -68
  69. package/src/rules/check-query-params/index.spec.ts +0 -117
  70. package/src/rules/check-query-params/index.ts +0 -106
  71. package/src/rules/no-batch-insert-loop/index.spec.ts +0 -105
  72. package/src/rules/no-batch-insert-loop/index.ts +0 -105
  73. package/src/rules/no-batch-insert-loop/no-batch-insert-loop.test.ts +0 -68
  74. package/src/rules/no-floating-query/index.spec.ts +0 -112
  75. package/src/rules/no-floating-query/index.ts +0 -81
  76. package/src/rules/no-floating-query/no-floating-query.test.ts +0 -68
  77. package/src/rules/no-hardcoded-credentials/index.spec.ts +0 -38
  78. package/src/rules/no-hardcoded-credentials/index.ts +0 -93
  79. package/src/rules/no-hardcoded-credentials/no-hardcoded-credentials.test.ts +0 -68
  80. package/src/rules/no-insecure-ssl/index.spec.ts +0 -40
  81. package/src/rules/no-insecure-ssl/index.ts +0 -81
  82. package/src/rules/no-insecure-ssl/no-insecure-ssl.test.ts +0 -68
  83. package/src/rules/no-missing-client-release/coverage-gaps.spec.ts +0 -42
  84. package/src/rules/no-missing-client-release/index.spec.ts +0 -52
  85. package/src/rules/no-missing-client-release/index.ts +0 -100
  86. package/src/rules/no-missing-client-release/no-missing-client-release.test.ts +0 -68
  87. package/src/rules/no-select-all/index.spec.ts +0 -44
  88. package/src/rules/no-select-all/index.ts +0 -92
  89. package/src/rules/no-select-all/no-select-all.test.ts +0 -68
  90. package/src/rules/no-transaction-on-pool/index.spec.ts +0 -36
  91. package/src/rules/no-transaction-on-pool/index.ts +0 -85
  92. package/src/rules/no-transaction-on-pool/no-transaction-on-pool.test.ts +0 -68
  93. package/src/rules/no-unsafe-copy-from/coverage-gaps.spec.ts +0 -76
  94. package/src/rules/no-unsafe-copy-from/index.spec.ts +0 -274
  95. package/src/rules/no-unsafe-copy-from/index.ts +0 -226
  96. package/src/rules/no-unsafe-copy-from/no-unsafe-copy-from.test.ts +0 -78
  97. package/src/rules/no-unsafe-query/coverage-gaps.spec.ts +0 -61
  98. package/src/rules/no-unsafe-query/index.spec.ts +0 -103
  99. package/src/rules/no-unsafe-query/index.ts +0 -149
  100. package/src/rules/no-unsafe-query/no-unsafe-query.test.ts +0 -73
  101. package/src/rules/no-unsafe-search-path/index.spec.ts +0 -46
  102. package/src/rules/no-unsafe-search-path/index.ts +0 -164
  103. package/src/rules/no-unsafe-search-path/no-unsafe-search-path.test.ts +0 -68
  104. package/src/rules/prefer-pool-query/coverage-gaps.spec.ts +0 -76
  105. package/src/rules/prefer-pool-query/index.spec.ts +0 -97
  106. package/src/rules/prefer-pool-query/index.ts +0 -118
  107. package/src/rules/prefer-pool-query/prefer-pool-query.test.ts +0 -68
  108. package/src/rules/prevent-double-release/coverage-gaps.spec.ts +0 -538
  109. package/src/rules/prevent-double-release/index.spec.ts +0 -824
  110. package/src/rules/prevent-double-release/index.ts +0 -534
  111. package/src/rules/prevent-double-release/prevent-double-release.test.ts +0 -70
  112. package/src/types/index.ts +0 -58
  113. /package/{dist/src → src}/types/index.d.ts +0 -0
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  <p align="center">
2
- <a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security" target="blank"><img src="https://eslint.interlace.tools/icon-light.svg" alt="Interlace" height="90" /></a>
2
+ <a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security" target="blank"><img src="https://eslint.interlace.tools/logos/interlace.svg" alt="Interlace" height="90" /></a>
3
3
  &nbsp;&nbsp;
4
- <a href="https://eslint.org" target="_blank"><img src="https://eslint.interlace.tools/eslint-logo.svg" alt="ESLint" height="90" /></a>
4
+ <a href="https://www.postgresql.org" target="_blank"><img src="https://eslint.interlace.tools/logos/postgresql.svg" alt="PostgreSQL" height="90" /></a>
5
5
  &nbsp;&nbsp;
6
- <a href="https://oxc.rs" target="_blank"><img src="https://eslint.interlace.tools/oxlint-logo.svg" alt="oxlint" height="90" /></a>
6
+ <a href="https://oxc.rs" target="_blank"><img src="https://eslint.interlace.tools/logos/oxlint.svg" alt="oxlint" height="90" /></a>
7
7
  &nbsp;&nbsp;
8
- <a href="https://www.npmjs.com/package/pg" target="_blank"><img src="https://eslint.interlace.tools/postgresql-logo.svg" alt="PostgreSQL" height="90" /></a>
8
+ <a href="https://eslint.org" target="_blank"><img src="https://eslint.interlace.tools/logos/eslint.svg" alt="ESLint" height="90" /></a>
9
9
  </p>
10
10
 
11
11
  <p align="center">
@@ -161,7 +161,7 @@ If this plugin caught a real bug for you, **[star the repo](https://github.com/o
161
161
  MIT © [Ofri Peretz](https://github.com/ofri-peretz)
162
162
 
163
163
  <p align="center">
164
- <a href="https://eslint.interlace.tools/docs/security/plugin-pg?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security"><img src="https://eslint.interlace.tools/images/og-pg.png" alt="ESLint Interlace Plugin" width="100%" /></a>
164
+ <a href="https://eslint.interlace.tools/docs/security/plugin-pg?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security"><img src="https://eslint.interlace.tools/images/og-postgresql-security.png" alt="ESLint Interlace Plugin" width="100%" /></a>
165
165
  </p>
166
166
 
167
167
  <p align="center">
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "eslint-plugin-postgresql-security",
3
- "version": "1.5.0",
4
- "description": "ESLint plugin for the pg PostgreSQL driver \u2014 detects SQL injection, unreleased clients, floating queries, unsafe search_path, and insecure SSL.",
3
+ "version": "1.5.2",
4
+ "description": "ESLint plugin for the pg PostgreSQL driver — detects SQL injection, unreleased clients, floating queries, unsafe search_path, and insecure SSL.",
5
5
  "type": "commonjs",
6
- "main": "./dist/src/index.js",
7
- "types": "./dist/src/index.d.ts",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/src/index.d.ts",
11
- "default": "./dist/src/index.js"
10
+ "types": "./src/index.d.ts",
11
+ "default": "./src/index.js"
12
12
  },
13
13
  "./oxlint": {
14
14
  "types": "./src/oxlint.d.ts",
@@ -20,7 +20,7 @@
20
20
  "homepage": "https://eslint.interlace.tools/docs/security/plugin-postgresql-security?utm_source=npm&utm_medium=referral&utm_campaign=eslint-plugin-postgresql-security",
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "https://github.com/ofri-peretz/eslint",
23
+ "url": "git+https://github.com/ofri-peretz/eslint.git",
24
24
  "directory": "packages/eslint-plugin-postgresql-security"
25
25
  },
26
26
  "bugs": {
@@ -31,10 +31,8 @@
31
31
  },
32
32
  "files": [
33
33
  "src/",
34
- "dist/",
35
34
  "README.md",
36
- "LICENSE",
37
- "CHANGELOG.md"
35
+ "LICENSE"
38
36
  ],
39
37
  "keywords": [
40
38
  "eslint",
@@ -78,19 +76,7 @@
78
76
  }
79
77
  },
80
78
  "dependencies": {
81
- "tslib": "^2.3.0",
82
- "@interlace/eslint-devkit": "^1.4.3"
83
- },
84
- "devDependencies": {
85
- "@typescript-eslint/parser": "^8.46.2",
86
- "@typescript-eslint/rule-tester": "^8.46.2",
87
- "pg": "^8.22.0"
88
- },
89
- "scripts": {
90
- "build": "tsx ../../scripts/build-package.ts",
91
- "test": "vitest run",
92
- "test:coverage": "vitest run --coverage",
93
- "typecheck": "tsc -p tsconfig.lib.json --noEmit"
79
+ "@interlace/eslint-devkit": "^1.10.0"
94
80
  },
95
81
  "funding": {
96
82
  "type": "github",
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PG_PROTOCOLS=void 0;exports.PG_PROTOCOLS=["postgres://","postgresql://"];
package/src/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ // Minimal declaration written by scripts/build-package.ts.
2
+ //
3
+ // tsc's generated entry declaration inlined every inferred rule-option type
4
+ // (up to 166 kB per plugin) for an API no consumer calls directly. This types
5
+ // what a flat config actually touches. Per-rule option types remain available
6
+ // from the "./types" subpath export where a plugin provides one.
7
+ import type { Linter, Rule } from 'eslint';
8
+
9
+ export declare const rules: Record<string, Rule.RuleModule>;
10
+ export declare const configs: Record<string, Linter.Config>;
11
+ export declare const plugin: {
12
+ meta: { name: string; version: string };
13
+ rules: Record<string, Rule.RuleModule>;
14
+ };
15
+
16
+ declare const _default: typeof plugin;
17
+ export default _default;
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;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}};exports.plugin={meta:{name:"eslint-plugin-postgresql-security",version:"1.5.2"},rules:exports.rules};exports.configs={flagship:{plugins:{"pg":exports.plugin},rules:{"pg/no-unsafe-query":"error"}},recommended:{plugins:{"pg":exports.plugin},rules:{"pg/no-unsafe-query":"error","pg/no-insecure-ssl":"error","pg/no-hardcoded-credentials":"error","pg/no-unsafe-search-path":"error","pg/no-unsafe-copy-from":"error","pg/no-transaction-on-pool":"error","pg/no-missing-client-release":"error","pg/prevent-double-release":"error","pg/no-floating-query":"error","pg/check-query-params":"warn","pg/no-select-all":"warn","pg/prefer-pool-query":"warn","pg/no-batch-insert-loop":"warn"}},strict:{plugins:{"pg":exports.plugin},rules:{"pg/no-unsafe-query":"error","pg/no-insecure-ssl":"error","pg/no-hardcoded-credentials":"error","pg/no-unsafe-search-path":"error","pg/no-unsafe-copy-from":"error","pg/no-transaction-on-pool":"error","pg/no-missing-client-release":"error","pg/prevent-double-release":"error","pg/no-floating-query":"error","pg/check-query-params":"error","pg/no-select-all":"error","pg/prefer-pool-query":"error","pg/no-batch-insert-loop":"error"}}};exports.default=exports.plugin;
@@ -0,0 +1,17 @@
1
+ // Minimal declaration written by scripts/build-package.ts.
2
+ //
3
+ // tsc's generated entry declaration inlined every inferred rule-option type
4
+ // (up to 166 kB per plugin) for an API no consumer calls directly. This types
5
+ // what a flat config actually touches. Per-rule option types remain available
6
+ // from the "./types" subpath export where a plugin provides one.
7
+ import type { Linter, Rule } from 'eslint';
8
+
9
+ export declare const rules: Record<string, Rule.RuleModule>;
10
+ export declare const configs: Record<string, Linter.Config>;
11
+ export declare const plugin: {
12
+ meta: { name: string; version: string };
13
+ rules: Record<string, Rule.RuleModule>;
14
+ };
15
+
16
+ declare const _default: typeof plugin;
17
+ export default _default;
package/src/oxlint.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";const index_1=require("./index");module.exports=index_1.plugin;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.checkQueryParams=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const SINGLE_QUOTE_REGEX=/'(?:[^']|'')*'/g;const DOUBLE_QUOTE_REGEX=/"(?:[^"]|"")*"/g;const LINE_COMMENT_REGEX=/--.*/g;const BLOCK_COMMENT_REGEX=/\/\*[\s\S]*?\*\//g;const PARAM_REGEX=/\$\d+/g;exports.checkQueryParams={meta:{type:"problem",docs:{description:"Ensure the number of query parameters matches the arguments array.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/check-query-params.md",cwe:"CWE-20",cvss:7.5},messages:{parameterCountMismatch:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Parameter Count Mismatch",description:"Query parameter count mismatch detected.",severity:"HIGH",cwe:"CWE-20",effort:"low",fix:"Ensure the number of arguments matches the number of placeholders ($1, $2, etc.).",documentationLink:"https://node-postgres.com/features/queries"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="query"){return}const args=node.arguments;if(args.length<2)return;const queryArg=args[0];const valuesArg=args[1];if(queryArg.type!==eslint_devkit_1.AST_NODE_TYPES.Literal||typeof queryArg.value!=="string"){return}if(valuesArg.type!==eslint_devkit_1.AST_NODE_TYPES.ArrayExpression){return}const queryText=queryArg.value;const cleanText=queryText.replace(SINGLE_QUOTE_REGEX,"").replace(DOUBLE_QUOTE_REGEX,"").replace(LINE_COMMENT_REGEX,"").replace(BLOCK_COMMENT_REGEX,"");const matches=cleanText.match(PARAM_REGEX);let maxParamIndex=0;if(matches){const indices=matches.map(m=>parseInt(m.substring(1),10));maxParamIndex=Math.max(0,...indices)}const providedArgCount=valuesArg.elements.length;if(providedArgCount<maxParamIndex){context.report({node:valuesArg,messageId:"parameterCountMismatch",data:{expected:maxParamIndex.toString(),actual:providedArgCount.toString()}})}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noBatchInsertLoop=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noBatchInsertLoop={meta:{type:"problem",docs:{description:"Prevent executing database queries within loops (N+1 problem).",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-batch-insert-loop.md",cwe:"CWE-1049",cvss:7.5},messages:{noBatchInsertLoop:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.PERFORMANCE,issueName:"N+1 Query Detection",description:"Database query loop detected.",severity:"HIGH",cwe:"CWE-1049",effort:"medium",fix:'Batch queries using arrays and "UNNEST" or a single batched INSERT.',documentationLink:"https://use-the-index-luke.com/sql/joins/nested-loops-join-n1-problem"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="query"){return}const args=node.arguments;if(args.length>0&&args[0].type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof args[0].value==="string"){const query=args[0].value.toUpperCase();if(!query.includes("INSERT")&&!query.includes("UPDATE")){return}}let ancestor=node.parent;while(ancestor){if(ancestor.type===eslint_devkit_1.AST_NODE_TYPES.ForStatement||ancestor.type===eslint_devkit_1.AST_NODE_TYPES.ForOfStatement||ancestor.type===eslint_devkit_1.AST_NODE_TYPES.ForInStatement||ancestor.type===eslint_devkit_1.AST_NODE_TYPES.WhileStatement||ancestor.type===eslint_devkit_1.AST_NODE_TYPES.DoWhileStatement){context.report({node,messageId:"noBatchInsertLoop"});break}if(ancestor.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression||ancestor.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression){if(ancestor.parent?.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&ancestor.parent.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&ancestor.parent.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&["map","forEach","reduce","filter"].includes(ancestor.parent.callee.property.name)){context.report({node,messageId:"noBatchInsertLoop"});break}if(ancestor.parent?.type!==eslint_devkit_1.AST_NODE_TYPES.CallExpression){break}}ancestor=ancestor.parent}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noFloatingQuery=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noFloatingQuery={meta:{type:"problem",docs:{description:"Ensure all queries are awaited or returned to prevent unhandled promise rejections.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-floating-query.md",cwe:"CWE-391",cvss:5.3},messages:{noFloatingQuery:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Floating Query",description:"Promise-returning query is neither awaited nor returned.",severity:"HIGH",cwe:"CWE-391",effort:"low",fix:'Add "await" or "return" to handle the query promise.',documentationLink:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="query"){return}const parent=node.parent;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.AwaitExpression)return;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.ReturnStatement)return;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression)return;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator)return;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression)return;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.AssignmentExpression)return;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.ExpressionStatement){context.report({node,messageId:"noFloatingQuery"})}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noHardcodedCredentials=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const constants_1=require("../../constants");exports.noHardcodedCredentials={meta:{type:"problem",docs:{description:"Detect hardcoded credentials in pg Client or Pool initialization.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-hardcoded-credentials.md",cwe:"CWE-798",cvss:9.8},messages:{noHardcodedCredentials:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Hardcoded Credentials",description:"Hardcoded credentials detected in database connection.",severity:"CRITICAL",cwe:"CWE-798",owasp:"A07:2021",compliance:["SOC2","PCI-DSS","ISO27001","NIST-CSF"],effort:"low",fix:"Use environment variables (process.env.DB_PASSWORD) instead of hardcoding secrets.",documentationLink:"https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_password"})},schema:[]},defaultOptions:[],create(context){return{NewExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||!["Client","Pool"].includes(node.callee.name)){return}if(node.arguments.length===0)return;const configArg=node.arguments[0];if(configArg.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof configArg.value==="string"){if(constants_1.PG_PROTOCOLS.some(protocol=>configArg.value.includes(protocol))){context.report({node:configArg,messageId:"noHardcodedCredentials"});return}}if(configArg.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){for(const prop of configArg.properties){if(prop.type!==eslint_devkit_1.AST_NODE_TYPES.Property||prop.key.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier){continue}if(prop.key.name==="password"){if(prop.value.type===eslint_devkit_1.AST_NODE_TYPES.Literal){context.report({node:prop.value,messageId:"noHardcodedCredentials"})}continue}if(prop.key.name==="connectionString"){if(prop.value.type===eslint_devkit_1.AST_NODE_TYPES.Literal){context.report({node:prop.value,messageId:"noHardcodedCredentials"})}}}}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noInsecureSsl=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noInsecureSsl={meta:{type:"problem",docs:{description:"Prevent the use of insecure SSL configurations (rejectUnauthorized: false).",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-insecure-ssl.md",cwe:"CWE-319",cvss:7.5},messages:{noInsecureSsl:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Insecure SSL",description:"Insecure SSL configuration detected (rejectUnauthorized: false).",severity:"HIGH",cwe:"CWE-319",owasp:"A05:2021",compliance:["SOC2","PCI-DSS","HIPAA","GDPR"],effort:"low",fix:'Set "rejectUnauthorized: true" or use a valid CA bundle. Do not disable SSL verification in production.',documentationLink:"https://node-postgres.com/features/ssl"})},schema:[]},defaultOptions:[],create(context){return{NewExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.name!=="Client"&&node.callee.name!=="Pool"){return}const configArg=node.arguments[0];if(!configArg||configArg.type!==eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){return}const sslProp=configArg.properties.find(prop=>prop.type===eslint_devkit_1.AST_NODE_TYPES.Property&&prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&prop.key.name==="ssl");if(!sslProp)return;if(sslProp.value.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){const rejectUnauthorized=sslProp.value.properties.find(prop=>prop.type===eslint_devkit_1.AST_NODE_TYPES.Property&&prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&prop.key.name==="rejectUnauthorized");if(rejectUnauthorized&&rejectUnauthorized.value.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&rejectUnauthorized.value.value===false){context.report({node:rejectUnauthorized,messageId:"noInsecureSsl"})}}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noMissingClientRelease=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noMissingClientRelease={meta:{type:"problem",docs:{description:"Ensure pg client is released after use to prevent pool exhaustion.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-missing-client-release.md"},messages:{missingClientRelease:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.PERFORMANCE,issueName:"Missing Client Release",description:"PG client acquired but not released.",severity:"HIGH",cwe:"CWE-404",owasp:"A05:2025",effort:"low",fix:'Ensure "client.release()" is called in a finally block to return the client to the pool.',documentationLink:"https://node-postgres.com/features/pooling#checkout-use-and-return"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="connect"){return}let currentNode=node;if(node.parent?.type===eslint_devkit_1.AST_NODE_TYPES.AwaitExpression){currentNode=node.parent}if(currentNode.parent?.type!==eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator){return}const declarator=currentNode.parent;if(declarator.id.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier){return}const variable=context.sourceCode.getDeclaredVariables(declarator)[0];if(!variable)return;const references=variable.references;const hasReleaseCall=references.some(ref=>{const id=ref.identifier;return id.parent?.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&id.parent.object===id&&id.parent.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&id.parent.property.name==="release"&&id.parent.parent?.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression});if(!hasReleaseCall){context.report({node:declarator,messageId:"missingClientRelease"})}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noSelectAll=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const COUNT_STAR_REGEX=/COUNT\s*\(\s*\*\s*\)/g;const SELECT_STAR_REGEX=/\bSELECT\s+\*/;const COMMA_STAR_REGEX=/,\s*\*/;const SELECT_KEYWORD_REGEX=/\bSELECT\b/;const UNNEST_PATTERN_REGEX=/\bSELECT\s+\*\s+FROM\s+UNNEST\s*\(/;exports.noSelectAll={meta:{type:"problem",docs:{description:"Prevent using * in SELECT statements (implicit columns).",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-select-all.md",cwe:"CWE-1049",cvss:5},messages:{noSelectAll:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.PERFORMANCE,issueName:"Select All",description:'Avoid using "SELECT *" which fetches all columns.',severity:"MEDIUM",cwe:"CWE-1049",effort:"low",fix:"Explicitly list the columns you need (e.g., SELECT id, name FROM ...).",documentationLink:"https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_SELECT_.2A"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="query"){return}const args=node.arguments;if(args.length===0)return;const queryArg=args[0];if(queryArg.type!==eslint_devkit_1.AST_NODE_TYPES.Literal||typeof queryArg.value!=="string"){return}const queryText=queryArg.value;const upperQuery=queryText.toUpperCase();const cleanedQuery=upperQuery.replace(COUNT_STAR_REGEX,"COUNT_ALL");if(SELECT_STAR_REGEX.test(cleanedQuery)||COMMA_STAR_REGEX.test(cleanedQuery)){if(SELECT_KEYWORD_REGEX.test(cleanedQuery)){if(UNNEST_PATTERN_REGEX.test(cleanedQuery)){return}context.report({node:queryArg,messageId:"noSelectAll"})}}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noTransactionOnPool=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const TRANSACTION_KEYWORDS=new Set(["BEGIN","COMMIT","ROLLBACK"]);exports.noTransactionOnPool={meta:{type:"problem",docs:{description:"Prevent starting transactions directly on the Pool, which is unsafe due to lack of client affinity.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-transaction-on-pool.md",cwe:"CWE-662",cweJustification:"CWE-662 (Improper Synchronization) \u2014 running BEGIN/COMMIT on a connection pool can split a logical transaction across different physical clients, breaking ACID atomicity.",confidence:"high"},messages:{noTransactionOnPool:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Transaction on Pool",description:"Transactions should not be started on the Pool directly.",severity:"HIGH",effort:"low",fix:'Use "await pool.connect()" to get a client, then start the transaction on the client.',documentationLink:"https://node-postgres.com/features/transactions"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="query"){return}const args=node.arguments;if(args.length===0)return;const queryArg=args[0];if(queryArg.type!==eslint_devkit_1.AST_NODE_TYPES.Literal||typeof queryArg.value!=="string"){return}const queryText=queryArg.value.toUpperCase().trim();const firstWord=queryText.split(/[;\s]/)[0];if(TRANSACTION_KEYWORDS.has(firstWord)){if(node.callee.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&(node.callee.object.name==="pool"||node.callee.object.name.toLowerCase().includes("pool"))){context.report({node:queryArg,messageId:"noTransactionOnPool"})}}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnsafeCopyFrom=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const COPY_FROM_REGEX=/\bCOPY\b.*\bFROM\b/i;const STDIN_REGEX=/\bFROM\s+STDIN\b/i;const FILE_PATH_REGEX=/FROM\s+['"]([^'"]+)['"]/i;const hasCopyFrom=str=>COPY_FROM_REGEX.test(str)&&!STDIN_REGEX.test(str);const extractFilePath=str=>{const match=FILE_PATH_REGEX.exec(str);return match?match[1]:null};exports.noUnsafeCopyFrom={meta:{type:"problem",docs:{description:"Prevent unsafe COPY FROM usage with dynamic file paths, which can lead to arbitrary file read/RCE.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-unsafe-copy-from.md",cwe:"CWE-73",cvss:9.5},messages:{dynamicPath:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"COPY FROM Injection",description:"Dynamic file path in COPY FROM detected - potential arbitrary file read.",severity:"CRITICAL",cwe:"CWE-73",owasp:"A03:2021",compliance:["SOC2","PCI-DSS"],effort:"low",fix:"Never use user input in COPY FROM paths. Use COPY FROM STDIN for user data.",documentationLink:"https://www.postgresql.org/docs/current/sql-copy.html"}),hardcodedPath:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Server-side COPY FROM",description:"Hardcoded file path in COPY FROM - server-side file access.",severity:"MEDIUM",cwe:"CWE-73",effort:"low",fix:"Prefer COPY FROM STDIN for application code. Use allowHardcodedPaths option if this is an admin script.",documentationLink:"https://www.postgresql.org/docs/current/sql-copy.html"}),unverifiablePath:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Unverifiable COPY FROM",description:"Cannot statically verify COPY FROM source - potential injection risk.",severity:"MEDIUM",cwe:"CWE-73",effort:"medium",fix:"Ensure the query source does not contain user input, or refactor to use COPY FROM STDIN.",documentationLink:"https://www.postgresql.org/docs/current/sql-copy.html"})},schema:[{type:"object",properties:{allowHardcodedPaths:{type:"boolean",description:"Allow hardcoded file paths (for admin/migration scripts)"},allowedPaths:{type:"array",items:{type:"string"},description:"List of allowed file path patterns (regex strings)"}},additionalProperties:false}]},defaultOptions:[{}],create(context){const options=context.options[0]??{};const allowHardcodedPaths=options.allowHardcodedPaths??false;const allowedPaths=(options.allowedPaths??[]).map(p=>new RegExp(p));const isPathAllowed=filePath=>{return allowedPaths.some(pattern=>pattern.test(filePath))};return{CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="query"){return}const args=node.arguments;if(args.length===0)return;const queryArg=args[0];if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof queryArg.value==="string"){if(hasCopyFrom(queryArg.value)){const filePath=extractFilePath(queryArg.value);if(filePath&&isPathAllowed(filePath)){return}if(allowHardcodedPaths){return}context.report({node:queryArg,messageId:"hardcodedPath"})}return}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral){const staticText=queryArg.quasis.map(q=>q.value.raw).join(" ");if(hasCopyFrom(staticText)){if(queryArg.expressions.length>0){context.report({node:queryArg,messageId:"dynamicPath"})}else{const filePath=extractFilePath(staticText);if(filePath&&isPathAllowed(filePath)){return}if(!allowHardcodedPaths){context.report({node:queryArg,messageId:"hardcodedPath"})}}}return}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression){const parts=[];let hasDynamicPart=false;const stack=[queryArg];for(let curr=stack.pop();curr!==void 0;curr=stack.pop()){if(curr.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression&&curr.operator==="+"){stack.push(curr.right);stack.push(curr.left)}else if(curr.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof curr.value==="string"){parts.push(curr.value)}else{hasDynamicPart=true}}const staticText=parts.join(" ");if(hasCopyFrom(staticText)){if(hasDynamicPart){context.report({node:queryArg,messageId:"dynamicPath"})}else{const filePath=extractFilePath(staticText);if(filePath&&isPathAllowed(filePath)){return}if(!allowHardcodedPaths){context.report({node:queryArg,messageId:"hardcodedPath"})}}}return}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.Identifier||queryArg.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression){return}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnsafeQuery=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");function isUnsafeStringConstruction(node){if(node.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression&&node.operator==="+"){return"concat"}if(node.type===eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral&&node.expressions.length>0){return"template"}return false}exports.noUnsafeQuery={meta:{type:"problem",docs:{description:"Prevent SQL injection by disallowing string concatenation or unsafe template literals in queries.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-unsafe-query.md",cwe:"CWE-89",cvss:9.8,confidence:"high"},messages:{noUnsafeQuery:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"Unsafe SQL query detected. Variable interpolation found.",severity:"CRITICAL",cwe:"CWE-89",owasp:"A03:2021",compliance:["SOC2","PCI-DSS","NIST-CSF"],effort:"high",fix:"Use parameterized queries ($1, $2) instead of string concatenation.",documentationLink:"https://node-postgres.com/features/queries#parameterized-queries"}),unsafeTemplateLiteral:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"SQL Injection Risk",description:"Unsafe SQL query construction detected (template literal).",severity:"CRITICAL",fix:"Use parameterized queries ($1, $2) instead of interpolating values.",documentationLink:"https://owasp.org/www-community/attacks/SQL_Injection"})},schema:[]},defaultOptions:[],create(context){const taintedVariables=new Map;return{VariableDeclarator(node){if(node.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.init){const unsafe=isUnsafeStringConstruction(node.init);if(unsafe){taintedVariables.set(node.id.name,unsafe)}}},AssignmentExpression(node){if(node.operator==="+="&&node.left.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const unsafe=isUnsafeStringConstruction(node.right);if(unsafe){taintedVariables.set(node.left.name,unsafe)}}},CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="query"){return}const args=node.arguments;if(args.length===0)return;const queryArg=args[0];if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression&&queryArg.operator==="+"){context.report({node:queryArg,messageId:"noUnsafeQuery"});return}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral&&queryArg.expressions.length>0){context.report({node:queryArg,messageId:"unsafeTemplateLiteral"});return}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const taint=taintedVariables.get(queryArg.name);if(taint){context.report({node:queryArg,messageId:taint==="template"?"unsafeTemplateLiteral":"noUnsafeQuery"})}}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnsafeSearchPath=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const hasSearchPath=str=>str.toLowerCase().includes("set search_path");exports.noUnsafeSearchPath={meta:{type:"problem",docs:{description:"Prevent unsafe SET search_path usage with dynamic values, which can lead to schema hijacking.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/no-unsafe-search-path.md",cwe:"CWE-426",cvss:7.5},messages:{noUnsafeSearchPath:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Schema Hijacking Risk",description:'Unsafe "SET search_path" detected.',severity:"CRITICAL",cwe:"CWE-426",owasp:"A05:2021",compliance:["SOC2","PCI-DSS"],effort:"low",fix:"Do not use dynamic values for search_path. Use static strings or strict validation.",documentationLink:"https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PATH"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.callee.property.name!=="query"){return}const args=node.arguments;if(args.length===0)return;const queryArg=args[0];if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression&&queryArg.operator==="+"){}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.Literal){if(typeof queryArg.value==="string"&&hasSearchPath(queryArg.value)){return}}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral){const rawText=queryArg.quasis.map(q=>q.value.raw).join(" ");if(hasSearchPath(rawText)){if(queryArg.expressions.length>0){context.report({node:queryArg,messageId:"noUnsafeSearchPath"})}}return}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression){const parts=[];const stack=[queryArg];for(let curr=stack.pop();curr!==void 0;curr=stack.pop()){if(curr.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression&&curr.operator==="+"){stack.push(curr.right);stack.push(curr.left)}else if(curr.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof curr.value==="string"){parts.push(curr.value)}}const combined=parts.join(" ");if(hasSearchPath(combined)){context.report({node:queryArg,messageId:"noUnsafeSearchPath"})}return}if(queryArg.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression){if(queryArg.arguments.length>0&&queryArg.arguments[0].type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof queryArg.arguments[0].value==="string"&&hasSearchPath(queryArg.arguments[0].value)){const allLiterals=queryArg.arguments.every(arg=>arg.type===eslint_devkit_1.AST_NODE_TYPES.Literal);if(allLiterals)return;context.report({node:queryArg,messageId:"noUnsafeSearchPath"})}}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.preferPoolQuery=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.preferPoolQuery={meta:{type:"suggestion",docs:{description:"Prefer pool.query() over client.query() for single-shot queries.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/prefer-pool-query.md"},messages:{preferPoolQuery:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.PERFORMANCE,issueName:"Prefer Pool Query",description:"Single-shot queries should use pool.query() directly.",severity:"MEDIUM",cwe:"CWE-400",effort:"low",fix:"Use pool.query(...) instead of manual client checkout/release for simple queries.",documentationLink:"https://node-postgres.com/features/pooling"})},schema:[]},defaultOptions:[],create(context){return{VariableDeclarator(node){if(!node.init||node.init.type!==eslint_devkit_1.AST_NODE_TYPES.AwaitExpression||node.init.argument.type!==eslint_devkit_1.AST_NODE_TYPES.CallExpression||node.init.argument.callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression||node.init.argument.callee.property.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||node.init.argument.callee.property.name!=="connect"){return}const variable=context.sourceCode.getDeclaredVariables(node)[0];if(!variable)return;const references=variable.references;let queryCallCount=0;let releaseCallCount=0;let otherUsageCount=0;for(const ref of references){if(ref.isWrite())continue;const id=ref.identifier;if(id.parent?.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&id.parent.object===id&&id.parent.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const method=id.parent.property.name;if(method==="query"){queryCallCount++;if(id.parent.parent?.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression){const call=id.parent.parent;if(call.arguments.length>0&&call.arguments[0].type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof call.arguments[0].value==="string"){const q=call.arguments[0].value.toUpperCase().trim();if(q.startsWith("BEGIN")||q.startsWith("COMMIT")||q.startsWith("ROLLBACK")){return}}}}else if(method==="release"){releaseCallCount++}else{otherUsageCount++}}else{otherUsageCount++}}if(queryCallCount===1&&releaseCallCount===1&&otherUsageCount===0){context.report({node,messageId:"preferPoolQuery"})}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.preventDoubleRelease=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");function findAncestor(node,predicate){let current=node?.parent;while(current){if(predicate(current))return current;current=current.parent}return null}function isInCatchBlock(node){return findAncestor(node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.CatchClause)}function isInFinallyBlock(node){const tryStmt=findAncestor(node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.TryStatement);if(!tryStmt?.finalizer)return null;const nodeRange=node.range;const finalizerRange=tryStmt.finalizer.range;if(nodeRange[0]>=finalizerRange[0]&&nodeRange[1]<=finalizerRange[1]){return tryStmt}return null}function isInTryBlock(node){const tryStmt=findAncestor(node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.TryStatement);if(!tryStmt)return null;const nodeRange=node.range;const blockRange=tryStmt.block.range;if(nodeRange[0]>=blockRange[0]&&nodeRange[1]<=blockRange[1]){return tryStmt}return null}function getContainingFunction(node){return findAncestor(node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.FunctionDeclaration||n.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression||n.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression)}function isGuardedByCondition(node){const ifStmt=findAncestor(node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.IfStatement);if(!ifStmt)return false;const conditionText=ifStmt.test;if(conditionText.type===eslint_devkit_1.AST_NODE_TYPES.UnaryExpression&&conditionText.operator==="!"){const arg=conditionText.argument;if(arg.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const name=arg.name.toLowerCase();return name.includes("released")||name.includes("done")||name.includes("closed")}if(arg.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&arg.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const name=arg.property.name.toLowerCase();return name.includes("released")||name.includes("done")||name.includes("closed")}}return false}function areMutuallyExclusiveBranches(nodeA,nodeB){const ifA=findAncestor(nodeA,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.IfStatement);const ifB=findAncestor(nodeB,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.IfStatement);if(!ifA||!ifB)return false;if(ifA===ifB){const nodeARange=nodeA.range;const nodeBRange=nodeB.range;const consequentRange=ifA.consequent.range;const alternateRange=ifA.alternate?.range;if(!alternateRange)return false;const aInConsequent=nodeARange[0]>=consequentRange[0]&&nodeARange[1]<=consequentRange[1];const bInConsequent=nodeBRange[0]>=consequentRange[0]&&nodeBRange[1]<=consequentRange[1];const aInAlternate=nodeARange[0]>=alternateRange[0]&&nodeARange[1]<=alternateRange[1];const bInAlternate=nodeBRange[0]>=alternateRange[0]&&nodeBRange[1]<=alternateRange[1];return aInConsequent&&bInAlternate||aInAlternate&&bInConsequent}return false}function hasExitBetween(block,startIdx,endIdx){for(let k=startIdx+1;k<endIdx;k++){const stmt=block.body[k];if(stmt.type===eslint_devkit_1.AST_NODE_TYPES.ReturnStatement)return true;if(stmt.type===eslint_devkit_1.AST_NODE_TYPES.ThrowStatement)return true}return false}function caseHasExit(switchCase){for(const stmt of switchCase.consequent){if(stmt.type===eslint_devkit_1.AST_NODE_TYPES.ReturnStatement)return true;if(stmt.type===eslint_devkit_1.AST_NODE_TYPES.ThrowStatement)return true;if(stmt.type===eslint_devkit_1.AST_NODE_TYPES.BreakStatement)return true}return false}function getSwitchCase(node){return findAncestor(node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.SwitchCase)}function getDirectIfStatement(node){return findAncestor(node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.IfStatement)}function ifBranchHasExitAfterRelease(releaseNode,ifStmt){const releaseRange=releaseNode.range;const consequentRange=ifStmt.consequent.range;const inConsequent=releaseRange[0]>=consequentRange[0]&&releaseRange[1]<=consequentRange[1];let branchBlock=null;if(inConsequent&&ifStmt.consequent.type===eslint_devkit_1.AST_NODE_TYPES.BlockStatement){branchBlock=ifStmt.consequent}else if(!inConsequent&&ifStmt.alternate?.type===eslint_devkit_1.AST_NODE_TYPES.BlockStatement){branchBlock=ifStmt.alternate}if(!branchBlock)return false;const releaseParentStmt=releaseNode.parent?.type===eslint_devkit_1.AST_NODE_TYPES.ExpressionStatement?releaseNode.parent:null;if(!releaseParentStmt)return false;const releaseIdx=branchBlock.body.indexOf(releaseParentStmt);if(releaseIdx===-1)return false;for(let i=releaseIdx+1;i<branchBlock.body.length;i++){const stmt=branchBlock.body[i];if(stmt.type===eslint_devkit_1.AST_NODE_TYPES.ReturnStatement||stmt.type===eslint_devkit_1.AST_NODE_TYPES.ThrowStatement){return true}}return false}exports.preventDoubleRelease={meta:{type:"problem",docs:{description:"Prevent releasing a pg client multiple times.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-postgresql-security/docs/rules/prevent-double-release.md",cwe:"CWE-415",cweJustification:"CWE-415 (Double Free) \u2014 semantic equivalent for connection lifecycle: releasing a pooled client twice corrupts the pool's internal accounting and can hand the same connection to two callers.",confidence:"medium"},messages:{doubleRelease:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Double Release",description:"Client release() called multiple times on the same object.",severity:"HIGH",effort:"low",fix:"Ensure client.release() is called exactly once per acquisition, preferably in a finally block.",documentationLink:"https://node-postgres.com/api/client#clientrelease"}),doubleReleaseCallback:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Double Release (Callback)",description:"Connection release callback (done) called multiple times.",severity:"HIGH",effort:"low",fix:"Ensure done() or release callback is called exactly once per pool.connect() callback.",documentationLink:"https://node-postgres.com/api/pool#poolconnect"})},schema:[]},defaultOptions:[],create(context){return{VariableDeclarator(node){const declaredVariables=context.sourceCode.getDeclaredVariables(node);for(const variable of declaredVariables){const def=variable.defs[0];const isDestructuredRelease=def?.type==="Variable"&&def.node.id.type===eslint_devkit_1.AST_NODE_TYPES.ObjectPattern&&def.name.name==="release";const releaseCalls=[];variable.references.forEach(ref=>{const id=ref.identifier;if(isDestructuredRelease){if(id.parent?.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&id.parent.callee===id){const callNode=id.parent;const guarded=isGuardedByCondition(callNode);releaseCalls.push({node:callNode,guarded})}}else{if(id.parent?.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&id.parent.object===id&&id.parent.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&id.parent.property.name==="release"&&id.parent.parent?.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression){const callNode=id.parent.parent;const guarded=isGuardedByCondition(callNode);releaseCalls.push({node:callNode,guarded})}}});if(releaseCalls.length>1){releaseCalls.sort((a,b)=>a.node.range[0]-b.node.range[0]);const reported=new Set;for(let i=0;i<releaseCalls.length;i++){for(let j=i+1;j<releaseCalls.length;j++){const callA=releaseCalls[i];const callB=releaseCalls[j];if(reported.has(callB.node))continue;if(callA.guarded&&callB.guarded)continue;if(areMutuallyExclusiveBranches(callA.node,callB.node))continue;const funcA=getContainingFunction(callA.node);const funcB=getContainingFunction(callB.node);if(funcA!==funcB)continue;const tryA=isInTryBlock(callA.node);const catchB=isInCatchBlock(callB.node);if(tryA&&catchB&&catchB.parent===tryA){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}const catchA=isInCatchBlock(callA.node);const tryB=isInTryBlock(callB.node);if(catchA&&tryB&&catchA.parent===tryB){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}const switchCaseA=getSwitchCase(callA.node);const switchCaseB=getSwitchCase(callB.node);if(switchCaseA&&switchCaseB&&switchCaseA!==switchCaseB){const switchA=findAncestor(switchCaseA,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.SwitchStatement);const switchB=findAncestor(switchCaseB,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.SwitchStatement);if(switchA===switchB&&switchA){if(!caseHasExit(switchCaseA)){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}}const ifA=getDirectIfStatement(callA.node);if(ifA&&!ifA.alternate){if(callB.node.range[0]>ifA.range[1]){const parentBlock=findAncestor(ifA,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.BlockStatement);if(parentBlock){const bParentStmt=callB.node.parent?.type===eslint_devkit_1.AST_NODE_TYPES.ExpressionStatement?callB.node.parent:null;if(bParentStmt&&parentBlock.body.includes(bParentStmt)){if(!ifBranchHasExitAfterRelease(callA.node,ifA)){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}}}}const ifB=getDirectIfStatement(callB.node);if(ifA&&ifB&&ifA!==ifB&&!ifA.alternate&&!ifB.alternate){const parentBlockA=ifA.parent;const parentBlockB=ifB.parent;if(parentBlockA===parentBlockB&&parentBlockA?.type===eslint_devkit_1.AST_NODE_TYPES.BlockStatement){if(!ifBranchHasExitAfterRelease(callA.node,ifA)){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}}const parentA=callA.node.parent?.parent;const parentB=callB.node.parent?.parent;if(parentA&&parentB&&parentA===parentB&&parentA.type===eslint_devkit_1.AST_NODE_TYPES.BlockStatement){const block=parentA;const indexA=block.body.indexOf(callA.node.parent);const indexB=block.body.indexOf(callB.node.parent);if(indexB>indexA&&!hasExitBetween(block,indexA,indexB)){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}const catchAForFinally=isInCatchBlock(callA.node);const finallyB=isInFinallyBlock(callB.node);if(catchAForFinally&&finallyB){const tryOfCatch=catchAForFinally.parent;if(tryOfCatch===finallyB){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}const tryAForFinally=isInTryBlock(callA.node);const finallyB2=isInFinallyBlock(callB.node);if(tryAForFinally&&finallyB2&&tryAForFinally===finallyB2){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}const finallyA=isInFinallyBlock(callA.node);if(finallyA){const tryEndPos=finallyA.range[1];if(callB.node.range[0]>tryEndPos){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}const tryAWithOrWithout=isInTryBlock(callA.node);if(tryAWithOrWithout){const tryEndPos=tryAWithOrWithout.range[1];if(callB.node.range[0]>tryEndPos&&!isInFinallyBlock(callB.node)){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}const ifStmtA=findAncestor(callA.node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.IfStatement);if(ifStmtA&&finallyB){if(!ifBranchHasExitAfterRelease(callA.node,ifStmtA)){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}const catchAForAfter=isInCatchBlock(callA.node);if(catchAForAfter){const tryOfCatchA=catchAForAfter.parent;const tryEndPos=tryOfCatchA.range[1];if(callB.node.range[0]>tryEndPos){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}const isInExpression=exprNode=>{let current=exprNode.parent;while(current){if(current.type===eslint_devkit_1.AST_NODE_TYPES.ConditionalExpression)return true;if(current.type===eslint_devkit_1.AST_NODE_TYPES.LogicalExpression)return true;if(current.type===eslint_devkit_1.AST_NODE_TYPES.ExpressionStatement)break;if(current.type===eslint_devkit_1.AST_NODE_TYPES.BlockStatement)break;current=current.parent}return false};if(isInExpression(callA.node)){let exprStmtA=callA.node;while(exprStmtA&&exprStmtA.type!==eslint_devkit_1.AST_NODE_TYPES.ExpressionStatement){exprStmtA=exprStmtA.parent??null}if(exprStmtA&&callB.node.range[0]>exprStmtA.range[1]){const blockA=findAncestor(exprStmtA,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.BlockStatement);const blockB=findAncestor(callB.node,n=>n.type===eslint_devkit_1.AST_NODE_TYPES.BlockStatement);if(blockA&&blockA===blockB){context.report({node:callB.node,messageId:"doubleRelease"});reported.add(callB.node);continue}}}}}}}}}}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});
package/CHANGELOG.md DELETED
@@ -1,150 +0,0 @@
1
- ## [1.4.3] - 2026-02-08
2
-
3
- ## 1.4.9
4
-
5
- ### Patch Changes
6
-
7
- - [#294](https://github.com/ofri-peretz/eslint/pull/294) [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Rewrite `description` and `keywords` on every published package for npm search discovery. npm ranks on name, description, and keywords, and the registry only picks up these fields at publish — so this is metadata-only and takes effect for each package on its next release.
8
-
9
- **Descriptions now lead with the search phrase.** Every one starts `ESLint plugin for <the thing you'd search>` instead of a brand-first or category-first framing, and names the concrete vulnerabilities the plugin actually detects. Three were corrected while doing so:
10
-
11
- - `eslint-plugin-import-next` claimed "100x faster no-cycle detection". No 100x measurement exists: `CLAIMS.md` records **3.1x end-to-end** (8x in pure rule execution) on a 5,483-file React codebase, and the highest number in any benchmark result is 54.9x on the synthetic corpus. The description now states the real-codebase figure.
12
- - `eslint-plugin-secure-coding` claimed SQL injection, XSS and CSRF coverage — none of which are its rules. It now names what it does detect: LDAP, XPath, XXE, GraphQL and template injection, unsafe deserialization, ReDoS, missing authentication, and PII in logs.
13
- - `eslint-plugin-secure-coding` ("89 rules") and `eslint-plugin-react-a11y` ("37 rules") hard-coded rule counts that had drifted from reality. Counts are generated into `interlace-numbers.json`; hand-typed copies are removed rather than corrected.
14
-
15
- **Keywords now match the vocabulary of the plugins that rank.** `eslint-plugin-security`, `eslint-plugin-jsx-a11y`, `eslint-plugin-n` and `eslint-plugin-import` all carry the `eslint` / `eslintplugin` / `eslint-plugin` trio — six of our packages were missing `eslintplugin`, and every one now carries all three plus `static-analysis`, `linting` and `code-quality`. Security plugins add `sast`, `appsec` and `vulnerability`; `node-security` and `secure-coding` also carry `nodesecurity`, the exact keyword `eslint-plugin-security` ranks on. Each plugin gained the CWE identifiers and attack names for what it detects (`cwe-78` command injection, `cwe-22` path traversal, `cwe-89` SQL injection, `cwe-79` XSS, `cwe-347` JWT algorithm confusion, `cwe-352` CSRF, `cwe-943` NoSQL injection), and `node-security` gained the crypto vocabulary it had been missing entirely despite absorbing the crypto rule set (`crypto`, `cryptography`, `weak-hash`, `md5`, `sha1`, `timing-attack`).
16
-
17
- No rule behavior, exports, or configuration changes.
18
-
19
- - Updated dependencies [[`e1cdf83`](https://github.com/ofri-peretz/eslint/commit/e1cdf83e3db761907f0ab06f7fc6c1f1da7513a5), [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358)]:
20
- - @interlace/eslint-devkit@1.4.3
21
-
22
- ## 1.4.8
23
-
24
- ### Patch Changes
25
-
26
- - [#269](https://github.com/ofri-peretz/eslint/pull/269) [`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - docs: dual-logo README header (Interlace mark + ESLint mark side by side) and closing Interlace footer — refreshes the README rendered on npmjs.com. No runtime changes.
27
-
28
- - Updated dependencies [[`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad)]:
29
- - @interlace/eslint-devkit@1.4.2
30
-
31
- ## 1.4.7
32
-
33
- ### Patch Changes
34
-
35
- - [#252](https://github.com/ofri-peretz/eslint/pull/252) [`d67e395`](https://github.com/ofri-peretz/eslint/commit/d67e3953c2748ad36e6aebe0f24b1d04e518b4d0) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Fix Codecov badge showing "unknown" — switch from flag to component URL format
36
-
37
- ## 1.4.6
38
-
39
- ### Patch Changes
40
-
41
- - [#225](https://github.com/ofri-peretz/eslint/pull/225) [`34ff5a8`](https://github.com/ofri-peretz/eslint/commit/34ff5a8e6f5126c5d1c0a524759e0af2b5476b46) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - CI-only: pin all coverage thresholds at 100% (integration target, merges last).
42
-
43
- ## 1.4.5
44
-
45
- ### Patch Changes
46
-
47
- - [#213](https://github.com/ofri-peretz/eslint/pull/213) [`391dbe6`](https://github.com/ofri-peretz/eslint/commit/391dbe6b39f78d549379218567cb959649f8c614) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Align every security rule's `meta.docs.cvss` to the CVSS its finding actually
48
- emits. The emitted machine-readable message sources its `CVSS:x` from
49
- `CWE_MAPPING` via `formatLLMMessage` → `enrichFromCWE`, but the static
50
- `meta.docs.cvss` documentation field had drifted on 45 rules across these 7
51
- plugins — e.g. `no-hardcoded-credentials` documented `9.5` while emitting
52
- `CVSS:9.8` (the value the published article and SARIF/LLM consumers already
53
- read).
54
-
55
- This corrects the **documentation metadata only** — no emitted finding changes.
56
- Locked by `security-cvss-docs-consistency.lock.test.ts` (cross-plugin: every
57
- security rule's `meta.docs.cvss` must equal the CVSS it emits), the
58
- `no-hardcoded-credentials` rule lock (real ESLint `Linter` emission), and a
59
- devkit `enrichFromCWE` contract test pinning `CWE-798 → 9.8`.
60
-
61
- Follow-up (not in scope): 50 security rules document a CVSS that never appears
62
- in any emitted message (their messages carry no CWE), and several rules emit the
63
- generic CWE score where a rule-specific score may be warranted — both change
64
- emitted output and are separate decisions.
65
-
66
- ## 1.4.4
67
-
68
- ### Patch Changes
69
-
70
- - [#143](https://github.com/ofri-peretz/eslint/pull/143) [`213cde1`](https://github.com/ofri-peretz/eslint/commit/213cde190ff2aea49ca7c1b533170940f879d9b4) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - fix(no-missing-null-checks): eliminate 53 false positives via three new narrowing patterns
71
-
72
- Rules that were recognized as null guards are now correctly identified as safe:
73
- 1. **Truthy if guard** — `if (obj) { obj.prop }` — direct truthy check proves non-null. Also covers chains: `if (response)` protects `response.data.items`.
74
- 2. **Short-circuit AND** — `obj && obj.prop` — right side of `&&` only runs when left is truthy.
75
- 3. **Ternary consequent** — `obj ? obj.prop : fallback` — truthy test guards the consequent.
76
-
77
- Also: bumped `beforeAll` timeout to 30 seconds in 7 compatibility test files (`__compatibility__/*.spec.ts`). Native-addon packages routinely exceed the previous 10-second default on a cold ESM load.
78
-
79
- - Updated dependencies [[`736a5fe`](https://github.com/ofri-peretz/eslint/commit/736a5fed47e673f6157ea900b29fe2a54e4bc7df)]:
80
- - @interlace/eslint-devkit@1.4.1
81
-
82
- ### Bug Fixes
83
-
84
- - align codecov component IDs with full package names ([2831b968](https://github.com/ofri-peretz/eslint/commit/2831b968))
85
- - resolve all benchmark FN/FP across security rules ([45ffb791](https://github.com/ofri-peretz/eslint/commit/45ffb791))
86
-
87
- ### Documentation
88
-
89
- - fix changelog header format across all packages ([c3a15082](https://github.com/ofri-peretz/eslint/commit/c3a15082))
90
-
91
- ### ❤️ Thank You
92
-
93
- - Ofri Peretz
94
-
95
- ## [1.4.2] - 2026-02-06
96
-
97
- ### Bug Fixes
98
-
99
- - align codecov component names and update docs components ([0a59a86c](https://github.com/ofri-peretz/eslint/commit/0a59a86c))
100
-
101
- ### ❤️ Thank You
102
-
103
- - Ofri Peretz
104
-
105
- ## [1.4.1] - 2026-02-02
106
-
107
- This was a version bump only for eslint-plugin-postgresql-security to align it with other projects, there were no code changes.
108
-
109
- # Changelog
110
-
111
- All notable changes to `eslint-plugin-postgresql-security` will be documented in this file.
112
-
113
- ## [0.0.1] - 2024-12-20
114
-
115
- ### Added
116
-
117
- - Initial release with 13 rules for PostgreSQL security and best practices
118
-
119
- #### Security Rules (6)
120
-
121
- - `no-unsafe-query` - Prevents SQL injection via string interpolation
122
- - `no-insecure-ssl` - Prevents disabling SSL certificate validation
123
- - `no-hardcoded-credentials` - Prevents hardcoded passwords in config
124
- - `no-unsafe-search-path` - Prevents dynamic search_path hijacking
125
- - `no-unsafe-copy-from` - Prevents COPY FROM file path exposure
126
- - `no-transaction-on-pool` - Prevents transaction commands on pool
127
-
128
- #### Resource Management Rules (3)
129
-
130
- - `no-missing-client-release` - Ensures pool clients are released
131
- - `prevent-double-release` - Prevents double client.release()
132
- - `no-floating-query` - Ensures query promises are handled
133
-
134
- #### Quality & Performance Rules (4)
135
-
136
- - `check-query-params` - Validates parameter count matches placeholders
137
- - `no-select-all` - Discourages SELECT \*
138
- - `prefer-pool-query` - Suggests pool.query() for simple queries
139
- - `no-batch-insert-loop` - Prevents N+1 mutation queries
140
-
141
- #### Presets
142
-
143
- - `recommended` - Balanced security and quality settings
144
- - `strict` - All rules as errors
145
-
146
- #### Documentation
147
-
148
- - Full documentation for all 13 rules
149
- - AGENTS.md for AI assistant integration
150
- - Benchmark folder for capability demonstration
package/dist/AGENTS.md DELETED
@@ -1,118 +0,0 @@
1
- # AGENTS.md
2
-
3
- > Context for AI coding agents working on eslint-plugin-postgresql-security
4
-
5
- ## Setup Commands
6
-
7
- ```bash
8
- # Install dependencies (from monorepo root)
9
- npm install
10
-
11
- # Build this package
12
- nx build eslint-plugin-postgresql-security
13
-
14
- # Run tests
15
- nx test eslint-plugin-postgresql-security
16
-
17
- # Run tests with coverage
18
- nx test eslint-plugin-postgresql-security --coverage
19
-
20
- # Lint this package
21
- nx lint eslint-plugin-postgresql-security
22
- ```
23
-
24
- ## Code Style
25
-
26
- - TypeScript strict mode with `@interlace/eslint-devkit` types
27
- - Use `AST_NODE_TYPES` constants, never string literals for node types
28
- - Use `formatLLMMessage()` for all rule error messages
29
- - Include CWE, CVSS in every security message
30
- - Use `c8 ignore` comments with documented reasons for untestable code
31
- - Single-pass AST traversal patterns (O(n) complexity)
32
- - Use `$1, $2` placeholders (pg standard), NOT `?` (MySQL style)
33
-
34
- ## Testing Instructions
35
-
36
- - Tests use `@typescript-eslint/rule-tester` with Vitest
37
- - Each rule has `index.ts` (implementation) and `*.test.ts` (tests) in same directory
38
- - Run specific rule test: `nx test eslint-plugin-postgresql-security --testPathPattern="no-unsafe-query"`
39
- - Coverage target: ≥90% lines, ≥95% functions
40
- - All tests must pass before committing
41
-
42
- ## Project Structure
43
-
44
- ```
45
- src/
46
- ├── index.ts # Plugin entry, exports rules and configs
47
- └── rules/ # 13 rule directories
48
- └── [rule-name]/
49
- ├── index.ts # Rule implementation
50
- └── *.test.ts # Rule tests
51
- docs/rules/ # Markdown documentation per rule
52
- ```
53
-
54
- ## Plugin Purpose
55
-
56
- Security and best practices ESLint plugin for **node-postgres (pg)**. Covers SQL injection, SSL, credentials, transactions, connection management, and query patterns.
57
-
58
- ## Rule Resolution Strategies
59
-
60
- ### SQL Injection (`pg/no-unsafe-query`)
61
-
62
- ```typescript
63
- // ❌ BAD: client.query(`SELECT * FROM users WHERE id = ${userId}`)
64
- // ✅ GOOD: client.query('SELECT * FROM users WHERE id = $1', [userId])
65
- ```
66
-
67
- ### SSL Issues (`pg/no-insecure-ssl`)
68
-
69
- ```typescript
70
- // ❌ BAD: new Client({ ssl: { rejectUnauthorized: false } })
71
- // ✅ GOOD: new Client({ ssl: true })
72
- // ✅ GOOD: new Client({ ssl: { ca: process.env.PG_SSL_CA } })
73
- ```
74
-
75
- ### Hardcoded Credentials (`pg/no-hardcoded-credentials`)
76
-
77
- ```typescript
78
- // ❌ BAD: new Client({ password: 'supersecret' })
79
- // ✅ GOOD: new Client({ password: process.env.PG_PASSWORD })
80
- ```
81
-
82
- ### Transaction on Pool (`pg/no-transaction-on-pool`)
83
-
84
- ```typescript
85
- // ❌ BAD: await pool.query('BEGIN'); await pool.query('COMMIT');
86
- // ✅ GOOD: const client = await pool.connect(); try { await client.query('BEGIN'); ... } finally { client.release(); }
87
- ```
88
-
89
- ### Missing Release (`pg/no-missing-client-release`)
90
-
91
- ```typescript
92
- // ❌ BAD: const client = await pool.connect(); await client.query('SELECT 1');
93
- // ✅ GOOD: const client = await pool.connect(); try { ... } finally { client.release(); }
94
- ```
95
-
96
- ### N+1 Queries (`pg/no-batch-insert-loop`)
97
-
98
- ```typescript
99
- // ❌ BAD: for (const user of users) { await client.query('INSERT...', [user.id]); }
100
- // ✅ GOOD: await client.query('INSERT INTO users SELECT * FROM unnest($1::int[])', [users.map(u => u.id)])
101
- ```
102
-
103
- ## Safe Patterns (Should NOT trigger)
104
-
105
- 1. **Parameterized queries:** `client.query('SELECT $1', [value])` ✅
106
- 2. **Static strings:** `client.query('SELECT 1')` ✅
107
- 3. **Environment variables:** `process.env.DATABASE_URL` ✅
108
- 4. **COPY FROM STDIN:** `'COPY users FROM STDIN'` ✅
109
- 5. **SELECT \* FROM UNNEST:** Bulk insert pattern ✅
110
- 6. **COUNT(\*):** Aggregate function ✅
111
-
112
- ## Code Style Preferences
113
-
114
- 1. **Prefer `pool.query()`** for single queries without transactions
115
- 2. **Always use try/finally** for pool.connect()
116
- 3. **Use `$1, $2` placeholders** (pg standard) not `?` (MySQL style)
117
- 4. **Bulk operations** over loops for performance
118
- 5. **Explicit columns** over SELECT \*