eslint-plugin-lambda-security 1.2.0 โ 1.2.2
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 +23 -0
- package/README.md +47 -105
- package/package.json +3 -3
- package/AGENTS.md +0 -106
- package/CHANGELOG.md +0 -42
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
package/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,112 +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-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security)
|
|
197
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security)
|
|
198
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security)
|
|
199
|
-
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security)
|
|
200
|
-
| [`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.
|
|
201
|
-
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next)
|
|
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. |
|
|
202
144
|
|
|
203
145
|
## ๐ License
|
|
204
146
|
|
|
205
147
|
MIT ยฉ [Ofri Peretz](https://github.com/ofri-peretz)
|
|
206
148
|
|
|
207
149
|
<p align="center">
|
|
208
|
-
<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="
|
|
209
|
-
</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.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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": {
|
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
|