eslint-plugin-lambda-security 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +54 -35
  3. package/package.json +3 -12
  4. package/src/index.d.ts +58 -20
  5. package/src/index.js +70 -3
  6. package/src/rules/no-env-logging/index.d.ts +17 -1
  7. package/src/rules/no-env-logging/index.js +5 -0
  8. package/src/rules/no-error-swallowing/index.d.ts +24 -0
  9. package/src/rules/no-error-swallowing/index.js +197 -0
  10. package/src/rules/no-exposed-error-details/index.d.ts +22 -0
  11. package/src/rules/no-exposed-error-details/index.js +161 -0
  12. package/src/rules/no-hardcoded-credentials-sdk/index.d.ts +18 -1
  13. package/src/rules/no-hardcoded-credentials-sdk/index.js +5 -0
  14. package/src/rules/no-missing-authorization-check/index.d.ts +24 -0
  15. package/src/rules/no-missing-authorization-check/index.js +220 -0
  16. package/src/rules/no-overly-permissive-iam-policy/index.d.ts +22 -0
  17. package/src/rules/no-overly-permissive-iam-policy/index.js +139 -0
  18. package/src/rules/no-permissive-cors-middy/index.d.ts +18 -1
  19. package/src/rules/no-permissive-cors-middy/index.js +5 -0
  20. package/src/rules/no-permissive-cors-response/index.d.ts +18 -1
  21. package/src/rules/no-permissive-cors-response/index.js +5 -0
  22. package/src/rules/no-secrets-in-env/index.d.ts +18 -1
  23. package/src/rules/no-secrets-in-env/index.js +5 -0
  24. package/src/rules/no-unbounded-batch-processing/index.d.ts +24 -0
  25. package/src/rules/no-unbounded-batch-processing/index.js +170 -0
  26. package/src/rules/no-unvalidated-event-body/index.d.ts +24 -0
  27. package/src/rules/no-unvalidated-event-body/index.js +270 -0
  28. package/src/rules/no-user-controlled-requests/index.d.ts +22 -0
  29. package/src/rules/no-user-controlled-requests/index.js +267 -0
  30. package/src/rules/require-timeout-handling/index.d.ts +22 -0
  31. package/src/rules/require-timeout-handling/index.js +171 -0
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noUnvalidatedEventBody = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ // Properties on 'event' that contain untrusted user input
11
+ const DANGEROUS_EVENT_PROPERTIES = [
12
+ 'body',
13
+ 'queryStringParameters',
14
+ 'pathParameters',
15
+ 'multiValueQueryStringParameters',
16
+ 'headers',
17
+ 'multiValueHeaders',
18
+ 'rawPath',
19
+ 'rawQueryString',
20
+ ];
21
+ // Property accesses that indicate validation
22
+ const VALIDATION_INDICATORS = [
23
+ // Middy validators
24
+ 'validator',
25
+ 'httpJsonBodyParser',
26
+ '@middy/validator',
27
+ // Schema libraries
28
+ 'parse', // zod.parse()
29
+ 'validate', // joi.validate(), yup.validate()
30
+ 'parseAsync', // zod.parseAsync()
31
+ 'safeParse',
32
+ 'safeParseAsync',
33
+ 'assert', // superstruct.assert()
34
+ 'is', // superstruct.is()
35
+ ];
36
+ exports.noUnvalidatedEventBody = (0, eslint_devkit_1.createRule)({
37
+ name: 'no-unvalidated-event-body',
38
+ meta: {
39
+ type: 'problem',
40
+ docs: {
41
+ description: 'Detects Lambda handlers using event body/params without validation',
42
+ },
43
+ hasSuggestions: true,
44
+ messages: {
45
+ unvalidatedInput: (0, eslint_devkit_1.formatLLMMessage)({
46
+ icon: eslint_devkit_1.MessageIcons.SECURITY,
47
+ issueName: 'Unvalidated Event Input',
48
+ cwe: 'CWE-20',
49
+ cvss: 8.0,
50
+ description: 'Lambda handler uses {{property}} without validation. This can lead to injection attacks.',
51
+ severity: 'HIGH',
52
+ fix: 'Validate event input using Middy validator, Zod, or Joi before use',
53
+ documentationLink: 'https://owasp.org/www-project-serverless-top-10/',
54
+ }),
55
+ useValidation: (0, eslint_devkit_1.formatLLMMessage)({
56
+ icon: eslint_devkit_1.MessageIcons.INFO,
57
+ issueName: 'Add Input Validation',
58
+ description: 'Add input validation using Middy validator middleware or a schema library',
59
+ severity: 'LOW',
60
+ fix: "import { validator } from '@middy/validator'; middy(handler).use(validator({ inputSchema }))",
61
+ documentationLink: 'https://middy.js.org/docs/middlewares/validator',
62
+ }),
63
+ },
64
+ schema: [
65
+ {
66
+ type: 'object',
67
+ properties: {
68
+ allowInTests: {
69
+ type: 'boolean',
70
+ default: true,
71
+ description: 'Allow unvalidated input in test files',
72
+ },
73
+ additionalProperties: {
74
+ type: 'array',
75
+ items: { type: 'string' },
76
+ default: [],
77
+ description: 'Additional event properties to check',
78
+ },
79
+ },
80
+ additionalProperties: false,
81
+ },
82
+ ],
83
+ },
84
+ defaultOptions: [
85
+ {
86
+ allowInTests: true,
87
+ additionalProperties: [],
88
+ },
89
+ ],
90
+ create(context, [options = {}]) {
91
+ const { allowInTests = true, additionalProperties = [] } = options;
92
+ const filename = context.filename || context.getFilename();
93
+ const isTestFile = /\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);
94
+ if (allowInTests && isTestFile) {
95
+ return {};
96
+ }
97
+ const dangerousProperties = [
98
+ ...DANGEROUS_EVENT_PROPERTIES,
99
+ ...additionalProperties,
100
+ ];
101
+ // Track which variables have been validated
102
+ const validatedVariables = new Set();
103
+ // Track which event parameters we're monitoring
104
+ const eventParameters = new Set();
105
+ // Track if we're inside a handler that uses validation middleware
106
+ let hasValidationMiddleware = false;
107
+ /**
108
+ * Check if an expression indicates validation has occurred
109
+ */
110
+ function isValidationCall(node) {
111
+ if (node.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression) {
112
+ // Check for schema.parse(x), schema.validate(x), etc.
113
+ if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression) {
114
+ const property = node.callee.property;
115
+ if (property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
116
+ VALIDATION_INDICATORS.includes(property.name)) {
117
+ return true;
118
+ }
119
+ }
120
+ // Check for direct function calls like validate(x)
121
+ if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
122
+ if (VALIDATION_INDICATORS.includes(node.callee.name)) {
123
+ return true;
124
+ }
125
+ }
126
+ }
127
+ return false;
128
+ }
129
+ /**
130
+ * Check if this is an event parameter access (e.g., event.body)
131
+ */
132
+ function isEventPropertyAccess(node) {
133
+ if (node.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
134
+ eventParameters.has(node.object.name) &&
135
+ node.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
136
+ dangerousProperties.includes(node.property.name)) {
137
+ return {
138
+ eventName: node.object.name,
139
+ property: node.property.name,
140
+ };
141
+ }
142
+ return null;
143
+ }
144
+ /**
145
+ * Check if JSON.parse is being called on event property
146
+ */
147
+ function isJsonParseOfEventBody(node) {
148
+ if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
149
+ node.callee.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
150
+ node.callee.object.name === 'JSON' &&
151
+ node.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
152
+ node.callee.property.name === 'parse' &&
153
+ node.arguments.length > 0) {
154
+ const arg = node.arguments[0];
155
+ if (arg.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression) {
156
+ return isEventPropertyAccess(arg) !== null;
157
+ }
158
+ }
159
+ return false;
160
+ }
161
+ return {
162
+ // Track arrow function/function parameters named 'event'
163
+ 'ArrowFunctionExpression, FunctionExpression, FunctionDeclaration'(node) {
164
+ for (const param of node.params) {
165
+ if (param.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
166
+ // Common Lambda handler parameter names
167
+ if (['event', 'evt', 'e', 'request', 'req'].includes(param.name)) {
168
+ eventParameters.add(param.name);
169
+ }
170
+ }
171
+ }
172
+ },
173
+ // Check for Middy with validation middleware
174
+ CallExpression(node) {
175
+ // Check for middy().use(validator(...))
176
+ if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
177
+ node.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
178
+ node.callee.property.name === 'use') {
179
+ // Check if argument is validator call
180
+ for (const arg of node.arguments) {
181
+ if (arg.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression &&
182
+ arg.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
183
+ ['validator', 'httpJsonBodyParser'].includes(arg.callee.name)) {
184
+ hasValidationMiddleware = true;
185
+ }
186
+ }
187
+ }
188
+ // Track validation calls that assign to variables
189
+ if (isValidationCall(node)) {
190
+ // If this is part of a variable assignment, mark that variable as validated
191
+ const parent = node.parent;
192
+ if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator &&
193
+ parent.id.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
194
+ validatedVariables.add(parent.id.name);
195
+ }
196
+ }
197
+ },
198
+ // Check direct access to event properties without validation
199
+ MemberExpression(node) {
200
+ // Skip if validation middleware is present
201
+ if (hasValidationMiddleware)
202
+ return;
203
+ const eventAccess = isEventPropertyAccess(node);
204
+ if (!eventAccess)
205
+ return;
206
+ // Check if this is being validated
207
+ const parent = node.parent;
208
+ // Case: const data = schema.parse(event.body) - this is OK
209
+ if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression &&
210
+ isValidationCall(parent)) {
211
+ return;
212
+ }
213
+ // Case: const body = JSON.parse(event.body); schema.parse(body); - track this
214
+ if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression &&
215
+ isJsonParseOfEventBody(parent)) {
216
+ // We need to check if this variable is later validated
217
+ // For now, flag it as potentially dangerous
218
+ // A more sophisticated analysis would track variable flow
219
+ }
220
+ // Case: Direct use without validation - DANGER
221
+ // Check common safe patterns
222
+ // Safe: typeof event.body === 'string'
223
+ if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.UnaryExpression &&
224
+ parent.operator === 'typeof') {
225
+ return;
226
+ }
227
+ // Safe: if (event.body) - null check
228
+ if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.IfStatement ||
229
+ parent?.type === eslint_devkit_1.AST_NODE_TYPES.ConditionalExpression) {
230
+ return;
231
+ }
232
+ // Safe: event.body?.prop - optional chain check
233
+ // If this node is event.body, and the parent is a MemberExpression with optional chaining
234
+ if (node.optional) {
235
+ return;
236
+ }
237
+ // Check if parent is using optional chaining on this node
238
+ // e.g., event.body?.name - the event.body node's parent is optional
239
+ if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
240
+ parent.optional) {
241
+ return;
242
+ }
243
+ // Also check ChainExpression wrapping
244
+ if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.ChainExpression) {
245
+ return;
246
+ }
247
+ // Safe: Logging event input (detected by property access in console.log argument)
248
+ if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression &&
249
+ parent.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
250
+ parent.callee.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
251
+ parent.callee.object.name === 'console') {
252
+ return;
253
+ }
254
+ context.report({
255
+ node,
256
+ messageId: 'unvalidatedInput',
257
+ data: {
258
+ property: `event.${eventAccess.property}`,
259
+ },
260
+ suggest: [
261
+ {
262
+ messageId: 'useValidation',
263
+ fix: () => null, // Complex fix requiring schema setup
264
+ },
265
+ ],
266
+ });
267
+ },
268
+ };
269
+ },
270
+ });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-user-controlled-requests
8
+ * Detects HTTP requests with user-controlled URLs (SSRF)
9
+ * CWE-918: Server-Side Request Forgery (SSRF)
10
+ *
11
+ * @see https://cwe.mitre.org/data/definitions/918.html
12
+ * @see https://owasp.org/www-community/attacks/Server_Side_Request_Forgery
13
+ */
14
+ import type { TSESLint } from '@interlace/eslint-devkit';
15
+ type MessageIds = 'ssrfVulnerability' | 'useAllowlist';
16
+ export interface Options {
17
+ /** Allow in test files. Default: true */
18
+ allowInTests?: boolean;
19
+ }
20
+ type RuleOptions = [Options?];
21
+ export declare const noUserControlledRequests: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
22
+ export {};
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noUserControlledRequests = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ // HTTP client function/method names
11
+ const HTTP_CLIENT_METHODS = [
12
+ // Built-in
13
+ 'fetch',
14
+ // Node.js http module
15
+ 'request',
16
+ 'get',
17
+ 'post',
18
+ 'put',
19
+ 'delete',
20
+ 'patch',
21
+ // Axios
22
+ 'axios',
23
+ // got
24
+ 'got',
25
+ // node-fetch
26
+ 'nodeFetch',
27
+ // superagent
28
+ 'superagent',
29
+ ];
30
+ // HTTP client objects with methods
31
+ const HTTP_CLIENT_OBJECTS = ['http', 'https', 'axios', 'got', 'request'];
32
+ // Event properties containing user input
33
+ const USER_INPUT_PROPERTIES = [
34
+ 'body',
35
+ 'queryStringParameters',
36
+ 'pathParameters',
37
+ 'multiValueQueryStringParameters',
38
+ 'headers',
39
+ 'rawPath',
40
+ 'rawQueryString',
41
+ ];
42
+ // Lambda event parameter names
43
+ const EVENT_PARAM_NAMES = ['event', 'evt', 'e', 'request', 'req'];
44
+ exports.noUserControlledRequests = (0, eslint_devkit_1.createRule)({
45
+ name: 'no-user-controlled-requests',
46
+ meta: {
47
+ type: 'problem',
48
+ docs: {
49
+ description: 'Detects HTTP requests with user-controlled URLs (SSRF vulnerability)',
50
+ },
51
+ hasSuggestions: true,
52
+ messages: {
53
+ ssrfVulnerability: (0, eslint_devkit_1.formatLLMMessage)({
54
+ icon: eslint_devkit_1.MessageIcons.SECURITY,
55
+ issueName: 'Server-Side Request Forgery (SSRF)',
56
+ cwe: 'CWE-918',
57
+ cvss: 9.1,
58
+ description: 'HTTP request URL contains user-controlled input from {{source}}. Attackers can access internal services or exfiltrate data.',
59
+ severity: 'CRITICAL',
60
+ fix: 'Validate URL against allowlist before making request. Never use user input directly in URLs.',
61
+ documentationLink: 'https://owasp.org/www-community/attacks/Server_Side_Request_Forgery',
62
+ }),
63
+ useAllowlist: (0, eslint_devkit_1.formatLLMMessage)({
64
+ icon: eslint_devkit_1.MessageIcons.INFO,
65
+ issueName: 'Use URL Allowlist',
66
+ description: 'Implement an allowlist for permitted URL domains/hosts',
67
+ severity: 'LOW',
68
+ fix: "const ALLOWED_HOSTS = ['api.trusted.com']; if (!ALLOWED_HOSTS.includes(new URL(url).host)) throw new Error('Invalid URL')",
69
+ documentationLink: 'https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html',
70
+ }),
71
+ },
72
+ schema: [
73
+ {
74
+ type: 'object',
75
+ properties: {
76
+ allowInTests: {
77
+ type: 'boolean',
78
+ default: true,
79
+ description: 'Allow user-controlled URLs in test files',
80
+ },
81
+ },
82
+ additionalProperties: false,
83
+ },
84
+ ],
85
+ },
86
+ defaultOptions: [
87
+ {
88
+ allowInTests: true,
89
+ },
90
+ ],
91
+ create(context, [options = {}]) {
92
+ const { allowInTests = true } = options;
93
+ const filename = context.filename || context.getFilename();
94
+ const isTestFile = /\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);
95
+ if (allowInTests && isTestFile) {
96
+ return {};
97
+ }
98
+ // Track event parameters
99
+ const eventParameters = new Set();
100
+ // Track variables that contain user input
101
+ const taintedVariables = new Map(); // variable name -> source
102
+ /**
103
+ * Check if an identifier is an event parameter
104
+ */
105
+ function isEventParameter(name) {
106
+ return eventParameters.has(name);
107
+ }
108
+ /**
109
+ * Check if a member expression accesses user input from event
110
+ */
111
+ function getEventInputSource(node) {
112
+ // event.body, event.queryStringParameters, etc.
113
+ if (node.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
114
+ isEventParameter(node.object.name) &&
115
+ node.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
116
+ USER_INPUT_PROPERTIES.includes(node.property.name)) {
117
+ return `event.${node.property.name}`;
118
+ }
119
+ // event.queryStringParameters.url, event.body.targetUrl, etc.
120
+ if (node.object.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
121
+ node.object.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
122
+ isEventParameter(node.object.object.name) &&
123
+ node.object.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
124
+ USER_INPUT_PROPERTIES.includes(node.object.property.name)) {
125
+ return `event.${node.object.property.name}.${node.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier
126
+ ? node.property.name
127
+ : '[...]'}`;
128
+ }
129
+ return null;
130
+ }
131
+ /**
132
+ * Get taint source from an expression
133
+ */
134
+ function getTaintSource(node) {
135
+ // Direct event property access
136
+ if (node.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression) {
137
+ const source = getEventInputSource(node);
138
+ if (source)
139
+ return source;
140
+ }
141
+ // Variable that was previously tainted
142
+ if (node.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
143
+ const source = taintedVariables.get(node.name);
144
+ if (source)
145
+ return source;
146
+ }
147
+ // Template literal with tainted content
148
+ if (node.type === eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral) {
149
+ for (const expr of node.expressions) {
150
+ const source = getTaintSource(expr);
151
+ if (source)
152
+ return source;
153
+ }
154
+ }
155
+ // Binary expression (string concatenation)
156
+ if (node.type === eslint_devkit_1.AST_NODE_TYPES.BinaryExpression) {
157
+ const leftSource = getTaintSource(node.left);
158
+ if (leftSource)
159
+ return leftSource;
160
+ const rightSource = getTaintSource(node.right);
161
+ if (rightSource)
162
+ return rightSource;
163
+ }
164
+ return null;
165
+ }
166
+ /**
167
+ * Check if this is an HTTP client call
168
+ */
169
+ function isHttpClientCall(node) {
170
+ // fetch(url), axios(url), got(url)
171
+ if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
172
+ HTTP_CLIENT_METHODS.includes(node.callee.name)) {
173
+ return true;
174
+ }
175
+ // axios.get(url), http.request(url), etc.
176
+ if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
177
+ node.callee.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
178
+ HTTP_CLIENT_OBJECTS.includes(node.callee.object.name)) {
179
+ return true;
180
+ }
181
+ // axios.create().get(url) - chained methods
182
+ if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
183
+ node.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
184
+ ['get', 'post', 'put', 'delete', 'patch', 'request'].includes(node.callee.property.name)) {
185
+ return true;
186
+ }
187
+ return false;
188
+ }
189
+ /**
190
+ * Check if URL argument is user-controlled
191
+ */
192
+ function checkUrlArgument(node) {
193
+ if (node.arguments.length === 0)
194
+ return null;
195
+ const urlArg = node.arguments[0];
196
+ const source = getTaintSource(urlArg);
197
+ if (source) {
198
+ return { tainted: true, source };
199
+ }
200
+ // Check object config { url: taintedVar }
201
+ if (urlArg.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
202
+ for (const prop of urlArg.properties) {
203
+ if (prop.type === eslint_devkit_1.AST_NODE_TYPES.Property &&
204
+ prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
205
+ ['url', 'uri', 'href', 'baseURL'].includes(prop.key.name)) {
206
+ const propSource = getTaintSource(prop.value);
207
+ if (propSource) {
208
+ return { tainted: true, source: propSource };
209
+ }
210
+ }
211
+ }
212
+ }
213
+ return null;
214
+ }
215
+ return {
216
+ // Track event parameters in handlers
217
+ 'ArrowFunctionExpression, FunctionExpression, FunctionDeclaration'(node) {
218
+ for (const param of node.params) {
219
+ if (param.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
220
+ if (EVENT_PARAM_NAMES.includes(param.name)) {
221
+ eventParameters.add(param.name);
222
+ }
223
+ }
224
+ }
225
+ },
226
+ // Track variable assignments that contain user input
227
+ VariableDeclarator(node) {
228
+ if (node.id.type === eslint_devkit_1.AST_NODE_TYPES.Identifier && node.init) {
229
+ const source = getTaintSource(node.init);
230
+ if (source) {
231
+ taintedVariables.set(node.id.name, source);
232
+ }
233
+ }
234
+ },
235
+ // Track reassignments
236
+ AssignmentExpression(node) {
237
+ if (node.left.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
238
+ const source = getTaintSource(node.right);
239
+ if (source) {
240
+ taintedVariables.set(node.left.name, source);
241
+ }
242
+ }
243
+ },
244
+ // Check HTTP client calls for tainted URLs
245
+ CallExpression(node) {
246
+ if (!isHttpClientCall(node))
247
+ return;
248
+ const result = checkUrlArgument(node);
249
+ if (result?.tainted) {
250
+ context.report({
251
+ node,
252
+ messageId: 'ssrfVulnerability',
253
+ data: {
254
+ source: result.source,
255
+ },
256
+ suggest: [
257
+ {
258
+ messageId: 'useAllowlist',
259
+ fix: () => null, // Complex fix requiring allowlist setup
260
+ },
261
+ ],
262
+ });
263
+ }
264
+ },
265
+ };
266
+ },
267
+ });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: require-timeout-handling
8
+ * Warns when Lambda handlers lack timeout handling
9
+ * CWE-400: Uncontrolled Resource Consumption
10
+ *
11
+ * @see https://cwe.mitre.org/data/definitions/400.html
12
+ * @see https://owasp.org/www-project-serverless-top-10/
13
+ */
14
+ import type { TSESLint } from '@interlace/eslint-devkit';
15
+ type MessageIds = 'missingTimeoutHandling' | 'addTimeoutCheck';
16
+ export interface Options {
17
+ /** Allow in test files. Default: true */
18
+ allowInTests?: boolean;
19
+ }
20
+ type RuleOptions = [Options?];
21
+ export declare const requireTimeoutHandling: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
22
+ export {};