eslint-plugin-sequelize-security 0.1.0 → 0.1.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/package.json +9 -21
- package/src/index.d.ts +17 -0
- package/{dist/src → src}/index.js +1 -28
- package/src/oxlint.d.ts +17 -0
- package/src/oxlint.js +3 -0
- package/src/rules/no-unsafe-query/index.js +20 -0
- package/src/types/index.js +2 -0
- package/dist/LICENSE +0 -23
- package/dist/README.md +0 -157
- package/dist/package.json +0 -98
- package/dist/src/index.d.ts +0 -30
- package/dist/src/oxlint.d.ts +0 -20
- package/dist/src/oxlint.js +0 -21
- package/dist/src/rules/no-unsafe-query/index.d.ts +0 -6
- package/dist/src/rules/no-unsafe-query/index.js +0 -41
- package/dist/src/types/index.js +0 -7
- package/src/index.test.ts +0 -50
- package/src/index.ts +0 -78
- package/src/oxlint.spec.ts +0 -67
- package/src/oxlint.ts +0 -23
- package/src/rules/no-unsafe-query/index.ts +0 -42
- package/src/rules/no-unsafe-query/no-unsafe-query.test.ts +0 -120
- package/src/types/index.ts +0 -11
- /package/{dist/src → src}/types/index.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-sequelize-security",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
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.",
|
|
5
5
|
"type": "commonjs",
|
|
6
|
-
"main": "./
|
|
7
|
-
"types": "./
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./
|
|
11
|
-
"default": "./
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
12
|
},
|
|
13
13
|
"./oxlint": {
|
|
14
14
|
"types": "./src/oxlint.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"homepage": "https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=npm&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "https://github.com/ofri-peretz/eslint",
|
|
23
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git",
|
|
24
24
|
"directory": "packages/eslint-plugin-sequelize-security"
|
|
25
25
|
},
|
|
26
26
|
"bugs": {
|
|
@@ -31,10 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"src/",
|
|
34
|
-
"dist/",
|
|
35
34
|
"README.md",
|
|
36
|
-
"LICENSE"
|
|
37
|
-
"CHANGELOG.md"
|
|
35
|
+
"LICENSE"
|
|
38
36
|
],
|
|
39
37
|
"keywords": [
|
|
40
38
|
"eslint",
|
|
@@ -79,20 +77,10 @@
|
|
|
79
77
|
},
|
|
80
78
|
"dependencies": {
|
|
81
79
|
"tslib": "^2.3.0",
|
|
82
|
-
"@interlace/eslint-devkit": "^1.
|
|
83
|
-
},
|
|
84
|
-
"devDependencies": {
|
|
85
|
-
"@typescript-eslint/parser": "^8.46.2",
|
|
86
|
-
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
87
|
-
},
|
|
88
|
-
"scripts": {
|
|
89
|
-
"build": "tsx ../../scripts/build-package.ts",
|
|
90
|
-
"test": "vitest run",
|
|
91
|
-
"test:coverage": "vitest run --coverage",
|
|
92
|
-
"typecheck": "tsc -p tsconfig.lib.json --noEmit"
|
|
80
|
+
"@interlace/eslint-devkit": "^1.6.1"
|
|
93
81
|
},
|
|
94
82
|
"funding": {
|
|
95
83
|
"type": "github",
|
|
96
|
-
"url": "https://github.com/ofri-peretz/eslint"
|
|
84
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git"
|
|
97
85
|
}
|
|
98
86
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
|
@@ -1,60 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
-
* MIT license that can be found in the LICENSE file.
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.configs = exports.plugin = exports.rules = void 0;
|
|
9
4
|
const no_unsafe_query_1 = require("./rules/no-unsafe-query");
|
|
10
|
-
/**
|
|
11
|
-
* Collection of all rules
|
|
12
|
-
*/
|
|
13
5
|
exports.rules = {
|
|
14
6
|
'no-unsafe-query': no_unsafe_query_1.noUnsafeQuery,
|
|
15
7
|
};
|
|
16
|
-
/**
|
|
17
|
-
* ESLint Plugin object
|
|
18
|
-
*/
|
|
19
8
|
exports.plugin = {
|
|
20
9
|
meta: {
|
|
21
10
|
name: 'eslint-plugin-sequelize-security',
|
|
22
|
-
version: '0.
|
|
11
|
+
version: '0.1.1',
|
|
23
12
|
},
|
|
24
13
|
rules: exports.rules,
|
|
25
14
|
};
|
|
26
|
-
/**
|
|
27
|
-
* Preset configurations
|
|
28
|
-
*/
|
|
29
15
|
exports.configs = {
|
|
30
|
-
/**
|
|
31
|
-
* Flagship preset — the highest-signal rule(s) from this plugin, shippable
|
|
32
|
-
* in a CI gate. Currently identical to `recommended`.
|
|
33
|
-
*/
|
|
34
16
|
flagship: {
|
|
35
17
|
plugins: { 'sequelize-security': exports.plugin },
|
|
36
18
|
rules: {
|
|
37
19
|
'sequelize-security/no-unsafe-query': 'error',
|
|
38
20
|
},
|
|
39
21
|
},
|
|
40
|
-
/**
|
|
41
|
-
* Recommended preset — balanced security for most projects
|
|
42
|
-
*/
|
|
43
22
|
recommended: {
|
|
44
23
|
plugins: { 'sequelize-security': exports.plugin },
|
|
45
24
|
rules: {
|
|
46
25
|
'sequelize-security/no-unsafe-query': 'error',
|
|
47
26
|
},
|
|
48
27
|
},
|
|
49
|
-
/**
|
|
50
|
-
* Strict preset — all rules as errors
|
|
51
|
-
*/
|
|
52
28
|
strict: {
|
|
53
29
|
plugins: { 'sequelize-security': exports.plugin },
|
|
54
30
|
rules: Object.fromEntries(Object.keys(exports.rules).map((ruleName) => [`sequelize-security/${ruleName}`, 'error'])),
|
|
55
31
|
},
|
|
56
32
|
};
|
|
57
|
-
/**
|
|
58
|
-
* Default export for ESLint plugin
|
|
59
|
-
*/
|
|
60
33
|
exports.default = exports.plugin;
|
package/src/oxlint.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
package/src/oxlint.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
});
|
package/dist/LICENSE
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Ofri Peretz
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
23
|
-
|
package/dist/README.md
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security" target="blank"><img src="https://eslint.interlace.tools/icon-light.svg" alt="Interlace" height="90" /></a>
|
|
3
|
-
|
|
4
|
-
<a href="https://eslint.org" target="_blank"><img src="https://eslint.interlace.tools/eslint-logo.svg" alt="ESLint" height="90" /></a>
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
Security rules for the Sequelize ORM (SQL injection prevention in raw queries).
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
<p align="center">
|
|
12
|
-
<a href="https://www.npmjs.com/package/eslint-plugin-sequelize-security" target="_blank"><img src="https://img.shields.io/npm/v/eslint-plugin-sequelize-security.svg" alt="NPM Version" /></a>
|
|
13
|
-
<a href="https://www.npmjs.com/package/eslint-plugin-sequelize-security" target="_blank"><img src="https://img.shields.io/npm/dm/eslint-plugin-sequelize-security.svg" alt="NPM Downloads" /></a>
|
|
14
|
-
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
15
|
-
<a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=eslint-plugin-sequelize-security" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=eslint-plugin-sequelize-security" alt="Codecov" /></a>
|
|
16
|
-
<a href="https://github.com/ofri-peretz/eslint" target="_blank"><img src="https://img.shields.io/badge/Since-Dec_2025-blue?logo=rocket&logoColor=white" alt="Since Dec 2025" /></a>
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
> ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
|
|
20
|
-
|
|
21
|
-
## Description
|
|
22
|
-
|
|
23
|
-
This plugin provides Security rules for the Sequelize ORM (SQL injection prevention in raw queries).
|
|
24
|
-
|
|
25
|
-
## Why Sequelize-specific?
|
|
26
|
-
|
|
27
|
-
An ORM is not a defence against SQL injection — it narrows the surface to the raw escapes, and those are still string-built. Sequelize has two: `sequelize.query()` and `Sequelize.literal()`. OWASP Juice Shop's two flagship injections are both the former, and neither was reported by any recommended preset in this ecosystem until this plugin existed — the only implementation of the detection shipped inside `eslint-plugin-pg`, which no Sequelize user installs.
|
|
28
|
-
|
|
29
|
-
Being Sequelize-specific is what makes the rule precise. It knows the safe conventions to stay quiet on (`replacements`, `bind`), and it knows `literal()` is a SQL sink rather than an ordinary helper — so it catches `ORDER BY` injection that a generic string-concatenation linter has no reason to flag. It also tracks variable taint across statements, so `const sql = "SELECT..." + id; sequelize.query(sql)` reports even with the concatenation on a separate line.
|
|
30
|
-
|
|
31
|
-
## Philosophy
|
|
32
|
-
|
|
33
|
-
**Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
|
|
34
|
-
|
|
35
|
-
## Getting Started
|
|
36
|
-
|
|
37
|
-
- To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security). 📚
|
|
38
|
-
- 要查看中文 [指南](https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security), 请访问 [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security). 📚
|
|
39
|
-
- [가이드](https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security) 문서는 [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security)에서 확인하실 수 있습니다. 📚
|
|
40
|
-
- [ガイド](https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security)は [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security)でご確認ください。 📚
|
|
41
|
-
- Para ver la [guía](https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security), visita [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security). 📚
|
|
42
|
-
- للاطلاع على [الدليل](https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security)، قم بزيارة [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security). 📚
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
npm install eslint-plugin-sequelize-security --save-dev
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## ⚙️ Configuration Presets
|
|
49
|
-
| Preset | Description |
|
|
50
|
-
| :------------ | :------------------------------------------------------- |
|
|
51
|
-
| `recommended` | Recommended preset - balanced security for most projects |
|
|
52
|
-
| `strict` | Strict preset - all rules as errors |
|
|
53
|
-
| `flagship` | Highest-signal rules only, for CI gates |
|
|
54
|
-
|
|
55
|
-
## 📚 Supported Libraries
|
|
56
|
-
| Library | npm | Downloads | Detection |
|
|
57
|
-
| ----------- | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------- |
|
|
58
|
-
| `sequelize` | [](https://www.npmjs.com/package/sequelize) | [](https://www.npmjs.com/package/sequelize) | SQL Injection |
|
|
59
|
-
|
|
60
|
-
Sequelize runs on Postgres, MySQL, MariaDB, SQLite, MSSQL and Snowflake — this plugin fires on the raw-SQL escapes regardless of which dialect is configured.
|
|
61
|
-
|
|
62
|
-
### Custom Configuration
|
|
63
|
-
|
|
64
|
-
```javascript
|
|
65
|
-
import sequelize from 'eslint-plugin-sequelize-security';
|
|
66
|
-
|
|
67
|
-
export default [
|
|
68
|
-
{
|
|
69
|
-
plugins: { 'sequelize-security': sequelizeSecurity },
|
|
70
|
-
rules: {
|
|
71
|
-
'sequelize-security/no-unsafe-query': 'error',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## 💡 What You Get
|
|
78
|
-
- **Covers the escapes your ORM leaves open:** `sequelize.query()` and `Sequelize.literal()`, the two places raw SQL still gets built by hand
|
|
79
|
-
- **Sequelize's own remediation:** every finding names `replacements` / `bind`, not a generic "use parameterized queries"
|
|
80
|
-
- **Cross-statement taint tracking:** catches queries assembled over several lines, including with `+=`
|
|
81
|
-
- **Quiet on safe code:** parameterized queries, static SQL and builder calls do not report
|
|
82
|
-
- **LLM-optimized messages:** structured 2-line errors with CWE + fixes that AI assistants can apply
|
|
83
|
-
|
|
84
|
-
Every rule produces a **structured error message**:
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
routes/search.ts
|
|
88
|
-
23:24 error 🔒 CWE-89 OWASP:A03-Injection CVSS:9.8 | Unsafe SQL query construction detected (template literal) | CRITICAL
|
|
89
|
-
Fix: Pass values via `replacements` or `bind` instead of interpolating them into the SQL string.
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## 📦 Compatibility
|
|
93
|
-
| Package | Version |
|
|
94
|
-
| :--- | :--- |
|
|
95
|
-
| ESLint | `^8.0.0 \|\| ^9.0.0 \|\| ^10.0.0` |
|
|
96
|
-
| Node.js | `>=18.0.0` |
|
|
97
|
-
|
|
98
|
-
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.
|
|
99
|
-
|
|
100
|
-
## Rules
|
|
101
|
-
|
|
102
|
-
**Legend**
|
|
103
|
-
|
|
104
|
-
| Icon | Description |
|
|
105
|
-
| :---: | :--- |
|
|
106
|
-
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
107
|
-
| ⚠️ | **Warns**: Set to warn in recommended preset. |
|
|
108
|
-
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
109
|
-
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
110
|
-
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
111
|
-
| 🟢 | **Type-unaware**: AST-only, runs in oxlint JS-plugin tier. |
|
|
112
|
-
| 🟡 | **Type-aware (refining)**: pure-AST primary path; types refine precision. |
|
|
113
|
-
| 🟠 | **Type-aware (graceful)**: requires TS program; silent without it. |
|
|
114
|
-
|
|
115
|
-
<!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
|
|
116
|
-
| Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
117
|
-
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
118
|
-
| [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 | 🟢 | 💼 | | | | |
|
|
119
|
-
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
120
|
-
## 🔗 Related ESLint Plugins
|
|
121
|
-
|
|
122
|
-
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
123
|
-
|
|
124
|
-
| Plugin | Downloads | Description |
|
|
125
|
-
| :--- | :---: | :--- |
|
|
126
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | General security rules & OWASP guidelines. |
|
|
127
|
-
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
128
|
-
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security) | [](https://www.npmjs.com/package/eslint-plugin-node-security) | Node.js core-module security (fs, child_process, vm, crypto, Buffer). |
|
|
129
|
-
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
130
|
-
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [](https://www.npmjs.com/package/eslint-plugin-browser-security) | Browser-specific security & XSS prevention. |
|
|
131
|
-
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security hardening rules. |
|
|
132
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda security best practices. |
|
|
133
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security rules & patterns. |
|
|
134
|
-
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | [](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | MongoDB security best practices. |
|
|
135
|
-
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security hardening. |
|
|
136
|
-
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [](https://www.npmjs.com/package/eslint-plugin-import-next) | Next-gen import sorting & architecture. |
|
|
137
|
-
|
|
138
|
-
<!-- INTERLACE:STAR_CTA:START -->
|
|
139
|
-
## ⭐ Support & follow
|
|
140
|
-
|
|
141
|
-
If this plugin caught a real bug for you, **[star the repo](https://github.com/ofri-peretz/eslint)** — stars are the signal that keeps the Interlace ESLint ecosystem maintained — and **[follow the writeups on Dev.to](https://dev.to/ofri-peretz)** for the benchmarks and security research behind these rules.
|
|
142
|
-
|
|
143
|
-
[](https://github.com/ofri-peretz/eslint)
|
|
144
|
-
|
|
145
|
-
<!-- INTERLACE:STAR_CTA:END -->
|
|
146
|
-
|
|
147
|
-
## 📄 License
|
|
148
|
-
|
|
149
|
-
MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
150
|
-
|
|
151
|
-
<p align="center">
|
|
152
|
-
<a href="https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security"><img src="https://eslint.interlace.tools/images/og-sequelize-security.png" alt="ESLint Interlace Plugin" width="100%" /></a>
|
|
153
|
-
</p>
|
|
154
|
-
|
|
155
|
-
<p align="center">
|
|
156
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security" target="blank"><img src="https://eslint.interlace.tools/icon-light.svg" alt="Interlace" height="70" /></a>
|
|
157
|
-
</p>
|
package/dist/package.json
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "eslint-plugin-sequelize-security",
|
|
3
|
-
"version": "0.0.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.",
|
|
5
|
-
"type": "commonjs",
|
|
6
|
-
"main": "./src/index.js",
|
|
7
|
-
"types": "./src/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./src/index.d.ts",
|
|
11
|
-
"default": "./src/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./oxlint": {
|
|
14
|
-
"types": "./src/oxlint.d.ts",
|
|
15
|
-
"default": "./src/oxlint.js"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"author": "Ofri Peretz <ofriperetzdev@gmail.com>",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"homepage": "https://eslint.interlace.tools/docs/security/plugin-sequelize-security?utm_source=npm&utm_medium=referral&utm_campaign=eslint-plugin-sequelize-security",
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "https://github.com/ofri-peretz/eslint",
|
|
24
|
-
"directory": "packages/eslint-plugin-sequelize-security"
|
|
25
|
-
},
|
|
26
|
-
"bugs": {
|
|
27
|
-
"url": "https://github.com/ofri-peretz/eslint/issues"
|
|
28
|
-
},
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
},
|
|
32
|
-
"files": [
|
|
33
|
-
"src/",
|
|
34
|
-
"dist/",
|
|
35
|
-
"README.md",
|
|
36
|
-
"LICENSE",
|
|
37
|
-
"CHANGELOG.md"
|
|
38
|
-
],
|
|
39
|
-
"keywords": [
|
|
40
|
-
"eslint",
|
|
41
|
-
"eslintplugin",
|
|
42
|
-
"eslint-plugin",
|
|
43
|
-
"static-analysis",
|
|
44
|
-
"linting",
|
|
45
|
-
"code-quality",
|
|
46
|
-
"security",
|
|
47
|
-
"sast",
|
|
48
|
-
"appsec",
|
|
49
|
-
"vulnerability",
|
|
50
|
-
"owasp",
|
|
51
|
-
"cwe",
|
|
52
|
-
"interlace-security",
|
|
53
|
-
"sequelize",
|
|
54
|
-
"orm",
|
|
55
|
-
"sql",
|
|
56
|
-
"sql-injection",
|
|
57
|
-
"cwe-89",
|
|
58
|
-
"raw-query",
|
|
59
|
-
"database",
|
|
60
|
-
"database-security",
|
|
61
|
-
"mysql",
|
|
62
|
-
"sqlite",
|
|
63
|
-
"postgres",
|
|
64
|
-
"llm-optimized",
|
|
65
|
-
"ai-assistant",
|
|
66
|
-
"typescript"
|
|
67
|
-
],
|
|
68
|
-
"engines": {
|
|
69
|
-
"node": ">=18.0.0"
|
|
70
|
-
},
|
|
71
|
-
"peerDependencies": {
|
|
72
|
-
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
73
|
-
"sequelize": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
74
|
-
},
|
|
75
|
-
"peerDependenciesMeta": {
|
|
76
|
-
"sequelize": {
|
|
77
|
-
"optional": true
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
"dependencies": {
|
|
81
|
-
"tslib": "^2.3.0",
|
|
82
|
-
"@interlace/eslint-devkit": "^1.4.3"
|
|
83
|
-
},
|
|
84
|
-
"devDependencies": {
|
|
85
|
-
"@typescript-eslint/parser": "^8.46.2",
|
|
86
|
-
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
87
|
-
},
|
|
88
|
-
"scripts": {
|
|
89
|
-
"build": "tsx ../../scripts/build-package.ts",
|
|
90
|
-
"test": "vitest run",
|
|
91
|
-
"test:coverage": "vitest run --coverage",
|
|
92
|
-
"typecheck": "tsc -p tsconfig.lib.json --noEmit"
|
|
93
|
-
},
|
|
94
|
-
"funding": {
|
|
95
|
-
"type": "github",
|
|
96
|
-
"url": "https://github.com/ofri-peretz/eslint"
|
|
97
|
-
}
|
|
98
|
-
}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* eslint-plugin-sequelize-security
|
|
8
|
-
*
|
|
9
|
-
* ESLint plugin with security rules for the Sequelize ORM.
|
|
10
|
-
*
|
|
11
|
-
* @see https://github.com/ofri-peretz/eslint/tree/main/packages/eslint-plugin-sequelize-security
|
|
12
|
-
*/
|
|
13
|
-
import { TSESLint } from '@interlace/eslint-devkit';
|
|
14
|
-
/**
|
|
15
|
-
* Collection of all rules
|
|
16
|
-
*/
|
|
17
|
-
export declare const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
18
|
-
/**
|
|
19
|
-
* ESLint Plugin object
|
|
20
|
-
*/
|
|
21
|
-
export declare const plugin: TSESLint.FlatConfig.Plugin;
|
|
22
|
-
/**
|
|
23
|
-
* Preset configurations
|
|
24
|
-
*/
|
|
25
|
-
export declare const configs: Record<string, TSESLint.FlatConfig.Config>;
|
|
26
|
-
/**
|
|
27
|
-
* Default export for ESLint plugin
|
|
28
|
-
*/
|
|
29
|
-
export default plugin;
|
|
30
|
-
export type { AllSequelizeRulesOptions, NoUnsafeQueryOptions } from './types/index';
|
package/dist/src/oxlint.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* oxlint sub-export.
|
|
8
|
-
*
|
|
9
|
-
* Consumers wire oxlint to this entry via:
|
|
10
|
-
* { "jsPlugins": ["eslint-plugin-sequelize-security/oxlint"] }
|
|
11
|
-
*
|
|
12
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-sequelize-security/oxlint')` and reads
|
|
13
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
14
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
15
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
16
|
-
*
|
|
17
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
18
|
-
*/
|
|
19
|
-
import { plugin } from './index';
|
|
20
|
-
export = plugin;
|
package/dist/src/oxlint.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
-
* MIT license that can be found in the LICENSE file.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* oxlint sub-export.
|
|
9
|
-
*
|
|
10
|
-
* Consumers wire oxlint to this entry via:
|
|
11
|
-
* { "jsPlugins": ["eslint-plugin-sequelize-security/oxlint"] }
|
|
12
|
-
*
|
|
13
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-sequelize-security/oxlint')` and reads
|
|
14
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
15
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
16
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
17
|
-
*
|
|
18
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
19
|
-
*/
|
|
20
|
-
const index_1 = require("./index");
|
|
21
|
-
module.exports = index_1.plugin;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
export declare const noUnsafeQuery: import("@typescript-eslint/utils/ts-eslint").RuleModule<import("@interlace/eslint-devkit").SqlInjectionMessageIds, [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
-
* MIT license that can be found in the LICENSE file.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.noUnsafeQuery = void 0;
|
|
9
|
-
/**
|
|
10
|
-
* no-unsafe-query — Sequelize-flavoured CWE-89.
|
|
11
|
-
*
|
|
12
|
-
* Instantiates the shared detector (`createSqlInjectionRule` in
|
|
13
|
-
* @interlace/eslint-devkit) with Sequelize's two raw-SQL escapes and
|
|
14
|
-
* Sequelize's remediation copy (`replacements` / `bind`).
|
|
15
|
-
*
|
|
16
|
-
* This is the rule that reports OWASP Juice Shop's `routes/search.ts` and
|
|
17
|
-
* `routes/login.ts` — the injections that no recommended preset caught,
|
|
18
|
-
* because the only implementation shipped inside the Postgres plugin.
|
|
19
|
-
*/
|
|
20
|
-
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
21
|
-
exports.noUnsafeQuery = (0, eslint_devkit_1.createSqlInjectionRule)({
|
|
22
|
-
meta: {
|
|
23
|
-
type: 'problem',
|
|
24
|
-
docs: {
|
|
25
|
-
description: 'Prevent SQL injection by disallowing string concatenation or interpolated template literals in raw Sequelize queries.',
|
|
26
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-sequelize-security/docs/rules/no-unsafe-query.md',
|
|
27
|
-
cwe: 'CWE-89',
|
|
28
|
-
cvss: 9.8,
|
|
29
|
-
confidence: 'high',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
// `sequelize.query()` runs raw SQL; `Sequelize.literal()` splices raw SQL
|
|
33
|
-
// into a builder query (the usual ORDER BY / column-name injection).
|
|
34
|
-
methods: ['query', 'literal'],
|
|
35
|
-
// Both names are unambiguous inside a Sequelize codebase, and this plugin
|
|
36
|
-
// is only installed by Sequelize users — so no keyword gate, which would
|
|
37
|
-
// otherwise miss `literal(`${sortColumn}`)` (no SQL keyword of its own).
|
|
38
|
-
requireSqlKeywords: false,
|
|
39
|
-
fix: 'Pass values via `replacements` or `bind` instead of interpolating them into the SQL string.',
|
|
40
|
-
documentationLink: 'https://sequelize.org/docs/v6/core-concepts/raw-queries/#replacements',
|
|
41
|
-
});
|
package/dist/src/types/index.js
DELETED
package/src/index.test.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import plugin from './index';
|
|
3
|
-
import { rules, configs } from './index';
|
|
4
|
-
|
|
5
|
-
describe('eslint-plugin-sequelize-security plugin interface', () => {
|
|
6
|
-
it('should export correct meta information', () => {
|
|
7
|
-
expect(plugin.meta).toBeDefined();
|
|
8
|
-
expect(plugin.meta?.name).toBe('eslint-plugin-sequelize-security');
|
|
9
|
-
expect(plugin.meta?.version).toBeDefined();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should export all sequelize-security rules', () => {
|
|
13
|
-
expect(plugin.rules).toBeDefined();
|
|
14
|
-
const ruleKeys = Object.keys(plugin.rules || {});
|
|
15
|
-
expect(ruleKeys).toEqual(['no-unsafe-query']);
|
|
16
|
-
expect(ruleKeys.length).toBe(1);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('configurations', () => {
|
|
20
|
-
it('should provide recommended configuration', () => {
|
|
21
|
-
expect(configs.recommended).toBeDefined();
|
|
22
|
-
expect(configs.recommended.plugins?.['sequelize-security']).toBeDefined();
|
|
23
|
-
|
|
24
|
-
const recommendedRules = configs.recommended.rules || {};
|
|
25
|
-
Object.keys(recommendedRules).forEach((ruleName) => {
|
|
26
|
-
expect(ruleName).toMatch(/^sequelize-security\//);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
expect(recommendedRules['sequelize-security/no-unsafe-query']).toBe('error');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should provide flagship configuration', () => {
|
|
33
|
-
expect(configs.flagship).toBeDefined();
|
|
34
|
-
expect(configs.flagship.rules?.['sequelize-security/no-unsafe-query']).toBe('error');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should provide strict configuration', () => {
|
|
38
|
-
expect(configs.strict).toBeDefined();
|
|
39
|
-
expect(configs.strict.plugins?.['sequelize-security']).toBeDefined();
|
|
40
|
-
|
|
41
|
-
const strictRules = configs.strict.rules || {};
|
|
42
|
-
Object.keys(strictRules).forEach((ruleName) => {
|
|
43
|
-
expect(ruleName).toMatch(/^sequelize-security\//);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
expect(strictRules['sequelize-security/no-unsafe-query']).toBe('error');
|
|
47
|
-
expect(Object.keys(strictRules).length).toBe(Object.keys(rules).length);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* eslint-plugin-sequelize-security
|
|
9
|
-
*
|
|
10
|
-
* ESLint plugin with security rules for the Sequelize ORM.
|
|
11
|
-
*
|
|
12
|
-
* @see https://github.com/ofri-peretz/eslint/tree/main/packages/eslint-plugin-sequelize-security
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { TSESLint } from '@interlace/eslint-devkit';
|
|
16
|
-
|
|
17
|
-
import { noUnsafeQuery } from './rules/no-unsafe-query';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Collection of all rules
|
|
21
|
-
*/
|
|
22
|
-
export const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>> = {
|
|
23
|
-
'no-unsafe-query': noUnsafeQuery,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* ESLint Plugin object
|
|
28
|
-
*/
|
|
29
|
-
export const plugin: TSESLint.FlatConfig.Plugin = {
|
|
30
|
-
meta: {
|
|
31
|
-
name: 'eslint-plugin-sequelize-security',
|
|
32
|
-
version: '0.0.0',
|
|
33
|
-
},
|
|
34
|
-
rules,
|
|
35
|
-
} satisfies TSESLint.FlatConfig.Plugin;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Preset configurations
|
|
39
|
-
*/
|
|
40
|
-
export const configs: Record<string, TSESLint.FlatConfig.Config> = {
|
|
41
|
-
/**
|
|
42
|
-
* Flagship preset — the highest-signal rule(s) from this plugin, shippable
|
|
43
|
-
* in a CI gate. Currently identical to `recommended`.
|
|
44
|
-
*/
|
|
45
|
-
flagship: {
|
|
46
|
-
plugins: { 'sequelize-security': plugin },
|
|
47
|
-
rules: {
|
|
48
|
-
'sequelize-security/no-unsafe-query': 'error',
|
|
49
|
-
},
|
|
50
|
-
} satisfies TSESLint.FlatConfig.Config,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Recommended preset — balanced security for most projects
|
|
54
|
-
*/
|
|
55
|
-
recommended: {
|
|
56
|
-
plugins: { 'sequelize-security': plugin },
|
|
57
|
-
rules: {
|
|
58
|
-
'sequelize-security/no-unsafe-query': 'error',
|
|
59
|
-
},
|
|
60
|
-
} satisfies TSESLint.FlatConfig.Config,
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Strict preset — all rules as errors
|
|
64
|
-
*/
|
|
65
|
-
strict: {
|
|
66
|
-
plugins: { 'sequelize-security': plugin },
|
|
67
|
-
rules: Object.fromEntries(
|
|
68
|
-
Object.keys(rules).map((ruleName) => [`sequelize-security/${ruleName}`, 'error']),
|
|
69
|
-
),
|
|
70
|
-
} satisfies TSESLint.FlatConfig.Config,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Default export for ESLint plugin
|
|
75
|
-
*/
|
|
76
|
-
export default plugin;
|
|
77
|
-
|
|
78
|
-
export type { AllSequelizeRulesOptions, NoUnsafeQueryOptions } from './types/index';
|
package/src/oxlint.spec.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { describe, it, expect } from 'vitest';
|
|
8
|
-
import * as fs from 'node:fs';
|
|
9
|
-
import * as path from 'node:path';
|
|
10
|
-
import { plugin as mainPlugin } from './index';
|
|
11
|
-
import * as typeExports from './types';
|
|
12
|
-
|
|
13
|
-
type Plugin = typeof mainPlugin;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Smoke tests for the `./oxlint` sub-export.
|
|
17
|
-
*
|
|
18
|
-
* Runtime shape: `oxlint.ts` uses `export = plugin`, which compiles to
|
|
19
|
-
* `module.exports = plugin`. From an ESM dynamic `import('./oxlint')` view,
|
|
20
|
-
* Node's CJS interop surfaces that value at `.default`. From oxlint's
|
|
21
|
-
* `require('eslint-plugin-sequelize-security/oxlint')` view, it sits at the top of
|
|
22
|
-
* `module.exports` — the `{ meta, rules }` shape oxlint's JS plugin loader
|
|
23
|
-
* expects.
|
|
24
|
-
*/
|
|
25
|
-
describe('eslint-plugin-sequelize-security/oxlint sub-export', () => {
|
|
26
|
-
it('declares the ./oxlint sub-export in package.json', () => {
|
|
27
|
-
const pkgJson = JSON.parse(
|
|
28
|
-
fs.readFileSync(path.resolve(__dirname, '..', 'package.json'), 'utf8'),
|
|
29
|
-
);
|
|
30
|
-
expect(pkgJson.exports['./oxlint']).toEqual({
|
|
31
|
-
types: './src/oxlint.d.ts',
|
|
32
|
-
default: './src/oxlint.js',
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('re-exports the plugin object (meta + rules at top level)', async () => {
|
|
37
|
-
const oxlintModule = await import('./oxlint.js');
|
|
38
|
-
const oxlintPlugin = (oxlintModule as unknown as { default: Plugin }).default;
|
|
39
|
-
expect(oxlintPlugin).toBeDefined();
|
|
40
|
-
expect(oxlintPlugin.meta?.name).toBe('eslint-plugin-sequelize-security');
|
|
41
|
-
expect(oxlintPlugin.rules).toBeDefined();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('exposes the same rule names as the main entry (no rules dropped)', async () => {
|
|
45
|
-
const oxlintModule = await import('./oxlint.js');
|
|
46
|
-
const oxlintPlugin = (oxlintModule as unknown as { default: Plugin }).default;
|
|
47
|
-
expect(Object.keys(oxlintPlugin.rules || {}).toSorted()).toEqual(
|
|
48
|
-
Object.keys(mainPlugin.rules || {}).toSorted(),
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('exposes the same rule references (pass-through, not a copy)', async () => {
|
|
53
|
-
const oxlintModule = await import('./oxlint.js');
|
|
54
|
-
const oxlintPlugin = (oxlintModule as unknown as { default: Plugin }).default;
|
|
55
|
-
for (const ruleName of Object.keys(mainPlugin.rules || {})) {
|
|
56
|
-
expect(oxlintPlugin.rules?.[ruleName]).toBe(
|
|
57
|
-
(mainPlugin.rules as Record<string, unknown>)[ruleName],
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('types sub-export', () => {
|
|
64
|
-
it('is a type-only module with no runtime exports', () => {
|
|
65
|
-
expect(Object.keys(typeExports)).toEqual([]);
|
|
66
|
-
});
|
|
67
|
-
});
|
package/src/oxlint.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* oxlint sub-export.
|
|
9
|
-
*
|
|
10
|
-
* Consumers wire oxlint to this entry via:
|
|
11
|
-
* { "jsPlugins": ["eslint-plugin-sequelize-security/oxlint"] }
|
|
12
|
-
*
|
|
13
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-sequelize-security/oxlint')` and reads
|
|
14
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
15
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
16
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
17
|
-
*
|
|
18
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import { plugin } from './index';
|
|
22
|
-
|
|
23
|
-
export = plugin;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* no-unsafe-query — Sequelize-flavoured CWE-89.
|
|
9
|
-
*
|
|
10
|
-
* Instantiates the shared detector (`createSqlInjectionRule` in
|
|
11
|
-
* @interlace/eslint-devkit) with Sequelize's two raw-SQL escapes and
|
|
12
|
-
* Sequelize's remediation copy (`replacements` / `bind`).
|
|
13
|
-
*
|
|
14
|
-
* This is the rule that reports OWASP Juice Shop's `routes/search.ts` and
|
|
15
|
-
* `routes/login.ts` — the injections that no recommended preset caught,
|
|
16
|
-
* because the only implementation shipped inside the Postgres plugin.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { createSqlInjectionRule } from '@interlace/eslint-devkit';
|
|
20
|
-
|
|
21
|
-
export const noUnsafeQuery = createSqlInjectionRule({
|
|
22
|
-
meta: {
|
|
23
|
-
type: 'problem',
|
|
24
|
-
docs: {
|
|
25
|
-
description:
|
|
26
|
-
'Prevent SQL injection by disallowing string concatenation or interpolated template literals in raw Sequelize queries.',
|
|
27
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-sequelize-security/docs/rules/no-unsafe-query.md',
|
|
28
|
-
cwe: 'CWE-89',
|
|
29
|
-
cvss: 9.8,
|
|
30
|
-
confidence: 'high',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
// `sequelize.query()` runs raw SQL; `Sequelize.literal()` splices raw SQL
|
|
34
|
-
// into a builder query (the usual ORDER BY / column-name injection).
|
|
35
|
-
methods: ['query', 'literal'],
|
|
36
|
-
// Both names are unambiguous inside a Sequelize codebase, and this plugin
|
|
37
|
-
// is only installed by Sequelize users — so no keyword gate, which would
|
|
38
|
-
// otherwise miss `literal(`${sortColumn}`)` (no SQL keyword of its own).
|
|
39
|
-
requireSqlKeywords: false,
|
|
40
|
-
fix: 'Pass values via `replacements` or `bind` instead of interpolating them into the SQL string.',
|
|
41
|
-
documentationLink: 'https://sequelize.org/docs/v6/core-concepts/raw-queries/#replacements',
|
|
42
|
-
});
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for sequelize/no-unsafe-query
|
|
3
|
-
* CWE-89 — SQL injection through Sequelize's raw-SQL escapes.
|
|
4
|
-
*
|
|
5
|
-
* The two Juice Shop sites are pinned verbatim: they are the findings that
|
|
6
|
-
* every recommended preset missed before this plugin existed, because the
|
|
7
|
-
* only implementation of this detection shipped inside eslint-plugin-pg.
|
|
8
|
-
*/
|
|
9
|
-
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
10
|
-
import { describe, it, afterAll } from 'vitest';
|
|
11
|
-
import * as parser from '@typescript-eslint/parser';
|
|
12
|
-
import { noUnsafeQuery } from './index';
|
|
13
|
-
|
|
14
|
-
RuleTester.afterAll = afterAll;
|
|
15
|
-
RuleTester.it = it;
|
|
16
|
-
RuleTester.itOnly = it.only;
|
|
17
|
-
RuleTester.describe = describe;
|
|
18
|
-
|
|
19
|
-
const ruleTester = new RuleTester({
|
|
20
|
-
languageOptions: {
|
|
21
|
-
parser,
|
|
22
|
-
parserOptions: { ecmaVersion: 2022, sourceType: 'module' },
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('no-unsafe-query', () => {
|
|
27
|
-
describe('Valid — parameterized and static SQL', () => {
|
|
28
|
-
ruleTester.run('valid', noUnsafeQuery, {
|
|
29
|
-
valid: [
|
|
30
|
-
{
|
|
31
|
-
name: 'replacements',
|
|
32
|
-
code: `models.sequelize.query('SELECT * FROM Products WHERE name LIKE :q', { replacements: { q } });`,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'bind parameters',
|
|
36
|
-
code: `sequelize.query('SELECT * FROM Users WHERE email = $1', { bind: [email] });`,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'static template literal',
|
|
40
|
-
code: 'sequelize.query(`SELECT * FROM Products`);',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'literal with a static string',
|
|
44
|
-
code: `Sequelize.literal('createdAt DESC');`,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: 'query builder, no raw SQL',
|
|
48
|
-
code: `Product.findAll({ where: { name }, order: [['createdAt', 'DESC']] });`,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'no arguments',
|
|
52
|
-
code: `sequelize.query();`,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'unrelated method',
|
|
56
|
-
code: 'logger.info(`fetched ${count} rows`);',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'safe variable passed through',
|
|
60
|
-
code: `const sql = 'SELECT * FROM Products'; sequelize.query(sql);`,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
invalid: [],
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe('Invalid — interpolated raw SQL', () => {
|
|
68
|
-
ruleTester.run('invalid', noUnsafeQuery, {
|
|
69
|
-
valid: [],
|
|
70
|
-
invalid: [
|
|
71
|
-
{
|
|
72
|
-
// OWASP Juice Shop routes/search.ts:23
|
|
73
|
-
name: 'juice shop product search',
|
|
74
|
-
code:
|
|
75
|
-
'models.sequelize.query(`SELECT * FROM Products WHERE ((name LIKE \'%${criteria}%\' OR description LIKE \'%${criteria}%\') AND deletedAt IS NULL) ORDER BY name`);',
|
|
76
|
-
errors: [{ messageId: 'unsafeTemplateLiteral' }],
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
// OWASP Juice Shop routes/login.ts:34
|
|
80
|
-
name: 'juice shop login bypass',
|
|
81
|
-
code:
|
|
82
|
-
"models.sequelize.query(`SELECT * FROM Users WHERE email = '${req.body.email || ''}' AND password = '${security.hash(req.body.password || '')}' AND deletedAt IS NULL`);",
|
|
83
|
-
errors: [{ messageId: 'unsafeTemplateLiteral' }],
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: 'string concatenation',
|
|
87
|
-
code: `sequelize.query('SELECT * FROM Users WHERE id = ' + userId);`,
|
|
88
|
-
errors: [{ messageId: 'noUnsafeQuery' }],
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: 'Sequelize.literal with interpolation (ORDER BY injection)',
|
|
92
|
-
code: 'Product.findAll({ order: Sequelize.literal(`${sortColumn} DESC`) });',
|
|
93
|
-
errors: [{ messageId: 'unsafeTemplateLiteral' }],
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: 'literal with concatenation',
|
|
97
|
-
code: `Product.findAll({ order: Sequelize.literal(sortColumn + ' DESC') });`,
|
|
98
|
-
errors: [{ messageId: 'noUnsafeQuery' }],
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'tainted variable',
|
|
102
|
-
code: [
|
|
103
|
-
'const sql = `SELECT * FROM Users WHERE email = \'${email}\'`;',
|
|
104
|
-
'await models.sequelize.query(sql);',
|
|
105
|
-
].join('\n'),
|
|
106
|
-
errors: [{ messageId: 'unsafeTemplateLiteral' }],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
name: 'query built with +=',
|
|
110
|
-
code: [
|
|
111
|
-
"let sql = 'SELECT * FROM Products WHERE 1=1';",
|
|
112
|
-
'sql += ` AND name = \'${name}\'`;',
|
|
113
|
-
'sequelize.query(sql);',
|
|
114
|
-
].join('\n'),
|
|
115
|
-
errors: [{ messageId: 'unsafeTemplateLiteral' }],
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
package/src/types/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export type NoUnsafeQueryOptions = [];
|
|
8
|
-
|
|
9
|
-
export interface AllSequelizeRulesOptions {
|
|
10
|
-
'sequelize-security/no-unsafe-query': NoUnsafeQueryOptions;
|
|
11
|
-
}
|
|
File without changes
|