eslint-plugin-drizzle-security 0.3.0 → 0.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-drizzle-security",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "ESLint plugin for drizzle-orm — detects SQL injection in raw queries built with string concatenation or template literals.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -76,7 +76,7 @@
76
76
  }
77
77
  },
78
78
  "dependencies": {
79
- "@interlace/eslint-devkit": "^1.9.0"
79
+ "@interlace/eslint-devkit": "^1.10.0"
80
80
  },
81
81
  "funding": {
82
82
  "type": "github",
package/src/index.js CHANGED
@@ -1,36 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configs = exports.plugin = exports.rules = void 0;
4
- exports.rules = {
5
- get 'no-mass-assignment'() { return require("./rules/no-mass-assignment").noMassAssignment; },
6
- get 'no-raw-identifier-interpolation'() { return require("./rules/no-raw-identifier-interpolation").noRawIdentifierInterpolation; },
7
- get 'no-unsafe-query'() { return require("./rules/no-unsafe-query").noUnsafeQuery; },
8
- get 'no-unscoped-mutation'() { return require("./rules/no-unscoped-mutation").noUnscopedMutation; },
9
-
10
- };
11
- exports.plugin = {
12
- meta: {
13
- name: 'eslint-plugin-drizzle-security',
14
- version: '0.3.0',
15
- },
16
- rules: exports.rules,
17
- };
18
- exports.configs = {
19
- flagship: {
20
- plugins: { 'drizzle-security': exports.plugin },
21
- rules: {
22
- 'drizzle-security/no-unsafe-query': 'error',
23
- },
24
- },
25
- recommended: {
26
- plugins: { 'drizzle-security': exports.plugin },
27
- rules: {
28
- 'drizzle-security/no-unsafe-query': 'error',
29
- },
30
- },
31
- strict: {
32
- plugins: { 'drizzle-security': exports.plugin },
33
- rules: Object.fromEntries(Object.keys(exports.rules).map((ruleName) => [`drizzle-security/${ruleName}`, 'error'])),
34
- },
35
- };
36
- exports.default = exports.plugin;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;exports.rules={get"no-mass-assignment"(){return require("./rules/no-mass-assignment").noMassAssignment},get"no-raw-identifier-interpolation"(){return require("./rules/no-raw-identifier-interpolation").noRawIdentifierInterpolation},get"no-unsafe-query"(){return require("./rules/no-unsafe-query").noUnsafeQuery},get"no-unscoped-mutation"(){return require("./rules/no-unscoped-mutation").noUnscopedMutation}};exports.plugin={meta:{name:"eslint-plugin-drizzle-security",version:"0.3.1"},rules:exports.rules};exports.configs={flagship:{plugins:{"drizzle-security":exports.plugin},rules:{"drizzle-security/no-unsafe-query":"error"}},recommended:{plugins:{"drizzle-security":exports.plugin},rules:{"drizzle-security/no-unsafe-query":"error"}},strict:{plugins:{"drizzle-security":exports.plugin},rules:Object.fromEntries(Object.keys(exports.rules).map(ruleName=>[`drizzle-security/${ruleName}`,"error"]))}};exports.default=exports.plugin;
package/src/oxlint.js CHANGED
@@ -1,3 +1 @@
1
- "use strict";
2
- const index_1 = require("./index");
3
- module.exports = index_1.plugin;
1
+ "use strict";const index_1=require("./index");module.exports=index_1.plugin;
@@ -1,22 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noMassAssignment = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- exports.noMassAssignment = (0, eslint_devkit_1.createMassAssignmentRule)({
6
- meta: {
7
- type: 'problem',
8
- docs: {
9
- description: 'Disallow writing an inbound request object straight to the database through Drizzle, which lets the caller set every column the model exposes.',
10
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-drizzle-security/docs/rules/no-mass-assignment.md',
11
- cwe: 'CWE-915',
12
- cvss: 8.1,
13
- confidence: 'high',
14
- },
15
- },
16
- methods: ['values', 'set'],
17
- payloadKeys: [],
18
- receiverPattern: /^(db|database|drizzle|tx|trx)$|[Dd]b$/,
19
- modules: ['drizzle-orm'],
20
- fix: 'Name the columns you accept — `.values({ name: req.body.name })` — or validate into a typed object first. Drizzle writes every key present on the object.',
21
- documentationLink: 'https://orm.drizzle.team/docs/insert',
22
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noMassAssignment=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noMassAssignment=(0,eslint_devkit_1.createMassAssignmentRule)({meta:{type:"problem",docs:{description:"Disallow writing an inbound request object straight to the database through Drizzle, which lets the caller set every column the model exposes.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-drizzle-security/docs/rules/no-mass-assignment.md",cwe:"CWE-915",cvss:8.1,confidence:"high"}},methods:["values","set"],payloadKeys:[],receiverPattern:/^(db|database|drizzle|tx|trx)$|[Dd]b$/,modules:["drizzle-orm"],fix:"Name the columns you accept \u2014 `.values({ name: req.body.name })` \u2014 or validate into a typed object first. Drizzle writes every key present on the object.",documentationLink:"https://orm.drizzle.team/docs/insert"});
@@ -1,23 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noRawIdentifierInterpolation = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- exports.noRawIdentifierInterpolation = (0, eslint_devkit_1.createRawIdentifierRule)({
6
- meta: {
7
- type: 'problem',
8
- docs: {
9
- description: 'Disallow interpolating table, column or sort identifiers into a Drizzle `sql` tagged template, where bind parameters cannot reach them.',
10
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-drizzle-security/docs/rules/no-raw-identifier-interpolation.md',
11
- cwe: 'CWE-89',
12
- cvss: 9.8,
13
- confidence: 'high',
14
- },
15
- },
16
- tags: ['sql'],
17
- modules: ['drizzle-orm'],
18
- requireImport: true,
19
- identifierHelpers: ['sql.identifier', 'sql.join', 'sql.fromList', 'sql.placeholder'],
20
- fix: 'Wrap the identifier in `sql.identifier(name)`, which quotes and escapes it, or map the input through a fixed allowlist first.',
21
- sortDirectionFix: 'Use Drizzle\'s `asc()` / `desc()` helpers on a known column, or resolve the direction to a literal: `input === "desc" ? "desc" : "asc"`.',
22
- documentationLink: 'https://orm.drizzle.team/docs/sql',
23
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noRawIdentifierInterpolation=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noRawIdentifierInterpolation=(0,eslint_devkit_1.createRawIdentifierRule)({meta:{type:"problem",docs:{description:"Disallow interpolating table, column or sort identifiers into a Drizzle `sql` tagged template, where bind parameters cannot reach them.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-drizzle-security/docs/rules/no-raw-identifier-interpolation.md",cwe:"CWE-89",cvss:9.8,confidence:"high"}},tags:["sql"],modules:["drizzle-orm"],requireImport:true,identifierHelpers:["sql.identifier","sql.join","sql.fromList","sql.placeholder"],fix:"Wrap the identifier in `sql.identifier(name)`, which quotes and escapes it, or map the input through a fixed allowlist first.",sortDirectionFix:'Use Drizzle\'s `asc()` / `desc()` helpers on a known column, or resolve the direction to a literal: `input === "desc" ? "desc" : "asc"`.',documentationLink:"https://orm.drizzle.team/docs/sql"});
@@ -1,20 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noUnsafeQuery = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- exports.noUnsafeQuery = (0, eslint_devkit_1.createSqlInjectionRule)({
6
- meta: {
7
- type: 'problem',
8
- docs: {
9
- description: 'Prevent SQL injection by disallowing string concatenation or interpolated template literals in Drizzle sql.raw() calls.',
10
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-drizzle-security/docs/rules/no-unsafe-query.md',
11
- cwe: 'CWE-89',
12
- cvss: 9.8,
13
- confidence: 'high',
14
- },
15
- },
16
- methods: ['raw'],
17
- requireSqlKeywords: false,
18
- fix: 'Use the `sql` tagged template, which parameterizes interpolated values, instead of `sql.raw()`.',
19
- documentationLink: 'https://orm.drizzle.team/docs/sql#sqlraw',
20
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnsafeQuery=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noUnsafeQuery=(0,eslint_devkit_1.createSqlInjectionRule)({meta:{type:"problem",docs:{description:"Prevent SQL injection by disallowing string concatenation or interpolated template literals in Drizzle sql.raw() calls.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-drizzle-security/docs/rules/no-unsafe-query.md",cwe:"CWE-89",cvss:9.8,confidence:"high"}},methods:["raw"],requireSqlKeywords:false,fix:"Use the `sql` tagged template, which parameterizes interpolated values, instead of `sql.raw()`.",documentationLink:"https://orm.drizzle.team/docs/sql#sqlraw"});
@@ -1,22 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noUnscopedMutation = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- exports.noUnscopedMutation = (0, eslint_devkit_1.createUnscopedMutationRule)({
6
- meta: {
7
- type: 'problem',
8
- docs: {
9
- description: 'Require a chained `.where()` on Drizzle delete and update builders, so a bulk mutation cannot rewrite or delete every row in the table.',
10
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-drizzle-security/docs/rules/no-unscoped-mutation.md',
11
- cwe: 'CWE-284',
12
- cvss: 7.5,
13
- confidence: 'high',
14
- },
15
- },
16
- methods: ['delete', 'update'],
17
- argumentRole: 'table',
18
- modules: ['drizzle-orm'],
19
- receiverPattern: /^(db|database|drizzle|tx|trx)$|[Dd]b$/,
20
- fix: 'Chain a `.where()` clause, e.g. `db.delete(users).where(eq(users.id, id))`.',
21
- documentationLink: 'https://orm.drizzle.team/docs/delete',
22
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnscopedMutation=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noUnscopedMutation=(0,eslint_devkit_1.createUnscopedMutationRule)({meta:{type:"problem",docs:{description:"Require a chained `.where()` on Drizzle delete and update builders, so a bulk mutation cannot rewrite or delete every row in the table.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-drizzle-security/docs/rules/no-unscoped-mutation.md",cwe:"CWE-284",cvss:7.5,confidence:"high"}},methods:["delete","update"],argumentRole:"table",modules:["drizzle-orm"],receiverPattern:/^(db|database|drizzle|tx|trx)$|[Dd]b$/,fix:"Chain a `.where()` clause, e.g. `db.delete(users).where(eq(users.id, id))`.",documentationLink:"https://orm.drizzle.team/docs/delete"});
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});