eslint-plugin-lambda-security 1.1.1 โ 1.2.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/LICENSE +2 -0
- package/README.md +47 -103
- package/package.json +6 -5
- package/src/index.d.ts +25 -98
- package/src/index.js +18 -34
- package/src/rules/no-env-logging/index.d.ts +3 -1
- package/src/rules/no-error-swallowing/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 +130 -0
- package/src/rules/no-exposed-error-details/index.d.ts +3 -1
- package/src/rules/no-hardcoded-credentials-sdk/index.d.ts +3 -1
- package/src/rules/no-missing-authorization-check/index.d.ts +3 -1
- package/src/rules/no-overly-permissive-iam-policy/index.d.ts +3 -1
- package/src/rules/no-permissive-cors-middy/index.d.ts +3 -1
- package/src/rules/no-permissive-cors-response/index.d.ts +3 -1
- package/src/rules/no-secrets-in-env/index.d.ts +3 -1
- package/src/rules/no-unbounded-batch-processing/index.d.ts +3 -1
- package/src/rules/no-unvalidated-event-body/index.d.ts +3 -1
- package/src/rules/no-user-controlled-requests/index.d.ts +3 -1
- package/src/rules/require-timeout-handling/index.d.ts +3 -1
- package/AGENTS.md +0 -106
- package/CHANGELOG.md +0 -42
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
## Description
|
|
18
18
|
|
|
19
|
-
This plugin
|
|
19
|
+
This plugin provides Security best practices for AWS Lambda functions (IAM, timeouts, environment).
|
|
20
|
+
By using this plugin, you can proactively identify and mitigate security risks across your entire codebase.
|
|
20
21
|
|
|
21
22
|
## Philosophy
|
|
22
23
|
|
|
@@ -24,19 +25,18 @@ This plugin secures your AWS Lambda functions by enforcing best practices relate
|
|
|
24
25
|
|
|
25
26
|
## Getting Started
|
|
26
27
|
|
|
27
|
-
- To check out the [guide](https://eslint.interlace.tools/docs/lambda-security), visit [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
28
|
-
- ่ฆๆฅ็ไธญๆ [ๆๅ](https://eslint.interlace.tools/docs/lambda-security), ่ฏท่ฎฟ้ฎ [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
29
|
-
- [๊ฐ์ด๋](https://eslint.interlace.tools/docs/lambda-security) ๋ฌธ์๋ [eslint.interlace.tools](https://eslint.interlace.tools)์์ ํ์ธํ์ค ์ ์์ต๋๋ค. ๐
|
|
30
|
-
- [ใฌใคใ](https://eslint.interlace.tools/docs/lambda-security)ใฏ [eslint.interlace.tools](https://eslint.interlace.tools)ใงใ็ขบ่ชใใ ใใใ ๐
|
|
31
|
-
- Para ver la [guรญa](https://eslint.interlace.tools/docs/lambda-security), visita [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
32
|
-
- ููุงุทูุงุน ุนูู [ุงูุฏููู](https://eslint.interlace.tools/docs/lambda-security)ุ ูู
ุจุฒูุงุฑุฉ [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
28
|
+
- To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-lambda-security), visit [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
29
|
+
- ่ฆๆฅ็ไธญๆ [ๆๅ](https://eslint.interlace.tools/docs/security/plugin-lambda-security), ่ฏท่ฎฟ้ฎ [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
30
|
+
- [๊ฐ์ด๋](https://eslint.interlace.tools/docs/security/plugin-lambda-security) ๋ฌธ์๋ [eslint.interlace.tools](https://eslint.interlace.tools)์์ ํ์ธํ์ค ์ ์์ต๋๋ค. ๐
|
|
31
|
+
- [ใฌใคใ](https://eslint.interlace.tools/docs/security/plugin-lambda-security)ใฏ [eslint.interlace.tools](https://eslint.interlace.tools)ใงใ็ขบ่ชใใ ใใใ ๐
|
|
32
|
+
- Para ver la [guรญa](https://eslint.interlace.tools/docs/security/plugin-lambda-security), visita [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
33
|
+
- ููุงุทูุงุน ุนูู [ุงูุฏููู](https://eslint.interlace.tools/docs/security/plugin-lambda-security)ุ ูู
ุจุฒูุงุฑุฉ [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
33
34
|
|
|
34
35
|
```bash
|
|
35
36
|
npm install eslint-plugin-lambda-security --save-dev
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
## ๐ก What you get
|
|
39
|
-
|
|
40
40
|
- **Serverless-focused coverage:** 5 rules targeting Lambda-specific vulnerabilities (credentials, CORS, secrets, logging).
|
|
41
41
|
- **LLM-optimized & MCP-ready:** Structured 2-line messages with CWE + OWASP + CVSS + concrete fixes so humans _and_ AI auto-fixers stay aligned.
|
|
42
42
|
- **Standards aligned:** OWASP Serverless Top 10, CWE tagging, CVSS scoring in every finding for compliance mapping.
|
|
@@ -62,14 +62,12 @@ src/handlers/api.ts
|
|
|
62
62
|
- ๐ **Documentation link** - learn more
|
|
63
63
|
|
|
64
64
|
## โ๏ธ Configuration Presets
|
|
65
|
-
|
|
66
65
|
| Preset | Description |
|
|
67
66
|
| :------------ | :--------------------------------------------------------------------- |
|
|
68
67
|
| `recommended` | Balanced security for Lambda projects (critical as error, others warn) |
|
|
69
68
|
| `strict` | Maximum security enforcement (all rules as errors) |
|
|
70
69
|
|
|
71
70
|
## ๐ Supported Libraries
|
|
72
|
-
|
|
73
71
|
| Library | npm | Downloads | Detection |
|
|
74
72
|
| :----------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------- |
|
|
75
73
|
| `aws-lambda` | [](https://www.npmjs.com/package/aws-lambda) | [](https://www.npmjs.com/package/aws-lambda) | IAM, Logging, Timeouts |
|
|
@@ -79,7 +77,6 @@ src/handlers/api.ts
|
|
|
79
77
|
---
|
|
80
78
|
|
|
81
79
|
## โ๏ธ Configuration Options
|
|
82
|
-
|
|
83
80
|
All rules accept these common options:
|
|
84
81
|
|
|
85
82
|
```javascript
|
|
@@ -98,110 +95,57 @@ All rules accept these common options:
|
|
|
98
95
|
|
|
99
96
|
---
|
|
100
97
|
|
|
101
|
-
## ๐ข Enterprise Integration Example
|
|
102
|
-
|
|
103
|
-
```javascript
|
|
104
|
-
// eslint.config.js
|
|
105
|
-
import lambdaSecurity from 'eslint-plugin-lambda-security';
|
|
106
|
-
|
|
107
|
-
export default [
|
|
108
|
-
// Baseline for all Lambda functions
|
|
109
|
-
lambdaSecurity.configs.recommended,
|
|
110
|
-
|
|
111
|
-
// Strict mode for payment/auth handlers
|
|
112
|
-
{
|
|
113
|
-
files: ['functions/payments/**', 'functions/auth/**'],
|
|
114
|
-
...lambdaSecurity.configs.strict,
|
|
115
|
-
},
|
|
116
|
-
];
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
98
|
## Rules
|
|
122
99
|
|
|
123
100
|
**Legend**
|
|
124
101
|
|
|
125
|
-
| Icon | Description
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
133
|
-
| Rule
|
|
134
|
-
|
|
|
135
|
-
| [no-
|
|
136
|
-
| [no-
|
|
137
|
-
| [no-
|
|
138
|
-
| [no-
|
|
139
|
-
| [no-
|
|
140
|
-
| [no-
|
|
141
|
-
| [
|
|
142
|
-
| [no-
|
|
143
|
-
| [no-
|
|
144
|
-
| [no-
|
|
145
|
-
| [no-
|
|
146
|
-
| [no-
|
|
147
|
-
| [no-
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## AI-Optimized Messages
|
|
152
|
-
|
|
153
|
-
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:
|
|
154
|
-
|
|
155
|
-
- Understand the exact vulnerability type via CWE references
|
|
156
|
-
- Apply the correct fix using structured guidance
|
|
157
|
-
- Provide educational context to developers
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
src/handlers/api.ts
|
|
161
|
-
18:5 error ๐ CWE-798 OWASP:SAS-2 CVSS:9.8 | Hardcoded AWS credentials detected | CRITICAL [SOC2,PCI-DSS]
|
|
162
|
-
Fix: Use credential provider chain or Lambda execution role | https://owasp.org/...
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
```json
|
|
166
|
-
// .cursor/mcp.json
|
|
167
|
-
{
|
|
168
|
-
"mcpServers": {
|
|
169
|
-
"eslint": {
|
|
170
|
-
"command": "npx",
|
|
171
|
-
"args": ["@eslint/mcp@latest"]
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
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.
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## ๐ Privacy
|
|
182
|
-
|
|
183
|
-
This plugin runs **100% locally**. No data ever leaves your machine.
|
|
102
|
+
| Icon | Description |
|
|
103
|
+
| :---: | :--- |
|
|
104
|
+
| ๐ผ | **Recommended**: Included in the recommended preset. |
|
|
105
|
+
| โ ๏ธ | **Warns**: Set towarn in recommended preset. |
|
|
106
|
+
| ๐ง | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
107
|
+
| ๐ก | **Suggestions**: Providing code suggestions in IDE. |
|
|
108
|
+
| ๐ซ | **Deprecated**: This rule is deprecated. |
|
|
109
|
+
|
|
110
|
+
| Rule | CWE | OWASP | CVSS | Description | ๐ผ | โ ๏ธ | ๐ง | ๐ก | ๐ซ |
|
|
111
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
112
|
+
| [no-env-logging](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-env-logging) | CWE-532 | | 7.5 | ESLint rule documentation for no-env-logging | ๐ผ | โ ๏ธ | | | |
|
|
113
|
+
| [no-error-swallowing](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-error-swallowing) | CWE-391 | | 7.5 | ESLint rule documentation for no-error-swallowing | ๐ผ | โ ๏ธ | | | |
|
|
114
|
+
| [no-exposed-debug-endpoints](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-exposed-debug-endpoints) | | | | ESLint rule documentation for no-exposed-debug-endpoints | | | | | |
|
|
115
|
+
| [no-exposed-error-details](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-exposed-error-details) | CWE-209 | | 7.5 | ESLint rule documentation for no-exposed-error-details | ๐ผ | โ ๏ธ | | | |
|
|
116
|
+
| [no-hardcoded-credentials-sdk](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-hardcoded-credentials-sdk) | CWE-798 | | 9.8 | ESLint rule documentation for no-hardcoded-credentials-sdk | ๐ผ | | | | |
|
|
117
|
+
| [no-missing-authorization-check](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-missing-authorization-check) | CWE-862 | | 7.5 | ESLint rule documentation for no-missing-authorization-check | ๐ผ | โ ๏ธ | | | |
|
|
118
|
+
| [no-overly-permissive-iam-policy](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-overly-permissive-iam-policy) | CWE-732 | | 9.8 | ESLint rule documentation for no-overly-permissive-iam-policy | ๐ผ | | | | |
|
|
119
|
+
| [no-permissive-cors-middy](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-permissive-cors-middy) | CWE-942 | | 9.1 | ESLint rule documentation for no-permissive-cors-middy | ๐ผ | | | | |
|
|
120
|
+
| [no-permissive-cors-response](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-permissive-cors-response) | CWE-942 | | 9.1 | ESLint rule documentation for no-permissive-cors-response | ๐ผ | | ๐ง | | |
|
|
121
|
+
| [no-secrets-in-env](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-secrets-in-env) | CWE-522 | | 9.8 | ESLint rule documentation for no-secrets-in-env | ๐ผ | | | | |
|
|
122
|
+
| [no-unbounded-batch-processing](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-unbounded-batch-processing) | CWE-400 | | 7.5 | ESLint rule documentation for no-unbounded-batch-processing | ๐ผ | โ ๏ธ | | | |
|
|
123
|
+
| [no-unvalidated-event-body](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-unvalidated-event-body) | CWE-20 | | 7.5 | ESLint rule documentation for no-unvalidated-event-body | ๐ผ | โ ๏ธ | | | |
|
|
124
|
+
| [no-user-controlled-requests](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-user-controlled-requests) | CWE-918 | | 9.8 | ESLint rule documentation for no-user-controlled-requests | ๐ผ | | | | |
|
|
125
|
+
| [require-timeout-handling](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/require-timeout-handling) | CWE-703 | | 7.5 | ESLint rule documentation for require-timeout-handling | ๐ผ | โ ๏ธ | | | |
|
|
184
126
|
|
|
185
127
|
## ๐ Related ESLint Plugins
|
|
186
128
|
|
|
187
129
|
Part of the **Interlace ESLint Ecosystem** โ AI-native security plugins with LLM-optimized error messages:
|
|
188
130
|
|
|
189
|
-
| Plugin
|
|
190
|
-
|
|
|
191
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding)
|
|
192
|
-
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg)
|
|
193
|
-
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto)
|
|
194
|
-
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt)
|
|
195
|
-
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security)
|
|
196
|
-
| [`eslint-plugin-
|
|
197
|
-
| [`eslint-plugin-
|
|
198
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security)
|
|
199
|
-
| [`eslint-plugin-
|
|
131
|
+
| Plugin | Downloads | Description |
|
|
132
|
+
| :--- | :---: | :--- |
|
|
133
|
+
| [`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. |
|
|
134
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
135
|
+
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://www.npmjs.com/package/eslint-plugin-crypto) | NodeJS Cryptography security rules. |
|
|
136
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
137
|
+
| [`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. |
|
|
138
|
+
| [`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. |
|
|
139
|
+
| [`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. |
|
|
140
|
+
| [`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. |
|
|
141
|
+
| [`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. |
|
|
142
|
+
| [`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. |
|
|
143
|
+
| [`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. |
|
|
200
144
|
|
|
201
145
|
## ๐ License
|
|
202
146
|
|
|
203
147
|
MIT ยฉ [Ofri Peretz](https://github.com/ofri-peretz)
|
|
204
148
|
|
|
205
149
|
<p align="center">
|
|
206
|
-
<a href="https://eslint.interlace.tools/docs/lambda-security"><img src="https://eslint.interlace.tools/images/og-lambda-security.png" alt="ESLint Interlace Plugin" width="
|
|
207
|
-
</p>
|
|
150
|
+
<a href="https://eslint.interlace.tools/docs/security/plugin-lambda-security"><img src="https://eslint.interlace.tools/images/og-lambda-security.png" alt="ESLint Interlace Plugin" width="100%" /></a>
|
|
151
|
+
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-lambda-security",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
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",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"author": "Ofri Peretz <ofriperetzdev@gmail.com>",
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"homepage": "https://github.com/ofri-peretz/eslint/
|
|
20
|
+
"homepage": "https://github.com/ofri-peretz/eslint/tree/main/packages/eslint-plugin-lambda-security#readme",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "
|
|
23
|
+
"url": "https://github.com/ofri-peretz/eslint",
|
|
24
24
|
"directory": "packages/eslint-plugin-lambda-security"
|
|
25
25
|
},
|
|
26
26
|
"bugs": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"eslint",
|
|
42
42
|
"eslint-plugin",
|
|
43
43
|
"eslintplugin",
|
|
44
|
+
"interlace-security",
|
|
44
45
|
"aws",
|
|
45
46
|
"lambda",
|
|
46
47
|
"aws-lambda",
|
|
@@ -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.d.ts
CHANGED
|
@@ -3,101 +3,28 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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>;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
rules: {
|
|
45
|
-
'lambda-security/no-hardcoded-credentials-sdk': string;
|
|
46
|
-
'lambda-security/no-permissive-cors-response': string;
|
|
47
|
-
'lambda-security/no-permissive-cors-middy': string;
|
|
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;
|
|
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;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
strict: {
|
|
61
|
-
name: string;
|
|
62
|
-
plugins: {
|
|
63
|
-
'lambda-security': {
|
|
64
|
-
rules: {
|
|
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>;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
rules: {
|
|
82
|
-
'lambda-security/no-hardcoded-credentials-sdk': string;
|
|
83
|
-
'lambda-security/no-permissive-cors-response': string;
|
|
84
|
-
'lambda-security/no-permissive-cors-middy': string;
|
|
85
|
-
'lambda-security/no-secrets-in-env': string;
|
|
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;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
meta: {
|
|
99
|
-
name: string;
|
|
100
|
-
version: string;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
export = _default;
|
|
6
|
+
/**
|
|
7
|
+
* eslint-plugin-lambda-security
|
|
8
|
+
* Security-focused ESLint rules for AWS Lambda and Middy applications
|
|
9
|
+
*
|
|
10
|
+
* Detects insecure API Gateway responses, missing security headers,
|
|
11
|
+
* CORS misconfigurations, input validation issues, authorization gaps,
|
|
12
|
+
* SSRF vulnerabilities, and more.
|
|
13
|
+
*
|
|
14
|
+
* OWASP Serverless Top 10 Coverage:
|
|
15
|
+
* - SAS-1: Injection โ
(no-unvalidated-event-body)
|
|
16
|
+
* - SAS-2: Broken Authentication โ
(no-hardcoded-credentials-sdk)
|
|
17
|
+
* - SAS-3: Sensitive Data Exposure โ
(no-env-logging, no-secrets-in-env)
|
|
18
|
+
* - SAS-4: Security Misconfiguration โ
(no-permissive-cors-*)
|
|
19
|
+
* - SAS-5: Broken Access Control โ
(no-missing-authorization-check, no-overly-permissive-iam-policy)
|
|
20
|
+
* - SAS-6: Insufficient Logging โ
(no-error-swallowing)
|
|
21
|
+
* - SAS-7: Denial of Service โ
(require-timeout-handling, no-unbounded-batch-processing)
|
|
22
|
+
* - SAS-8: Server-Side Request Forgery โ
(no-user-controlled-requests)
|
|
23
|
+
* - SAS-9: Functions Misconfiguration โ
(no-exposed-error-details)
|
|
24
|
+
* - SAS-10: Improper Crypto โก๏ธ (Use eslint-plugin-crypto)
|
|
25
|
+
*/
|
|
26
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
27
|
+
export declare const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
28
|
+
export declare const plugin: TSESLint.FlatConfig.Plugin;
|
|
29
|
+
export declare const configs: Record<string, TSESLint.FlatConfig.Config>;
|
|
30
|
+
export default plugin;
|
package/src/index.js
CHANGED
|
@@ -4,26 +4,8 @@
|
|
|
4
4
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
5
|
* MIT license that can be found in the LICENSE file.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Security-focused ESLint rules for AWS Lambda and Middy applications
|
|
10
|
-
*
|
|
11
|
-
* Detects insecure API Gateway responses, missing security headers,
|
|
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)
|
|
26
|
-
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.configs = exports.plugin = exports.rules = void 0;
|
|
27
9
|
// Original P0 Critical Rules
|
|
28
10
|
const no_hardcoded_credentials_sdk_1 = require("./rules/no-hardcoded-credentials-sdk");
|
|
29
11
|
const no_permissive_cors_response_1 = require("./rules/no-permissive-cors-response");
|
|
@@ -44,7 +26,8 @@ const no_unbounded_batch_processing_1 = require("./rules/no-unbounded-batch-proc
|
|
|
44
26
|
const no_user_controlled_requests_1 = require("./rules/no-user-controlled-requests");
|
|
45
27
|
// SAS-9: Functions Misconfiguration
|
|
46
28
|
const no_exposed_error_details_1 = require("./rules/no-exposed-error-details");
|
|
47
|
-
const
|
|
29
|
+
const no_exposed_debug_endpoints_1 = require("./rules/no-exposed-debug-endpoints");
|
|
30
|
+
exports.rules = {
|
|
48
31
|
// Original rules
|
|
49
32
|
'no-hardcoded-credentials-sdk': no_hardcoded_credentials_sdk_1.noHardcodedCredentialsSdk,
|
|
50
33
|
'no-permissive-cors-response': no_permissive_cors_response_1.noPermissiveCorsResponse,
|
|
@@ -65,12 +48,19 @@ const rules = {
|
|
|
65
48
|
'no-user-controlled-requests': no_user_controlled_requests_1.noUserControlledRequests,
|
|
66
49
|
// SAS-9: Functions Misconfiguration
|
|
67
50
|
'no-exposed-error-details': no_exposed_error_details_1.noExposedErrorDetails,
|
|
51
|
+
'no-exposed-debug-endpoints': no_exposed_debug_endpoints_1.noExposedDebugEndpoints,
|
|
52
|
+
};
|
|
53
|
+
exports.plugin = {
|
|
54
|
+
meta: {
|
|
55
|
+
name: 'eslint-plugin-lambda-security',
|
|
56
|
+
version: '1.1.0',
|
|
57
|
+
},
|
|
58
|
+
rules: exports.rules,
|
|
68
59
|
};
|
|
69
|
-
|
|
60
|
+
exports.configs = {
|
|
70
61
|
recommended: {
|
|
71
|
-
name: 'lambda-security/recommended',
|
|
72
62
|
plugins: {
|
|
73
|
-
'lambda-security':
|
|
63
|
+
'lambda-security': exports.plugin,
|
|
74
64
|
},
|
|
75
65
|
rules: {
|
|
76
66
|
// Critical: Always error
|
|
@@ -84,6 +74,7 @@ const configs = {
|
|
|
84
74
|
'lambda-security/no-unvalidated-event-body': 'warn',
|
|
85
75
|
'lambda-security/no-missing-authorization-check': 'warn',
|
|
86
76
|
'lambda-security/no-exposed-error-details': 'warn',
|
|
77
|
+
'lambda-security/no-exposed-debug-endpoints': 'error',
|
|
87
78
|
// Medium: Warn in recommended
|
|
88
79
|
'lambda-security/no-env-logging': 'warn',
|
|
89
80
|
'lambda-security/no-error-swallowing': 'warn',
|
|
@@ -92,9 +83,8 @@ const configs = {
|
|
|
92
83
|
},
|
|
93
84
|
},
|
|
94
85
|
strict: {
|
|
95
|
-
name: 'lambda-security/strict',
|
|
96
86
|
plugins: {
|
|
97
|
-
'lambda-security':
|
|
87
|
+
'lambda-security': exports.plugin,
|
|
98
88
|
},
|
|
99
89
|
rules: {
|
|
100
90
|
// All rules as errors in strict mode
|
|
@@ -111,14 +101,8 @@ const configs = {
|
|
|
111
101
|
'lambda-security/no-unbounded-batch-processing': 'error',
|
|
112
102
|
'lambda-security/no-user-controlled-requests': 'error',
|
|
113
103
|
'lambda-security/no-exposed-error-details': 'error',
|
|
104
|
+
'lambda-security/no-exposed-debug-endpoints': 'error',
|
|
114
105
|
},
|
|
115
106
|
},
|
|
116
107
|
};
|
|
117
|
-
|
|
118
|
-
rules,
|
|
119
|
-
configs,
|
|
120
|
-
meta: {
|
|
121
|
-
name: 'eslint-plugin-lambda-security',
|
|
122
|
-
version: '1.1.0',
|
|
123
|
-
},
|
|
124
|
-
};
|
|
108
|
+
exports.default = exports.plugin;
|
|
@@ -17,5 +17,7 @@ export interface Options {
|
|
|
17
17
|
allowInTests?: boolean;
|
|
18
18
|
}
|
|
19
19
|
type RuleOptions = [Options?];
|
|
20
|
-
export declare const noEnvLogging: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
20
|
+
export declare const noEnvLogging: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
21
23
|
export {};
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
allowWithComment?: boolean;
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noErrorSwallowing: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const noErrorSwallowing: 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,130 @@
|
|
|
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 AWS Lambda handlers
|
|
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 AWS Lambda handlers',
|
|
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
|
+
if (ignoreFiles.some(pattern => filename.includes(pattern))) {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
function report(node) {
|
|
61
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
Property(node) {
|
|
65
|
+
if (node.key.type === 'Identifier' && node.key.name === 'path' &&
|
|
66
|
+
node.value.type === 'Literal' && typeof node.value.value === 'string') {
|
|
67
|
+
const path = node.value.value.toLowerCase();
|
|
68
|
+
if (debugPaths.some(dp => path.includes(dp.toLowerCase()))) {
|
|
69
|
+
// Check if it's inside an 'http' or 'httpApi' block
|
|
70
|
+
let parent = node.parent;
|
|
71
|
+
while (parent) {
|
|
72
|
+
if (parent.type === 'Property' && parent.key.type === 'Identifier' &&
|
|
73
|
+
['http', 'httpApi'].includes(parent.key.name)) {
|
|
74
|
+
report(node.value);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
parent = parent.parent;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
BinaryExpression(node) {
|
|
83
|
+
// Detect event.path === '/debug' or event.rawPath.includes('/admin')
|
|
84
|
+
if (node.operator === '===' || node.operator === '==' || node.operator === '!==' || node.operator === '!=') {
|
|
85
|
+
const checkNode = (side) => {
|
|
86
|
+
if (side.type === 'Literal' && typeof side.value === 'string') {
|
|
87
|
+
const val = side.value.toLowerCase();
|
|
88
|
+
if (debugPaths.some(dp => val.includes(dp.toLowerCase()))) {
|
|
89
|
+
// Check if the other side is an event property
|
|
90
|
+
const other = side === node.left ? node.right : node.left;
|
|
91
|
+
if (other.type === 'MemberExpression' &&
|
|
92
|
+
other.object.type === 'Identifier' &&
|
|
93
|
+
(other.object.name === 'event' || other.object.name === 'evt') &&
|
|
94
|
+
other.property.type === 'Identifier' &&
|
|
95
|
+
['path', 'rawPath', 'resource', 'routeKey'].includes(other.property.name)) {
|
|
96
|
+
report(side);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
checkNode(node.left);
|
|
102
|
+
checkNode(node.right);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
Literal(node) {
|
|
106
|
+
if (typeof node.value === 'string') {
|
|
107
|
+
const path = node.value.toLowerCase();
|
|
108
|
+
if (debugPaths.some(dp => path === dp.toLowerCase())) {
|
|
109
|
+
// Avoid double reporting if it's already in a BinaryExpression path check
|
|
110
|
+
const parent = node.parent;
|
|
111
|
+
if (parent && parent.type === 'BinaryExpression' &&
|
|
112
|
+
(parent.left === node || parent.right === node)) {
|
|
113
|
+
const other = parent.left === node ? parent.right : parent.left;
|
|
114
|
+
if (other.type === 'MemberExpression' &&
|
|
115
|
+
other.object.type === 'Identifier' &&
|
|
116
|
+
(other.object.name === 'event' || other.object.name === 'evt')) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Avoid double reporting for Serverless config check handled by Property listener
|
|
121
|
+
if (parent && parent.type === 'Property' && parent.key.type === 'Identifier' && parent.key.name === 'path') {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
report(node);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
});
|
|
@@ -18,5 +18,7 @@ export interface Options {
|
|
|
18
18
|
allowInTests?: boolean;
|
|
19
19
|
}
|
|
20
20
|
type RuleOptions = [Options?];
|
|
21
|
-
export declare const noExposedErrorDetails: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
21
|
+
export declare const noExposedErrorDetails: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
22
24
|
export {};
|
|
@@ -18,5 +18,7 @@ export interface Options {
|
|
|
18
18
|
allowInTests?: boolean;
|
|
19
19
|
}
|
|
20
20
|
type RuleOptions = [Options?];
|
|
21
|
-
export declare const noHardcodedCredentialsSdk: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
21
|
+
export declare const noHardcodedCredentialsSdk: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
22
24
|
export {};
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
handlerPatterns?: string[];
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noMissingAuthorizationCheck: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const noMissingAuthorizationCheck: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -18,5 +18,7 @@ export interface Options {
|
|
|
18
18
|
allowInTests?: boolean;
|
|
19
19
|
}
|
|
20
20
|
type RuleOptions = [Options?];
|
|
21
|
-
export declare const noOverlyPermissiveIamPolicy: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
21
|
+
export declare const noOverlyPermissiveIamPolicy: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
22
24
|
export {};
|
|
@@ -18,5 +18,7 @@ export interface Options {
|
|
|
18
18
|
allowInTests?: boolean;
|
|
19
19
|
}
|
|
20
20
|
type RuleOptions = [Options?];
|
|
21
|
-
export declare const noPermissiveCorsMidly: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
21
|
+
export declare const noPermissiveCorsMidly: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
22
24
|
export {};
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
allowedOrigins?: string[];
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noPermissiveCorsResponse: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const noPermissiveCorsResponse: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
additionalPatterns?: string[];
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noSecretsInEnv: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const noSecretsInEnv: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
maxBatchSize?: number;
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noUnboundedBatchProcessing: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const noUnboundedBatchProcessing: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
additionalProperties?: string[];
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noUnvalidatedEventBody: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const noUnvalidatedEventBody: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -18,5 +18,7 @@ export interface Options {
|
|
|
18
18
|
allowInTests?: boolean;
|
|
19
19
|
}
|
|
20
20
|
type RuleOptions = [Options?];
|
|
21
|
-
export declare const noUserControlledRequests: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
21
|
+
export declare const noUserControlledRequests: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
22
24
|
export {};
|
|
@@ -18,5 +18,7 @@ export interface Options {
|
|
|
18
18
|
allowInTests?: boolean;
|
|
19
19
|
}
|
|
20
20
|
type RuleOptions = [Options?];
|
|
21
|
-
export declare const requireTimeoutHandling: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
21
|
+
export declare const requireTimeoutHandling: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
22
24
|
export {};
|
package/AGENTS.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# AGENTS.md
|
|
2
|
-
|
|
3
|
-
> Context for AI coding agents working on eslint-plugin-lambda-security
|
|
4
|
-
|
|
5
|
-
## Setup Commands
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Install dependencies (from monorepo root)
|
|
9
|
-
pnpm install
|
|
10
|
-
|
|
11
|
-
# Build this package
|
|
12
|
-
nx build eslint-plugin-lambda-security
|
|
13
|
-
|
|
14
|
-
# Run tests
|
|
15
|
-
nx test eslint-plugin-lambda-security
|
|
16
|
-
|
|
17
|
-
# Run tests with coverage
|
|
18
|
-
nx test eslint-plugin-lambda-security --coverage
|
|
19
|
-
|
|
20
|
-
# Lint this package
|
|
21
|
-
nx lint eslint-plugin-lambda-security
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Code Style
|
|
25
|
-
|
|
26
|
-
- TypeScript strict mode with `@interlace/eslint-devkit` types
|
|
27
|
-
- Use `AST_NODE_TYPES` constants, never string literals for node types
|
|
28
|
-
- Use `formatLLMMessage()` for all rule error messages
|
|
29
|
-
- Include CWE, CVSS, OWASP Serverless Top 10 in every security message
|
|
30
|
-
- Use `c8 ignore` comments with documented reasons for untestable code
|
|
31
|
-
- Single-pass AST traversal patterns (O(n) complexity)
|
|
32
|
-
|
|
33
|
-
## Testing Instructions
|
|
34
|
-
|
|
35
|
-
- Tests use `@typescript-eslint/rule-tester` with Vitest
|
|
36
|
-
- Each rule has `index.ts` (implementation) and `*.test.ts` (tests) in same directory
|
|
37
|
-
- Run specific rule test: `nx test eslint-plugin-lambda-security --testPathPattern="no-hardcoded-credentials"`
|
|
38
|
-
- Coverage target: โฅ90% lines, โฅ95% functions
|
|
39
|
-
- All tests must pass before committing
|
|
40
|
-
|
|
41
|
-
## Project Structure
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
src/
|
|
45
|
-
โโโ index.ts # Plugin entry, exports rules and 2 configs
|
|
46
|
-
โโโ types/index.ts # Exported rule option types
|
|
47
|
-
โโโ rules/ # 5 rule directories
|
|
48
|
-
โโโ [rule-name]/
|
|
49
|
-
โโโ index.ts # Rule implementation
|
|
50
|
-
โโโ *.test.ts # Rule tests
|
|
51
|
-
docs/rules/ # Markdown documentation per rule
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Plugin Purpose
|
|
55
|
-
|
|
56
|
-
Security-focused ESLint plugin with **5 rules** for AWS Lambda, Middy, and serverless applications. Covers hardcoded credentials, secrets exposure, environment logging, and CORS misconfigurations.
|
|
57
|
-
|
|
58
|
-
## Rule Categories
|
|
59
|
-
|
|
60
|
-
| Category | Rules | CWEs |
|
|
61
|
-
| --------------------- | --------------------------------------------------------------------- | -------- |
|
|
62
|
-
| Credentials & Secrets | `no-hardcoded-credentials-sdk`, `no-secrets-in-env`, `no-env-logging` | 532, 798 |
|
|
63
|
-
| CORS | `no-permissive-cors-response`, `no-permissive-cors-middy` | 942 |
|
|
64
|
-
|
|
65
|
-
## AWS SDK Clients Detected
|
|
66
|
-
|
|
67
|
-
S3Client, DynamoDBClient, LambdaClient, STSClient, SecretsManagerClient, SQSClient, SNSClient, EC2Client, ECSClient, CloudWatchClient, CloudWatchLogsClient, APIGatewayClient, CognitoIdentityClient, CognitoIdentityProviderClient, EventBridgeClient, StepFunctionsClient, RDSClient, ElastiCacheClient
|
|
68
|
-
|
|
69
|
-
## AWS Access Key Patterns
|
|
70
|
-
|
|
71
|
-
| Pattern | Type |
|
|
72
|
-
| ------- | ------------------------ |
|
|
73
|
-
| `AKIA*` | IAM user access key |
|
|
74
|
-
| `ASIA*` | STS temporary access key |
|
|
75
|
-
| `AIDA*` | IAM user ID |
|
|
76
|
-
|
|
77
|
-
## Common Fix Patterns
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
// Hardcoded credentials
|
|
81
|
-
// BAD: new S3Client({ credentials: { accessKeyId: 'AKIA...', secretAccessKey: '...' } })
|
|
82
|
-
// GOOD: new S3Client({ region: 'us-east-1' }) // Uses Lambda execution role
|
|
83
|
-
// GOOD: new S3Client({ credentials: fromNodeProviderChain() })
|
|
84
|
-
|
|
85
|
-
// Secrets in env
|
|
86
|
-
// BAD: process.env.DB_PASSWORD = 'my-secret'
|
|
87
|
-
// GOOD: const secret = await client.send(new GetSecretValueCommand({ SecretId: 'my-secret' }))
|
|
88
|
-
|
|
89
|
-
// Logging env
|
|
90
|
-
// BAD: console.log(process.env)
|
|
91
|
-
// GOOD: console.log('Region:', process.env.AWS_REGION)
|
|
92
|
-
|
|
93
|
-
// Lambda CORS
|
|
94
|
-
// BAD: return { headers: { 'Access-Control-Allow-Origin': '*' }, ... }
|
|
95
|
-
// GOOD: return { headers: { 'Access-Control-Allow-Origin': 'https://your-app.com' }, ... }
|
|
96
|
-
|
|
97
|
-
// Middy CORS
|
|
98
|
-
// BAD: middy(handler).use(httpCors())
|
|
99
|
-
// GOOD: middy(handler).use(httpCors({ origins: ['https://your-app.com'] }))
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Security Considerations
|
|
103
|
-
|
|
104
|
-
- All rules map to OWASP Serverless Top 10: SAS-2, SAS-3, SAS-4
|
|
105
|
-
- CWE coverage: 532, 798, 942
|
|
106
|
-
- Real AWS key pattern detection (not just string length checks)
|
package/CHANGELOG.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `eslint-plugin-lambda-security` will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.0.0] - 2025-12-29
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
#### Credential & Secrets Protection Rules (3)
|
|
13
|
-
|
|
14
|
-
- `no-hardcoded-credentials-sdk` - Detect hardcoded AWS credentials in SDK v3 clients (CWE-798)
|
|
15
|
-
- `no-secrets-in-env` - Detect secrets hardcoded in environment variables (CWE-798)
|
|
16
|
-
- `no-env-logging` - Detect logging entire process.env object (CWE-532)
|
|
17
|
-
|
|
18
|
-
#### CORS Security Rules (2)
|
|
19
|
-
|
|
20
|
-
- `no-permissive-cors-response` - Detect wildcard CORS in Lambda response headers (CWE-942)
|
|
21
|
-
- `no-permissive-cors-middy` - Detect permissive CORS in @middy/http-cors middleware (CWE-942)
|
|
22
|
-
|
|
23
|
-
#### Presets (2)
|
|
24
|
-
|
|
25
|
-
- `recommended` - Balanced security defaults
|
|
26
|
-
- `strict` - All 5 rules as errors
|
|
27
|
-
|
|
28
|
-
#### Features
|
|
29
|
-
|
|
30
|
-
- LLM-optimized error messages with CWE references
|
|
31
|
-
- OWASP Serverless Top 10 alignment (SAS-2, SAS-3, SAS-4)
|
|
32
|
-
- AWS SDK v3 client detection (S3, DynamoDB, Lambda, STS, etc.)
|
|
33
|
-
- Middy middleware detection (@middy/http-cors)
|
|
34
|
-
- Real AWS access key pattern matching (AKIA*, ASIA*)
|
|
35
|
-
- TypeScript support with exported option types
|
|
36
|
-
- Comprehensive test coverage (78 tests, 97.40% line coverage)
|
|
37
|
-
- Auto-fix for CORS violations
|
|
38
|
-
|
|
39
|
-
### Security
|
|
40
|
-
|
|
41
|
-
- Covers 3 CWEs: 532, 798, 942
|
|
42
|
-
- Maps to OWASP Serverless Top 10: SAS-2, SAS-3, SAS-4
|