eslint-plugin-typeorm-security 0.2.0 → 0.3.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
@@ -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.0",
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.9.0"
80
80
  },
81
81
  "funding": {
82
82
  "type": "github",
package/src/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configs = exports.plugin = exports.rules = void 0;
4
4
  exports.rules = {
5
+ get 'no-hardcoded-credentials'() { return require("./rules/no-hardcoded-credentials").noHardcodedCredentials; },
6
+ get 'no-mass-assignment'() { return require("./rules/no-mass-assignment").noMassAssignment; },
5
7
  get 'no-unsafe-query'() { return require("./rules/no-unsafe-query").noUnsafeQuery; },
6
8
  get 'require-tls'() { return require("./rules/require-tls").requireTls; },
7
9
 
@@ -9,7 +11,7 @@ exports.rules = {
9
11
  exports.plugin = {
10
12
  meta: {
11
13
  name: 'eslint-plugin-typeorm-security',
12
- version: '0.2.0',
14
+ version: '0.3.0',
13
15
  },
14
16
  rules: exports.rules,
15
17
  };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noHardcodedCredentials = void 0;
4
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
+ exports.noHardcodedCredentials = (0, eslint_devkit_1.createHardcodedCredentialsRule)({
6
+ meta: {
7
+ type: 'problem',
8
+ docs: {
9
+ description: 'Disallow literal database passwords in TypeORM DataSource configuration, including credentials embedded in a connection URL.',
10
+ url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-typeorm-security/docs/rules/no-hardcoded-credentials.md',
11
+ cwe: 'CWE-798',
12
+ cvss: 9.8,
13
+ confidence: 'high',
14
+ },
15
+ },
16
+ modules: ['typeorm'],
17
+ connectionKeys: ['extra', 'type', 'entities', 'synchronize', 'options'],
18
+ urlSchemes: ['postgres', 'postgresql', 'mysql', 'mariadb'],
19
+ fix: 'Read the password from the environment — `password: process.env.DB_PASSWORD` — and keep the value in your secret manager, never in the repo.',
20
+ 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`.',
21
+ documentationLink: 'https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_password',
22
+ });
@@ -0,0 +1,22 @@
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 TypeORM, which lets the caller set every column the model exposes.',
10
+ url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-typeorm-security/docs/rules/no-mass-assignment.md',
11
+ cwe: 'CWE-915',
12
+ cvss: 8.1,
13
+ confidence: 'high',
14
+ },
15
+ },
16
+ methods: ['save', 'insert', 'update', 'create', 'merge', 'preload'],
17
+ payloadKeys: [],
18
+ receiverPattern: /^(repo|repository|manager|em|ds|dataSource|db|database|tx|trx)$|[Rr]epository$|[Mm]anager$/,
19
+ modules: ['typeorm'],
20
+ 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.',
21
+ documentationLink: 'https://typeorm.io/repository-api',
22
+ });
@@ -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
  }