eslint-plugin-lambda-security 2.0.1 → 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 +55 -58
- package/package.json +2 -2
- package/src/index.js +1 -1
- package/src/rules/no-exposed-debug-endpoints/index.js +1 -1
- package/src/rules/no-hardcoded-credentials-sdk/index.js +1 -1
- package/src/rules/no-overly-permissive-iam-policy/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/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">
|
|
@@ -27,57 +27,25 @@
|
|
|
27
27
|
|
|
28
28
|
This plugin provides Security best practices for AWS Lambda functions (IAM, timeouts, environment).
|
|
29
29
|
|
|
30
|
-
## Philosophy
|
|
31
|
-
|
|
32
|
-
**Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
|
|
33
|
-
|
|
34
30
|
<!-- AUTO-GENERATED:DOCTRINE:START - Do not edit manually -->
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
That is a trade, and it is made deliberately. It costs recall, and we measure what it
|
|
44
|
-
costs rather than assuming it is free.
|
|
45
|
-
|
|
46
|
-
## How the rules decide
|
|
47
|
-
|
|
48
|
-
**Evidence, not names.** A rule fires on what the code *does*, resolved through the
|
|
49
|
-
AST and ESLint's own scope analysis — not on an identifier that happens to contain
|
|
50
|
-
`query`, a method called `setItem`, or a file whose path contains `key`. Every one of
|
|
51
|
-
those was a real false positive in this ecosystem, found by reading our own output on
|
|
52
|
-
open-source projects and fixed with a test that fails on the unfixed rule.
|
|
53
|
-
|
|
54
|
-
Where a rule has known false-positive shapes, its page carries a **Not a finding**
|
|
55
|
-
section: what it deliberately stays quiet on, and what to check first when it fires
|
|
56
|
-
and you disagree.
|
|
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.
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
structured JSON for an agent. Install it, enable
|
|
63
|
-
`recommended`, and read the findings. If one of them is wrong,
|
|
64
|
-
[open an issue](https://github.com/ofri-peretz/eslint/issues) — a false positive is a
|
|
65
|
-
bug here, not a tuning exercise for you.
|
|
66
|
-
|
|
67
|
-
How that is measured, on which projects, and where it falls short:
|
|
68
|
-
[benchmark methodology](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-METHODOLOGY.md)
|
|
69
|
-
and [results](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-RESULTS.md).
|
|
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).
|
|
70
43
|
|
|
71
44
|
<!-- AUTO-GENERATED:DOCTRINE:END -->
|
|
72
45
|
|
|
73
46
|
## Getting Started
|
|
74
47
|
|
|
75
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). 📚
|
|
76
|
-
- 要查看中文 [指南](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). 📚
|
|
77
|
-
- [가이드](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)에서 확인하실 수 있습니다. 📚
|
|
78
|
-
- [ガイド](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)でご確認ください。 📚
|
|
79
|
-
- 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). 📚
|
|
80
|
-
- للاطلاع على [الدليل](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). 📚
|
|
81
49
|
|
|
82
50
|
```bash
|
|
83
51
|
npm install eslint-plugin-lambda-security --save-dev
|
|
@@ -182,23 +150,52 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
182
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) | 🟢 | 💼 | | | | |
|
|
183
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 | 🟢 | | ⚠️ | | | |
|
|
184
152
|
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
153
|
+
<!-- AUTO-GENERATED:ECOSYSTEM_TABLE:START - Do not edit manually -->
|
|
154
|
+
|
|
185
155
|
## 🔗 Related ESLint Plugins
|
|
186
156
|
|
|
187
|
-
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**
|
|
188
185
|
|
|
189
186
|
| Plugin | Downloads | Description |
|
|
190
187
|
| :--- | :---: | :--- |
|
|
191
|
-
| [`eslint-plugin-
|
|
192
|
-
| [`eslint-plugin-
|
|
193
|
-
| [`eslint-plugin-
|
|
194
|
-
| [`eslint-plugin-
|
|
195
|
-
| [`eslint-plugin-
|
|
196
|
-
| [`eslint-plugin-
|
|
197
|
-
| [`eslint-plugin-
|
|
198
|
-
| [`eslint-plugin-
|
|
199
|
-
| [`eslint-plugin-
|
|
200
|
-
|
|
201
|
-
|
|
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 -->
|
|
202
199
|
|
|
203
200
|
<!-- INTERLACE:STAR_CTA:START -->
|
|
204
201
|
## ⭐ Support & follow
|
|
@@ -218,5 +215,5 @@ MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
|
218
215
|
</p>
|
|
219
216
|
|
|
220
217
|
<p align="center">
|
|
221
|
-
<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>
|
|
222
219
|
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-lambda-security",
|
|
3
|
-
"version": "2.0
|
|
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;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.0
|
|
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.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.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)){
|
|
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.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;
|
|
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.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
|
|
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},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){
|
|
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.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."}};
|