eslint-plugin-drizzle-security 0.1.1 β 0.2.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/README.md +7 -2
- package/package.json +2 -2
- package/src/index.js +3 -1
- package/src/rules/no-unscoped-mutation/index.js +22 -0
- package/src/types/index.d.ts +8 -0
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-drizzle-security" target="blank"><img src="https://eslint.interlace.tools/
|
|
2
|
+
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-drizzle-security" target="blank"><img src="https://eslint.interlace.tools/logos/interlace.svg" alt="Interlace" height="90" /></a>
|
|
3
3
|
|
|
4
|
-
<a href="https://
|
|
4
|
+
<a href="https://orm.drizzle.team" target="_blank"><img src="https://eslint.interlace.tools/logos/drizzle.svg" alt="Drizzle ORM" height="90" /></a>
|
|
5
|
+
|
|
6
|
+
<a href="https://oxc.rs" target="_blank"><img src="https://eslint.interlace.tools/logos/oxlint.svg" alt="oxlint" height="90" /></a>
|
|
7
|
+
|
|
8
|
+
<a href="https://eslint.org" target="_blank"><img src="https://eslint.interlace.tools/logos/eslint.svg" alt="ESLint" height="90" /></a>
|
|
5
9
|
</p>
|
|
6
10
|
|
|
7
11
|
<p align="center">
|
|
@@ -114,6 +118,7 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
114
118
|
| Rule | CWE | OWASP | CVSS | Description | π§ | πΌ | β οΈ | π§ | π‘ | π« |
|
|
115
119
|
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
116
120
|
| [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
|
+
| [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
122
|
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
118
123
|
## π Related ESLint Plugins
|
|
119
124
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-drizzle-security",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"tslib": "^2.3.0",
|
|
80
|
-
"@interlace/eslint-devkit": "^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.
|
|
13
|
+
version: '0.2.1',
|
|
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
|
+
});
|
package/src/types/index.d.ts
CHANGED
|
@@ -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
|
}
|