eslint-plugin-prisma-security 0.3.0 → 0.3.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.
- package/README.md +1 -1
- package/package.json +3 -3
- package/src/index.js +1 -36
- package/src/oxlint.js +1 -3
- package/src/rules/no-mass-assignment/index.js +1 -22
- package/src/rules/no-raw-identifier-interpolation/index.js +1 -23
- package/src/rules/no-unsafe-query/index.js +1 -20
- package/src/rules/no-unscoped-mutation/index.js +1 -21
- package/src/types/index.js +1 -2
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ src/db.ts
|
|
|
94
94
|
## 📦 Compatibility
|
|
95
95
|
| Package | Version |
|
|
96
96
|
| :--- | :--- |
|
|
97
|
-
| ESLint | `^8.
|
|
97
|
+
| ESLint | `^8.40.0 \|\| ^9.0.0 \|\| ^10.0.0` |
|
|
98
98
|
| Node.js | `>=18.0.0` |
|
|
99
99
|
|
|
100
100
|
See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) — current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-prisma-security",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "ESLint plugin for @prisma/client — detects SQL injection in raw queries built with string concatenation or template literals.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"node": ">=18.0.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"eslint": "^8.
|
|
70
|
+
"eslint": "^8.40.0 || ^9.0.0 || ^10.0.0",
|
|
71
71
|
"@prisma/client": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependenciesMeta": {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@interlace/eslint-devkit": "^1.
|
|
79
|
+
"@interlace/eslint-devkit": "^1.11.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-prisma-security',
|
|
14
|
-
version: '0.3.0',
|
|
15
|
-
},
|
|
16
|
-
rules: exports.rules,
|
|
17
|
-
};
|
|
18
|
-
exports.configs = {
|
|
19
|
-
flagship: {
|
|
20
|
-
plugins: { 'prisma-security': exports.plugin },
|
|
21
|
-
rules: {
|
|
22
|
-
'prisma-security/no-unsafe-query': 'error',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
recommended: {
|
|
26
|
-
plugins: { 'prisma-security': exports.plugin },
|
|
27
|
-
rules: {
|
|
28
|
-
'prisma-security/no-unsafe-query': 'error',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
strict: {
|
|
32
|
-
plugins: { 'prisma-security': exports.plugin },
|
|
33
|
-
rules: Object.fromEntries(Object.keys(exports.rules).map((ruleName) => [`prisma-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-prisma-security",version:"0.3.2"},rules:exports.rules};exports.configs={flagship:{plugins:{"prisma-security":exports.plugin},rules:{"prisma-security/no-unsafe-query":"error"}},recommended:{plugins:{"prisma-security":exports.plugin},rules:{"prisma-security/no-unsafe-query":"error"}},strict:{plugins:{"prisma-security":exports.plugin},rules:Object.fromEntries(Object.keys(exports.rules).map(ruleName=>[`prisma-security/${ruleName}`,"error"]))}};exports.default=exports.plugin;
|
package/src/oxlint.js
CHANGED
|
@@ -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 Prisma, which lets the caller set every column the model exposes.',
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-prisma-security/docs/rules/no-mass-assignment.md',
|
|
11
|
-
cwe: 'CWE-915',
|
|
12
|
-
cvss: 8.1,
|
|
13
|
-
confidence: 'high',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
methods: ['create', 'update', 'upsert', 'createMany', 'updateMany'],
|
|
17
|
-
payloadKeys: ['data', 'create', 'update'],
|
|
18
|
-
receiverPattern: /^(prisma|db|database|client|tx|trx)$|[Pp]risma$|[Cc]lient$/,
|
|
19
|
-
modules: ['@prisma/client'],
|
|
20
|
-
fix: 'Name the columns you accept — `data: { name: req.body.name }` — or validate into a typed object first (`const input = UserUpdate.parse(req.body)`). Prisma will happily write any column in the model.',
|
|
21
|
-
documentationLink: 'https://www.prisma.io/docs/orm/prisma-client/queries/crud',
|
|
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 Prisma, which lets the caller set every column the model exposes.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-prisma-security/docs/rules/no-mass-assignment.md",cwe:"CWE-915",cvss:8.1,confidence:"high"}},methods:["create","update","upsert","createMany","updateMany"],payloadKeys:["data","create","update"],receiverPattern:/^(prisma|db|database|client|tx|trx)$|[Pp]risma$|[Cc]lient$/,modules:["@prisma/client"],fix:"Name the columns you accept \u2014 `data: { name: req.body.name }` \u2014 or validate into a typed object first (`const input = UserUpdate.parse(req.body)`). Prisma will happily write any column in the model.",documentationLink:"https://www.prisma.io/docs/orm/prisma-client/queries/crud"});
|
|
@@ -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 Prisma $queryRaw / $executeRaw template, where bind parameters cannot reach them.',
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-prisma-security/docs/rules/no-raw-identifier-interpolation.md',
|
|
11
|
-
cwe: 'CWE-89',
|
|
12
|
-
cvss: 9.8,
|
|
13
|
-
confidence: 'high',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
tags: ['$queryRaw', '$executeRaw'],
|
|
17
|
-
modules: ['@prisma/client'],
|
|
18
|
-
requireImport: false,
|
|
19
|
-
identifierHelpers: [],
|
|
20
|
-
fix: 'Map the input through a fixed allowlist before it reaches the query — `const column = ALLOWED[input] ?? "id"`. Prisma has no identifier escaper, so an allowlist is the only safe construction.',
|
|
21
|
-
sortDirectionFix: 'Resolve the direction to a literal: `const dir = input === "desc" ? "desc" : "asc"`, or move the sort into the type-safe `orderBy` argument.',
|
|
22
|
-
documentationLink: 'https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/raw-queries#considerations',
|
|
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 Prisma $queryRaw / $executeRaw template, where bind parameters cannot reach them.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-prisma-security/docs/rules/no-raw-identifier-interpolation.md",cwe:"CWE-89",cvss:9.8,confidence:"high"}},tags:["$queryRaw","$executeRaw"],modules:["@prisma/client"],requireImport:false,identifierHelpers:[],fix:'Map the input through a fixed allowlist before it reaches the query \u2014 `const column = ALLOWED[input] ?? "id"`. Prisma has no identifier escaper, so an allowlist is the only safe construction.',sortDirectionFix:'Resolve the direction to a literal: `const dir = input === "desc" ? "desc" : "asc"`, or move the sort into the type-safe `orderBy` argument.',documentationLink:"https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/raw-queries#considerations"});
|
|
@@ -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 Prisma raw queries.',
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-prisma-security/docs/rules/no-unsafe-query.md',
|
|
11
|
-
cwe: 'CWE-89',
|
|
12
|
-
cvss: 9.8,
|
|
13
|
-
confidence: 'high',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
methods: ['$queryRawUnsafe', '$executeRawUnsafe'],
|
|
17
|
-
requireSqlKeywords: false,
|
|
18
|
-
fix: 'Use the `$queryRaw` tagged template (or `Prisma.sql`), which parameterizes interpolated values.',
|
|
19
|
-
documentationLink: 'https://www.prisma.io/docs/orm/prisma-client/queries/raw-database-access/raw-queries#queryrawunsafe',
|
|
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 Prisma raw queries.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-prisma-security/docs/rules/no-unsafe-query.md",cwe:"CWE-89",cvss:9.8,confidence:"high"}},methods:["$queryRawUnsafe","$executeRawUnsafe"],requireSqlKeywords:false,fix:"Use the `$queryRaw` tagged template (or `Prisma.sql`), which parameterizes interpolated values.",documentationLink:"https://www.prisma.io/docs/orm/prisma-client/queries/raw-database-access/raw-queries#queryrawunsafe"});
|
|
@@ -1,21 +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 `where` filter on Prisma bulk mutations, so deleteMany and updateMany cannot rewrite or delete every row in the table.',
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-prisma-security/docs/rules/no-unscoped-mutation.md',
|
|
11
|
-
cwe: 'CWE-284',
|
|
12
|
-
cvss: 7.5,
|
|
13
|
-
confidence: 'high',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
methods: ['deleteMany', 'updateMany'],
|
|
17
|
-
modules: ['@prisma/client', '.prisma/client'],
|
|
18
|
-
receiverPattern: /^(prisma|db|database|client|tx|trx)$|[Pp]risma$|[Cc]lient$/,
|
|
19
|
-
fix: 'Pass a `where` filter, e.g. `prisma.user.deleteMany({ where: { id } })`.',
|
|
20
|
-
documentationLink: 'https://www.prisma.io/docs/orm/prisma-client/queries/crud#delete-all-records',
|
|
21
|
-
});
|
|
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 `where` filter on Prisma bulk mutations, so deleteMany and updateMany cannot rewrite or delete every row in the table.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-prisma-security/docs/rules/no-unscoped-mutation.md",cwe:"CWE-284",cvss:7.5,confidence:"high"}},methods:["deleteMany","updateMany"],modules:["@prisma/client",".prisma/client"],receiverPattern:/^(prisma|db|database|client|tx|trx)$|[Pp]risma$|[Cc]lient$/,fix:"Pass a `where` filter, e.g. `prisma.user.deleteMany({ where: { id } })`.",documentationLink:"https://www.prisma.io/docs/orm/prisma-client/queries/crud#delete-all-records"});
|
package/src/types/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});
|