eslint-plugin-typeorm-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 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-hardcoded-credentials](https://eslint.interlace.tools/docs/security/plugin-typeorm-security/rules/no-hardcoded-credentials?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-typeorm-security) | CWE-798 | A07:2021 | | Disallow literal database passwords in TypeORM connection configuration, including credentials embedded in… | 🟢 | | | | | |
121
+ | [no-mass-assignment](https://eslint.interlace.tools/docs/security/plugin-typeorm-security/rules/no-mass-assignment?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-typeorm-security) | CWE-915 | A04:2021 | | Disallow writing an inbound request object straight to the database through TypeORM, which lets the caller… | 🟢 | | | | | |
120
122
  | [no-unsafe-query](https://eslint.interlace.tools/docs/security/plugin-typeorm-security/rules/no-unsafe-query?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-typeorm-security) | CWE-89 | A03:2021 | | Prevent SQL injection by disallowing string concatenation or interpolated template literals in TypeORM raw… | 🟢 | 💼 | | | | |
121
123
  | [require-tls](https://eslint.interlace.tools/docs/security/plugin-typeorm-security/rules/require-tls?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-typeorm-security) | CWE-319 | A02:2021 | | Require TLS on TypeORM DataSource connections, so queries and credentials are not sent in cleartext and the… | 🟢 | | | | | |
122
124
  <!-- AUTO-GENERATED:RULES_TABLE:END -->
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-typeorm-security",
3
- "version": "0.2.0",
4
- "description": "ESLint plugin for typeorm — detects SQL injection in raw queries built with string concatenation or template literals, and connection configuration that disables TLS or certificate validation.",
3
+ "version": "0.3.1",
4
+ "description": "ESLint plugin for typeorm — detects SQL injection in raw queries 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.8.0"
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-typeorm-security',
12
- version: '0.2.0',
13
- },
14
- rules: exports.rules,
15
- };
16
- exports.configs = {
17
- flagship: {
18
- plugins: { 'typeorm-security': exports.plugin },
19
- rules: {
20
- 'typeorm-security/no-unsafe-query': 'error',
21
- },
22
- },
23
- recommended: {
24
- plugins: { 'typeorm-security': exports.plugin },
25
- rules: {
26
- 'typeorm-security/no-unsafe-query': 'error',
27
- },
28
- },
29
- strict: {
30
- plugins: { 'typeorm-security': exports.plugin },
31
- rules: Object.fromEntries(Object.keys(exports.rules).map((ruleName) => [`typeorm-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-typeorm-security",version:"0.3.1"},rules:exports.rules};exports.configs={flagship:{plugins:{"typeorm-security":exports.plugin},rules:{"typeorm-security/no-unsafe-query":"error"}},recommended:{plugins:{"typeorm-security":exports.plugin},rules:{"typeorm-security/no-unsafe-query":"error"}},strict:{plugins:{"typeorm-security":exports.plugin},rules:Object.fromEntries(Object.keys(exports.rules).map(ruleName=>[`typeorm-security/${ruleName}`,"error"]))}};exports.default=exports.plugin;
package/src/oxlint.js CHANGED
@@ -1,3 +1 @@
1
- "use strict";
2
- const index_1 = require("./index");
3
- module.exports = index_1.plugin;
1
+ "use strict";const index_1=require("./index");module.exports=index_1.plugin;
@@ -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 TypeORM DataSource configuration, including credentials embedded in a connection URL.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-typeorm-security/docs/rules/no-hardcoded-credentials.md",cwe:"CWE-798",cvss:9.8,confidence:"high"}},modules:["typeorm"],connectionKeys:["extra","type","entities","synchronize","options"],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 TypeORM, which lets the caller set every column the model exposes.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-typeorm-security/docs/rules/no-mass-assignment.md",cwe:"CWE-915",cvss:8.1,confidence:"high"}},methods:["save","insert","update","create","merge","preload"],payloadKeys:[],receiverPattern:/^(repo|repository|manager|em|ds|dataSource|db|database|tx|trx)$|[Rr]epository$|[Mm]anager$/,modules:["typeorm"],fix:"Name the columns you accept, or build the entity explicitly and assign only the fields this endpoint owns. `save()` writes every property present on the object.",documentationLink:"https://typeorm.io/repository-api"});
@@ -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 TypeORM raw queries.',
10
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-typeorm-security/docs/rules/no-unsafe-query.md',
11
- cwe: 'CWE-89',
12
- cvss: 9.8,
13
- confidence: 'high',
14
- },
15
- },
16
- methods: ['query'],
17
- requireSqlKeywords: false,
18
- fix: 'Pass values as the second-argument parameters array, or use query-builder parameters (`:name`), instead of interpolating them.',
19
- documentationLink: 'https://typeorm.io/#/select-query-builder/using-parameters-to-escape-data',
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 TypeORM raw queries.",url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-typeorm-security/docs/rules/no-unsafe-query.md",cwe:"CWE-89",cvss:9.8,confidence:"high"}},methods:["query"],requireSqlKeywords:false,fix:"Pass values as the second-argument parameters array, or use query-builder parameters (`:name`), instead of interpolating them.",documentationLink:"https://typeorm.io/#/select-query-builder/using-parameters-to-escape-data"});
@@ -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 TypeORM DataSource 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-typeorm-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: ['typeorm'],
18
- connectionKeys: ['extra', 'type', 'entities', 'synchronize', 'options'],
19
- urlSchemes: ['postgres', 'postgresql', 'mysql', 'mariadb'],
20
- fix: 'Keep TLS on and supply the CA — `ssl: { ca: fs.readFileSync(caPath) }`, or `extra: { ssl: { ca } }` for driver passthrough.',
21
- documentationLink: 'https://typeorm.io/data-source-options',
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 TypeORM DataSource 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-typeorm-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:["typeorm"],connectionKeys:["extra","type","entities","synchronize","options"],urlSchemes:["postgres","postgresql","mysql","mariadb"],fix:"Keep TLS on and supply the CA \u2014 `ssl: { ca: fs.readFileSync(caPath) }`, or `extra: { ssl: { ca } }` for driver passthrough.",documentationLink:"https://typeorm.io/data-source-options"});
@@ -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 AllTypeORMRulesOptions {
28
+ 'typeorm-security/no-mass-assignment': NoMassAssignmentOptions;
29
+ 'typeorm-security/no-hardcoded-credentials': NoHardcodedCredentialsOptions;
15
30
  'typeorm-security/no-unsafe-query': NoUnsafeQueryOptions;
16
31
  'typeorm-security/require-tls': RequireTlsOptions;
17
32
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});