eslint-plugin-lambda-security 2.0.0 → 2.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/README.md +60 -23
- package/package.json +2 -2
- package/src/index.js +1 -1
- package/src/rules/no-env-logging/index.js +1 -1
- package/src/rules/no-error-swallowing/index.js +1 -1
- package/src/rules/no-exposed-debug-endpoints/index.js +1 -1
- package/src/rules/no-exposed-error-details/index.js +1 -1
- package/src/rules/no-hardcoded-credentials-sdk/index.js +1 -1
- package/src/rules/no-missing-authorization-check/index.js +1 -1
- package/src/rules/no-overly-permissive-iam-policy/index.js +1 -1
- package/src/rules/no-permissive-cors-middy/index.js +1 -1
- package/src/rules/no-permissive-cors-response/index.js +1 -1
- package/src/rules/no-secrets-in-env/index.js +1 -1
- package/src/rules/no-unbounded-batch-processing/index.js +1 -1
- package/src/rules/no-unvalidated-event-body/index.js +1 -1
- package/src/rules/no-user-controlled-requests/index.js +1 -1
- package/src/rules/require-timeout-handling/index.js +1 -1
- package/src/utils/handler-params.js +1 -0
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security" target="blank"><img src="https://eslint.interlace.tools/logos/interlace.svg" alt="Interlace" height="90" /></a>
|
|
2
|
+
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security" target="blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/interlace-dark.svg"><img src="https://eslint.interlace.tools/logos/interlace-light.svg" alt="Interlace" height="90" /></picture></a>
|
|
3
3
|
|
|
4
4
|
<a href="https://aws.amazon.com/lambda/" target="_blank"><img src="https://eslint.interlace.tools/logos/lambda.svg" alt="AWS Lambda" height="90" /></a>
|
|
5
5
|
|
|
6
|
-
<a href="https://oxc.rs" target="_blank"><img src="https://eslint.interlace.tools/logos/oxlint.svg" alt="oxlint" height="90" /></a>
|
|
6
|
+
<a href="https://oxc.rs" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/oxlint-dark.svg"><img src="https://eslint.interlace.tools/logos/oxlint-light.svg" alt="oxlint" height="90" /></picture></a>
|
|
7
7
|
|
|
8
|
-
<a href="https://eslint.org" target="_blank"><img src="https://eslint.interlace.tools/logos/eslint.svg" alt="ESLint" height="90" /></a>
|
|
8
|
+
<a href="https://eslint.org" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/eslint-dark.svg"><img src="https://eslint.interlace.tools/logos/eslint-light.svg" alt="ESLint" height="90" /></picture></a>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
19
19
|
<a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=eslint-plugin-lambda-security" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=eslint-plugin-lambda-security" alt="Codecov" /></a>
|
|
20
20
|
<a href="https://github.com/ofri-peretz/eslint" target="_blank"><img src="https://img.shields.io/badge/Since-Dec_2025-blue?logo=rocket&logoColor=white" alt="Since Dec 2025" /></a>
|
|
21
|
+
<a href="https://scorecard.dev/viewer/?uri=github.com/ofri-peretz/eslint" target="_blank"><img src="https://api.securityscorecards.dev/projects/github.com/ofri-peretz/eslint/badge" alt="OpenSSF Scorecard" /></a>
|
|
21
22
|
</p>
|
|
22
23
|
|
|
23
24
|
> ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
|
|
@@ -26,18 +27,25 @@
|
|
|
26
27
|
|
|
27
28
|
This plugin provides Security best practices for AWS Lambda functions (IAM, timeouts, environment).
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
<!-- AUTO-GENERATED:DOCTRINE:START - Do not edit manually -->
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
- **Why** — a linter nobody reads protects nothing. We would rather miss a finding
|
|
33
|
+
than spend your attention on one that was never real.
|
|
34
|
+
- **How** — evidence, not names. A rule fires on what the code *does*, resolved
|
|
35
|
+
through the AST and ESLint's own scope analysis.
|
|
36
|
+
- **What** — every finding carries its fix, in prose for a human and as structured
|
|
37
|
+
JSON for an agent. Security rules add a CWE mapping and, where assigned, a CVSS score.
|
|
38
|
+
|
|
39
|
+
That trade costs recall, and we measure it:
|
|
40
|
+
[methodology](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-METHODOLOGY.md)
|
|
41
|
+
· [results](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-RESULTS.md)
|
|
42
|
+
· [a false positive is a bug](https://github.com/ofri-peretz/eslint/issues).
|
|
43
|
+
|
|
44
|
+
<!-- AUTO-GENERATED:DOCTRINE:END -->
|
|
32
45
|
|
|
33
46
|
## Getting Started
|
|
34
47
|
|
|
35
48
|
- To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-lambda-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security). 📚
|
|
36
|
-
- 要查看中文 [指南](https://eslint.interlace.tools/docs/security/plugin-lambda-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security), 请访问 [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security). 📚
|
|
37
|
-
- [가이드](https://eslint.interlace.tools/docs/security/plugin-lambda-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security) 문서는 [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security)에서 확인하실 수 있습니다. 📚
|
|
38
|
-
- [ガイド](https://eslint.interlace.tools/docs/security/plugin-lambda-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security)は [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security)でご確認ください。 📚
|
|
39
|
-
- Para ver la [guía](https://eslint.interlace.tools/docs/security/plugin-lambda-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security), visita [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security). 📚
|
|
40
|
-
- للاطلاع على [الدليل](https://eslint.interlace.tools/docs/security/plugin-lambda-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security)، قم بزيارة [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security). 📚
|
|
41
49
|
|
|
42
50
|
```bash
|
|
43
51
|
npm install eslint-plugin-lambda-security --save-dev
|
|
@@ -142,23 +150,52 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
142
150
|
| [no-user-controlled-requests](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/no-user-controlled-requests?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security) | CWE-918 | A10:2021 | | Detect HTTP requests with user-controlled URLs (SSRF) | 🟢 | 💼 | | | | |
|
|
143
151
|
| [require-timeout-handling](https://eslint.interlace.tools/docs/security/plugin-lambda-security/rules/require-timeout-handling?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security) | CWE-400 | | | Require timeout handling in Lambda handlers with external calls | 🟢 | | ⚠️ | | | |
|
|
144
152
|
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
153
|
+
<!-- AUTO-GENERATED:ECOSYSTEM_TABLE:START - Do not edit manually -->
|
|
154
|
+
|
|
145
155
|
## 🔗 Related ESLint Plugins
|
|
146
156
|
|
|
147
|
-
Part of the **Interlace ESLint
|
|
157
|
+
Part of the **Interlace ESLint ecosystem** — AI-native rules with LLM-optimized error messages:
|
|
158
|
+
|
|
159
|
+
**Security**
|
|
160
|
+
|
|
161
|
+
| Plugin | Downloads | Description |
|
|
162
|
+
| :--- | :---: | :--- |
|
|
163
|
+
| [`eslint-plugin-anthropic-security`](https://www.npmjs.com/package/eslint-plugin-anthropic-security) | [](https://www.npmjs.com/package/eslint-plugin-anthropic-security) | Anthropic SDK security. |
|
|
164
|
+
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [](https://www.npmjs.com/package/eslint-plugin-browser-security) | XSS, DOM security. |
|
|
165
|
+
| [`eslint-plugin-drizzle-security`](https://www.npmjs.com/package/eslint-plugin-drizzle-security) | [](https://www.npmjs.com/package/eslint-plugin-drizzle-security) | Drizzle security. |
|
|
166
|
+
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://www.npmjs.com/package/eslint-plugin-express-security) | Express middleware hardening. |
|
|
167
|
+
| [`eslint-plugin-gemini-security`](https://www.npmjs.com/package/eslint-plugin-gemini-security) | [](https://www.npmjs.com/package/eslint-plugin-gemini-security) | Google Gemini SDK security. |
|
|
168
|
+
| [`eslint-plugin-jwt-security`](https://www.npmjs.com/package/eslint-plugin-jwt-security) | [](https://www.npmjs.com/package/eslint-plugin-jwt-security) | Token security. |
|
|
169
|
+
| [`eslint-plugin-knex-security`](https://www.npmjs.com/package/eslint-plugin-knex-security) | [](https://www.npmjs.com/package/eslint-plugin-knex-security) | Knex security. |
|
|
170
|
+
| [`eslint-plugin-mcp-sdk-security`](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security) | [](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security) | MCP SDK security. |
|
|
171
|
+
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | [](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | MongoDB injection. |
|
|
172
|
+
| [`eslint-plugin-mysql-security`](https://www.npmjs.com/package/eslint-plugin-mysql-security) | [](https://www.npmjs.com/package/eslint-plugin-mysql-security) | MySQL security. |
|
|
173
|
+
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS framework hardening. |
|
|
174
|
+
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security) | [](https://www.npmjs.com/package/eslint-plugin-node-security) | Server-side patterns. |
|
|
175
|
+
| [`eslint-plugin-openai-security`](https://www.npmjs.com/package/eslint-plugin-openai-security) | [](https://www.npmjs.com/package/eslint-plugin-openai-security) | OpenAI SDK security. |
|
|
176
|
+
| [`eslint-plugin-postgresql-security`](https://www.npmjs.com/package/eslint-plugin-postgresql-security) | [](https://www.npmjs.com/package/eslint-plugin-postgresql-security) | PostgreSQL security. |
|
|
177
|
+
| [`eslint-plugin-prisma-security`](https://www.npmjs.com/package/eslint-plugin-prisma-security) | [](https://www.npmjs.com/package/eslint-plugin-prisma-security) | Prisma security. |
|
|
178
|
+
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | Injection prevention. |
|
|
179
|
+
| [`eslint-plugin-sequelize-security`](https://www.npmjs.com/package/eslint-plugin-sequelize-security) | [](https://www.npmjs.com/package/eslint-plugin-sequelize-security) | Sequelize ORM security. |
|
|
180
|
+
| [`eslint-plugin-sqlite-security`](https://www.npmjs.com/package/eslint-plugin-sqlite-security) | [](https://www.npmjs.com/package/eslint-plugin-sqlite-security) | SQLite security. |
|
|
181
|
+
| [`eslint-plugin-typeorm-security`](https://www.npmjs.com/package/eslint-plugin-typeorm-security) | [](https://www.npmjs.com/package/eslint-plugin-typeorm-security) | TypeORM security. |
|
|
182
|
+
| [`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) | AI SDK security. |
|
|
183
|
+
|
|
184
|
+
**Code quality**
|
|
148
185
|
|
|
149
186
|
| Plugin | Downloads | Description |
|
|
150
187
|
| :--- | :---: | :--- |
|
|
151
|
-
| [`eslint-plugin-
|
|
152
|
-
| [`eslint-plugin-
|
|
153
|
-
| [`eslint-plugin-
|
|
154
|
-
| [`eslint-plugin-
|
|
155
|
-
| [`eslint-plugin-
|
|
156
|
-
| [`eslint-plugin-
|
|
157
|
-
| [`eslint-plugin-
|
|
158
|
-
| [`eslint-plugin-
|
|
159
|
-
| [`eslint-plugin-
|
|
160
|
-
|
|
161
|
-
|
|
188
|
+
| [`eslint-plugin-conventions`](https://www.npmjs.com/package/eslint-plugin-conventions) | [](https://www.npmjs.com/package/eslint-plugin-conventions) | Team-specific habits and styles. |
|
|
189
|
+
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [](https://www.npmjs.com/package/eslint-plugin-import-next) | Fast cycle + import-graph analysis. |
|
|
190
|
+
| [`eslint-plugin-maintainability`](https://www.npmjs.com/package/eslint-plugin-maintainability) | [](https://www.npmjs.com/package/eslint-plugin-maintainability) | Cognitive load and clean-code patterns. |
|
|
191
|
+
| [`eslint-plugin-modernization`](https://www.npmjs.com/package/eslint-plugin-modernization) | [](https://www.npmjs.com/package/eslint-plugin-modernization) | ESNext migration + syntax evolution. |
|
|
192
|
+
| [`eslint-plugin-modularity`](https://www.npmjs.com/package/eslint-plugin-modularity) | [](https://www.npmjs.com/package/eslint-plugin-modularity) | Structural integrity and DDD patterns. |
|
|
193
|
+
| [`eslint-plugin-operability`](https://www.npmjs.com/package/eslint-plugin-operability) | [](https://www.npmjs.com/package/eslint-plugin-operability) | Production readiness and resource health. |
|
|
194
|
+
| [`eslint-plugin-react-a11y`](https://www.npmjs.com/package/eslint-plugin-react-a11y) | [](https://www.npmjs.com/package/eslint-plugin-react-a11y) | React accessibility / WCAG. |
|
|
195
|
+
| [`eslint-plugin-react-features`](https://www.npmjs.com/package/eslint-plugin-react-features) | [](https://www.npmjs.com/package/eslint-plugin-react-features) | React best practices and optimization. |
|
|
196
|
+
| [`eslint-plugin-reliability`](https://www.npmjs.com/package/eslint-plugin-reliability) | [](https://www.npmjs.com/package/eslint-plugin-reliability) | Runtime stability and error safety. |
|
|
197
|
+
|
|
198
|
+
<!-- AUTO-GENERATED:ECOSYSTEM_TABLE:END -->
|
|
162
199
|
|
|
163
200
|
<!-- INTERLACE:STAR_CTA:START -->
|
|
164
201
|
## ⭐ Support & follow
|
|
@@ -178,5 +215,5 @@ MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
|
178
215
|
</p>
|
|
179
216
|
|
|
180
217
|
<p align="center">
|
|
181
|
-
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security" target="blank"><img src="https://eslint.interlace.tools/
|
|
218
|
+
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security" target="blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/interlace-dark.svg"><img src="https://eslint.interlace.tools/logos/interlace-light.svg" alt="Interlace" height="70" /></picture></a>
|
|
182
219
|
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-lambda-security",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "ESLint plugin for AWS Lambda security — detects overly permissive IAM policies and CORS, unvalidated event bodies, secrets in env vars, and leaked error details.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"node": ">=18.0.0"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@interlace/eslint-devkit": "^1.
|
|
74
|
+
"@interlace/eslint-devkit": "^1.18.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"eslint": "^8.40.0 || ^9.0.0 || ^10.0.0",
|
package/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;exports.rules={get"no-hardcoded-credentials-sdk"(){return require("./rules/no-hardcoded-credentials-sdk").noHardcodedCredentialsSdk},get"no-permissive-cors-response"(){return require("./rules/no-permissive-cors-response").noPermissiveCorsResponse},get"no-permissive-cors-middy"(){return require("./rules/no-permissive-cors-middy").noPermissiveCorsMidly},get"no-secrets-in-env"(){return require("./rules/no-secrets-in-env").noSecretsInEnv},get"no-env-logging"(){return require("./rules/no-env-logging").noEnvLogging},get"no-unvalidated-event-body"(){return require("./rules/no-unvalidated-event-body").noUnvalidatedEventBody},get"no-missing-authorization-check"(){return require("./rules/no-missing-authorization-check").noMissingAuthorizationCheck},get"no-overly-permissive-iam-policy"(){return require("./rules/no-overly-permissive-iam-policy").noOverlyPermissiveIamPolicy},get"no-error-swallowing"(){return require("./rules/no-error-swallowing").noErrorSwallowing},get"require-timeout-handling"(){return require("./rules/require-timeout-handling").requireTimeoutHandling},get"no-unbounded-batch-processing"(){return require("./rules/no-unbounded-batch-processing").noUnboundedBatchProcessing},get"no-user-controlled-requests"(){return require("./rules/no-user-controlled-requests").noUserControlledRequests},get"no-exposed-error-details"(){return require("./rules/no-exposed-error-details").noExposedErrorDetails},get"no-exposed-debug-endpoints"(){return require("./rules/no-exposed-debug-endpoints").noExposedDebugEndpoints}};exports.plugin={meta:{name:"eslint-plugin-lambda-security",version:"2.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.rules={get"no-hardcoded-credentials-sdk"(){return require("./rules/no-hardcoded-credentials-sdk").noHardcodedCredentialsSdk},get"no-permissive-cors-response"(){return require("./rules/no-permissive-cors-response").noPermissiveCorsResponse},get"no-permissive-cors-middy"(){return require("./rules/no-permissive-cors-middy").noPermissiveCorsMidly},get"no-secrets-in-env"(){return require("./rules/no-secrets-in-env").noSecretsInEnv},get"no-env-logging"(){return require("./rules/no-env-logging").noEnvLogging},get"no-unvalidated-event-body"(){return require("./rules/no-unvalidated-event-body").noUnvalidatedEventBody},get"no-missing-authorization-check"(){return require("./rules/no-missing-authorization-check").noMissingAuthorizationCheck},get"no-overly-permissive-iam-policy"(){return require("./rules/no-overly-permissive-iam-policy").noOverlyPermissiveIamPolicy},get"no-error-swallowing"(){return require("./rules/no-error-swallowing").noErrorSwallowing},get"require-timeout-handling"(){return require("./rules/require-timeout-handling").requireTimeoutHandling},get"no-unbounded-batch-processing"(){return require("./rules/no-unbounded-batch-processing").noUnboundedBatchProcessing},get"no-user-controlled-requests"(){return require("./rules/no-user-controlled-requests").noUserControlledRequests},get"no-exposed-error-details"(){return require("./rules/no-exposed-error-details").noExposedErrorDetails},get"no-exposed-debug-endpoints"(){return require("./rules/no-exposed-debug-endpoints").noExposedDebugEndpoints}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-lambda-security",exports.rules);exports.plugin={meta:{name:"eslint-plugin-lambda-security",version:"2.1.0"},rules:exports.rules};exports.configs={recommended:{plugins:{"lambda-security":exports.plugin},rules:{"lambda-security/no-hardcoded-credentials-sdk":"error","lambda-security/no-permissive-cors-response":"error","lambda-security/no-permissive-cors-middy":"error","lambda-security/no-secrets-in-env":"error","lambda-security/no-user-controlled-requests":"error","lambda-security/no-overly-permissive-iam-policy":"error","lambda-security/no-unvalidated-event-body":"warn","lambda-security/no-missing-authorization-check":"warn","lambda-security/no-exposed-error-details":"warn","lambda-security/no-exposed-debug-endpoints":"error","lambda-security/no-env-logging":"warn","lambda-security/no-error-swallowing":"warn","lambda-security/require-timeout-handling":"warn","lambda-security/no-unbounded-batch-processing":"warn"}},strict:{plugins:{"lambda-security":exports.plugin},rules:{"lambda-security/no-hardcoded-credentials-sdk":"error","lambda-security/no-permissive-cors-response":"error","lambda-security/no-permissive-cors-middy":"error","lambda-security/no-secrets-in-env":"error","lambda-security/no-env-logging":"error","lambda-security/no-unvalidated-event-body":"error","lambda-security/no-missing-authorization-check":"error","lambda-security/no-overly-permissive-iam-policy":"error","lambda-security/no-error-swallowing":"error","lambda-security/require-timeout-handling":"error","lambda-security/no-unbounded-batch-processing":"error","lambda-security/no-user-controlled-requests":"error","lambda-security/no-exposed-error-details":"error","lambda-security/no-exposed-debug-endpoints":"error"}}};exports.default=exports.plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noEnvLogging=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");const LOGGING_FUNCTIONS=new Set(["log","info","warn","error","debug","trace"]);exports.noEnvLogging=(0,eslint_devkit_1.createRule)({name:"no-env-logging",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-env-logging.md",description:"Detects logging of process.env which may expose secrets",cwe:"CWE-532",cvss:5.3},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noEnvLogging=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");const LOGGING_FUNCTIONS=new Set(["log","info","warn","error","debug","trace"]);exports.noEnvLogging=(0,eslint_devkit_1.createRule)({name:"no-env-logging",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-env-logging.md",description:"Detects logging of process.env which may expose secrets",cwe:"CWE-532",cvss:5.3},messages:{envLogging:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Environment Variable Logging",cwe:"CWE-532",description:"Logging process.env may expose secrets (API keys, passwords, tokens)",severity:"HIGH",fix:"Remove process.env from log statements or log specific non-sensitive values",documentationLink:"https://cwe.mitre.org/data/definitions/532.html"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}const sourceCode=context.sourceCode;function isProcessEnv(node){if(node.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.object.name==="process"&&node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.property.name==="env"){return true}return false}function containsProcessEnv(node){const text=sourceCode.getText(node);return text.includes("process.env")}function isLoggingCall(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){const obj=node.callee.object;const prop=node.callee.property;if(prop.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier)return false;const methodName=prop.name;if(!LOGGING_FUNCTIONS.has(methodName))return false;if(obj.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&obj.name==="console"){return true}if(obj.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&/log(ger)?/i.test(obj.name)){return true}}return false}return{CallExpression(node){if(!isLoggingCall(node))return;for(const arg of node.arguments){if(isProcessEnv(arg)){context.report({node:arg,messageId:"envLogging"})}else if(containsProcessEnv(arg)){const text=sourceCode.getText(arg);if(/process\.env\s*[,)\]]/.test(text)||/JSON\.stringify\s*\(\s*process\.env\s*\)/.test(text)){context.report({node:arg,messageId:"envLogging"})}}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noErrorSwallowing=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noErrorSwallowing=(0,eslint_devkit_1.createRule)({name:"no-error-swallowing",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-error-swallowing.md",description:"Detects empty catch blocks and missing error logging in Lambda handlers",cwe:"CWE-390",cvss:5},hasSuggestions:true,messages:{emptyCatchBlock:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Error Swallowing",cwe:"CWE-390",cvss:5,description:"Catch block swallows error without logging. Security incidents may go undetected.",severity:"MEDIUM",fix:'Log the error with context: console.error("Operation failed", { error, awsRequestId: context.awsRequestId })',documentationLink:"https://cwe.mitre.org/data/definitions/390.html"}),addErrorLogging:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Add Error Logging",description:"Log errors with context for security monitoring",severity:"LOW",fix:'console.error("Error:", error); // or use structured logger',documentationLink:"https://docs.aws.amazon.com/lambda/latest/dg/nodejs-logging.html"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true},allowWithComment:{type:"boolean",default:true,description:"Allow an empty catch block that carries an explanatory comment"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true,allowWithComment:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true,allowWithComment=true}=options;const filename=context.filename;const isTestFile
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noErrorSwallowing=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noErrorSwallowing=(0,eslint_devkit_1.createRule)({name:"no-error-swallowing",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-error-swallowing.md",description:"Detects empty catch blocks and missing error logging in Lambda handlers",cwe:"CWE-390",cvss:5},hasSuggestions:true,messages:{emptyCatchBlock:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Error Swallowing",cwe:"CWE-390",cvss:5,description:"Catch block swallows error without logging. Security incidents may go undetected.",severity:"MEDIUM",fix:'Log the error with context: console.error("Operation failed", { error, awsRequestId: context.awsRequestId })',documentationLink:"https://cwe.mitre.org/data/definitions/390.html"}),addErrorLogging:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Add Error Logging",description:"Log errors with context for security monitoring",severity:"LOW",fix:'console.error("Error:", error); // or use structured logger',documentationLink:"https://docs.aws.amazon.com/lambda/latest/dg/nodejs-logging.html"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true},allowWithComment:{type:"boolean",default:true,description:"Allow an empty catch block that carries an explanatory comment"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true,allowWithComment:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true,allowWithComment=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}const LOGGER_OBJECTS=/^(console|logger|log|winston|pino|bunyan|sentry|Sentry)$/;const LOGGER_METHODS=/^(log|error|warn|info|debug|captureException|captureMessage)$/;const LOGGING_FUNCTIONS=/^(log|report|capture|track|record|notify)\w*$/i;const FORWARDING_CALLBACKS=/^(next|reject|callback|cb|done|fail|emit)$/;const RESPONSE_OBJECTS=/^(res|response|reply|ctx)$/;const RESPONSE_METHODS=/^(status|sendStatus|json|send|end|writeHead|render|redirect)$/;function mentions(nodes,name){const stack=[...nodes];while(stack.length>0){const node=stack.pop();if(!node||typeof node.type!=="string")continue;if(node.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.name===name)return true;for(const key of Object.keys(node)){if(key==="parent")continue;const value=node[key];if(Array.isArray(value))stack.push(...value);else if(value&&typeof value==="object")stack.push(value)}}return false}function rootName(node){let current=node;while(current.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression)current=current.object;return current.type===eslint_devkit_1.AST_NODE_TYPES.Identifier?current.name:void 0}function memberNames(node){const names=[];let current=node;while(current.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){if(current.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){names.unshift(current.property.name)}current=current.object}return names}function classifyCall(call,caughtName){const callee=call.callee;if(callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){if(FORWARDING_CALLBACKS.test(callee.name)){return caughtName!==void 0&&mentions(call.arguments,caughtName)?"forward":void 0}if(LOGGING_FUNCTIONS.test(callee.name))return"log";return void 0}if(callee.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression)return void 0;const names=memberNames(callee);const method=names.at(-1)??"";if(names.length>1&&LOGGER_OBJECTS.test(names.at(-2)??"")&&LOGGER_METHODS.test(method)){return"log"}const root=rootName(callee);if(root===void 0)return void 0;if(LOGGER_OBJECTS.test(root)&&LOGGER_METHODS.test(method))return"log";if(RESPONSE_OBJECTS.test(root)&&names.some(n=>RESPONSE_METHODS.test(n))){return"respond"}return void 0}function analyze(block,caughtName){const result={logs:false,forwards:false,responds:false};const seen=new Set;const visit=node=>{if(!node||typeof node.type!=="string"||seen.has(node))return;seen.add(node);if(node.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression){const kind=classifyCall(node,caughtName);if(kind==="log")result.logs=true;else if(kind==="forward")result.forwards=true;else if(kind==="respond")result.responds=true}for(const key of Object.keys(node)){if(key==="parent")continue;const value=node[key];if(Array.isArray(value)){for(const item of value)visit(item)}else if(value&&typeof value==="object"){visit(value)}}};visit(block);return result}function hasIntentionalComment(node){if(!allowWithComment)return false;const sourceCode=context.sourceCode;const comments=sourceCode.getCommentsInside(node.body);return comments.some(comment=>/intentional|expected|ignore|suppress|handled|silent/i.test(comment.value))}function hasThrow(block){return block.body.some(stmt=>stmt.type===eslint_devkit_1.AST_NODE_TYPES.ThrowStatement)}function returnsFallback(block){return block.body.some(stmt=>{if(stmt.type!==eslint_devkit_1.AST_NODE_TYPES.ReturnStatement)return false;const value=stmt.argument;if(value===null)return false;if(value.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&value.value===null)return false;if(value.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&value.name==="undefined"){return false}if(value.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&value.value===true)return false;if(value.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){const status=value.properties.find(p=>p.type===eslint_devkit_1.AST_NODE_TYPES.Property&&p.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&/^(statusCode|status|ok|allowed|authorized)$/.test(p.key.name));if(status){const literal=status.value.type===eslint_devkit_1.AST_NODE_TYPES.Literal?status.value.value:void 0;if(literal===true)return false;const code=Number(literal);if(code>=200&&code<300)return false}}return true})}return{CatchClause(node){const body=node.body;if(body.body.length===0){if(!hasIntentionalComment(node)){context.report({node,messageId:"emptyCatchBlock",suggest:[{messageId:"addErrorLogging",fix:fixer=>{const errorParam=node.param?.type===eslint_devkit_1.AST_NODE_TYPES.Identifier?node.param.name:"error";return fixer.replaceText(body,`{ console.error('Error:', ${errorParam}); }`)}}]})}return}if(hasThrow(body)){return}const caughtName=node.param?.type===eslint_devkit_1.AST_NODE_TYPES.Identifier?node.param.name:void 0;const{logs,forwards,responds}=analyze(body,caughtName);if(logs||forwards||responds||returnsFallback(body)){return}if(!hasIntentionalComment(node)){context.report({node,messageId:"emptyCatchBlock"})}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noExposedDebugEndpoints=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");const DEFAULT_DEBUG_PATHS=["/debug","/__debug__","/admin","/_admin","/test","/health"];exports.noExposedDebugEndpoints=(0,eslint_devkit_1.createRule)({name:"no-exposed-debug-endpoints",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-exposed-debug-endpoints.md",description:"Detect debug endpoints without auth in AWS Lambda handlers",cwe:"CWE-489",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Exposed Debug Endpoint",cwe:"CWE-489",description:"Debug endpoint exposed without authentication",severity:"HIGH",fix:"Remove debug endpoints from production or add authentication",documentationLink:"https://cwe.mitre.org/data/definitions/489.html"})},schema:[{type:"object",properties:{endpoints:{type:"array",items:{type:"string"},description:"Custom list of debug/admin endpoints to flag"},ignoreFiles:{type:"array",items:{type:"string"},description:"List of files or patterns to ignore"}},additionalProperties:false}]},defaultOptions:[{}],create(context){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const options=context.options[0]||{};const debugPaths=options.endpoints||DEFAULT_DEBUG_PATHS;const ignoreFiles=options.ignoreFiles||[];const filename=context.filename;if(ignoreFiles.some(pattern=>filename.includes(pattern))){return{}}function report(node){context.report({node,messageId:"violationDetected"})}return{Property(node){if(node.key.type==="Identifier"&&node.key.name==="path"&&
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noExposedDebugEndpoints=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");const DEFAULT_DEBUG_PATHS=["/debug","/__debug__","/admin","/_admin","/test","/health"];exports.noExposedDebugEndpoints=(0,eslint_devkit_1.createRule)({name:"no-exposed-debug-endpoints",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-exposed-debug-endpoints.md",description:"Detect debug endpoints without auth in AWS Lambda handlers",cwe:"CWE-489",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Exposed Debug Endpoint",cwe:"CWE-489",description:"Debug endpoint exposed without authentication",severity:"HIGH",fix:"Remove debug endpoints from production or add authentication",documentationLink:"https://cwe.mitre.org/data/definitions/489.html"})},schema:[{type:"object",properties:{endpoints:{type:"array",items:{type:"string"},description:"Custom list of debug/admin endpoints to flag"},ignoreFiles:{type:"array",items:{type:"string"},description:"List of files or patterns to ignore"}},additionalProperties:false}]},defaultOptions:[{}],create(context){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const options=context.options[0]||{};const debugPaths=options.endpoints||DEFAULT_DEBUG_PATHS;const ignoreFiles=options.ignoreFiles||[];const filename=context.filename;if(ignoreFiles.some(pattern=>filename.includes(pattern))){return{}}function report(node){context.report({node,messageId:"violationDetected"})}return{Property(node){const pathText=(0,eslint_devkit_1.staticString)(node.value);if(node.key.type==="Identifier"&&node.key.name==="path"&&pathText!==null){const path=pathText.toLowerCase();if(debugPaths.some(dp=>path.includes(dp.toLowerCase()))){let parent=node.parent;while(parent){if(parent.type==="Property"&&parent.key.type==="Identifier"&&["http","httpApi"].includes(parent.key.name)){report(node.value);return}parent=parent.parent}}}},BinaryExpression(node){if(node.operator==="==="||node.operator==="=="||node.operator==="!=="||node.operator==="!="){const checkNode=side=>{const staticText=(0,eslint_devkit_1.staticString)(side);if(staticText!==null){const val=staticText.toLowerCase();if(debugPaths.some(dp=>val.includes(dp.toLowerCase()))){const other=side===node.left?node.right:node.left;if(other.type==="MemberExpression"&&other.object.type==="Identifier"&&(other.object.name==="event"||other.object.name==="evt")&&other.property.type==="Identifier"&&["path","rawPath","resource","routeKey"].includes(other.property.name)){report(side)}}}};checkNode(node.left);checkNode(node.right)}},Literal(node){if(typeof node.value==="string"){const path=node.value.toLowerCase();if(debugPaths.some(dp=>path===dp.toLowerCase())){const parent=node.parent;if(parent&&parent.type==="BinaryExpression"&&(parent.left===node||parent.right===node)){const other=parent.left===node?parent.right:parent.left;if(other.type==="MemberExpression"&&other.object.type==="Identifier"&&(other.object.name==="event"||other.object.name==="evt")){return}}if(parent&&parent.type==="Property"&&parent.key.type==="Identifier"&&parent.key.name==="path"){return}report(node)}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noExposedErrorDetails=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const SENSITIVE_ERROR_PROPERTIES=new Set(["stack","stackTrace","trace","cause","__dirname","__filename","path","hostname","config","env"]);exports.noExposedErrorDetails=(0,eslint_devkit_1.createRule)({name:"no-exposed-error-details",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-exposed-error-details.md",description:"Detects Lambda handlers exposing internal error details in responses",cwe:"CWE-209",cvss:4.3},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noExposedErrorDetails=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const SENSITIVE_ERROR_PROPERTIES=new Set(["stack","stackTrace","trace","cause","__dirname","__filename","path","hostname","config","env"]);exports.noExposedErrorDetails=(0,eslint_devkit_1.createRule)({name:"no-exposed-error-details",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-exposed-error-details.md",description:"Detects Lambda handlers exposing internal error details in responses",cwe:"CWE-209",cvss:4.3},messages:{exposedErrorDetails:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Exposed Error Details",cwe:"CWE-209",cvss:4.3,description:"Response exposes {{property}} which may leak internal paths, configs, or stack traces.",severity:"MEDIUM",fix:"Return generic error message. Log detailed errors server-side: console.error(error)",documentationLink:"https://cwe.mitre.org/data/definitions/209.html"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}let insideApiResponse=false;function isApiResponse(node){return node.properties.some(prop=>prop.type===eslint_devkit_1.AST_NODE_TYPES.Property&&prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&["statusCode","body","headers"].includes(prop.key.name))}function getSensitiveProperty(node){if(node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){if(SENSITIVE_ERROR_PROPERTIES.has(node.property.name)){return node.property.name}}return null}return{ReturnStatement(node){if(node.argument?.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression&&isApiResponse(node.argument)){insideApiResponse=true}},"ReturnStatement:exit"(){insideApiResponse=false},MemberExpression(node){if(!insideApiResponse)return;const sensitiveProperty=getSensitiveProperty(node);if(sensitiveProperty){const parent=node.parent;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.Property||parent?.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression){context.report({node,messageId:"exposedErrorDetails",data:{property:sensitiveProperty}})}}},CallExpression(node){if(!insideApiResponse)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.object.name==="JSON"&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="stringify"){const arg=node.arguments[0];if(arg?.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){if(/error|err|e|exception/i.test(arg.name)){context.report({node,messageId:"exposedErrorDetails",data:{property:"error object"}})}}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noHardcodedCredentialsSdk=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");const AWS_ACCESS_KEY_PATTERNS=[/^AKIA[0-9A-Z]{16}$/,/^ASIA[0-9A-Z]{16}$/,/^AIDA[0-9A-Z]{16}$/];const CREDENTIAL_PROPERTY_NAMES=["accessKeyId","secretAccessKey","sessionToken","awsAccessKeyId","awsSecretAccessKey"];const AWS_SDK_V3_CLIENTS=new Set(["S3Client","DynamoDBClient","LambdaClient","SQSClient","SNSClient","SecretsManagerClient","KMSClient","STSClient","IAMClient","EC2Client","ECSClient","CloudWatchClient","CloudWatchLogsClient","APIGatewayClient","CognitoIdentityClient","CognitoIdentityProviderClient","EventBridgeClient","StepFunctionsClient","RDSClient","ElastiCacheClient"]);exports.noHardcodedCredentialsSdk=(0,eslint_devkit_1.createRule)({name:"no-hardcoded-credentials-sdk",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-hardcoded-credentials-sdk.md",description:"Detects hardcoded AWS credentials in SDK client configurations",cwe:"CWE-798",cvss:9.8},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noHardcodedCredentialsSdk=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");const AWS_ACCESS_KEY_PATTERNS=[/^AKIA[0-9A-Z]{16}$/,/^ASIA[0-9A-Z]{16}$/,/^AIDA[0-9A-Z]{16}$/];const CREDENTIAL_PROPERTY_NAMES=["accessKeyId","secretAccessKey","sessionToken","awsAccessKeyId","awsSecretAccessKey"];const AWS_SDK_V3_CLIENTS=new Set(["S3Client","DynamoDBClient","LambdaClient","SQSClient","SNSClient","SecretsManagerClient","KMSClient","STSClient","IAMClient","EC2Client","ECSClient","CloudWatchClient","CloudWatchLogsClient","APIGatewayClient","CognitoIdentityClient","CognitoIdentityProviderClient","EventBridgeClient","StepFunctionsClient","RDSClient","ElastiCacheClient"]);exports.noHardcodedCredentialsSdk=(0,eslint_devkit_1.createRule)({name:"no-hardcoded-credentials-sdk",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-hardcoded-credentials-sdk.md",description:"Detects hardcoded AWS credentials in SDK client configurations",cwe:"CWE-798",cvss:9.8},messages:{hardcodedCredentials:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Hardcoded AWS Credentials",cwe:"CWE-798",description:"Hardcoded AWS credentials detected in {{clientName}} config: {{property}}",severity:"CRITICAL",fix:"Use credential provider chain: new {{clientName}}({ credentials: fromNodeProviderChain() })",documentationLink:"https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true,description:"Allow hardcoded credentials in test files"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}function looksLikeAwsAccessKey(value){return AWS_ACCESS_KEY_PATTERNS.some(pattern=>pattern.test(value))}function isCredentialProperty(name){return CREDENTIAL_PROPERTY_NAMES.some(credProp=>name.toLowerCase()===credProp.toLowerCase())}function getAwsClientName(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const name=node.callee.name;if(AWS_SDK_V3_CLIENTS.has(name)){return name}if(name.endsWith("Client")&&/^(S3|DynamoDB|Lambda|SQS|SNS|Secrets|KMS|STS|IAM|EC2|ECS|CloudWatch|APIGateway|Cognito|EventBridge|StepFunctions|RDS|ElastiCache|SSM|Athena|Glue|Kinesis|Firehose|Rekognition|Textract|Comprehend|Polly|Lex|Bedrock|My|Custom|AWS)/i.test(name)){return name}}return null}function checkCredentialsObject(obj,clientName){for(const prop of obj.properties){if(prop.type!==eslint_devkit_1.AST_NODE_TYPES.Property)continue;if(prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&prop.key.name==="credentials"&&prop.value.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){checkCredentialsInner(prop.value,clientName)}if(prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&isCredentialProperty(prop.key.name)){const staticText1=(0,eslint_devkit_1.staticString)(prop.value);if(staticText1!==null){reportHardcodedCredential(prop,clientName,prop.key.name)}}}}function checkCredentialsInner(obj,clientName){for(const prop of obj.properties){if(prop.type!==eslint_devkit_1.AST_NODE_TYPES.Property)continue;if(prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&isCredentialProperty(prop.key.name)){const staticText2=(0,eslint_devkit_1.staticString)(prop.value);if(staticText2!==null){const value=staticText2;const keyName=prop.key.name.toLowerCase();if(keyName==="accesskeyid"){if(looksLikeAwsAccessKey(value)){reportHardcodedCredential(prop,clientName,prop.key.name)}}else if(keyName==="secretaccesskey"){if(value.length>=20){reportHardcodedCredential(prop,clientName,prop.key.name)}}else if(keyName==="sessiontoken"){if(value.length>=15){reportHardcodedCredential(prop,clientName,prop.key.name)}}}else if(prop.value.type===eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral){reportHardcodedCredential(prop,clientName,prop.key.name)}}}}function reportHardcodedCredential(node,clientName,propertyName){context.report({node,messageId:"hardcodedCredentials",data:{clientName,property:propertyName}})}return{NewExpression(node){const clientName=getAwsClientName(node);if(!clientName)return;if(node.arguments.length>0&&node.arguments[0].type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){checkCredentialsObject(node.arguments[0],clientName)}},VariableDeclarator(node){if(node.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.id.name.toLowerCase().includes("credential")&&node.init?.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){checkCredentialsInner(node.init,"AWSClient")}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noMissingAuthorizationCheck=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const AUTHORIZATION_CHECK_PATTERNS=["requestContext.authorizer","requestContext.identity","Authorization","authorization","claims","principalId","isAdmin","isAuthenticated","userId","sub","scope","permissions"];const SENSITIVE_OPERATIONS=new Set(["query","put","delete","update","insert","remove","create","send","invoke","putObject","deleteObject","getObject","putItem","deleteItem","updateItem","getItem"]);const EVENT_PARAM_NAMES=new Set(["event","evt","e","request","req"]);exports.noMissingAuthorizationCheck=(0,eslint_devkit_1.createRule)({name:"no-missing-authorization-check",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-missing-authorization-check.md",description:"Detects Lambda handlers without authorization checks",cwe:"CWE-862",cvss:7.5},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noMissingAuthorizationCheck=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const AUTHORIZATION_CHECK_PATTERNS=["requestContext.authorizer","requestContext.identity","Authorization","authorization","claims","principalId","isAdmin","isAuthenticated","userId","sub","scope","permissions"];const SENSITIVE_OPERATIONS=new Set(["query","put","delete","update","insert","remove","create","send","invoke","putObject","deleteObject","getObject","putItem","deleteItem","updateItem","getItem"]);const EVENT_PARAM_NAMES=new Set(["event","evt","e","request","req"]);exports.noMissingAuthorizationCheck=(0,eslint_devkit_1.createRule)({name:"no-missing-authorization-check",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-missing-authorization-check.md",description:"Detects Lambda handlers without authorization checks",cwe:"CWE-862",cvss:7.5},messages:{missingAuthCheck:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Missing Authorization Check",cwe:"CWE-862",cvss:7.5,description:"Lambda handler performs {{operation}} operation without authorization check. Users may access resources without proper permissions.",severity:"HIGH",fix:"Add authorization check: const claims = event.requestContext.authorizer?.claims; if (!claims?.sub) { return { statusCode: 401 } }",documentationLink:"https://cwe.mitre.org/data/definitions/862.html"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true,description:"Allow missing auth in test files"},handlerPatterns:{type:"array",items:{type:"string"},description:"Handler file patterns to check"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true,handlerPatterns:[]}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}let currentFunctionNode=null;let hasAuthCheck=false;let hasEventParameter=false;const sensitiveOperations=[];function enterFunction(node){const hasEvent=node.params.some(param=>param.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&EVENT_PARAM_NAMES.has(param.name));if(hasEvent){currentFunctionNode=node;hasAuthCheck=false;hasEventParameter=true;sensitiveOperations.length=0}}function exitFunction(node){if(currentFunctionNode!==node)return;if(hasEventParameter&&!hasAuthCheck){for(const{node:opNode,operation}of sensitiveOperations){context.report({node:opNode,messageId:"missingAuthCheck",data:{operation}})}}currentFunctionNode=null;hasEventParameter=false}function isAuthorizationAccess(node){const sourceCode=context.sourceCode;const text=sourceCode.getText(node);return AUTHORIZATION_CHECK_PATTERNS.some(pattern=>text.includes(pattern)||text.toLowerCase().includes(pattern.toLowerCase()))}function getSensitiveOperationName(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){const property=node.callee.property;if(property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){if(SENSITIVE_OPERATIONS.has(property.name)){return property.name}}}return null}return{"ArrowFunctionExpression, FunctionExpression, FunctionDeclaration"(node){enterFunction(node)},"ArrowFunctionExpression:exit"(node){exitFunction(node)},"FunctionExpression:exit"(node){exitFunction(node)},"FunctionDeclaration:exit"(node){exitFunction(node)},MemberExpression(node){if(!currentFunctionNode)return;if(isAuthorizationAccess(node)){hasAuthCheck=true}},CallExpression(node){if(!currentFunctionNode)return;const operation=getSensitiveOperationName(node);if(operation){sensitiveOperations.push({node,operation})}},ReturnStatement(node){if(!currentFunctionNode)return;if(node.argument?.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){for(const prop of node.argument.properties){if(prop.type===eslint_devkit_1.AST_NODE_TYPES.Property&&prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&prop.key.name==="statusCode"&&prop.value.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&(prop.value.value===401||prop.value.value===403)){hasAuthCheck=true}}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noOverlyPermissiveIamPolicy=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const POLICY_PROPERTIES=new Set(["Resource","Action","Principal"]);const DANGEROUS_WILDCARDS=new Set(["*","arn:aws:*","arn:*:*:*:*:*"]);exports.noOverlyPermissiveIamPolicy=(0,eslint_devkit_1.createRule)({name:"no-overly-permissive-iam-policy",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-overly-permissive-iam-policy.md",description:"Detects IAM policies with overly broad permissions (wildcards)",cwe:"CWE-732",cvss:6.5},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noOverlyPermissiveIamPolicy=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const POLICY_PROPERTIES=new Set(["Resource","Action","Principal"]);const DANGEROUS_WILDCARDS=new Set(["*","arn:aws:*","arn:*:*:*:*:*"]);exports.noOverlyPermissiveIamPolicy=(0,eslint_devkit_1.createRule)({name:"no-overly-permissive-iam-policy",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-overly-permissive-iam-policy.md",description:"Detects IAM policies with overly broad permissions (wildcards)",cwe:"CWE-732",cvss:6.5},messages:{permissivePolicy:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Overly Permissive IAM Policy",cwe:"CWE-732",cvss:6.5,description:'IAM policy has wildcard {{property}}: "{{value}}". Violates principle of least privilege.',severity:"HIGH",fix:'Restrict {{property}} to specific resources/actions. Example: "arn:aws:s3:::my-bucket/*" instead of "*"',documentationLink:"https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}function isDangerousWildcard(value){return DANGEROUS_WILDCARDS.has(value)||value.endsWith("*")&&value.includes(":*:")}function checkPolicyProperty(node,propertyName){const value=node.value;const staticText=(0,eslint_devkit_1.staticString)(value);if(staticText!==null){if(isDangerousWildcard(staticText)){context.report({node,messageId:"permissivePolicy",data:{property:propertyName,value:staticText}})}}if(value.type===eslint_devkit_1.AST_NODE_TYPES.ArrayExpression){for(const element of value.elements){if(element?.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof element.value==="string"){if(isDangerousWildcard(element.value)){context.report({node:element,messageId:"permissivePolicy",data:{property:propertyName,value:element.value}})}}}}}return{Property(node){if(node.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const keyName=node.key.name;if(POLICY_PROPERTIES.has(keyName)){checkPolicyProperty(node,keyName)}}if(node.key.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof node.key.value==="string"){const keyName=node.key.value;if(POLICY_PROPERTIES.has(keyName)){checkPolicyProperty(node,keyName)}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noPermissiveCorsMidly=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");exports.noPermissiveCorsMidly=(0,eslint_devkit_1.createRule)({name:"no-permissive-cors-middy",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-permissive-cors-middy.md",description:"Detects @middy/http-cors middleware with permissive origin (*)",cwe:"CWE-942",cvss:7.5},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noPermissiveCorsMidly=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");exports.noPermissiveCorsMidly=(0,eslint_devkit_1.createRule)({name:"no-permissive-cors-middy",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-permissive-cors-middy.md",description:"Detects @middy/http-cors middleware with permissive origin (*)",cwe:"CWE-942",cvss:7.5},messages:{permissiveCors:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Permissive CORS in Middy",cwe:"CWE-942",description:"Wildcard CORS origin in @middy/http-cors allows any domain",severity:"HIGH",fix:'Use specific origins: httpCors({ origins: ["https://your-domain.com"] })',documentationLink:"https://middy.js.org/docs/middlewares/http-cors"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}function isCorsMiddlewareCall(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const name=node.callee.name.toLowerCase();return name==="httpcors"||name==="cors"}return false}function checkCorsOptions(node,optionsObj){for(const prop of optionsObj.properties){if(prop.type!==eslint_devkit_1.AST_NODE_TYPES.Property)continue;if(prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const keyName=prop.key.name.toLowerCase();if(keyName==="origin"||keyName==="origins"){if(prop.value.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&prop.value.value==="*"){context.report({node:prop,messageId:"permissiveCors"})}else if(prop.value.type===eslint_devkit_1.AST_NODE_TYPES.ArrayExpression){for(const element of prop.value.elements){if(element?.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&element.value==="*"){context.report({node:element,messageId:"permissiveCors"})}}}}}}}return{CallExpression(node){if(!isCorsMiddlewareCall(node))return;if(node.arguments.length===0){context.report({node,messageId:"permissiveCors"});return}if(node.arguments[0]?.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){checkCorsOptions(node,node.arguments[0])}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noPermissiveCorsResponse=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");exports.noPermissiveCorsResponse=(0,eslint_devkit_1.createRule)({name:"no-permissive-cors-response",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-permissive-cors-response.md",description:"Detects permissive CORS (Access-Control-Allow-Origin: *) in Lambda response headers",cwe:"CWE-942",cvss:7.5},fixable:"code",messages:{permissiveCors:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Permissive CORS in Lambda Response",cwe:"CWE-942",description:"Wildcard CORS origin (*) allows any domain to access this Lambda function",severity:"HIGH",fix:'Use specific origins: headers: { "Access-Control-Allow-Origin": "https://your-domain.com" }',documentationLink:"https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html"}),useSpecificOrigin:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Specific Origin",description:"Specify allowed origins instead of wildcard",severity:"LOW",fix:'Replace "*" with specific domain(s)',documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true,description:"Allow permissive CORS in test files"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noPermissiveCorsResponse=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");exports.noPermissiveCorsResponse=(0,eslint_devkit_1.createRule)({name:"no-permissive-cors-response",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-permissive-cors-response.md",description:"Detects permissive CORS (Access-Control-Allow-Origin: *) in Lambda response headers",cwe:"CWE-942",cvss:7.5},fixable:"code",messages:{permissiveCors:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Permissive CORS in Lambda Response",cwe:"CWE-942",description:"Wildcard CORS origin (*) allows any domain to access this Lambda function",severity:"HIGH",fix:'Use specific origins: headers: { "Access-Control-Allow-Origin": "https://your-domain.com" }',documentationLink:"https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html"}),useSpecificOrigin:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Specific Origin",description:"Specify allowed origins instead of wildcard",severity:"LOW",fix:'Replace "*" with specific domain(s)',documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true,description:"Allow permissive CORS in test files"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}function isLambdaResponse(obj){const propNames=obj.properties.filter(p=>p.type===eslint_devkit_1.AST_NODE_TYPES.Property).map(p=>p.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier?p.key.name:"");return propNames.includes("statusCode")||propNames.includes("body")}function checkHeadersObject(obj){for(const prop of obj.properties){if(prop.type!==eslint_devkit_1.AST_NODE_TYPES.Property)continue;let headerName="";if(prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){headerName=prop.key.name}else{headerName=(0,eslint_devkit_1.staticString)(prop.key)??""}if(headerName.toLowerCase()==="access-control-allow-origin"){if(prop.value.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&prop.value.value==="*"){context.report({node:prop,messageId:"permissiveCors",fix:fixer=>{return fixer.replaceText(prop.value,'"https://your-domain.com"')}})}}}}function checkResponseObject(obj){if(!isLambdaResponse(obj))return;for(const prop of obj.properties){if(prop.type===eslint_devkit_1.AST_NODE_TYPES.Property&&prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&prop.key.name==="headers"&&prop.value.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){checkHeadersObject(prop.value)}}}return{ReturnStatement(node){if(node.argument?.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){checkResponseObject(node.argument)}},ArrowFunctionExpression(node){if(node.body.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){checkResponseObject(node.body)}},VariableDeclarator(node){if(node.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.id.name.toLowerCase().includes("response")&&node.init?.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){checkResponseObject(node.init)}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noSecretsInEnv=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");const SECRET_PATTERNS=[/password/i,/secret/i,/api[_-]?key/i,/api[_-]?token/i,/auth[_-]?token/i,/access[_-]?token/i,/private[_-]?key/i,/encryption[_-]?key/i,/db[_-]?pass/i,/database[_-]?password/i,/jwt[_-]?secret/i,/signing[_-]?key/i,/client[_-]?secret/i,/aws[_-]?secret/i];exports.noSecretsInEnv=(0,eslint_devkit_1.createRule)({name:"no-secrets-in-env",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-secrets-in-env.md",description:"Detects secrets directly assigned to environment variables",cwe:"CWE-798",cvss:9.8},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noSecretsInEnv=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const lambda_evidence_1=require("../../utils/lambda-evidence");const SECRET_PATTERNS=[/password/i,/secret/i,/api[_-]?key/i,/api[_-]?token/i,/auth[_-]?token/i,/access[_-]?token/i,/private[_-]?key/i,/encryption[_-]?key/i,/db[_-]?pass/i,/database[_-]?password/i,/jwt[_-]?secret/i,/signing[_-]?key/i,/client[_-]?secret/i,/aws[_-]?secret/i];exports.noSecretsInEnv=(0,eslint_devkit_1.createRule)({name:"no-secrets-in-env",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-secrets-in-env.md",description:"Detects secrets directly assigned to environment variables",cwe:"CWE-798",cvss:9.8},messages:{secretsInEnv:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Secret in Environment Variable",cwe:"CWE-798",description:'Secret "{{varName}}" should not be hardcoded in environment variables',severity:"CRITICAL",fix:'Use AWS Secrets Manager: const secret = await secretsClient.send(new GetSecretValueCommand({ SecretId: "{{varName}}" }))',documentationLink:"https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true},additionalPatterns:{type:"array",items:{type:"string"},default:[],description:"Extra environment-variable name patterns to treat as secrets"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true,additionalPatterns:[]}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true,additionalPatterns=[]}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}const allPatterns=[...SECRET_PATTERNS,...additionalPatterns.map(p=>new RegExp(p,"i"))];function isSecretName(name){return allPatterns.some(pattern=>pattern.test(name))}function isHardcodedSecretValue(node){const staticText=(0,eslint_devkit_1.staticString)(node);if(staticText!==null){return staticText.length>5}if(node.type===eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral){return node.quasis.some(quasi=>quasi.value.raw.length>5)}return false}return{AssignmentExpression(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.object.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.object.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.left.object.object.name==="process"&&node.left.object.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.left.object.property.name==="env"){let envVarName="";if(node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){envVarName=node.left.property.name}else{envVarName=(0,eslint_devkit_1.staticString)(node.left.property)??""}if(isSecretName(envVarName)&&isHardcodedSecretValue(node.right)){context.report({node,messageId:"secretsInEnv",data:{varName:envVarName}})}}},Property(node){let propName="";if(node.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){propName=node.key.name}else{propName=(0,eslint_devkit_1.staticString)(node.key)??""}if(isSecretName(propName)&&isHardcodedSecretValue(node.value)){let parent=node.parent;while(parent){if(parent.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){parent=parent.parent;continue}if(parent.type===eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator&&parent.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&/env|config|settings/i.test(parent.id.name)){context.report({node,messageId:"secretsInEnv",data:{varName:propName}});break}break}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnboundedBatchProcessing=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const BATCH_SOURCE_PROPERTIES=new Set(["Records","records","items","messages"]);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnboundedBatchProcessing=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const handler_params_1=require("../../utils/handler-params");const eslint_devkit_1=require("@interlace/eslint-devkit");const BATCH_SOURCE_PROPERTIES=new Set(["Records","records","items","messages"]);exports.noUnboundedBatchProcessing=(0,eslint_devkit_1.createRule)({name:"no-unbounded-batch-processing",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-unbounded-batch-processing.md",description:"Detects processing batch records without size validation",cwe:"CWE-770",cvss:5.5},messages:{unboundedBatch:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Unbounded Batch Processing",cwe:"CWE-770",cvss:5.5,description:"Processing {{source}} without size check. Large batches may cause timeout or memory exhaustion.",severity:"MEDIUM",fix:'Validate batch size before processing: if (event.Records.length > MAX_BATCH) throw new Error("Batch too large")',documentationLink:"https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html"})},schema:[{type:"object",properties:{...handler_params_1.HANDLER_PARAM_SCHEMA,allowInTests:{type:"boolean",default:true},maxBatchSize:{type:"number",default:100,description:"Batch size above which processing must be explicitly bounded"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true,maxBatchSize:100}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const eventParamNames=new Set(options.eventParamNames??handler_params_1.DEFAULT_EVENT_PARAM_NAMES);const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}let currentHandlerNode=null;let hasBatchSizeCheck=false;const batchAccessNodes=[];const eventParamName=[];function enterFunction(node){const hasEvent=node.params.some(p=>{if(p.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&eventParamNames.has(p.name)){eventParamName.push(p.name);return true}return false});if(hasEvent){currentHandlerNode=node;hasBatchSizeCheck=false;batchAccessNodes.length=0}}function exitFunction(node){if(currentHandlerNode!==node)return;if(!hasBatchSizeCheck){for(const{node:batchNode,source}of batchAccessNodes){context.report({node:batchNode,messageId:"unboundedBatch",data:{source}})}}currentHandlerNode=null;eventParamName.length=0}return{"ArrowFunctionExpression, FunctionExpression, FunctionDeclaration"(node){enterFunction(node)},"ArrowFunctionExpression:exit"(node){exitFunction(node)},"FunctionExpression:exit"(node){exitFunction(node)},"FunctionDeclaration:exit"(node){exitFunction(node)},MemberExpression(node){if(!currentHandlerNode)return;if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&eventParamName.includes(node.object.name)&&node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&BATCH_SOURCE_PROPERTIES.has(node.property.name)){batchAccessNodes.push({node,source:`${node.object.name}.${node.property.name}`})}if(node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.property.name==="length"){if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.object.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&BATCH_SOURCE_PROPERTIES.has(node.object.property.name)){hasBatchSizeCheck=true}}},CallExpression(node){if(!currentHandlerNode)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&["slice","splice","take","chunk"].includes(node.callee.property.name)){hasBatchSizeCheck=true}if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&["slice","splice","take","chunk"].includes(node.callee.name)){hasBatchSizeCheck=true}},BinaryExpression(node){if(!currentHandlerNode)return;if(["<","<=",">",">="].includes(node.operator)){const sourceCode=context.sourceCode;const text=sourceCode.getText(node);if(/\.length|Records|records/.test(text)){hasBatchSizeCheck=true}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnvalidatedEventBody=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_EVENT_PROPERTIES=["body","queryStringParameters","pathParameters","multiValueQueryStringParameters","headers","multiValueHeaders","rawPath","rawQueryString"];const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnvalidatedEventBody=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_EVENT_PROPERTIES=["body","queryStringParameters","pathParameters","multiValueQueryStringParameters","headers","multiValueHeaders","rawPath","rawQueryString"];const DEFAULT_VALIDATION_METHOD_NAMES=["validator","httpJsonBodyParser","@middy/validator","parse","validate","parseAsync","safeParse","safeParseAsync","assert","is"];exports.noUnvalidatedEventBody=(0,eslint_devkit_1.createRule)({name:"no-unvalidated-event-body",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-unvalidated-event-body.md",description:"Detects Lambda handlers using event body/params without validation",cwe:"CWE-20",cvss:8},messages:{unvalidatedInput:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Unvalidated Event Input",cwe:"CWE-20",cvss:8,description:"Lambda handler uses {{property}} without validation. This can lead to injection attacks.",severity:"HIGH",fix:"Validate event input using Middy validator, Zod, or Joi before use",documentationLink:"https://owasp.org/www-project-serverless-top-10/"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true,description:"Allow unvalidated input in test files"},additionalProperties:{type:"array",items:{type:"string"},default:[],description:"Additional event properties to check"},validationMethodNames:{type:"array",items:{type:"string"},default:[...DEFAULT_VALIDATION_METHOD_NAMES],description:"Method names that count as validating a value. Replaces the default."}},additionalProperties:false}]},defaultOptions:[{allowInTests:true,additionalProperties:[]}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true,additionalProperties=[],validationMethodNames:configuredValidationMethods}=options;const validationMethodNames=new Set(configuredValidationMethods??DEFAULT_VALIDATION_METHOD_NAMES);const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}const dangerousProperties=new Set([...DANGEROUS_EVENT_PROPERTIES,...additionalProperties]);const validatedVariables=new Set;const eventParameters=new Set;let hasValidationMiddleware=false;function isValidationCall(node){if(node.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){const property=node.callee.property;if(property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&validationMethodNames.has(property.name)){return true}}if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){if(validationMethodNames.has(node.callee.name)){return true}}}return false}function isEventPropertyAccess(node){if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&eventParameters.has(node.object.name)&&node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&dangerousProperties.has(node.property.name)){return{eventName:node.object.name,property:node.property.name}}return null}function semanticParent(node){let current=node;let parent=current.parent;while(parent&&(parent.type===eslint_devkit_1.AST_NODE_TYPES.LogicalExpression||parent.type===eslint_devkit_1.AST_NODE_TYPES.TSAsExpression||parent.type===eslint_devkit_1.AST_NODE_TYPES.TSNonNullExpression)){current=parent;parent=current.parent}return parent}const sourceCode=context.sourceCode;const fileImportsLambda=sourceCode.ast.body.some(n=>{if(n.type!==eslint_devkit_1.AST_NODE_TYPES.ImportDeclaration)return false;const src=String(n.source.value);return src==="aws-lambda"||src.startsWith("@aws-sdk/")||src.startsWith("@middy/")||src==="@aws-cdk/aws-lambda"});function isExportedAsHandler(node){if(node.type===eslint_devkit_1.AST_NODE_TYPES.FunctionDeclaration&&node.id?.name==="handler"){return true}const parent=node.parent;if(!parent)return false;if(parent.type===eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator&&parent.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&parent.id.name==="handler"){return true}if(parent.type===eslint_devkit_1.AST_NODE_TYPES.AssignmentExpression){const left=parent.left;if(left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&left.property.name==="handler"){return true}}return false}function isLambdaSignature(params,node){if(params.length<1)return false;const first=params[0];if(first.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier)return false;const second=params[1];const hasContextSibling=second?.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&(second.name==="context"||second.name==="callback");const looksLikeExpress=second?.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&(first.name==="req"&&second.name==="res"||first.name==="request"&&second.name==="response");if(looksLikeExpress)return false;const isEventName=first.name==="event"||first.name==="evt";if(isEventName&&hasContextSibling)return true;if(isEventName&&fileImportsLambda)return true;if(isExportedAsHandler(node)){const allowedHandlerParam=["event","evt","e","request","req"];if(allowedHandlerParam.includes(first.name))return true}return false}return{"ArrowFunctionExpression, FunctionExpression, FunctionDeclaration"(node){if(!isLambdaSignature(node.params,node))return;const first=node.params[0];eventParameters.add(first.name)},CallExpression(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="use"){for(const arg of node.arguments){if(arg.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&arg.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&["validator","httpJsonBodyParser"].includes(arg.callee.name)){hasValidationMiddleware=true}}}if(isValidationCall(node)){const parent=node.parent;if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator&&parent.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){validatedVariables.add(parent.id.name)}}},MemberExpression(node){if(hasValidationMiddleware)return;const eventAccess=isEventPropertyAccess(node);if(!eventAccess)return;const parent=semanticParent(node);if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&isValidationCall(parent)){return}if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.UnaryExpression&&parent.operator==="typeof"){return}if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.IfStatement||parent?.type===eslint_devkit_1.AST_NODE_TYPES.ConditionalExpression){return}if(node.optional){return}if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&parent.optional){return}if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.ChainExpression){return}if(parent?.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&parent.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&parent.callee.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&parent.callee.object.name==="console"){return}context.report({node,messageId:"unvalidatedInput",data:{property:`event.${eventAccess.property}`}})}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUserControlledRequests=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const HTTP_CLIENT_METHODS=new Set(["fetch","request","get","post","put","delete","patch","axios","got","nodeFetch","superagent"]);const HTTP_CLIENT_OBJECTS=new Set(["http","https","axios","got","request"]);const USER_INPUT_PROPERTIES=new Set(["body","queryStringParameters","pathParameters","multiValueQueryStringParameters","headers","rawPath","rawQueryString"]);const EVENT_PARAM_NAMES=new Set(["event","evt","e","request","req"]);exports.noUserControlledRequests=(0,eslint_devkit_1.createRule)({name:"no-user-controlled-requests",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-user-controlled-requests.md",description:"Detects HTTP requests with user-controlled URLs (SSRF vulnerability)",cwe:"CWE-918",cvss:9.1},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUserControlledRequests=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const eslint_devkit_1=require("@interlace/eslint-devkit");const HTTP_CLIENT_METHODS=new Set(["fetch","request","get","post","put","delete","patch","axios","got","nodeFetch","superagent"]);const HTTP_CLIENT_OBJECTS=new Set(["http","https","axios","got","request"]);const USER_INPUT_PROPERTIES=new Set(["body","queryStringParameters","pathParameters","multiValueQueryStringParameters","headers","rawPath","rawQueryString"]);const EVENT_PARAM_NAMES=new Set(["event","evt","e","request","req"]);exports.noUserControlledRequests=(0,eslint_devkit_1.createRule)({name:"no-user-controlled-requests",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/no-user-controlled-requests.md",description:"Detects HTTP requests with user-controlled URLs (SSRF vulnerability)",cwe:"CWE-918",cvss:9.1},messages:{ssrfVulnerability:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Server-Side Request Forgery (SSRF)",cwe:"CWE-918",cvss:9.1,description:"HTTP request URL contains user-controlled input from {{source}}. Attackers can access internal services or exfiltrate data.",severity:"CRITICAL",fix:"Validate URL against allowlist before making request. Never use user input directly in URLs.",documentationLink:"https://owasp.org/www-community/attacks/Server_Side_Request_Forgery"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true,description:"Allow user-controlled URLs in test files"}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}const eventParameters=new Set;const taintedVariables=new Map;function isEventParameter(name){return eventParameters.has(name)}function getEventInputSource(node){if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&isEventParameter(node.object.name)&&node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&USER_INPUT_PROPERTIES.has(node.property.name)){return`event.${node.property.name}`}if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.object.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&isEventParameter(node.object.object.name)&&node.object.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&USER_INPUT_PROPERTIES.has(node.object.property.name)){return`event.${node.object.property.name}.${node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier?node.property.name:"[...]"}`}return null}function getTaintSource(node){if(node.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){const source=getEventInputSource(node);if(source)return source}if(node.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const source=taintedVariables.get(node.name);if(source)return source}if(node.type===eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral){for(const expr of node.expressions){const source=getTaintSource(expr);if(source)return source}}if(node.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression){const leftSource=getTaintSource(node.left);if(leftSource)return leftSource;const rightSource=getTaintSource(node.right);if(rightSource)return rightSource}return null}function isHttpClientCall(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&HTTP_CLIENT_METHODS.has(node.callee.name)){return true}if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&HTTP_CLIENT_OBJECTS.has(node.callee.object.name)){return true}if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&["get","post","put","delete","patch","request"].includes(node.callee.property.name)){return true}return false}function checkUrlArgument(node){if(node.arguments.length===0)return null;const urlArg=node.arguments[0];const source=getTaintSource(urlArg);if(source){return{tainted:true,source}}if(urlArg.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){for(const prop of urlArg.properties){if(prop.type===eslint_devkit_1.AST_NODE_TYPES.Property&&prop.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&["url","uri","href","baseURL"].includes(prop.key.name)){const propSource=getTaintSource(prop.value);if(propSource){return{tainted:true,source:propSource}}}}}return null}return{"ArrowFunctionExpression, FunctionExpression, FunctionDeclaration"(node){for(const param of node.params){if(param.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){if(EVENT_PARAM_NAMES.has(param.name)){eventParameters.add(param.name)}}}},VariableDeclarator(node){if(node.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.init){const source=getTaintSource(node.init);if(source){taintedVariables.set(node.id.name,source)}}},AssignmentExpression(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const source=getTaintSource(node.right);if(source){taintedVariables.set(node.left.name,source)}}},CallExpression(node){if(!isHttpClientCall(node))return;const result=checkUrlArgument(node);if(result?.tainted){context.report({node,messageId:"ssrfVulnerability",data:{source:result.source}})}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireTimeoutHandling=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireTimeoutHandling=void 0;const lambda_evidence_1=require("../../utils/lambda-evidence");const handler_params_1=require("../../utils/handler-params");const eslint_devkit_1=require("@interlace/eslint-devkit");const EXTERNAL_CALL_PATTERNS=new Set(["fetch","axios","got","request","send","invoke","query","execute","connect","promise","wait"]);exports.requireTimeoutHandling=(0,eslint_devkit_1.createRule)({name:"require-timeout-handling",meta:{type:"suggestion",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-lambda-security/docs/rules/require-timeout-handling.md",description:"Warns when Lambda handlers with external calls lack timeout handling",cwe:"CWE-400",cvss:6},messages:{missingTimeoutHandling:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Missing Timeout Handling",cwe:"CWE-400",cvss:6,description:"Lambda handler makes external calls without timeout handling. Function may timeout without cleanup.",severity:"MEDIUM",fix:"Use context.getRemainingTimeInMillis() to check available time before external calls, or use AbortController",documentationLink:"https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html"})},schema:[{type:"object",properties:{...handler_params_1.HANDLER_PARAM_SCHEMA,contextParamNames:{type:"array",items:{type:"string"},default:[...handler_params_1.DEFAULT_CONTEXT_PARAM_NAMES],description:"Parameter names that identify the Lambda context argument. Replaces the default."},allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){if(!(0,lambda_evidence_1.fileIsLambda)(context.sourceCode.ast))return{};const eventParamNames=new Set(options.eventParamNames??handler_params_1.DEFAULT_EVENT_PARAM_NAMES);const contextParamNames=new Set(options.contextParamNames??handler_params_1.DEFAULT_CONTEXT_PARAM_NAMES);const{allowInTests=true}=options;const filename=context.filename;const isTestFile=(0,eslint_devkit_1.isTestFilePath)(filename);if(allowInTests&&isTestFile){return{}}let currentHandlerNode=null;let hasTimeoutCheck=false;let hasExternalCalls=false;let hasContextParam=false;function enterFunction(node){const params=node.params;const hasEvent=params.some(p=>p.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&eventParamNames.has(p.name));const hasContext=params.some(p=>p.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&contextParamNames.has(p.name));if(hasEvent){currentHandlerNode=node;hasTimeoutCheck=false;hasExternalCalls=false;hasContextParam=hasContext}}function exitFunction(node){if(currentHandlerNode!==node)return;if(hasExternalCalls&&!hasTimeoutCheck&&hasContextParam){context.report({node,messageId:"missingTimeoutHandling"})}currentHandlerNode=null}return{"ArrowFunctionExpression, FunctionExpression, FunctionDeclaration"(node){enterFunction(node)},"ArrowFunctionExpression:exit"(node){exitFunction(node)},"FunctionExpression:exit"(node){exitFunction(node)},"FunctionDeclaration:exit"(node){exitFunction(node)},MemberExpression(node){if(!currentHandlerNode)return;if(node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.property.name==="getRemainingTimeInMillis"){hasTimeoutCheck=true}},NewExpression(node){if(!currentHandlerNode)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.name==="AbortController"){hasTimeoutCheck=true}},CallExpression(node){if(!currentHandlerNode)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){if(EXTERNAL_CALL_PATTERNS.has(node.callee.name)){hasExternalCalls=true}}if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){const property=node.callee.property;if(property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&EXTERNAL_CALL_PATTERNS.has(property.name)){hasExternalCalls=true}}if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.object.name==="Promise"&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="race"){hasTimeoutCheck=true}}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.HANDLER_PARAM_SCHEMA=exports.DEFAULT_CONTEXT_PARAM_NAMES=exports.DEFAULT_EVENT_PARAM_NAMES=void 0;exports.DEFAULT_EVENT_PARAM_NAMES=["event","evt","e","request","req"];exports.DEFAULT_CONTEXT_PARAM_NAMES=["context","ctx","lambdaContext"];exports.HANDLER_PARAM_SCHEMA={eventParamNames:{type:"array",items:{type:"string"},default:[...exports.DEFAULT_EVENT_PARAM_NAMES],description:"Parameter names that identify the Lambda event argument. Replaces the default."}};
|