eslint-plugin-drizzle-security 0.1.1 β†’ 0.2.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
@@ -114,6 +114,7 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
114
114
  | Rule | CWE | OWASP | CVSS | Description | 🧠 | πŸ’Ό | ⚠️ | πŸ”§ | πŸ’‘ | 🚫 |
115
115
  | :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
116
116
  | [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.… | 🟒 | πŸ’Ό | | | | |
117
+ | [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… | 🟒 | | | | | |
117
118
  <!-- AUTO-GENERATED:RULES_TABLE:END -->
118
119
  ## πŸ”— Related ESLint Plugins
119
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-drizzle-security",
3
- "version": "0.1.1",
3
+ "version": "0.2.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",
@@ -77,7 +77,7 @@
77
77
  },
78
78
  "dependencies": {
79
79
  "tslib": "^2.3.0",
80
- "@interlace/eslint-devkit": "^1.6.1"
80
+ "@interlace/eslint-devkit": "^1.7.0"
81
81
  },
82
82
  "funding": {
83
83
  "type": "github",
package/src/index.js CHANGED
@@ -2,13 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configs = exports.plugin = exports.rules = void 0;
4
4
  const no_unsafe_query_1 = require("./rules/no-unsafe-query");
5
+ const no_unscoped_mutation_1 = require("./rules/no-unscoped-mutation");
5
6
  exports.rules = {
6
7
  'no-unsafe-query': no_unsafe_query_1.noUnsafeQuery,
8
+ 'no-unscoped-mutation': no_unscoped_mutation_1.noUnscopedMutation,
7
9
  };
8
10
  exports.plugin = {
9
11
  meta: {
10
12
  name: 'eslint-plugin-drizzle-security',
11
- version: '0.1.1',
13
+ version: '0.2.0',
12
14
  },
13
15
  rules: exports.rules,
14
16
  };
@@ -0,0 +1,22 @@
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
+ });
@@ -4,6 +4,14 @@
4
4
  * MIT license that can be found in the LICENSE file.
5
5
  */
6
6
  export type NoUnsafeQueryOptions = [];
7
+ /**
8
+ * Options for `no-unscoped-mutation`.
9
+ *
10
+ * The rule takes none: what counts as a scoped mutation is fixed by the
11
+ * driver's own API, not by project preference.
12
+ */
13
+ export type NoUnscopedMutationOptions = [];
7
14
  export interface AllDrizzleRulesOptions {
8
15
  'drizzle-security/no-unsafe-query': NoUnsafeQueryOptions;
16
+ 'drizzle-security/no-unscoped-mutation': NoUnscopedMutationOptions;
9
17
  }