eslint-plugin-drizzle-security 0.2.1 β†’ 0.3.0

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/README.md CHANGED
@@ -117,6 +117,8 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
117
117
  <!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
118
118
  | Rule | CWE | OWASP | CVSS | Description | 🧠 | πŸ’Ό | ⚠️ | πŸ”§ | πŸ’‘ | 🚫 |
119
119
  | :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
120
+ | [no-mass-assignment](https://eslint.interlace.tools/docs/security/plugin-drizzle-security/rules/no-mass-assignment?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-drizzle-security) | CWE-915 | A04:2021 | | Disallow writing an inbound request object straight to the database through Drizzle, which lets the caller… | 🟒 | | | | | |
121
+ | [no-raw-identifier-interpolation](https://eslint.interlace.tools/docs/security/plugin-drizzle-security/rules/no-raw-identifier-interpolation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-drizzle-security) | CWE-89 | A03:2021 | | Disallow interpolating table, column or sort identifiers into a Drizzle `sql` tagged template, where bind p… | 🟒 | | | | | |
120
122
  | [no-unsafe-query](https://eslint.interlace.tools/docs/security/plugin-drizzle-security/rules/no-unsafe-query?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-drizzle-security) | CWE-89 | A03:2021 | | Prevent SQL injection by disallowing string concatenation or interpolated template literals in Drizzle sql.… | 🟒 | πŸ’Ό | | | | |
121
123
  | [no-unscoped-mutation](https://eslint.interlace.tools/docs/security/plugin-drizzle-security/rules/no-unscoped-mutation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-drizzle-security) | CWE-284 | A01:2021 | | Require a chained `.where()` on Drizzle delete and update builders, so a bulk mutation cannot rewrite or de… | 🟒 | | | | | |
122
124
  <!-- AUTO-GENERATED:RULES_TABLE:END -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-drizzle-security",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
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,8 +76,7 @@
76
76
  }
77
77
  },
78
78
  "dependencies": {
79
- "tslib": "^2.3.0",
80
- "@interlace/eslint-devkit": "^1.7.0"
79
+ "@interlace/eslint-devkit": "^1.9.0"
81
80
  },
82
81
  "funding": {
83
82
  "type": "github",
package/src/index.js CHANGED
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configs = exports.plugin = exports.rules = void 0;
4
- const no_unsafe_query_1 = require("./rules/no-unsafe-query");
5
- const no_unscoped_mutation_1 = require("./rules/no-unscoped-mutation");
6
4
  exports.rules = {
7
- 'no-unsafe-query': no_unsafe_query_1.noUnsafeQuery,
8
- 'no-unscoped-mutation': no_unscoped_mutation_1.noUnscopedMutation,
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
+
9
10
  };
10
11
  exports.plugin = {
11
12
  meta: {
12
13
  name: 'eslint-plugin-drizzle-security',
13
- version: '0.2.1',
14
+ version: '0.3.0',
14
15
  },
15
16
  rules: exports.rules,
16
17
  };
@@ -0,0 +1,22 @@
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
+ });
@@ -0,0 +1,23 @@
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
+ });
@@ -3,6 +3,20 @@
3
3
  * Licensed under the MIT License. Use of this source code is governed by the
4
4
  * MIT license that can be found in the LICENSE file.
5
5
  */
6
+ /**
7
+ * Options for `no-mass-assignment`.
8
+ *
9
+ * The rule takes none. An allowlist option would let a project re-approve the
10
+ * dangerous shape wholesale, one config file further from the call site.
11
+ */
12
+ export type NoMassAssignmentOptions = [];
13
+ /**
14
+ * Options for `no-raw-identifier-interpolation`.
15
+ *
16
+ * The rule takes none. Which SQL positions can accept a bind parameter is
17
+ * fixed by the database's grammar, not by project preference.
18
+ */
19
+ export type NoRawIdentifierInterpolationOptions = [];
6
20
  export type NoUnsafeQueryOptions = [];
7
21
  /**
8
22
  * Options for `no-unscoped-mutation`.
@@ -12,6 +26,8 @@ export type NoUnsafeQueryOptions = [];
12
26
  */
13
27
  export type NoUnscopedMutationOptions = [];
14
28
  export interface AllDrizzleRulesOptions {
29
+ 'drizzle-security/no-mass-assignment': NoMassAssignmentOptions;
30
+ 'drizzle-security/no-raw-identifier-interpolation': NoRawIdentifierInterpolationOptions;
15
31
  'drizzle-security/no-unsafe-query': NoUnsafeQueryOptions;
16
32
  'drizzle-security/no-unscoped-mutation': NoUnscopedMutationOptions;
17
33
  }