eslint-plugin-express-security 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/package.json +4 -3
- package/src/index.js +3 -0
- package/src/rules/no-cors-credentials-wildcard/index.d.ts +3 -1
- package/src/rules/no-exposed-debug-endpoints/index.d.ts +14 -0
- package/src/rules/no-exposed-debug-endpoints/index.js +97 -0
- package/src/rules/no-express-unsafe-regex-route/index.d.ts +3 -1
- package/src/rules/no-graphql-introspection-production/index.d.ts +3 -1
- package/src/rules/no-insecure-cookie-options/index.d.ts +3 -1
- package/src/rules/no-permissive-cors/index.d.ts +3 -1
- package/src/rules/require-csrf-protection/index.d.ts +3 -1
- package/src/rules/require-express-body-parser-limits/index.d.ts +3 -1
- package/src/rules/require-helmet/index.d.ts +3 -1
- package/src/rules/require-rate-limiting/index.d.ts +3 -1
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -146,10 +146,11 @@ Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with L
|
|
|
146
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
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
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
149
|
| [`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
150
|
| [`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
151
|
| [`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. |
|
|
152
|
+
| [`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. |
|
|
153
|
+
| [`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. |
|
|
153
154
|
| [`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
155
|
|
|
155
156
|
## 📄 License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-express-security",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"eslint",
|
|
42
42
|
"eslint-plugin",
|
|
43
43
|
"eslintplugin",
|
|
44
|
+
"interlace-security",
|
|
44
45
|
"express",
|
|
45
46
|
"expressjs",
|
|
46
47
|
"security",
|
|
@@ -62,8 +63,8 @@
|
|
|
62
63
|
"node": ">=18.0.0"
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"
|
|
66
|
-
"
|
|
66
|
+
"tslib": "^2.3.0",
|
|
67
|
+
"@interlace/eslint-devkit": "^1.2.1"
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {},
|
|
69
70
|
"peerDependenciesMeta": {
|
package/src/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const no_graphql_introspection_production_1 = require("./rules/no-graphql-intros
|
|
|
20
20
|
const no_cors_credentials_wildcard_1 = require("./rules/no-cors-credentials-wildcard");
|
|
21
21
|
const require_express_body_parser_limits_1 = require("./rules/require-express-body-parser-limits");
|
|
22
22
|
const no_express_unsafe_regex_route_1 = require("./rules/no-express-unsafe-regex-route");
|
|
23
|
+
const no_exposed_debug_endpoints_1 = require("./rules/no-exposed-debug-endpoints");
|
|
23
24
|
/**
|
|
24
25
|
* Collection of all Express security ESLint rules
|
|
25
26
|
*/
|
|
@@ -38,6 +39,7 @@ exports.rules = {
|
|
|
38
39
|
'no-cors-credentials-wildcard': no_cors_credentials_wildcard_1.noCorsCredentialsWildcard,
|
|
39
40
|
'require-express-body-parser-limits': require_express_body_parser_limits_1.requireExpressBodyParserLimits,
|
|
40
41
|
'no-express-unsafe-regex-route': no_express_unsafe_regex_route_1.noExpressUnsafeRegexRoute,
|
|
42
|
+
'no-exposed-debug-endpoints': no_exposed_debug_endpoints_1.noExposedDebugEndpoints,
|
|
41
43
|
};
|
|
42
44
|
/**
|
|
43
45
|
* ESLint Plugin object
|
|
@@ -67,6 +69,7 @@ const recommendedRules = {
|
|
|
67
69
|
'express-security/no-cors-credentials-wildcard': 'error',
|
|
68
70
|
'express-security/require-express-body-parser-limits': 'warn',
|
|
69
71
|
'express-security/no-express-unsafe-regex-route': 'error',
|
|
72
|
+
'express-security/no-exposed-debug-endpoints': 'error',
|
|
70
73
|
};
|
|
71
74
|
/**
|
|
72
75
|
* Preset configurations for Express security rules
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
allowInTests?: boolean;
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noCorsCredentialsWildcard: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const noCorsCredentialsWildcard: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
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 interface Options {
|
|
7
|
+
endpoints?: string[];
|
|
8
|
+
ignoreFiles?: string[];
|
|
9
|
+
}
|
|
10
|
+
type RuleOptions = [Options?];
|
|
11
|
+
export declare const noExposedDebugEndpoints: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
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.noExposedDebugEndpoints = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Detect debug endpoints without auth in Express applications
|
|
11
|
+
*/
|
|
12
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
13
|
+
const DEFAULT_DEBUG_PATHS = ['/debug', '/__debug__', '/admin', '/_admin', '/test', '/health'];
|
|
14
|
+
exports.noExposedDebugEndpoints = (0, eslint_devkit_1.createRule)({
|
|
15
|
+
name: 'no-exposed-debug-endpoints',
|
|
16
|
+
meta: {
|
|
17
|
+
type: 'problem',
|
|
18
|
+
docs: {
|
|
19
|
+
description: 'Detect debug endpoints without auth in Express applications',
|
|
20
|
+
},
|
|
21
|
+
messages: {
|
|
22
|
+
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
23
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
24
|
+
issueName: 'Exposed Debug Endpoint',
|
|
25
|
+
cwe: 'CWE-489',
|
|
26
|
+
description: 'Debug endpoint exposed without authentication',
|
|
27
|
+
severity: 'HIGH',
|
|
28
|
+
fix: 'Remove debug endpoints from production or add authentication',
|
|
29
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/489.html',
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
schema: [
|
|
33
|
+
{
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
endpoints: {
|
|
37
|
+
type: 'array',
|
|
38
|
+
items: { type: 'string' },
|
|
39
|
+
description: 'Custom list of debug/admin endpoints to flag'
|
|
40
|
+
},
|
|
41
|
+
ignoreFiles: {
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: { type: 'string' },
|
|
44
|
+
description: 'List of files or patterns to ignore'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
additionalProperties: false
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
defaultOptions: [{}],
|
|
52
|
+
create(context) {
|
|
53
|
+
const options = context.options[0] || {};
|
|
54
|
+
const debugPaths = options.endpoints || DEFAULT_DEBUG_PATHS;
|
|
55
|
+
const ignoreFiles = options.ignoreFiles || [];
|
|
56
|
+
const filename = context.filename;
|
|
57
|
+
// Check if current file should be ignored
|
|
58
|
+
if (ignoreFiles.some(pattern => filename.includes(pattern))) {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
function report(node) {
|
|
62
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
63
|
+
}
|
|
64
|
+
const isExpressRouteCall = (node) => {
|
|
65
|
+
return (node.callee.type === 'MemberExpression' &&
|
|
66
|
+
node.callee.object.type === 'Identifier' &&
|
|
67
|
+
['app', 'router', 'express'].includes(node.callee.object.name) &&
|
|
68
|
+
node.callee.property.type === 'Identifier' &&
|
|
69
|
+
['get', 'post', 'use'].includes(node.callee.property.name));
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
CallExpression(node) {
|
|
73
|
+
if (isExpressRouteCall(node)) {
|
|
74
|
+
const pathArg = node.arguments[0];
|
|
75
|
+
if (pathArg && pathArg.type === 'Literal' && typeof pathArg.value === 'string') {
|
|
76
|
+
const path = pathArg.value.toLowerCase();
|
|
77
|
+
if (debugPaths.some(dp => path.includes(dp.toLowerCase()))) {
|
|
78
|
+
report(pathArg);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
Literal(node) {
|
|
84
|
+
if (typeof node.value === 'string') {
|
|
85
|
+
const path = node.value.toLowerCase();
|
|
86
|
+
if (debugPaths.some(dp => path === dp.toLowerCase())) {
|
|
87
|
+
const parent = node.parent;
|
|
88
|
+
if (parent && parent.type === 'CallExpression' && isExpressRouteCall(parent) && parent.arguments[0] === node) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
report(node);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
});
|
|
@@ -21,5 +21,7 @@ export interface Options {
|
|
|
21
21
|
allowInTests?: boolean;
|
|
22
22
|
}
|
|
23
23
|
type RuleOptions = [Options?];
|
|
24
|
-
export declare const noExpressUnsafeRegexRoute: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
24
|
+
export declare const noExpressUnsafeRegexRoute: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
25
27
|
export {};
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
allowInDevelopment?: boolean;
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noGraphqlIntrospectionProduction: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const noGraphqlIntrospectionProduction: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -26,5 +26,7 @@ export interface Options {
|
|
|
26
26
|
acceptableSameSiteValues?: string[];
|
|
27
27
|
}
|
|
28
28
|
type RuleOptions = [Options?];
|
|
29
|
-
export declare const noInsecureCookieOptions: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
29
|
+
export declare const noInsecureCookieOptions: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
30
32
|
export {};
|
|
@@ -22,5 +22,7 @@ export interface Options {
|
|
|
22
22
|
allowedOrigins?: string[];
|
|
23
23
|
}
|
|
24
24
|
type RuleOptions = [Options?];
|
|
25
|
-
export declare const noPermissiveCors: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
25
|
+
export declare const noPermissiveCors: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
26
28
|
export {};
|
|
@@ -22,5 +22,7 @@ export interface Options {
|
|
|
22
22
|
ignorePatterns?: string[];
|
|
23
23
|
}
|
|
24
24
|
type RuleOptions = [Options?];
|
|
25
|
-
export declare const requireCsrfProtection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
25
|
+
export declare const requireCsrfProtection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
26
28
|
export {};
|
|
@@ -25,5 +25,7 @@ export interface Options {
|
|
|
25
25
|
excessiveLimits?: string[];
|
|
26
26
|
}
|
|
27
27
|
type RuleOptions = [Options?];
|
|
28
|
-
export declare const requireExpressBodyParserLimits: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
28
|
+
export declare const requireExpressBodyParserLimits: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
29
31
|
export {};
|
|
@@ -23,5 +23,7 @@ export interface Options {
|
|
|
23
23
|
assumeHelmetMiddleware?: boolean;
|
|
24
24
|
}
|
|
25
25
|
type RuleOptions = [Options?];
|
|
26
|
-
export declare const requireHelmet: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
26
|
+
export declare const requireHelmet: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
27
29
|
export {};
|
|
@@ -25,5 +25,7 @@ export interface Options {
|
|
|
25
25
|
assumeRateLimiting?: boolean;
|
|
26
26
|
}
|
|
27
27
|
type RuleOptions = [Options?];
|
|
28
|
-
export declare const requireRateLimiting: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
28
|
+
export declare const requireRateLimiting: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
29
31
|
export {};
|
package/LICENSE
DELETED
|
@@ -1,21 +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.
|