eslint-plugin-lambda-security 1.0.4 → 1.1.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/LICENSE +21 -0
- package/README.md +54 -35
- package/package.json +3 -12
- package/src/index.d.ts +58 -20
- package/src/index.js +70 -3
- package/src/rules/no-env-logging/index.d.ts +17 -1
- package/src/rules/no-env-logging/index.js +5 -0
- package/src/rules/no-error-swallowing/index.d.ts +24 -0
- package/src/rules/no-error-swallowing/index.js +197 -0
- package/src/rules/no-exposed-error-details/index.d.ts +22 -0
- package/src/rules/no-exposed-error-details/index.js +161 -0
- package/src/rules/no-hardcoded-credentials-sdk/index.d.ts +18 -1
- package/src/rules/no-hardcoded-credentials-sdk/index.js +5 -0
- package/src/rules/no-missing-authorization-check/index.d.ts +24 -0
- package/src/rules/no-missing-authorization-check/index.js +220 -0
- package/src/rules/no-overly-permissive-iam-policy/index.d.ts +22 -0
- package/src/rules/no-overly-permissive-iam-policy/index.js +139 -0
- package/src/rules/no-permissive-cors-middy/index.d.ts +18 -1
- package/src/rules/no-permissive-cors-middy/index.js +5 -0
- package/src/rules/no-permissive-cors-response/index.d.ts +18 -1
- package/src/rules/no-permissive-cors-response/index.js +5 -0
- package/src/rules/no-secrets-in-env/index.d.ts +18 -1
- package/src/rules/no-secrets-in-env/index.js +5 -0
- package/src/rules/no-unbounded-batch-processing/index.d.ts +24 -0
- package/src/rules/no-unbounded-batch-processing/index.js +170 -0
- package/src/rules/no-unvalidated-event-body/index.d.ts +24 -0
- package/src/rules/no-unvalidated-event-body/index.js +270 -0
- package/src/rules/no-user-controlled-requests/index.d.ts +22 -0
- package/src/rules/no-user-controlled-requests/index.js +267 -0
- package/src/rules/require-timeout-handling/index.d.ts +22 -0
- package/src/rules/require-timeout-handling/index.js +171 -0
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,11 +1,16 @@
|
|
|
1
1
|
# eslint-plugin-lambda-security
|
|
2
2
|
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="https://eslint.interlace.tools/images/interlace-hero.png" alt="ESLint Interlace - eslint-plugin-lambda-security" width="100%" />
|
|
5
|
+
</div>
|
|
6
|
+
|
|
3
7
|
> 🔐 Security-focused ESLint plugin for AWS Lambda and serverless applications. Detects hardcoded credentials, permissive CORS, environment secrets, and logging issues with AI-optimized fix guidance.
|
|
4
8
|
|
|
5
9
|
[](https://www.npmjs.com/package/eslint-plugin-lambda-security)
|
|
6
10
|
[](https://www.npmjs.com/package/eslint-plugin-lambda-security)
|
|
7
11
|
[](https://opensource.org/licenses/MIT)
|
|
8
12
|
[](https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=lambda_security)
|
|
13
|
+
[](https://github.com/ofri-peretz/eslint)
|
|
9
14
|
|
|
10
15
|
> **Serverless-first security:** This plugin provides security rules for **AWS Lambda**, **Middy.js**, **Serverless Framework**, **AWS SAM**, and **AWS SDK v3**.
|
|
11
16
|
> With **5 security rules** mapped to OWASP Serverless Top 10, CWE and CVSS, it transforms your linter into a serverless security auditor that AI assistants can understand and fix.
|
|
@@ -42,40 +47,53 @@ src/handlers/api.ts
|
|
|
42
47
|
|
|
43
48
|
## 📊 OWASP Serverless Top 10 Coverage Matrix
|
|
44
49
|
|
|
45
|
-
| OWASP Category | Coverage |
|
|
46
|
-
|
|
|
47
|
-
| **SAS-1: Injection**
|
|
48
|
-
| **SAS-2: Broken Authentication**
|
|
49
|
-
| **SAS-3: Sensitive Data Exposure**
|
|
50
|
-
| **SAS-4: Security Misconfiguration**
|
|
51
|
-
| **SAS-5: Broken Access Control**
|
|
52
|
-
| **SAS-6: Insufficient Logging**
|
|
53
|
-
| **SAS-7: Denial of Service**
|
|
54
|
-
| **SAS-8: Server-Side Request Forgery** |
|
|
55
|
-
| **SAS-9: Functions Misconfiguration** |
|
|
56
|
-
| **SAS-10: Improper Crypto**
|
|
57
|
-
|
|
50
|
+
| OWASP Category | Coverage | Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
51
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
52
|
+
| **SAS-1: Injection** | | | | | | | | | |
|
|
53
|
+
| **SAS-2: Broken Authentication** | | | | | | | | | |
|
|
54
|
+
| **SAS-3: Sensitive Data Exposure** | | | | | | | | | |
|
|
55
|
+
| **SAS-4: Security Misconfiguration** | | | | | | | | | |
|
|
56
|
+
| **SAS-5: Broken Access Control** | | | | | | | | | |
|
|
57
|
+
| **SAS-6: Insufficient Logging** | | | | | | | | | |
|
|
58
|
+
| **SAS-7: Denial of Service** | | | | | | | | | |
|
|
59
|
+
| **SAS-8: Server-Side Request Forgery** | | | | | | | | | |
|
|
60
|
+
| **SAS-9: Functions Misconfiguration** | | | | | | | | | |
|
|
61
|
+
| **SAS-10: Improper Crypto** | | | | | | | | | |
|
|
58
62
|
---
|
|
59
63
|
|
|
60
|
-
## 🔐
|
|
64
|
+
## 🔐 13 Security Rules
|
|
61
65
|
|
|
62
66
|
💼 = Set in `recommended` | ⚠️ = Warns in `recommended` | 🔧 = Auto-fixable | 💡 = Suggestions
|
|
63
67
|
|
|
64
68
|
### Credential & Secrets Protection (3 rules)
|
|
65
69
|
|
|
66
|
-
| Rule
|
|
67
|
-
|
|
|
68
|
-
| [no-hardcoded-credentials-sdk](#no-hardcoded-credentials-sdk) | CWE-798 | SAS-2 | 9.8
|
|
69
|
-
| [no-secrets-in-env](#no-secrets-in-env)
|
|
70
|
-
| [no-env-logging](#no-env-logging)
|
|
71
|
-
|
|
70
|
+
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
71
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
72
|
+
| [no-hardcoded-credentials-sdk](#no-hardcoded-credentials-sdk) | CWE-798 | SAS-2 | 9.8 | Hardcoded AWS credentials in SDK v3 clients | 💼 | | | | |
|
|
73
|
+
| [no-secrets-in-env](#no-secrets-in-env) | CWE-798 | SAS-3 | 9.8 | Secrets hardcoded in environment variables | 💼 | | | | |
|
|
74
|
+
| [no-env-logging](#no-env-logging) | CWE-532 | SAS-3 | 7.5 | Logging entire `process.env` object | | ⚠️ | | | |
|
|
72
75
|
### CORS Security (2 rules)
|
|
73
76
|
|
|
74
|
-
| Rule
|
|
75
|
-
|
|
|
76
|
-
| [no-permissive-cors-response](#no-permissive-cors-response) | CWE-942 | SAS-4 | 9.1
|
|
77
|
-
| [no-permissive-cors-middy](#no-permissive-cors-middy)
|
|
78
|
-
|
|
77
|
+
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
78
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
79
|
+
| [no-permissive-cors-response](#no-permissive-cors-response) | CWE-942 | SAS-4 | 9.1 | Wildcard CORS in Lambda response headers | 💼 | | 🔧 | | |
|
|
80
|
+
| [no-permissive-cors-middy](#no-permissive-cors-middy) | CWE-942 | SAS-4 | 9.1 | Permissive CORS in @middy/http-cors middleware | 💼 | | | | |
|
|
81
|
+
### Input Validation & Access Control (4 rules)
|
|
82
|
+
|
|
83
|
+
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
84
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
85
|
+
| no-unvalidated-event-body | CWE-20 | SAS-1 | 8.0 | Lambda handlers using event body without validation | | ⚠️ | | 💡 | |
|
|
86
|
+
| no-missing-authorization-check | CWE-862 | SAS-5 | 7.5 | Lambda handlers without authorization checks | | ⚠️ | | 💡 | |
|
|
87
|
+
| no-overly-permissive-iam-policy | CWE-732 | SAS-5 | 6.5 | IAM policies with wildcard permissions | 💼 | | | 💡 | |
|
|
88
|
+
| no-user-controlled-requests | CWE-918 | SAS-8 | 9.1 | HTTP requests with user-controlled URLs (SSRF) | 💼 | | | 💡 | |
|
|
89
|
+
### Security Operations (4 rules)
|
|
90
|
+
|
|
91
|
+
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
92
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
93
|
+
| no-error-swallowing | CWE-390 | SAS-6 | 5.0 | Empty catch blocks and missing error logging | | ⚠️ | | 💡 | |
|
|
94
|
+
| require-timeout-handling | CWE-400 | SAS-7 | 6.0 | External calls without timeout handling | | ⚠️ | | 💡 | |
|
|
95
|
+
| no-unbounded-batch-processing | CWE-770 | SAS-7 | 5.5 | Processing batch records without size limits | | ⚠️ | | 💡 | |
|
|
96
|
+
| no-exposed-error-details | CWE-209 | SAS-9 | 4.3 | Exposing internal error details in responses | | ⚠️ | | 💡 | |
|
|
79
97
|
---
|
|
80
98
|
|
|
81
99
|
## 🔍 Rule Details
|
|
@@ -332,16 +350,17 @@ This plugin is optimized for ESLint's [Model Context Protocol (MCP)](https://esl
|
|
|
332
350
|
|
|
333
351
|
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
334
352
|
|
|
335
|
-
| Plugin | Downloads | Description
|
|
336
|
-
|
|
|
337
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding)
|
|
338
|
-
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security)
|
|
339
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security)
|
|
340
|
-
| [`eslint-plugin-
|
|
341
|
-
| [`eslint-plugin-
|
|
342
|
-
| [`eslint-plugin-
|
|
343
|
-
| [`eslint-plugin-
|
|
344
|
-
|
|
353
|
+
| Plugin | Downloads | Description | Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
354
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
355
|
+
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | | | | | | | | | |
|
|
356
|
+
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | | | | | | | | | |
|
|
357
|
+
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | | | | | | | | | |
|
|
358
|
+
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | | | | | | | | | |
|
|
359
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | | | | | | | | | |
|
|
360
|
+
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | | | | | | | | | |
|
|
361
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | | | | | | | | | |
|
|
362
|
+
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | | | | | | | | | |
|
|
363
|
+
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | | | | | | | | | |
|
|
345
364
|
---
|
|
346
365
|
|
|
347
366
|
## 🔒 Privacy
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-lambda-security",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Security-focused ESLint plugin for AWS Lambda and Middy applications. Detects insecure API Gateway responses, missing security headers, CORS misconfigurations, input validation 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
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Detects insecure API Gateway responses, missing security headers,
|
|
6
|
-
* CORS misconfigurations, input validation issues, and more.
|
|
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.
|
|
7
5
|
*/
|
|
8
6
|
declare const _default: {
|
|
9
7
|
rules: {
|
|
10
|
-
'no-hardcoded-credentials-sdk':
|
|
11
|
-
'no-permissive-cors-response':
|
|
12
|
-
'no-permissive-cors-middy':
|
|
13
|
-
'no-secrets-in-env':
|
|
14
|
-
'no-env-logging':
|
|
8
|
+
'no-hardcoded-credentials-sdk': import("@typescript-eslint/utils/ts-eslint").RuleModule<"hardcodedCredentials" | "useCredentialProvider", [import("./rules/no-hardcoded-credentials-sdk").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
9
|
+
'no-permissive-cors-response': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissiveCors" | "useSpecificOrigin", [import("./rules/no-permissive-cors-response").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
10
|
+
'no-permissive-cors-middy': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissiveCors" | "useSpecificOrigins", [import("./rules/no-permissive-cors-middy").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
11
|
+
'no-secrets-in-env': import("@typescript-eslint/utils/ts-eslint").RuleModule<"secretsInEnv" | "useSecretsManager", [import("./rules/no-secrets-in-env").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
12
|
+
'no-env-logging': import("@typescript-eslint/utils/ts-eslint").RuleModule<"envLogging" | "removeEnvLogging", [import("./rules/no-env-logging").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
13
|
+
'no-unvalidated-event-body': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unvalidatedInput" | "useValidation", [import("./rules/no-unvalidated-event-body").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
14
|
+
'no-missing-authorization-check': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingAuthCheck" | "addAuthCheck", [import("./rules/no-missing-authorization-check").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
15
|
+
'no-overly-permissive-iam-policy': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissivePolicy" | "useLeastPrivilege", [import("./rules/no-overly-permissive-iam-policy").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
16
|
+
'no-error-swallowing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"emptyCatchBlock" | "addErrorLogging", [import("./rules/no-error-swallowing").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
17
|
+
'require-timeout-handling': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingTimeoutHandling" | "addTimeoutCheck", [import("./rules/require-timeout-handling").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
18
|
+
'no-unbounded-batch-processing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unboundedBatch" | "addBatchLimit", [import("./rules/no-unbounded-batch-processing").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
19
|
+
'no-user-controlled-requests': import("@typescript-eslint/utils/ts-eslint").RuleModule<"ssrfVulnerability" | "useAllowlist", [import("./rules/no-user-controlled-requests").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
20
|
+
'no-exposed-error-details': import("@typescript-eslint/utils/ts-eslint").RuleModule<"exposedErrorDetails" | "sanitizeError", [import("./rules/no-exposed-error-details").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
15
21
|
};
|
|
16
22
|
configs: {
|
|
17
23
|
recommended: {
|
|
@@ -19,11 +25,19 @@ declare const _default: {
|
|
|
19
25
|
plugins: {
|
|
20
26
|
'lambda-security': {
|
|
21
27
|
rules: {
|
|
22
|
-
'no-hardcoded-credentials-sdk':
|
|
23
|
-
'no-permissive-cors-response':
|
|
24
|
-
'no-permissive-cors-middy':
|
|
25
|
-
'no-secrets-in-env':
|
|
26
|
-
'no-env-logging':
|
|
28
|
+
'no-hardcoded-credentials-sdk': import("@typescript-eslint/utils/ts-eslint").RuleModule<"hardcodedCredentials" | "useCredentialProvider", [import("./rules/no-hardcoded-credentials-sdk").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
29
|
+
'no-permissive-cors-response': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissiveCors" | "useSpecificOrigin", [import("./rules/no-permissive-cors-response").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
30
|
+
'no-permissive-cors-middy': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissiveCors" | "useSpecificOrigins", [import("./rules/no-permissive-cors-middy").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
31
|
+
'no-secrets-in-env': import("@typescript-eslint/utils/ts-eslint").RuleModule<"secretsInEnv" | "useSecretsManager", [import("./rules/no-secrets-in-env").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
32
|
+
'no-env-logging': import("@typescript-eslint/utils/ts-eslint").RuleModule<"envLogging" | "removeEnvLogging", [import("./rules/no-env-logging").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
33
|
+
'no-unvalidated-event-body': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unvalidatedInput" | "useValidation", [import("./rules/no-unvalidated-event-body").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
34
|
+
'no-missing-authorization-check': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingAuthCheck" | "addAuthCheck", [import("./rules/no-missing-authorization-check").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
35
|
+
'no-overly-permissive-iam-policy': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissivePolicy" | "useLeastPrivilege", [import("./rules/no-overly-permissive-iam-policy").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
36
|
+
'no-error-swallowing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"emptyCatchBlock" | "addErrorLogging", [import("./rules/no-error-swallowing").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
37
|
+
'require-timeout-handling': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingTimeoutHandling" | "addTimeoutCheck", [import("./rules/require-timeout-handling").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
38
|
+
'no-unbounded-batch-processing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unboundedBatch" | "addBatchLimit", [import("./rules/no-unbounded-batch-processing").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
39
|
+
'no-user-controlled-requests': import("@typescript-eslint/utils/ts-eslint").RuleModule<"ssrfVulnerability" | "useAllowlist", [import("./rules/no-user-controlled-requests").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
40
|
+
'no-exposed-error-details': import("@typescript-eslint/utils/ts-eslint").RuleModule<"exposedErrorDetails" | "sanitizeError", [import("./rules/no-exposed-error-details").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
27
41
|
};
|
|
28
42
|
};
|
|
29
43
|
};
|
|
@@ -32,7 +46,15 @@ declare const _default: {
|
|
|
32
46
|
'lambda-security/no-permissive-cors-response': string;
|
|
33
47
|
'lambda-security/no-permissive-cors-middy': string;
|
|
34
48
|
'lambda-security/no-secrets-in-env': string;
|
|
49
|
+
'lambda-security/no-user-controlled-requests': string;
|
|
50
|
+
'lambda-security/no-overly-permissive-iam-policy': string;
|
|
51
|
+
'lambda-security/no-unvalidated-event-body': string;
|
|
52
|
+
'lambda-security/no-missing-authorization-check': string;
|
|
53
|
+
'lambda-security/no-exposed-error-details': string;
|
|
35
54
|
'lambda-security/no-env-logging': string;
|
|
55
|
+
'lambda-security/no-error-swallowing': string;
|
|
56
|
+
'lambda-security/require-timeout-handling': string;
|
|
57
|
+
'lambda-security/no-unbounded-batch-processing': string;
|
|
36
58
|
};
|
|
37
59
|
};
|
|
38
60
|
strict: {
|
|
@@ -40,11 +62,19 @@ declare const _default: {
|
|
|
40
62
|
plugins: {
|
|
41
63
|
'lambda-security': {
|
|
42
64
|
rules: {
|
|
43
|
-
'no-hardcoded-credentials-sdk':
|
|
44
|
-
'no-permissive-cors-response':
|
|
45
|
-
'no-permissive-cors-middy':
|
|
46
|
-
'no-secrets-in-env':
|
|
47
|
-
'no-env-logging':
|
|
65
|
+
'no-hardcoded-credentials-sdk': import("@typescript-eslint/utils/ts-eslint").RuleModule<"hardcodedCredentials" | "useCredentialProvider", [import("./rules/no-hardcoded-credentials-sdk").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
66
|
+
'no-permissive-cors-response': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissiveCors" | "useSpecificOrigin", [import("./rules/no-permissive-cors-response").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
67
|
+
'no-permissive-cors-middy': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissiveCors" | "useSpecificOrigins", [import("./rules/no-permissive-cors-middy").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
68
|
+
'no-secrets-in-env': import("@typescript-eslint/utils/ts-eslint").RuleModule<"secretsInEnv" | "useSecretsManager", [import("./rules/no-secrets-in-env").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
69
|
+
'no-env-logging': import("@typescript-eslint/utils/ts-eslint").RuleModule<"envLogging" | "removeEnvLogging", [import("./rules/no-env-logging").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
70
|
+
'no-unvalidated-event-body': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unvalidatedInput" | "useValidation", [import("./rules/no-unvalidated-event-body").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
71
|
+
'no-missing-authorization-check': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingAuthCheck" | "addAuthCheck", [import("./rules/no-missing-authorization-check").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
72
|
+
'no-overly-permissive-iam-policy': import("@typescript-eslint/utils/ts-eslint").RuleModule<"permissivePolicy" | "useLeastPrivilege", [import("./rules/no-overly-permissive-iam-policy").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
73
|
+
'no-error-swallowing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"emptyCatchBlock" | "addErrorLogging", [import("./rules/no-error-swallowing").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
74
|
+
'require-timeout-handling': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingTimeoutHandling" | "addTimeoutCheck", [import("./rules/require-timeout-handling").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
75
|
+
'no-unbounded-batch-processing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unboundedBatch" | "addBatchLimit", [import("./rules/no-unbounded-batch-processing").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
76
|
+
'no-user-controlled-requests': import("@typescript-eslint/utils/ts-eslint").RuleModule<"ssrfVulnerability" | "useAllowlist", [import("./rules/no-user-controlled-requests").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
77
|
+
'no-exposed-error-details': import("@typescript-eslint/utils/ts-eslint").RuleModule<"exposedErrorDetails" | "sanitizeError", [import("./rules/no-exposed-error-details").Options?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
48
78
|
};
|
|
49
79
|
};
|
|
50
80
|
};
|
|
@@ -54,6 +84,14 @@ declare const _default: {
|
|
|
54
84
|
'lambda-security/no-permissive-cors-middy': string;
|
|
55
85
|
'lambda-security/no-secrets-in-env': string;
|
|
56
86
|
'lambda-security/no-env-logging': string;
|
|
87
|
+
'lambda-security/no-unvalidated-event-body': string;
|
|
88
|
+
'lambda-security/no-missing-authorization-check': string;
|
|
89
|
+
'lambda-security/no-overly-permissive-iam-policy': string;
|
|
90
|
+
'lambda-security/no-error-swallowing': string;
|
|
91
|
+
'lambda-security/require-timeout-handling': string;
|
|
92
|
+
'lambda-security/no-unbounded-batch-processing': string;
|
|
93
|
+
'lambda-security/no-user-controlled-requests': string;
|
|
94
|
+
'lambda-security/no-exposed-error-details': string;
|
|
57
95
|
};
|
|
58
96
|
};
|
|
59
97
|
};
|
package/src/index.js
CHANGED
|
@@ -1,23 +1,70 @@
|
|
|
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
|
/**
|
|
3
8
|
* eslint-plugin-lambda-security
|
|
4
9
|
* Security-focused ESLint rules for AWS Lambda and Middy applications
|
|
5
10
|
*
|
|
6
11
|
* Detects insecure API Gateway responses, missing security headers,
|
|
7
|
-
* CORS misconfigurations, input validation issues,
|
|
12
|
+
* CORS misconfigurations, input validation issues, authorization gaps,
|
|
13
|
+
* SSRF vulnerabilities, and more.
|
|
14
|
+
*
|
|
15
|
+
* OWASP Serverless Top 10 Coverage:
|
|
16
|
+
* - SAS-1: Injection ✅ (no-unvalidated-event-body)
|
|
17
|
+
* - SAS-2: Broken Authentication ✅ (no-hardcoded-credentials-sdk)
|
|
18
|
+
* - SAS-3: Sensitive Data Exposure ✅ (no-env-logging, no-secrets-in-env)
|
|
19
|
+
* - SAS-4: Security Misconfiguration ✅ (no-permissive-cors-*)
|
|
20
|
+
* - SAS-5: Broken Access Control ✅ (no-missing-authorization-check, no-overly-permissive-iam-policy)
|
|
21
|
+
* - SAS-6: Insufficient Logging ✅ (no-error-swallowing)
|
|
22
|
+
* - SAS-7: Denial of Service ✅ (require-timeout-handling, no-unbounded-batch-processing)
|
|
23
|
+
* - SAS-8: Server-Side Request Forgery ✅ (no-user-controlled-requests)
|
|
24
|
+
* - SAS-9: Functions Misconfiguration ✅ (no-exposed-error-details)
|
|
25
|
+
* - SAS-10: Improper Crypto ➡️ (Use eslint-plugin-crypto)
|
|
8
26
|
*/
|
|
9
|
-
// P0 Critical Rules
|
|
27
|
+
// Original P0 Critical Rules
|
|
10
28
|
const no_hardcoded_credentials_sdk_1 = require("./rules/no-hardcoded-credentials-sdk");
|
|
11
29
|
const no_permissive_cors_response_1 = require("./rules/no-permissive-cors-response");
|
|
12
30
|
const no_permissive_cors_middy_1 = require("./rules/no-permissive-cors-middy");
|
|
13
31
|
const no_secrets_in_env_1 = require("./rules/no-secrets-in-env");
|
|
14
32
|
const no_env_logging_1 = require("./rules/no-env-logging");
|
|
33
|
+
// SAS-1: Injection
|
|
34
|
+
const no_unvalidated_event_body_1 = require("./rules/no-unvalidated-event-body");
|
|
35
|
+
// SAS-5: Broken Access Control
|
|
36
|
+
const no_missing_authorization_check_1 = require("./rules/no-missing-authorization-check");
|
|
37
|
+
const no_overly_permissive_iam_policy_1 = require("./rules/no-overly-permissive-iam-policy");
|
|
38
|
+
// SAS-6: Insufficient Logging
|
|
39
|
+
const no_error_swallowing_1 = require("./rules/no-error-swallowing");
|
|
40
|
+
// SAS-7: Denial of Service
|
|
41
|
+
const require_timeout_handling_1 = require("./rules/require-timeout-handling");
|
|
42
|
+
const no_unbounded_batch_processing_1 = require("./rules/no-unbounded-batch-processing");
|
|
43
|
+
// SAS-8: Server-Side Request Forgery
|
|
44
|
+
const no_user_controlled_requests_1 = require("./rules/no-user-controlled-requests");
|
|
45
|
+
// SAS-9: Functions Misconfiguration
|
|
46
|
+
const no_exposed_error_details_1 = require("./rules/no-exposed-error-details");
|
|
15
47
|
const rules = {
|
|
48
|
+
// Original rules
|
|
16
49
|
'no-hardcoded-credentials-sdk': no_hardcoded_credentials_sdk_1.noHardcodedCredentialsSdk,
|
|
17
50
|
'no-permissive-cors-response': no_permissive_cors_response_1.noPermissiveCorsResponse,
|
|
18
51
|
'no-permissive-cors-middy': no_permissive_cors_middy_1.noPermissiveCorsMidly,
|
|
19
52
|
'no-secrets-in-env': no_secrets_in_env_1.noSecretsInEnv,
|
|
20
53
|
'no-env-logging': no_env_logging_1.noEnvLogging,
|
|
54
|
+
// SAS-1: Injection
|
|
55
|
+
'no-unvalidated-event-body': no_unvalidated_event_body_1.noUnvalidatedEventBody,
|
|
56
|
+
// SAS-5: Broken Access Control
|
|
57
|
+
'no-missing-authorization-check': no_missing_authorization_check_1.noMissingAuthorizationCheck,
|
|
58
|
+
'no-overly-permissive-iam-policy': no_overly_permissive_iam_policy_1.noOverlyPermissiveIamPolicy,
|
|
59
|
+
// SAS-6: Insufficient Logging
|
|
60
|
+
'no-error-swallowing': no_error_swallowing_1.noErrorSwallowing,
|
|
61
|
+
// SAS-7: Denial of Service
|
|
62
|
+
'require-timeout-handling': require_timeout_handling_1.requireTimeoutHandling,
|
|
63
|
+
'no-unbounded-batch-processing': no_unbounded_batch_processing_1.noUnboundedBatchProcessing,
|
|
64
|
+
// SAS-8: SSRF
|
|
65
|
+
'no-user-controlled-requests': no_user_controlled_requests_1.noUserControlledRequests,
|
|
66
|
+
// SAS-9: Functions Misconfiguration
|
|
67
|
+
'no-exposed-error-details': no_exposed_error_details_1.noExposedErrorDetails,
|
|
21
68
|
};
|
|
22
69
|
const configs = {
|
|
23
70
|
recommended: {
|
|
@@ -26,11 +73,22 @@ const configs = {
|
|
|
26
73
|
'lambda-security': { rules },
|
|
27
74
|
},
|
|
28
75
|
rules: {
|
|
76
|
+
// Critical: Always error
|
|
29
77
|
'lambda-security/no-hardcoded-credentials-sdk': 'error',
|
|
30
78
|
'lambda-security/no-permissive-cors-response': 'error',
|
|
31
79
|
'lambda-security/no-permissive-cors-middy': 'error',
|
|
32
80
|
'lambda-security/no-secrets-in-env': 'error',
|
|
81
|
+
'lambda-security/no-user-controlled-requests': 'error',
|
|
82
|
+
'lambda-security/no-overly-permissive-iam-policy': 'error',
|
|
83
|
+
// High: Warn in recommended
|
|
84
|
+
'lambda-security/no-unvalidated-event-body': 'warn',
|
|
85
|
+
'lambda-security/no-missing-authorization-check': 'warn',
|
|
86
|
+
'lambda-security/no-exposed-error-details': 'warn',
|
|
87
|
+
// Medium: Warn in recommended
|
|
33
88
|
'lambda-security/no-env-logging': 'warn',
|
|
89
|
+
'lambda-security/no-error-swallowing': 'warn',
|
|
90
|
+
'lambda-security/require-timeout-handling': 'warn',
|
|
91
|
+
'lambda-security/no-unbounded-batch-processing': 'warn',
|
|
34
92
|
},
|
|
35
93
|
},
|
|
36
94
|
strict: {
|
|
@@ -39,11 +97,20 @@ const configs = {
|
|
|
39
97
|
'lambda-security': { rules },
|
|
40
98
|
},
|
|
41
99
|
rules: {
|
|
100
|
+
// All rules as errors in strict mode
|
|
42
101
|
'lambda-security/no-hardcoded-credentials-sdk': 'error',
|
|
43
102
|
'lambda-security/no-permissive-cors-response': 'error',
|
|
44
103
|
'lambda-security/no-permissive-cors-middy': 'error',
|
|
45
104
|
'lambda-security/no-secrets-in-env': 'error',
|
|
46
105
|
'lambda-security/no-env-logging': 'error',
|
|
106
|
+
'lambda-security/no-unvalidated-event-body': 'error',
|
|
107
|
+
'lambda-security/no-missing-authorization-check': 'error',
|
|
108
|
+
'lambda-security/no-overly-permissive-iam-policy': 'error',
|
|
109
|
+
'lambda-security/no-error-swallowing': 'error',
|
|
110
|
+
'lambda-security/require-timeout-handling': 'error',
|
|
111
|
+
'lambda-security/no-unbounded-batch-processing': 'error',
|
|
112
|
+
'lambda-security/no-user-controlled-requests': 'error',
|
|
113
|
+
'lambda-security/no-exposed-error-details': 'error',
|
|
47
114
|
},
|
|
48
115
|
},
|
|
49
116
|
};
|
|
@@ -52,6 +119,6 @@ module.exports = {
|
|
|
52
119
|
configs,
|
|
53
120
|
meta: {
|
|
54
121
|
name: 'eslint-plugin-lambda-security',
|
|
55
|
-
version: '
|
|
122
|
+
version: '1.1.0',
|
|
56
123
|
},
|
|
57
124
|
};
|
|
@@ -1,5 +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: no-env-logging
|
|
8
|
+
* Detects logging of environment variables which may contain secrets
|
|
9
|
+
* CWE-532: Insertion of Sensitive Information into Log File
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/532.html
|
|
12
|
+
*/
|
|
13
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
14
|
+
type MessageIds = 'envLogging' | 'removeEnvLogging';
|
|
1
15
|
export interface Options {
|
|
2
16
|
/** Allow in test files. Default: true */
|
|
3
17
|
allowInTests?: boolean;
|
|
4
18
|
}
|
|
5
|
-
|
|
19
|
+
type RuleOptions = [Options?];
|
|
20
|
+
export declare const noEnvLogging: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
21
|
+
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.noEnvLogging = void 0;
|
|
4
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -0,0 +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-error-swallowing
|
|
8
|
+
* Detects empty catch blocks and missing error logging
|
|
9
|
+
* CWE-390: Detection of Error Condition Without Action
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/390.html
|
|
12
|
+
* @see https://owasp.org/www-project-serverless-top-10/
|
|
13
|
+
*/
|
|
14
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
+
type MessageIds = 'emptyCatchBlock' | 'addErrorLogging';
|
|
16
|
+
export interface Options {
|
|
17
|
+
/** Allow in test files. Default: true */
|
|
18
|
+
allowInTests?: boolean;
|
|
19
|
+
/** Allow comments as documentation of intentional swallowing. Default: true */
|
|
20
|
+
allowWithComment?: boolean;
|
|
21
|
+
}
|
|
22
|
+
type RuleOptions = [Options?];
|
|
23
|
+
export declare const noErrorSwallowing: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
24
|
+
export {};
|