eslint-plugin-sequelize-security 0.2.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/README.md +2 -0
- package/package.json +3 -3
- package/src/index.js +1 -34
- package/src/oxlint.js +1 -3
- package/src/rules/no-hardcoded-credentials/index.js +1 -0
- package/src/rules/no-mass-assignment/index.js +1 -0
- package/src/rules/no-unsafe-query/index.js +1 -20
- package/src/rules/require-tls/index.js +1 -22
- package/src/types/index.d.ts +15 -0
- package/src/types/index.js +1 -2
package/README.md
CHANGED
|
@@ -119,6 +119,8 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
119
119
|
<!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
|
|
120
120
|
| Rule | CWE | OWASP | CVSS | Description | π§ | πΌ | β οΈ | π§ | π‘ | π« |
|
|
121
121
|
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
122
|
+
| [no-hardcoded-credentials](https://eslint.interlace.tools/docs/security/plugin-sequelize-security/rules/no-hardcoded-credentials?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security) | CWE-798 | A07:2021 | | Disallow literal database passwords in Sequelize connection configuration, including credentials embedded iβ¦ | π’ | | | | | |
|
|
123
|
+
| [no-mass-assignment](https://eslint.interlace.tools/docs/security/plugin-sequelize-security/rules/no-mass-assignment?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security) | CWE-915 | A04:2021 | | Disallow writing an inbound request object straight to the database through Sequelize, which lets the calleβ¦ | π’ | | | | | |
|
|
122
124
|
| [no-unsafe-query](https://eslint.interlace.tools/docs/security/plugin-sequelize-security/rules/no-unsafe-query?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security) | CWE-89 | A03:2021 | | Detects SQL injection in raw Sequelize queries built with string concatenation or template literals | π’ | πΌ | | | | |
|
|
123
125
|
| [require-tls](https://eslint.interlace.tools/docs/security/plugin-sequelize-security/rules/require-tls?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security) | CWE-319 | A02:2021 | | Require TLS on Sequelize connections, so queries and credentials are not sent in cleartext and the server iβ¦ | π’ | | | | | |
|
|
124
126
|
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-sequelize-security",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "ESLint plugin for the Sequelize ORM β detects SQL injection in raw sequelize.query() and Sequelize.literal() calls built with string concatenation or template literals,
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "ESLint plugin for the Sequelize ORM β detects SQL injection in raw sequelize.query() and Sequelize.literal() calls built with string concatenation or template literals, connection configuration that disables TLS or certificate validation, and hardcoded database credentials.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./src/index.d.ts",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@interlace/eslint-devkit": "^1.
|
|
79
|
+
"@interlace/eslint-devkit": "^1.10.0"
|
|
80
80
|
},
|
|
81
81
|
"funding": {
|
|
82
82
|
"type": "github",
|
package/src/index.js
CHANGED
|
@@ -1,34 +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-unsafe-query'() { return require("./rules/no-unsafe-query").noUnsafeQuery; },
|
|
6
|
-
get 'require-tls'() { return require("./rules/require-tls").requireTls; },
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
exports.plugin = {
|
|
10
|
-
meta: {
|
|
11
|
-
name: 'eslint-plugin-sequelize-security',
|
|
12
|
-
version: '0.2.0',
|
|
13
|
-
},
|
|
14
|
-
rules: exports.rules,
|
|
15
|
-
};
|
|
16
|
-
exports.configs = {
|
|
17
|
-
flagship: {
|
|
18
|
-
plugins: { 'sequelize-security': exports.plugin },
|
|
19
|
-
rules: {
|
|
20
|
-
'sequelize-security/no-unsafe-query': 'error',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
recommended: {
|
|
24
|
-
plugins: { 'sequelize-security': exports.plugin },
|
|
25
|
-
rules: {
|
|
26
|
-
'sequelize-security/no-unsafe-query': 'error',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
strict: {
|
|
30
|
-
plugins: { 'sequelize-security': exports.plugin },
|
|
31
|
-
rules: Object.fromEntries(Object.keys(exports.rules).map((ruleName) => [`sequelize-security/${ruleName}`, 'error'])),
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
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-hardcoded-credentials"(){return require("./rules/no-hardcoded-credentials").noHardcodedCredentials},get"no-mass-assignment"(){return require("./rules/no-mass-assignment").noMassAssignment},get"no-unsafe-query"(){return require("./rules/no-unsafe-query").noUnsafeQuery},get"require-tls"(){return require("./rules/require-tls").requireTls}};exports.plugin={meta:{name:"eslint-plugin-sequelize-security",version:"0.3.1"},rules:exports.rules};exports.configs={flagship:{plugins:{"sequelize-security":exports.plugin},rules:{"sequelize-security/no-unsafe-query":"error"}},recommended:{plugins:{"sequelize-security":exports.plugin},rules:{"sequelize-security/no-unsafe-query":"error"}},strict:{plugins:{"sequelize-security":exports.plugin},rules:Object.fromEntries(Object.keys(exports.rules).map(ruleName=>[`sequelize-security/${ruleName}`,"error"]))}};exports.default=exports.plugin;
|
package/src/oxlint.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noHardcodedCredentials=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noHardcodedCredentials=(0,eslint_devkit_1.createHardcodedCredentialsRule)({meta:{type:"problem",docs:{description:"Disallow literal database passwords in Sequelize connection configuration, including credentials embedded in a connection URL.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-sequelize-security/docs/rules/no-hardcoded-credentials.md",cwe:"CWE-798",cvss:9.8,confidence:"high"}},modules:["sequelize","sequelize-typescript"],connectionKeys:["dialectOptions","dialect","replication"],urlSchemes:["postgres","postgresql","mysql","mariadb"],fix:"Read the password from the environment \u2014 `password: process.env.DB_PASSWORD` \u2014 and keep the value in your secret manager, never in the repo.",urlFix:"Keep the secret out of the URL: build the config from discrete fields with `password: process.env.DB_PASSWORD`, or inject the whole URL as `process.env.DATABASE_URL`.",documentationLink:"https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_password"});
|
|
@@ -0,0 +1 @@
|
|
|
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 Sequelize, which lets the caller set every column the model exposes.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-sequelize-security/docs/rules/no-mass-assignment.md",cwe:"CWE-915",cvss:8.1,confidence:"high"}},methods:["create","update","bulkCreate","set","upsert"],payloadKeys:[],receiverPattern:/^(sequelize|db|database|model|Model|tx|trx)$|[Ss]equelize$|[Mm]odel$/,modules:["sequelize","sequelize-typescript"],fix:"Name the attributes you accept, or pass Sequelize's own allowlist \u2014 `User.create(req.body, { fields: ['name', 'email'] })`, which is exactly what `fields` is for.",documentationLink:"https://sequelize.org/docs/v6/core-concepts/model-instances/"});
|
|
@@ -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 raw Sequelize queries.',
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-sequelize-security/docs/rules/no-unsafe-query.md',
|
|
11
|
-
cwe: 'CWE-89',
|
|
12
|
-
cvss: 9.8,
|
|
13
|
-
confidence: 'high',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
methods: ['query', 'literal'],
|
|
17
|
-
requireSqlKeywords: false,
|
|
18
|
-
fix: 'Pass values via `replacements` or `bind` instead of interpolating them into the SQL string.',
|
|
19
|
-
documentationLink: 'https://sequelize.org/docs/v7/querying/raw-queries/',
|
|
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 raw Sequelize queries.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-sequelize-security/docs/rules/no-unsafe-query.md",cwe:"CWE-89",cvss:9.8,confidence:"high"}},methods:["query","literal"],requireSqlKeywords:false,fix:"Pass values via `replacements` or `bind` instead of interpolating them into the SQL string.",documentationLink:"https://sequelize.org/docs/v7/querying/raw-queries/"});
|
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireTls = void 0;
|
|
4
|
-
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
-
exports.requireTls = (0, eslint_devkit_1.createRequireTlsRule)({
|
|
6
|
-
meta: {
|
|
7
|
-
type: 'problem',
|
|
8
|
-
docs: {
|
|
9
|
-
description: 'Require TLS on Sequelize connections, so queries and credentials are not sent in cleartext and the server is authenticated.',
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-sequelize-security/docs/rules/require-tls.md',
|
|
11
|
-
cwe: 'CWE-319',
|
|
12
|
-
cweJustification: 'CWE-319 (Cleartext Transmission) covers the tlsDisabled finding. The second finding, certificateValidationDisabled, is CWE-295 (Improper Certificate Validation): the channel is still encrypted, but the peer is no longer authenticated, so an attacker who answers in place of the database completes the handshake. One rule, two weaknesses β meta.docs.cwe carries a single identifier, so the secondary mapping is recorded here.',
|
|
13
|
-
cvss: 7.4,
|
|
14
|
-
confidence: 'high',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
modules: ['sequelize', 'sequelize-typescript'],
|
|
18
|
-
connectionKeys: ['dialectOptions', 'dialect', 'replication'],
|
|
19
|
-
urlSchemes: ['postgres', 'postgresql', 'mysql', 'mariadb'],
|
|
20
|
-
fix: 'Keep TLS on and supply the CA β `dialectOptions: { ssl: { require: true, ca } }`.',
|
|
21
|
-
documentationLink: 'https://sequelize.org/docs/v6/other-topics/dialect-specific-things/#postgresql',
|
|
22
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireTls=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.requireTls=(0,eslint_devkit_1.createRequireTlsRule)({meta:{type:"problem",docs:{description:"Require TLS on Sequelize connections, so queries and credentials are not sent in cleartext and the server is authenticated.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-sequelize-security/docs/rules/require-tls.md",cwe:"CWE-319",cweJustification:"CWE-319 (Cleartext Transmission) covers the tlsDisabled finding. The second finding, certificateValidationDisabled, is CWE-295 (Improper Certificate Validation): the channel is still encrypted, but the peer is no longer authenticated, so an attacker who answers in place of the database completes the handshake. One rule, two weaknesses \u2014 meta.docs.cwe carries a single identifier, so the secondary mapping is recorded here.",cvss:7.4,confidence:"high"}},modules:["sequelize","sequelize-typescript"],connectionKeys:["dialectOptions","dialect","replication"],urlSchemes:["postgres","postgresql","mysql","mariadb"],fix:"Keep TLS on and supply the CA \u2014 `dialectOptions: { ssl: { require: true, ca } }`.",documentationLink:"https://sequelize.org/docs/v6/other-topics/dialect-specific-things/#postgresql"});
|
package/src/types/index.d.ts
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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-hardcoded-credentials`.
|
|
15
|
+
*
|
|
16
|
+
* The rule takes none: a literal password is a literal password.
|
|
17
|
+
*/
|
|
18
|
+
export type NoHardcodedCredentialsOptions = [];
|
|
6
19
|
export type NoUnsafeQueryOptions = [];
|
|
7
20
|
/**
|
|
8
21
|
* Options for `require-tls`.
|
|
@@ -12,6 +25,8 @@ export type NoUnsafeQueryOptions = [];
|
|
|
12
25
|
*/
|
|
13
26
|
export type RequireTlsOptions = [];
|
|
14
27
|
export interface AllSequelizeRulesOptions {
|
|
28
|
+
'sequelize-security/no-mass-assignment': NoMassAssignmentOptions;
|
|
29
|
+
'sequelize-security/no-hardcoded-credentials': NoHardcodedCredentialsOptions;
|
|
15
30
|
'sequelize-security/no-unsafe-query': NoUnsafeQueryOptions;
|
|
16
31
|
'sequelize-security/require-tls': RequireTlsOptions;
|
|
17
32
|
}
|
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});
|