eslint-plugin-express-security 1.0.4 → 1.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/CHANGELOG.md +6 -0
- package/LICENSE +21 -0
- package/README.md +87 -350
- package/package.json +3 -12
- package/src/index.d.ts +5 -0
- package/src/index.js +3 -12
- package/src/rules/no-cors-credentials-wildcard/index.d.ts +20 -1
- package/src/rules/no-cors-credentials-wildcard/index.js +5 -0
- package/src/rules/no-express-unsafe-regex-route/index.d.ts +21 -1
- package/src/rules/no-express-unsafe-regex-route/index.js +5 -0
- package/src/rules/no-graphql-introspection-production/index.d.ts +18 -1
- package/src/rules/no-graphql-introspection-production/index.js +5 -0
- package/src/rules/no-insecure-cookie-options/index.d.ts +18 -1
- package/src/rules/no-insecure-cookie-options/index.js +5 -0
- package/src/rules/no-permissive-cors/index.d.ts +18 -1
- package/src/rules/no-permissive-cors/index.js +5 -0
- package/src/rules/require-csrf-protection/index.d.ts +18 -1
- package/src/rules/require-csrf-protection/index.js +5 -0
- package/src/rules/require-express-body-parser-limits/index.d.ts +21 -1
- package/src/rules/require-express-body-parser-limits/index.js +5 -0
- package/src/rules/require-helmet/index.d.ts +19 -1
- package/src/rules/require-helmet/index.js +5 -0
- package/src/rules/require-rate-limiting/index.d.ts +18 -1
- package/src/rules/require-rate-limiting/index.js +5 -0
- package/src/types/index.d.ts +5 -0
- package/src/types/index.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to `eslint-plugin-express-security` will be documented in th
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Documentation
|
|
11
|
+
|
|
12
|
+
- 📘 Launched new documentation site: [eslint.interlace.tools](https://eslint.interlace.tools/)
|
|
13
|
+
|
|
8
14
|
## [1.0.0] - 2025-12-29
|
|
9
15
|
|
|
10
16
|
### Added
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,351 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://eslint.interlace.tools" target="blank"><img src="https://eslint.interlace.tools/eslint-interlace-logo-light.svg" alt="ESLint Interlace Logo" width="120" /></a>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
>
|
|
5
|
+
<p align="center">
|
|
6
|
+
Comprehensive security rules for Express.js applications, mapping to OWASP Top 10.
|
|
7
|
+
</p>
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/eslint-plugin-express-security" target="_blank"><img src="https://img.shields.io/npm/v/eslint-plugin-express-security.svg" alt="NPM Version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/eslint-plugin-express-security" target="_blank"><img src="https://img.shields.io/npm/dm/eslint-plugin-express-security.svg" alt="NPM Downloads" /></a>
|
|
12
|
+
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
13
|
+
<a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=express-security" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=express-security" alt="Codecov" /></a>
|
|
14
|
+
<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>
|
|
15
|
+
</p>
|
|
9
16
|
|
|
10
|
-
|
|
11
|
-
> With **8 security rules** mapped to OWASP Top 10, CWE and CVSS, it transforms your linter into an Express security auditor that AI assistants can understand and fix.
|
|
17
|
+
## Description
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## 💡 What you get
|
|
16
|
-
|
|
17
|
-
- **Express-focused coverage:** 8 rules targeting Express-specific vulnerabilities (CORS, CSRF, cookies, headers, rate limiting).
|
|
18
|
-
- **LLM-optimized & MCP-ready:** Structured 2-line messages with CWE + OWASP + CVSS + concrete fixes so humans _and_ AI auto-fixers stay aligned.
|
|
19
|
-
- **Standards aligned:** OWASP Top 10 Web 2021, CWE tagging, CVSS scoring in every finding for compliance mapping.
|
|
20
|
-
- **Tiered presets:** `recommended`, `strict`, `api`, `graphql` for fast policy rollout.
|
|
21
|
-
- **Middleware-aware:** Detects helmet, cors, csurf, express-rate-limit, body-parser patterns.
|
|
22
|
-
- **Low false positive rate:** Context-aware detection with production heuristics.
|
|
23
|
-
|
|
24
|
-
Every security rule produces a **structured 2-line error message**:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
src/app.ts
|
|
28
|
-
18:5 error 🔒 CWE-942 OWASP:A05 CVSS:9.1 | Permissive CORS with wildcard origin | CRITICAL [SOC2,PCI-DSS]
|
|
29
|
-
Fix: Specify allowed origins: cors({ origin: ['https://your-app.com'] }) | https://owasp.org/...
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**Each message includes:**
|
|
33
|
-
|
|
34
|
-
- 🔒 **CWE reference** - vulnerability classification
|
|
35
|
-
- 📋 **OWASP category** - Top 10 mapping
|
|
36
|
-
- 📊 **CVSS score** - severity rating (0.0-10.0)
|
|
37
|
-
- 🏢 **Compliance tags** - affected frameworks (SOC2, PCI-DSS, HIPAA)
|
|
38
|
-
- ✅ **Fix instruction** - exact code to write
|
|
39
|
-
- 📚 **Documentation link** - learn more
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## 📊 OWASP Top 10 Coverage Matrix
|
|
44
|
-
|
|
45
|
-
| OWASP Category | Coverage | Rules |
|
|
46
|
-
| ----------------------------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
47
|
-
| **A01:2021** Access Control | ✅ | `no-graphql-introspection-production` |
|
|
48
|
-
| **A03:2021** Injection | ✅ | `no-express-unsafe-regex-route` (ReDoS) |
|
|
49
|
-
| **A05:2021** Misconfiguration | ✅ | `require-helmet`, `no-permissive-cors`, `no-cors-credentials-wildcard`, `require-rate-limiting`, `require-express-body-parser-limits` |
|
|
50
|
-
| **A07:2021** Auth/Session | ✅ | `require-csrf-protection`, `no-insecure-cookie-options` |
|
|
51
|
-
|
|
52
|
-
> [!TIP]
|
|
53
|
-
> For **complete OWASP coverage**, combine with [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) which provides 78 additional rules covering all OWASP categories.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## 🔐 8 Security Rules
|
|
58
|
-
|
|
59
|
-
💼 = Set in `recommended` | ⚠️ = Warns in `recommended` | 🔧 = Auto-fixable | 💡 = Suggestions
|
|
60
|
-
|
|
61
|
-
### Headers & CORS (4 rules)
|
|
62
|
-
|
|
63
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
64
|
-
| ------------------------------------------------------------------------- | ------- | ----- | ---- | -------------------------------------- | --- | --- | --- | --- |
|
|
65
|
-
| [require-helmet](#require-helmet) | CWE-693 | A05 | 7.1 | Require helmet() middleware | 💼 | | | |
|
|
66
|
-
| [no-permissive-cors](#no-permissive-cors) | CWE-942 | A05 | 9.1 | Detect wildcard CORS origins | 💼 | | | |
|
|
67
|
-
| [no-cors-credentials-wildcard](#no-cors-credentials-wildcard) | CWE-942 | A05 | 9.1 | Block credentials: true + origin: "\*" | 💼 | | | |
|
|
68
|
-
| [require-express-body-parser-limits](#require-express-body-parser-limits) | CWE-770 | A05 | 7.5 | Require body parser size limits | | ⚠️ | | |
|
|
69
|
-
|
|
70
|
-
### CSRF & Cookies (2 rules)
|
|
71
|
-
|
|
72
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
73
|
-
| --------------------------------------------------------- | ------- | ----- | ---- | ------------------------------ | --- | --- | --- | --- |
|
|
74
|
-
| [require-csrf-protection](#require-csrf-protection) | CWE-352 | A07 | 8.8 | Require CSRF middleware | | ⚠️ | | |
|
|
75
|
-
| [no-insecure-cookie-options](#no-insecure-cookie-options) | CWE-614 | A07 | 5.3 | Detect missing Secure/HttpOnly | 💼 | | | |
|
|
19
|
+
This plugin offers comprehensive security rules tailored for Express.js applications, directly mapping to the OWASP Top 10 vulnerabilities. It proactively identifies security misconfigurations and unsafe coding patterns, helping you harden your server-side code against common attacks. Implementing these rules is an essential step in building secure, production-ready APIs and web services.
|
|
76
20
|
|
|
77
|
-
|
|
21
|
+
## Philosophy
|
|
78
22
|
|
|
79
|
-
|
|
80
|
-
| --------------------------------------------------------------- | -------- | ----- | ---- | -------------------------------- | --- | --- | --- | --- |
|
|
81
|
-
| [require-rate-limiting](#require-rate-limiting) | CWE-770 | A05 | 7.5 | Require rate limiting middleware | | ⚠️ | | |
|
|
82
|
-
| [no-express-unsafe-regex-route](#no-express-unsafe-regex-route) | CWE-1333 | A03 | 7.5 | Detect ReDoS in route patterns | 💼 | | | |
|
|
23
|
+
**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.
|
|
83
24
|
|
|
84
|
-
|
|
25
|
+
## Getting Started
|
|
85
26
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
## 🔍 Rule Details
|
|
93
|
-
|
|
94
|
-
### `require-helmet`
|
|
95
|
-
|
|
96
|
-
Requires helmet() middleware for security headers.
|
|
97
|
-
|
|
98
|
-
**❌ Incorrect**
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
const app = express();
|
|
102
|
-
app.get('/', handler); // No helmet middleware
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**✅ Correct**
|
|
106
|
-
|
|
107
|
-
```javascript
|
|
108
|
-
import helmet from 'helmet';
|
|
109
|
-
|
|
110
|
-
const app = express();
|
|
111
|
-
app.use(helmet()); // Adds 11+ security headers
|
|
112
|
-
app.get('/', handler);
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
### `no-permissive-cors`
|
|
118
|
-
|
|
119
|
-
Detects wildcard CORS configuration that allows any origin.
|
|
120
|
-
|
|
121
|
-
**❌ Incorrect**
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
app.use(cors({ origin: '*' }));
|
|
125
|
-
app.use(cors()); // Defaults to '*'
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
**✅ Correct**
|
|
129
|
-
|
|
130
|
-
```javascript
|
|
131
|
-
app.use(
|
|
132
|
-
cors({
|
|
133
|
-
origin: ['https://your-app.com', 'https://admin.your-app.com'],
|
|
134
|
-
}),
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
// Or use dynamic validation
|
|
138
|
-
app.use(
|
|
139
|
-
cors({
|
|
140
|
-
origin: (origin, callback) => {
|
|
141
|
-
if (allowedOrigins.includes(origin)) {
|
|
142
|
-
callback(null, true);
|
|
143
|
-
} else {
|
|
144
|
-
callback(new Error('Not allowed by CORS'));
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
}),
|
|
148
|
-
);
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
### `no-cors-credentials-wildcard`
|
|
154
|
-
|
|
155
|
-
Blocks the dangerous combination of `credentials: true` with wildcard origins.
|
|
156
|
-
|
|
157
|
-
**❌ Incorrect**
|
|
158
|
-
|
|
159
|
-
```javascript
|
|
160
|
-
// CRITICAL: This exposes credentials to any origin!
|
|
161
|
-
app.use(
|
|
162
|
-
cors({
|
|
163
|
-
origin: '*',
|
|
164
|
-
credentials: true,
|
|
165
|
-
}),
|
|
166
|
-
);
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
**✅ Correct**
|
|
170
|
-
|
|
171
|
-
```javascript
|
|
172
|
-
app.use(
|
|
173
|
-
cors({
|
|
174
|
-
origin: 'https://your-app.com',
|
|
175
|
-
credentials: true,
|
|
176
|
-
}),
|
|
177
|
-
);
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
### `require-csrf-protection`
|
|
183
|
-
|
|
184
|
-
Requires CSRF protection middleware for state-changing routes.
|
|
185
|
-
|
|
186
|
-
**❌ Incorrect**
|
|
187
|
-
|
|
188
|
-
```javascript
|
|
189
|
-
app.post('/api/transfer', handler); // No CSRF protection
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
**✅ Correct**
|
|
193
|
-
|
|
194
|
-
```javascript
|
|
195
|
-
import csurf from 'csurf';
|
|
196
|
-
|
|
197
|
-
app.use(csurf({ cookie: true }));
|
|
198
|
-
app.post('/api/transfer', handler);
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
### `no-insecure-cookie-options`
|
|
204
|
-
|
|
205
|
-
Detects cookies missing Secure, HttpOnly, or SameSite attributes.
|
|
206
|
-
|
|
207
|
-
**❌ Incorrect**
|
|
208
|
-
|
|
209
|
-
```javascript
|
|
210
|
-
res.cookie('session', token); // Missing security attributes
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
**✅ Correct**
|
|
214
|
-
|
|
215
|
-
```javascript
|
|
216
|
-
res.cookie('session', token, {
|
|
217
|
-
httpOnly: true,
|
|
218
|
-
secure: true,
|
|
219
|
-
sameSite: 'strict',
|
|
220
|
-
});
|
|
221
|
-
```
|
|
27
|
+
- To check out the [guide](https://eslint.interlace.tools/docs/express-security), visit [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
28
|
+
- 要查看中文 [指南](https://eslint.interlace.tools/docs/express-security), 请访问 [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
29
|
+
- [가이드](https://eslint.interlace.tools/docs/express-security) 문서는 [eslint.interlace.tools](https://eslint.interlace.tools)에서 확인하실 수 있습니다. 📚
|
|
30
|
+
- [ガイド](https://eslint.interlace.tools/docs/express-security)は [eslint.interlace.tools](https://eslint.interlace.tools)でご確認ください。 📚
|
|
31
|
+
- Para ver la [guía](https://eslint.interlace.tools/docs/express-security), visita [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
32
|
+
- للاطلاع على [الدليل](https://eslint.interlace.tools/docs/express-security)، قم بزيارة [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
222
33
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
### `require-rate-limiting`
|
|
226
|
-
|
|
227
|
-
Requires rate limiting middleware to prevent DoS attacks.
|
|
228
|
-
|
|
229
|
-
**❌ Incorrect**
|
|
230
|
-
|
|
231
|
-
```javascript
|
|
232
|
-
app.post('/api/login', handler); // No rate limiting
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
**✅ Correct**
|
|
236
|
-
|
|
237
|
-
```javascript
|
|
238
|
-
import rateLimit from 'express-rate-limit';
|
|
239
|
-
|
|
240
|
-
const limiter = rateLimit({
|
|
241
|
-
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
242
|
-
max: 100, // limit each IP to 100 requests per windowMs
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
app.use('/api/', limiter);
|
|
246
|
-
app.post('/api/login', handler);
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
### `require-express-body-parser-limits`
|
|
252
|
-
|
|
253
|
-
Requires size limits on body parser to prevent DoS via large payloads.
|
|
254
|
-
|
|
255
|
-
**❌ Incorrect**
|
|
256
|
-
|
|
257
|
-
```javascript
|
|
258
|
-
app.use(express.json()); // No size limit
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
**✅ Correct**
|
|
262
|
-
|
|
263
|
-
```javascript
|
|
264
|
-
app.use(express.json({ limit: '100kb' }));
|
|
265
|
-
app.use(express.urlencoded({ limit: '100kb', extended: true }));
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
### `no-express-unsafe-regex-route`
|
|
271
|
-
|
|
272
|
-
Detects ReDoS-vulnerable regex patterns in Express routes.
|
|
273
|
-
|
|
274
|
-
**❌ Incorrect**
|
|
275
|
-
|
|
276
|
-
```javascript
|
|
277
|
-
// Catastrophic backtracking possible
|
|
278
|
-
app.get('/api/:id(\\d+)+', handler);
|
|
279
|
-
app.get(/^\/user\/(.*)$/, handler);
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
**✅ Correct**
|
|
283
|
-
|
|
284
|
-
```javascript
|
|
285
|
-
app.get('/api/:id(\\d{1,10})', handler); // Bounded
|
|
286
|
-
app.get('/user/:userId', handler); // Named parameter
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
### `no-graphql-introspection-production`
|
|
292
|
-
|
|
293
|
-
Disables GraphQL introspection queries in production.
|
|
294
|
-
|
|
295
|
-
**❌ Incorrect**
|
|
296
|
-
|
|
297
|
-
```javascript
|
|
298
|
-
const server = new ApolloServer({
|
|
299
|
-
typeDefs,
|
|
300
|
-
resolvers,
|
|
301
|
-
introspection: true, // Exposes schema in production
|
|
302
|
-
});
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
**✅ Correct**
|
|
306
|
-
|
|
307
|
-
```javascript
|
|
308
|
-
const server = new ApolloServer({
|
|
309
|
-
typeDefs,
|
|
310
|
-
resolvers,
|
|
311
|
-
introspection: process.env.NODE_ENV !== 'production',
|
|
312
|
-
});
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
## 🚀 Quick Start
|
|
318
|
-
|
|
319
|
-
### ESLint Flat Config (Recommended)
|
|
320
|
-
|
|
321
|
-
```javascript
|
|
322
|
-
// eslint.config.js
|
|
323
|
-
import expressSecurity from 'eslint-plugin-express-security';
|
|
324
|
-
|
|
325
|
-
export default [
|
|
326
|
-
expressSecurity.configs.recommended,
|
|
327
|
-
// ... other configs
|
|
328
|
-
];
|
|
34
|
+
```bash
|
|
35
|
+
npm install eslint-plugin-express-security --save-dev
|
|
329
36
|
```
|
|
330
37
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
```javascript
|
|
334
|
-
import expressSecurity from 'eslint-plugin-express-security';
|
|
335
|
-
|
|
336
|
-
export default [expressSecurity.configs.strict];
|
|
337
|
-
```
|
|
38
|
+
## ⚙️ Configuration Presets
|
|
338
39
|
|
|
339
|
-
|
|
40
|
+
| Preset | Description |
|
|
41
|
+
| :------------ | :---------------------------------------------------------------------- |
|
|
42
|
+
| `recommended` | Balanced security for Express projects (critical as error, others warn) |
|
|
43
|
+
| `strict` | Maximum security enforcement (all rules as errors) |
|
|
44
|
+
| `api` | HTTP/API security rules only (CORS, CSRF, cookies, rate limiting) |
|
|
45
|
+
| `graphql` | GraphQL-specific security rules only |
|
|
340
46
|
|
|
341
|
-
##
|
|
47
|
+
## 📚 Supported Libraries
|
|
342
48
|
|
|
343
|
-
|
|
|
344
|
-
|
|
|
345
|
-
|
|
|
346
|
-
|
|
|
347
|
-
|
|
|
348
|
-
|
|
|
49
|
+
| Library | npm | Downloads | Detection |
|
|
50
|
+
| :-------- | :---------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------- | :----------------------- |
|
|
51
|
+
| `express` | [](https://www.npmjs.com/package/express) | [](https://www.npmjs.com/package/express) | Misconfig, DoS |
|
|
52
|
+
| `helmet` | [](https://www.npmjs.com/package/helmet) | [](https://www.npmjs.com/package/helmet) | Missing Security Headers |
|
|
53
|
+
| `cors` | [](https://www.npmjs.com/package/cors) | [](https://www.npmjs.com/package/cors) | Permissive CORS |
|
|
54
|
+
| `csurf` | [](https://www.npmjs.com/package/csurf) | [](https://www.npmjs.com/package/csurf) | Missing CSRF Protection |
|
|
349
55
|
|
|
350
56
|
---
|
|
351
57
|
|
|
@@ -375,7 +81,7 @@ export default [
|
|
|
375
81
|
|
|
376
82
|
---
|
|
377
83
|
|
|
378
|
-
##
|
|
84
|
+
## AI-Optimized Messages
|
|
379
85
|
|
|
380
86
|
This plugin is optimized for ESLint's [Model Context Protocol (MCP)](https://eslint.org/docs/latest/use/mcp), enabling AI assistants like **Cursor**, **GitHub Copilot**, and **Claude** to:
|
|
381
87
|
|
|
@@ -395,21 +101,7 @@ This plugin is optimized for ESLint's [Model Context Protocol (MCP)](https://esl
|
|
|
395
101
|
}
|
|
396
102
|
```
|
|
397
103
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
## 🔗 Related ESLint Plugins
|
|
401
|
-
|
|
402
|
-
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
403
|
-
|
|
404
|
-
| Plugin | Downloads | Description | Rules |
|
|
405
|
-
| ---------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------: | -------------------------------------------------------------------------- | :---: |
|
|
406
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://npmjs.com/package/eslint-plugin-secure-coding) | Framework-agnostic security (OWASP Web + Mobile Top 10) | 89 |
|
|
407
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security (guards, validation pipes, throttler) | 5 |
|
|
408
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda/Middy security (API Gateway, headers, validation) | 5 |
|
|
409
|
-
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://npmjs.com/package/eslint-plugin-jwt) | JWT security (algorithm confusion, weak secrets, claims validation) | 13 |
|
|
410
|
-
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://npmjs.com/package/eslint-plugin-crypto) | Cryptographic best practices (weak algorithms, key handling, CVE-specific) | 24 |
|
|
411
|
-
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://npmjs.com/package/eslint-plugin-pg) | PostgreSQL/node-postgres security and best practices | 13 |
|
|
412
|
-
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security (OWASP LLM + Agentic Top 10) | 19 |
|
|
104
|
+
By providing this structured context (CWE, OWASP, Fix), we enable AI tools to **reason** about the security flaw rather than hallucinating. This allows Copilot/Cursor to suggest the _exact_ correct fix immediately.
|
|
413
105
|
|
|
414
106
|
---
|
|
415
107
|
|
|
@@ -419,6 +111,51 @@ This plugin runs **100% locally**. No data ever leaves your machine.
|
|
|
419
111
|
|
|
420
112
|
---
|
|
421
113
|
|
|
114
|
+
## Rules
|
|
115
|
+
|
|
116
|
+
**Legend**
|
|
117
|
+
|
|
118
|
+
| Icon | Description |
|
|
119
|
+
| :--: | :----------------------------------------------------------------- |
|
|
120
|
+
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
121
|
+
| ⚠️ | **Warns**: Set towarn in recommended preset. |
|
|
122
|
+
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
123
|
+
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
124
|
+
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
125
|
+
|
|
126
|
+
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
127
|
+
| :------------------------------------------------------------------------------------------------------------------------------------ | :------: | :---: | :--: | :-------------------------------------------------------------------------- | :-: | :-: | :-: | :-: | :-: |
|
|
128
|
+
| [require-helmet](https://eslint.interlace.tools/docs/express-security/rules/require-helmet) | CWE-693 | | 7.1 | [require-helmet](#require-helmet) | 💼 | | | | |
|
|
129
|
+
| [no-permissive-cors](https://eslint.interlace.tools/docs/express-security/rules/no-permissive-cors) | CWE-942 | | 9.1 | [no-permissive-cors](#no-permissive-cors) | 💼 | | | | |
|
|
130
|
+
| [no-cors-credentials-wildcard](https://eslint.interlace.tools/docs/express-security/rules/no-cors-credentials-wildcard) | CWE-942 | | 9.1 | [no-cors-credentials-wildcard](#no-cors-credentials-wildcard) | 💼 | | | | |
|
|
131
|
+
| [require-express-body-parser-limits](https://eslint.interlace.tools/docs/express-security/rules/require-express-body-parser-limits) | CWE-770 | | 7.5 | [require-express-body-parser-limits](#require-express-body-parser-limits) | 💼 | ⚠️ | | | |
|
|
132
|
+
| [require-csrf-protection](https://eslint.interlace.tools/docs/express-security/rules/require-csrf-protection) | CWE-352 | | 8.8 | [require-csrf-protection](#require-csrf-protection) | 💼 | ⚠️ | | | |
|
|
133
|
+
| [no-insecure-cookie-options](https://eslint.interlace.tools/docs/express-security/rules/no-insecure-cookie-options) | CWE-614 | | 5.3 | [no-insecure-cookie-options](#no-insecure-cookie-options) | 💼 | | | | |
|
|
134
|
+
| [require-rate-limiting](https://eslint.interlace.tools/docs/express-security/rules/require-rate-limiting) | CWE-770 | | 7.5 | [require-rate-limiting](#require-rate-limiting) | 💼 | ⚠️ | | | |
|
|
135
|
+
| [no-express-unsafe-regex-route](https://eslint.interlace.tools/docs/express-security/rules/no-express-unsafe-regex-route) | CWE-1333 | | 7.5 | [no-express-unsafe-regex-route](#no-express-unsafe-regex-route) | 💼 | | | | |
|
|
136
|
+
| [no-graphql-introspection-production](https://eslint.interlace.tools/docs/express-security/rules/no-graphql-introspection-production) | CWE-200 | | 5.3 | [no-graphql-introspection-production](#no-graphql-introspection-production) | 💼 | ⚠️ | | | |
|
|
137
|
+
|
|
138
|
+
## 🔗 Related ESLint Plugins
|
|
139
|
+
|
|
140
|
+
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
141
|
+
|
|
142
|
+
| Plugin | Downloads | Description |
|
|
143
|
+
| :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------ |
|
|
144
|
+
| [`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. |
|
|
145
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
146
|
+
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://www.npmjs.com/package/eslint-plugin-crypto) | NodeJS Cryptography security rules. |
|
|
147
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
148
|
+
| [`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. |
|
|
149
|
+
| [`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 rules. |
|
|
150
|
+
| [`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. |
|
|
151
|
+
| [`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. |
|
|
152
|
+
| [`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. |
|
|
153
|
+
| [`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. |
|
|
154
|
+
|
|
422
155
|
## 📄 License
|
|
423
156
|
|
|
424
157
|
MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
158
|
+
|
|
159
|
+
<p align="center">
|
|
160
|
+
<a href="https://eslint.interlace.tools/docs/express-security"><img src="https://eslint.interlace.tools/images/og-express-security.png" alt="ESLint Interlace Plugin" width="300" /></a>
|
|
161
|
+
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-express-security",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Security-focused ESLint plugin for Express.js applications. Detects insecure cookies, missing security headers, CORS misconfigurations, CSRF vulnerabilities, GraphQL security issues, and more.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -63,9 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@interlace/eslint-devkit": "^1.2.1",
|
|
66
|
-
"tslib": "^2.3.0"
|
|
67
|
-
"vitest": "^4.0.6",
|
|
68
|
-
"@nx/vite": "^22.0.3"
|
|
66
|
+
"tslib": "^2.3.0"
|
|
69
67
|
},
|
|
70
68
|
"peerDependencies": {},
|
|
71
69
|
"peerDependenciesMeta": {
|
|
@@ -85,15 +83,8 @@
|
|
|
85
83
|
"optional": true
|
|
86
84
|
}
|
|
87
85
|
},
|
|
88
|
-
"scripts": {
|
|
89
|
-
"test": "vitest run",
|
|
90
|
-
"test:watch": "vitest watch",
|
|
91
|
-
"test:coverage": "vitest run --coverage"
|
|
92
|
-
},
|
|
93
86
|
"devDependencies": {
|
|
94
87
|
"@typescript-eslint/parser": "^8.46.2",
|
|
95
|
-
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
96
|
-
"@vitest/coverage-v8": "^4.0.6",
|
|
97
|
-
"vitest": "^4.0.6"
|
|
88
|
+
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
98
89
|
}
|
|
99
90
|
}
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* with rules for detecting and preventing security vulnerabilities.
|
|
7
|
-
*
|
|
8
|
-
* Features:
|
|
9
|
-
* - LLM-optimized error messages with CWE references
|
|
10
|
-
* - OWASP Top 10 coverage
|
|
11
|
-
* - Express-specific security patterns
|
|
12
|
-
* - Framework-aware middleware detection
|
|
13
|
-
*
|
|
14
|
-
* @see https://github.com/ofri-peretz/eslint#readme
|
|
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.
|
|
15
6
|
*/
|
|
16
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
8
|
exports.configs = exports.plugin = exports.rules = void 0;
|
|
@@ -1,5 +1,24 @@
|
|
|
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 Rule: no-cors-credentials-wildcard
|
|
8
|
+
* Prevents dangerous CORS configurations with credentials: true and wildcard origin
|
|
9
|
+
*
|
|
10
|
+
* CVE-2024-25124 - CVSS 9.1 Critical
|
|
11
|
+
* CWE-942: Permissive Cross-domain Policy with Untrusted Domains
|
|
12
|
+
*
|
|
13
|
+
* @see https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-25124
|
|
14
|
+
* @see https://cwe.mitre.org/data/definitions/942.html
|
|
15
|
+
*/
|
|
16
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
17
|
+
type MessageIds = 'credentialsWildcard' | 'useExplicitOrigins';
|
|
1
18
|
export interface Options {
|
|
2
19
|
/** Allow in test files. Default: false */
|
|
3
20
|
allowInTests?: boolean;
|
|
4
21
|
}
|
|
5
|
-
|
|
22
|
+
type RuleOptions = [Options?];
|
|
23
|
+
export declare const noCorsCredentialsWildcard: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
24
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.noCorsCredentialsWildcard = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -1,5 +1,25 @@
|
|
|
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 Rule: no-express-unsafe-regex-route
|
|
8
|
+
* Detects ReDoS-vulnerable regular expressions in Express.js route patterns
|
|
9
|
+
* CWE-1333: Inefficient Regular Expression Complexity
|
|
10
|
+
*
|
|
11
|
+
* Vulnerable patterns can cause catastrophic backtracking,
|
|
12
|
+
* leading to denial of service via CPU exhaustion.
|
|
13
|
+
*
|
|
14
|
+
* @see https://cwe.mitre.org/data/definitions/1333.html
|
|
15
|
+
* @see https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
|
|
16
|
+
*/
|
|
17
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
18
|
+
type MessageIds = 'unsafeRegexRoute' | 'unsafeParamPattern' | 'refactorRoute';
|
|
1
19
|
export interface Options {
|
|
2
20
|
/** Allow in test files. Default: false */
|
|
3
21
|
allowInTests?: boolean;
|
|
4
22
|
}
|
|
5
|
-
|
|
23
|
+
type RuleOptions = [Options?];
|
|
24
|
+
export declare const noExpressUnsafeRegexRoute: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
25
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.noExpressUnsafeRegexRoute = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -1,7 +1,24 @@
|
|
|
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 Rule: no-graphql-introspection-production
|
|
8
|
+
* Detects GraphQL servers with introspection enabled in production
|
|
9
|
+
* CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/200.html
|
|
12
|
+
* @see https://cheatsheetseries.owasp.org/cheatsheets/GraphQL_Cheat_Sheet.html
|
|
13
|
+
*/
|
|
14
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
+
type MessageIds = 'graphqlIntrospection' | 'disableIntrospection';
|
|
1
16
|
export interface Options {
|
|
2
17
|
/** Allow introspection in test files. Default: true */
|
|
3
18
|
allowInTests?: boolean;
|
|
4
19
|
/** Allow introspection in development. Default: true */
|
|
5
20
|
allowInDevelopment?: boolean;
|
|
6
21
|
}
|
|
7
|
-
|
|
22
|
+
type RuleOptions = [Options?];
|
|
23
|
+
export declare const noGraphqlIntrospectionProduction: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
24
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.noGraphqlIntrospectionProduction = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -1,3 +1,18 @@
|
|
|
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 Rule: no-insecure-cookie-options
|
|
8
|
+
* Detects cookies set without secure flags (httpOnly, secure, sameSite)
|
|
9
|
+
* CWE-614: Sensitive Cookie in HTTPS Session Without 'Secure' Attribute
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/614.html
|
|
12
|
+
* @see https://owasp.org/www-community/controls/SecureCookieAttribute
|
|
13
|
+
*/
|
|
14
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
+
type MessageIds = 'insecureCookie' | 'addSecureFlags';
|
|
1
16
|
export interface Options {
|
|
2
17
|
/** Allow insecure cookies in test files. Default: false */
|
|
3
18
|
allowInTests?: boolean;
|
|
@@ -10,4 +25,6 @@ export interface Options {
|
|
|
10
25
|
/** Acceptable sameSite values. Default: ['strict', 'lax'] */
|
|
11
26
|
acceptableSameSiteValues?: string[];
|
|
12
27
|
}
|
|
13
|
-
|
|
28
|
+
type RuleOptions = [Options?];
|
|
29
|
+
export declare const noInsecureCookieOptions: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
30
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.noInsecureCookieOptions = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -1,3 +1,18 @@
|
|
|
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 Rule: no-permissive-cors
|
|
8
|
+
* Detects overly permissive CORS configurations in Express.js applications
|
|
9
|
+
* CWE-942: Permissive Cross-domain Policy with Untrusted Domains
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/942.html
|
|
12
|
+
* @see https://owasp.org/www-community/attacks/CORS_OriginHeaderScrutiny
|
|
13
|
+
*/
|
|
14
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
+
type MessageIds = 'permissiveCors' | 'useWhitelist';
|
|
1
16
|
export interface Options {
|
|
2
17
|
/** Allow permissive CORS in test files. Default: false */
|
|
3
18
|
allowInTests?: boolean;
|
|
@@ -6,4 +21,6 @@ export interface Options {
|
|
|
6
21
|
/** Allowed origins that should not trigger warnings. Default: [] */
|
|
7
22
|
allowedOrigins?: string[];
|
|
8
23
|
}
|
|
9
|
-
|
|
24
|
+
type RuleOptions = [Options?];
|
|
25
|
+
export declare const noPermissiveCors: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
26
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.noPermissiveCors = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -1,3 +1,18 @@
|
|
|
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 Rule: require-csrf-protection
|
|
8
|
+
* Detects Express.js routes handling state-changing requests without CSRF protection
|
|
9
|
+
* CWE-352: Cross-Site Request Forgery (CSRF)
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/352.html
|
|
12
|
+
* @see https://owasp.org/www-community/attacks/csrf
|
|
13
|
+
*/
|
|
14
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
+
type MessageIds = 'missingCsrf' | 'addCsrf';
|
|
1
16
|
export interface Options {
|
|
2
17
|
/** Allow missing CSRF in test files. Default: false */
|
|
3
18
|
allowInTests?: boolean;
|
|
@@ -6,4 +21,6 @@ export interface Options {
|
|
|
6
21
|
/** Route patterns to ignore (e.g., /api/webhook). Default: [] */
|
|
7
22
|
ignorePatterns?: string[];
|
|
8
23
|
}
|
|
9
|
-
|
|
24
|
+
type RuleOptions = [Options?];
|
|
25
|
+
export declare const requireCsrfProtection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
26
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.requireCsrfProtection = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -1,3 +1,21 @@
|
|
|
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 Rule: require-express-body-parser-limits
|
|
8
|
+
* Detects Express.js body parsers missing or with excessive size limits
|
|
9
|
+
* CWE-400: Uncontrolled Resource Consumption
|
|
10
|
+
*
|
|
11
|
+
* CVE-2024-45590 highlights DoS vulnerabilities in body-parser.
|
|
12
|
+
* Without size limits, attackers can exhaust server memory.
|
|
13
|
+
*
|
|
14
|
+
* @see https://cwe.mitre.org/data/definitions/400.html
|
|
15
|
+
* @see https://expressjs.com/en/4x/api.html#express.json
|
|
16
|
+
*/
|
|
17
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
18
|
+
type MessageIds = 'missingLimit' | 'excessiveLimit' | 'addLimit';
|
|
1
19
|
export interface Options {
|
|
2
20
|
/** Allow in test files. Default: false */
|
|
3
21
|
allowInTests?: boolean;
|
|
@@ -6,4 +24,6 @@ export interface Options {
|
|
|
6
24
|
/** Limits that are considered excessive (as strings). Default: ['50mb', '100mb', '500mb', '1gb'] */
|
|
7
25
|
excessiveLimits?: string[];
|
|
8
26
|
}
|
|
9
|
-
|
|
27
|
+
type RuleOptions = [Options?];
|
|
28
|
+
export declare const requireExpressBodyParserLimits: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
29
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.requireExpressBodyParserLimits = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -1,3 +1,19 @@
|
|
|
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 Rule: require-helmet
|
|
8
|
+
* Detects Express.js applications missing helmet middleware for security headers
|
|
9
|
+
* CWE-693: Protection Mechanism Failure
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/693.html
|
|
12
|
+
* @see https://helmetjs.github.io/
|
|
13
|
+
* @see https://owasp.org/www-project-secure-headers/
|
|
14
|
+
*/
|
|
15
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
16
|
+
type MessageIds = 'missingHelmet' | 'addHelmet';
|
|
1
17
|
export interface Options {
|
|
2
18
|
/** Allow missing helmet in test files. Default: false */
|
|
3
19
|
allowInTests?: boolean;
|
|
@@ -6,4 +22,6 @@ export interface Options {
|
|
|
6
22
|
/** Skip rule if helmet/security headers are provided elsewhere (e.g., reverse proxy). Default: false */
|
|
7
23
|
assumeHelmetMiddleware?: boolean;
|
|
8
24
|
}
|
|
9
|
-
|
|
25
|
+
type RuleOptions = [Options?];
|
|
26
|
+
export declare const requireHelmet: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
27
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.requireHelmet = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -1,3 +1,18 @@
|
|
|
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 Rule: require-rate-limiting
|
|
8
|
+
* Detects Express.js applications missing rate limiting middleware
|
|
9
|
+
* CWE-770: Allocation of Resources Without Limits or Throttling
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/770.html
|
|
12
|
+
* @see https://owasp.org/www-community/controls/Blocking_Brute_Force_Attacks
|
|
13
|
+
*/
|
|
14
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
+
type MessageIds = 'missingRateLimiting' | 'addRateLimiting';
|
|
1
16
|
export interface Options {
|
|
2
17
|
/** Allow missing rate limiting in test files. Default: false */
|
|
3
18
|
allowInTests?: boolean;
|
|
@@ -9,4 +24,6 @@ export interface Options {
|
|
|
9
24
|
*/
|
|
10
25
|
assumeRateLimiting?: boolean;
|
|
11
26
|
}
|
|
12
|
-
|
|
27
|
+
type RuleOptions = [Options?];
|
|
28
|
+
export declare const requireRateLimiting: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
29
|
+
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
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
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.requireRateLimiting = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
package/src/types/index.d.ts
CHANGED
package/src/types/index.js
CHANGED