eslint-plugin-lambda-security 1.2.9 → 1.2.11

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 (35) hide show
  1. package/package.json +5 -22
  2. package/src/index.d.ts +17 -30
  3. package/src/index.js +1 -24
  4. package/src/oxlint.d.ts +17 -20
  5. package/src/oxlint.js +0 -18
  6. package/src/rules/no-env-logging/index.js +0 -23
  7. package/src/rules/no-error-swallowing/index.js +1 -27
  8. package/src/rules/no-exposed-debug-endpoints/index.js +0 -13
  9. package/src/rules/no-exposed-error-details/index.js +0 -17
  10. package/src/rules/no-hardcoded-credentials-sdk/index.js +4 -43
  11. package/src/rules/no-missing-authorization-check/index.js +0 -31
  12. package/src/rules/no-overly-permissive-iam-policy/index.js +0 -17
  13. package/src/rules/no-permissive-cors-middy/index.js +0 -16
  14. package/src/rules/no-permissive-cors-response/index.js +19 -41
  15. package/src/rules/no-secrets-in-env/index.js +0 -18
  16. package/src/rules/no-unbounded-batch-processing/index.js +4 -20
  17. package/src/rules/no-unvalidated-event-body/index.js +19 -86
  18. package/src/rules/no-user-controlled-requests/index.js +2 -48
  19. package/src/rules/require-timeout-handling/index.js +0 -20
  20. package/AGENTS.md +0 -106
  21. package/CHANGELOG.md +0 -203
  22. package/src/rules/no-env-logging/index.d.ts +0 -23
  23. package/src/rules/no-error-swallowing/index.d.ts +0 -26
  24. package/src/rules/no-exposed-debug-endpoints/index.d.ts +0 -14
  25. package/src/rules/no-exposed-error-details/index.d.ts +0 -24
  26. package/src/rules/no-hardcoded-credentials-sdk/index.d.ts +0 -24
  27. package/src/rules/no-missing-authorization-check/index.d.ts +0 -26
  28. package/src/rules/no-overly-permissive-iam-policy/index.d.ts +0 -24
  29. package/src/rules/no-permissive-cors-middy/index.d.ts +0 -24
  30. package/src/rules/no-permissive-cors-response/index.d.ts +0 -26
  31. package/src/rules/no-secrets-in-env/index.d.ts +0 -26
  32. package/src/rules/no-unbounded-batch-processing/index.d.ts +0 -26
  33. package/src/rules/no-unvalidated-event-body/index.d.ts +0 -26
  34. package/src/rules/no-user-controlled-requests/index.d.ts +0 -24
  35. package/src/rules/require-timeout-handling/index.d.ts +0 -24
@@ -1,19 +1,12 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noHardcodedCredentialsSdk = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
- // Patterns that indicate AWS access keys
11
5
  const AWS_ACCESS_KEY_PATTERNS = [
12
- /^AKIA[0-9A-Z]{16}$/, // IAM user access key
13
- /^ASIA[0-9A-Z]{16}$/, // STS temporary access key
14
- /^AIDA[0-9A-Z]{16}$/, // IAM user ID
6
+ /^AKIA[0-9A-Z]{16}$/,
7
+ /^ASIA[0-9A-Z]{16}$/,
8
+ /^AIDA[0-9A-Z]{16}$/,
15
9
  ];
16
- // Property names that indicate credentials
17
10
  const CREDENTIAL_PROPERTY_NAMES = [
18
11
  'accessKeyId',
19
12
  'secretAccessKey',
@@ -21,7 +14,6 @@ const CREDENTIAL_PROPERTY_NAMES = [
21
14
  'awsAccessKeyId',
22
15
  'awsSecretAccessKey',
23
16
  ];
24
- // AWS SDK v3 client names
25
17
  const AWS_SDK_V3_CLIENTS = new Set([
26
18
  'S3Client',
27
19
  'DynamoDBClient',
@@ -100,51 +92,33 @@ exports.noHardcodedCredentialsSdk = (0, eslint_devkit_1.createRule)({
100
92
  if (allowInTests && isTestFile) {
101
93
  return {};
102
94
  }
103
- /**
104
- * Check if a value looks like an AWS access key
105
- */
106
95
  function looksLikeAwsAccessKey(value) {
107
96
  return AWS_ACCESS_KEY_PATTERNS.some(pattern => pattern.test(value));
108
97
  }
109
- /**
110
- * Check if a property name is credential-related
111
- */
112
98
  function isCredentialProperty(name) {
113
99
  return CREDENTIAL_PROPERTY_NAMES.some(credProp => name.toLowerCase() === credProp.toLowerCase());
114
100
  }
115
- /**
116
- * Get the AWS client name from the call expression
117
- * Only match known AWS SDK clients or names ending with 'Client' that look like AWS
118
- */
119
101
  function getAwsClientName(node) {
120
102
  if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
121
103
  const name = node.callee.name;
122
- // Known AWS SDK v3 clients
123
104
  if (AWS_SDK_V3_CLIENTS.has(name)) {
124
105
  return name;
125
106
  }
126
- // Only match *Client if it looks like AWS (contains common AWS service prefixes)
127
107
  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)) {
128
108
  return name;
129
109
  }
130
110
  }
131
111
  return null;
132
112
  }
133
- /**
134
- * Check ObjectExpression for credential properties with hardcoded values
135
- */
136
113
  function checkCredentialsObject(obj, clientName) {
137
114
  for (const prop of obj.properties) {
138
115
  if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
139
116
  continue;
140
- // Check for credentials property
141
117
  if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
142
118
  prop.key.name === 'credentials' &&
143
119
  prop.value.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
144
- // Check nested credentials object
145
120
  checkCredentialsInner(prop.value, clientName);
146
121
  }
147
- // Also check top-level credential properties (older pattern)
148
122
  if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
149
123
  isCredentialProperty(prop.key.name)) {
150
124
  if (prop.value.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof prop.value.value === 'string') {
@@ -153,47 +127,36 @@ exports.noHardcodedCredentialsSdk = (0, eslint_devkit_1.createRule)({
153
127
  }
154
128
  }
155
129
  }
156
- /**
157
- * Check inner credentials object
158
- */
159
130
  function checkCredentialsInner(obj, clientName) {
160
131
  for (const prop of obj.properties) {
161
132
  if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
162
133
  continue;
163
134
  if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier && isCredentialProperty(prop.key.name)) {
164
- // Check for literal string values
165
135
  if (prop.value.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof prop.value.value === 'string') {
166
136
  const value = prop.value.value;
167
137
  const keyName = prop.key.name.toLowerCase();
168
- // For accessKeyId, check if it looks like an actual AWS key (AKIA/ASIA pattern)
169
138
  if (keyName === 'accesskeyid') {
170
139
  if (looksLikeAwsAccessKey(value)) {
171
140
  reportHardcodedCredential(prop, clientName, prop.key.name);
172
141
  }
173
142
  }
174
- // For secretAccessKey, require minimum length (AWS secrets are 40+ chars)
175
143
  else if (keyName === 'secretaccesskey') {
176
144
  if (value.length >= 20) {
177
145
  reportHardcodedCredential(prop, clientName, prop.key.name);
178
146
  }
179
147
  }
180
- // For sessionToken, any non-short value is suspicious
181
148
  else if (keyName === 'sessiontoken') {
182
149
  if (value.length >= 15) {
183
150
  reportHardcodedCredential(prop, clientName, prop.key.name);
184
151
  }
185
152
  }
186
153
  }
187
- // Check for template literals (always flag - dynamic construction is suspicious)
188
154
  else if (prop.value.type === eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral) {
189
155
  reportHardcodedCredential(prop, clientName, prop.key.name);
190
156
  }
191
157
  }
192
158
  }
193
159
  }
194
- /**
195
- * Report hardcoded credential
196
- */
197
160
  function reportHardcodedCredential(node, clientName, propertyName) {
198
161
  context.report({
199
162
  node,
@@ -205,7 +168,7 @@ exports.noHardcodedCredentialsSdk = (0, eslint_devkit_1.createRule)({
205
168
  suggest: [
206
169
  {
207
170
  messageId: 'useCredentialProvider',
208
- fix: () => null, // Complex fix - just provide suggestion
171
+ fix: () => null,
209
172
  },
210
173
  ],
211
174
  });
@@ -215,12 +178,10 @@ exports.noHardcodedCredentialsSdk = (0, eslint_devkit_1.createRule)({
215
178
  const clientName = getAwsClientName(node);
216
179
  if (!clientName)
217
180
  return;
218
- // Check constructor arguments
219
181
  if (node.arguments.length > 0 && node.arguments[0].type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
220
182
  checkCredentialsObject(node.arguments[0], clientName);
221
183
  }
222
184
  },
223
- // Also check for { credentials: { accessKeyId: ... } } patterns in variable declarations
224
185
  VariableDeclarator(node) {
225
186
  if (node.id.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
226
187
  node.id.name.toLowerCase().includes('credential') &&
@@ -1,21 +1,12 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noMissingAuthorizationCheck = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
- // Property accesses that indicate authorization checks
11
5
  const AUTHORIZATION_CHECK_PATTERNS = [
12
- // API Gateway authorizer
13
6
  'requestContext.authorizer',
14
7
  'requestContext.identity',
15
- // JWT/Token validation
16
8
  'Authorization',
17
9
  'authorization',
18
- // Common auth checks
19
10
  'claims',
20
11
  'principalId',
21
12
  'isAdmin',
@@ -25,9 +16,7 @@ const AUTHORIZATION_CHECK_PATTERNS = [
25
16
  'scope',
26
17
  'permissions',
27
18
  ];
28
- // Sensitive operations that require authorization
29
19
  const SENSITIVE_OPERATIONS = new Set([
30
- // Database operations
31
20
  'query',
32
21
  'put',
33
22
  'delete',
@@ -35,7 +24,6 @@ const SENSITIVE_OPERATIONS = new Set([
35
24
  'insert',
36
25
  'remove',
37
26
  'create',
38
- // AWS SDK operations
39
27
  'send',
40
28
  'invoke',
41
29
  'putObject',
@@ -46,7 +34,6 @@ const SENSITIVE_OPERATIONS = new Set([
46
34
  'updateItem',
47
35
  'getItem',
48
36
  ]);
49
- // Event parameter names
50
37
  const EVENT_PARAM_NAMES = new Set(['event', 'evt', 'e', 'request', 'req']);
51
38
  exports.noMissingAuthorizationCheck = (0, eslint_devkit_1.createRule)({
52
39
  name: 'no-missing-authorization-check',
@@ -111,16 +98,11 @@ exports.noMissingAuthorizationCheck = (0, eslint_devkit_1.createRule)({
111
98
  if (allowInTests && isTestFile) {
112
99
  return {};
113
100
  }
114
- // Track state within each handler function
115
101
  let currentFunctionNode = null;
116
102
  let hasAuthCheck = false;
117
103
  let hasEventParameter = false;
118
104
  const sensitiveOperations = [];
119
- /**
120
- * Reset state when entering a new function
121
- */
122
105
  function enterFunction(node) {
123
- // Check if this function has an event parameter
124
106
  const hasEvent = node.params.some((param) => param.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
125
107
  EVENT_PARAM_NAMES.has(param.name));
126
108
  if (hasEvent) {
@@ -130,13 +112,9 @@ exports.noMissingAuthorizationCheck = (0, eslint_devkit_1.createRule)({
130
112
  sensitiveOperations.length = 0;
131
113
  }
132
114
  }
133
- /**
134
- * Check and report on function exit
135
- */
136
115
  function exitFunction(node) {
137
116
  if (currentFunctionNode !== node)
138
117
  return;
139
- // Report if we have sensitive operations without auth check
140
118
  if (hasEventParameter && !hasAuthCheck) {
141
119
  for (const { node: opNode, operation } of sensitiveOperations) {
142
120
  context.report({
@@ -155,18 +133,12 @@ exports.noMissingAuthorizationCheck = (0, eslint_devkit_1.createRule)({
155
133
  currentFunctionNode = null;
156
134
  hasEventParameter = false;
157
135
  }
158
- /**
159
- * Check if a member expression chain indicates auth check
160
- */
161
136
  function isAuthorizationAccess(node) {
162
137
  const sourceCode = context.sourceCode;
163
138
  const text = sourceCode.getText(node);
164
139
  return AUTHORIZATION_CHECK_PATTERNS.some((pattern) => text.includes(pattern) ||
165
140
  text.toLowerCase().includes(pattern.toLowerCase()));
166
141
  }
167
- /**
168
- * Check if call is a sensitive operation
169
- */
170
142
  function getSensitiveOperationName(node) {
171
143
  if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression) {
172
144
  const property = node.callee.property;
@@ -191,7 +163,6 @@ exports.noMissingAuthorizationCheck = (0, eslint_devkit_1.createRule)({
191
163
  'FunctionDeclaration:exit'(node) {
192
164
  exitFunction(node);
193
165
  },
194
- // Detect authorization checks
195
166
  MemberExpression(node) {
196
167
  if (!currentFunctionNode)
197
168
  return;
@@ -199,7 +170,6 @@ exports.noMissingAuthorizationCheck = (0, eslint_devkit_1.createRule)({
199
170
  hasAuthCheck = true;
200
171
  }
201
172
  },
202
- // Track sensitive operations
203
173
  CallExpression(node) {
204
174
  if (!currentFunctionNode)
205
175
  return;
@@ -208,7 +178,6 @@ exports.noMissingAuthorizationCheck = (0, eslint_devkit_1.createRule)({
208
178
  sensitiveOperations.push({ node, operation });
209
179
  }
210
180
  },
211
- // Detect early returns (401/403) as auth checks
212
181
  ReturnStatement(node) {
213
182
  if (!currentFunctionNode)
214
183
  return;
@@ -1,15 +1,8 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noOverlyPermissiveIamPolicy = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
- // IAM policy property names
11
5
  const POLICY_PROPERTIES = new Set(['Resource', 'Action', 'Principal']);
12
- // Wildcards that indicate overly permissive
13
6
  const DANGEROUS_WILDCARDS = new Set(['*', 'arn:aws:*', 'arn:*:*:*:*:*']);
14
7
  exports.noOverlyPermissiveIamPolicy = (0, eslint_devkit_1.createRule)({
15
8
  name: 'no-overly-permissive-iam-policy',
@@ -63,19 +56,12 @@ exports.noOverlyPermissiveIamPolicy = (0, eslint_devkit_1.createRule)({
63
56
  if (allowInTests && isTestFile) {
64
57
  return {};
65
58
  }
66
- /**
67
- * Check if a value is a dangerous wildcard
68
- */
69
59
  function isDangerousWildcard(value) {
70
60
  return (DANGEROUS_WILDCARDS.has(value) ||
71
61
  (value.endsWith('*') && value.includes(':*:')));
72
62
  }
73
- /**
74
- * Check property values for wildcards
75
- */
76
63
  function checkPolicyProperty(node, propertyName) {
77
64
  const value = node.value;
78
- // Check literal string
79
65
  if (value.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof value.value === 'string') {
80
66
  if (isDangerousWildcard(value.value)) {
81
67
  context.report({
@@ -94,7 +80,6 @@ exports.noOverlyPermissiveIamPolicy = (0, eslint_devkit_1.createRule)({
94
80
  });
95
81
  }
96
82
  }
97
- // Check array of values
98
83
  if (value.type === eslint_devkit_1.AST_NODE_TYPES.ArrayExpression) {
99
84
  for (const element of value.elements) {
100
85
  if (element?.type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
@@ -121,14 +106,12 @@ exports.noOverlyPermissiveIamPolicy = (0, eslint_devkit_1.createRule)({
121
106
  }
122
107
  return {
123
108
  Property(node) {
124
- // Check for IAM policy properties
125
109
  if (node.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
126
110
  const keyName = node.key.name;
127
111
  if (POLICY_PROPERTIES.has(keyName)) {
128
112
  checkPolicyProperty(node, keyName);
129
113
  }
130
114
  }
131
- // Also check string key properties
132
115
  if (node.key.type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
133
116
  typeof node.key.value === 'string') {
134
117
  const keyName = node.key.value;
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noPermissiveCorsMidly = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -58,9 +53,6 @@ exports.noPermissiveCorsMidly = (0, eslint_devkit_1.createRule)({
58
53
  if (allowInTests && isTestFile) {
59
54
  return {};
60
55
  }
61
- /**
62
- * Check if a call is to httpCors/cors middleware
63
- */
64
56
  function isCorsMiddlewareCall(node) {
65
57
  if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
66
58
  const name = node.callee.name.toLowerCase();
@@ -68,18 +60,13 @@ exports.noPermissiveCorsMidly = (0, eslint_devkit_1.createRule)({
68
60
  }
69
61
  return false;
70
62
  }
71
- /**
72
- * Check cors options for permissive origin
73
- */
74
63
  function checkCorsOptions(node, optionsObj) {
75
64
  for (const prop of optionsObj.properties) {
76
65
  if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
77
66
  continue;
78
- // Check for 'origin' or 'origins' property
79
67
  if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
80
68
  const keyName = prop.key.name.toLowerCase();
81
69
  if (keyName === 'origin' || keyName === 'origins') {
82
- // Check for wildcard string
83
70
  if (prop.value.type === eslint_devkit_1.AST_NODE_TYPES.Literal && prop.value.value === '*') {
84
71
  context.report({
85
72
  node: prop,
@@ -92,7 +79,6 @@ exports.noPermissiveCorsMidly = (0, eslint_devkit_1.createRule)({
92
79
  ],
93
80
  });
94
81
  }
95
- // Check for array with wildcard
96
82
  else if (prop.value.type === eslint_devkit_1.AST_NODE_TYPES.ArrayExpression) {
97
83
  for (const element of prop.value.elements) {
98
84
  if (element?.type === eslint_devkit_1.AST_NODE_TYPES.Literal && element.value === '*') {
@@ -117,7 +103,6 @@ exports.noPermissiveCorsMidly = (0, eslint_devkit_1.createRule)({
117
103
  CallExpression(node) {
118
104
  if (!isCorsMiddlewareCall(node))
119
105
  return;
120
- // httpCors() with no arguments defaults to permissive
121
106
  if (node.arguments.length === 0) {
122
107
  context.report({
123
108
  node,
@@ -131,7 +116,6 @@ exports.noPermissiveCorsMidly = (0, eslint_devkit_1.createRule)({
131
116
  });
132
117
  return;
133
118
  }
134
- // Check options object
135
119
  if (node.arguments[0]?.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
136
120
  checkCorsOptions(node, node.arguments[0]);
137
121
  }
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noPermissiveCorsResponse = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -70,25 +65,16 @@ exports.noPermissiveCorsResponse = (0, eslint_devkit_1.createRule)({
70
65
  if (allowInTests && isTestFile) {
71
66
  return {};
72
67
  }
73
- /**
74
- * Check if this is a Lambda response structure
75
- * { statusCode, headers, body }
76
- */
77
68
  function isLambdaResponse(obj) {
78
- // oxlint-disable-next-line prefer-set-has
79
69
  const propNames = obj.properties
80
70
  .filter((p) => p.type === eslint_devkit_1.AST_NODE_TYPES.Property)
81
71
  .map(p => (p.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier ? p.key.name : ''));
82
72
  return propNames.includes('statusCode') || propNames.includes('body');
83
73
  }
84
- /**
85
- * Check headers object for permissive CORS
86
- */
87
74
  function checkHeadersObject(obj) {
88
75
  for (const prop of obj.properties) {
89
76
  if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
90
77
  continue;
91
- // Get header name
92
78
  let headerName = '';
93
79
  if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
94
80
  headerName = prop.key.name;
@@ -96,9 +82,7 @@ exports.noPermissiveCorsResponse = (0, eslint_devkit_1.createRule)({
96
82
  else if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof prop.key.value === 'string') {
97
83
  headerName = prop.key.value;
98
84
  }
99
- // Check for Access-Control-Allow-Origin
100
85
  if (headerName.toLowerCase() === 'access-control-allow-origin') {
101
- // Check if value is wildcard
102
86
  if (prop.value.type === eslint_devkit_1.AST_NODE_TYPES.Literal && prop.value.value === '*') {
103
87
  context.report({
104
88
  node: prop,
@@ -111,40 +95,34 @@ exports.noPermissiveCorsResponse = (0, eslint_devkit_1.createRule)({
111
95
  }
112
96
  }
113
97
  }
98
+ function checkResponseObject(obj) {
99
+ if (!isLambdaResponse(obj))
100
+ return;
101
+ for (const prop of obj.properties) {
102
+ if (prop.type === eslint_devkit_1.AST_NODE_TYPES.Property &&
103
+ prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
104
+ prop.key.name === 'headers' &&
105
+ prop.value.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
106
+ checkHeadersObject(prop.value);
107
+ }
108
+ }
109
+ }
114
110
  return {
115
- // Check return statements that return Lambda response objects
116
111
  ReturnStatement(node) {
117
112
  if (node.argument?.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
118
- const obj = node.argument;
119
- if (isLambdaResponse(obj)) {
120
- // Find headers property
121
- for (const prop of obj.properties) {
122
- if (prop.type === eslint_devkit_1.AST_NODE_TYPES.Property &&
123
- prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
124
- prop.key.name === 'headers' &&
125
- prop.value.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
126
- checkHeadersObject(prop.value);
127
- }
128
- }
129
- }
113
+ checkResponseObject(node.argument);
114
+ }
115
+ },
116
+ ArrowFunctionExpression(node) {
117
+ if (node.body.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
118
+ checkResponseObject(node.body);
130
119
  }
131
120
  },
132
- // Also check variable declarations with Lambda response pattern
133
121
  VariableDeclarator(node) {
134
122
  if (node.id.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
135
123
  node.id.name.toLowerCase().includes('response') &&
136
124
  node.init?.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
137
- const obj = node.init;
138
- if (isLambdaResponse(obj)) {
139
- for (const prop of obj.properties) {
140
- if (prop.type === eslint_devkit_1.AST_NODE_TYPES.Property &&
141
- prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
142
- prop.key.name === 'headers' &&
143
- prop.value.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
144
- checkHeadersObject(prop.value);
145
- }
146
- }
147
- }
125
+ checkResponseObject(node.init);
148
126
  }
149
127
  },
150
128
  };
@@ -1,13 +1,7 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noSecretsInEnv = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
- // Patterns that indicate secrets
11
5
  const SECRET_PATTERNS = [
12
6
  /password/i,
13
7
  /secret/i,
@@ -73,33 +67,23 @@ exports.noSecretsInEnv = (0, eslint_devkit_1.createRule)({
73
67
  if (allowInTests && isTestFile) {
74
68
  return {};
75
69
  }
76
- // Compile additional patterns
77
70
  const allPatterns = [
78
71
  ...SECRET_PATTERNS,
79
72
  ...additionalPatterns.map(p => new RegExp(p, 'i')),
80
73
  ];
81
- /**
82
- * Check if a variable name looks like a secret
83
- */
84
74
  function isSecretName(name) {
85
75
  return allPatterns.some(pattern => pattern.test(name));
86
76
  }
87
- /**
88
- * Check if a value looks like it contains a secret (not just a reference)
89
- */
90
77
  function isHardcodedSecretValue(node) {
91
- // Literal strings with reasonable length could be secrets
92
78
  if (node.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof node.value === 'string') {
93
79
  return node.value.length > 5;
94
80
  }
95
- // Template literals with string parts
96
81
  if (node.type === eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral) {
97
82
  return node.quasis.some(quasi => quasi.value.raw.length > 5);
98
83
  }
99
84
  return false;
100
85
  }
101
86
  return {
102
- // Detect process.env.SECRET_KEY = 'value'
103
87
  AssignmentExpression(node) {
104
88
  if (node.left.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
105
89
  node.left.object.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
@@ -124,7 +108,6 @@ exports.noSecretsInEnv = (0, eslint_devkit_1.createRule)({
124
108
  }
125
109
  }
126
110
  },
127
- // Detect { DB_PASSWORD: 'value' } in environment config objects
128
111
  Property(node) {
129
112
  let propName = '';
130
113
  if (node.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
@@ -134,7 +117,6 @@ exports.noSecretsInEnv = (0, eslint_devkit_1.createRule)({
134
117
  propName = node.key.value;
135
118
  }
136
119
  if (isSecretName(propName) && isHardcodedSecretValue(node.value)) {
137
- // Check if this is in an environment/config context
138
120
  let parent = node.parent;
139
121
  while (parent) {
140
122
  if (parent.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
@@ -1,20 +1,13 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noUnboundedBatchProcessing = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
- // Event sources with Records array
11
5
  const BATCH_SOURCE_PROPERTIES = new Set([
12
- 'Records', // SQS, SNS, DynamoDB Streams, Kinesis, S3
13
- 'records', // Some custom structures
14
- 'items', // Custom batches
15
- 'messages', // Custom message batches
6
+ 'Records',
7
+ 'records',
8
+ 'items',
9
+ 'messages',
16
10
  ]);
17
- // Event parameter names
18
11
  const EVENT_PARAM_NAMES = new Set(['event', 'evt', 'e', 'request', 'req']);
19
12
  exports.noUnboundedBatchProcessing = (0, eslint_devkit_1.createRule)({
20
13
  name: 'no-unbounded-batch-processing',
@@ -72,7 +65,6 @@ exports.noUnboundedBatchProcessing = (0, eslint_devkit_1.createRule)({
72
65
  if (allowInTests && isTestFile) {
73
66
  return {};
74
67
  }
75
- // Track handler functions
76
68
  let currentHandlerNode = null;
77
69
  let hasBatchSizeCheck = false;
78
70
  const batchAccessNodes = [];
@@ -95,7 +87,6 @@ exports.noUnboundedBatchProcessing = (0, eslint_devkit_1.createRule)({
95
87
  function exitFunction(node) {
96
88
  if (currentHandlerNode !== node)
97
89
  return;
98
- // Report if batch is processed without size check
99
90
  if (!hasBatchSizeCheck) {
100
91
  for (const { node: batchNode, source } of batchAccessNodes) {
101
92
  context.report({
@@ -127,11 +118,9 @@ exports.noUnboundedBatchProcessing = (0, eslint_devkit_1.createRule)({
127
118
  'FunctionDeclaration:exit'(node) {
128
119
  exitFunction(node);
129
120
  },
130
- // Detect event.Records access
131
121
  MemberExpression(node) {
132
122
  if (!currentHandlerNode)
133
123
  return;
134
- // event.Records
135
124
  if (node.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
136
125
  eventParamName.includes(node.object.name) &&
137
126
  node.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
@@ -141,10 +130,8 @@ exports.noUnboundedBatchProcessing = (0, eslint_devkit_1.createRule)({
141
130
  source: `${node.object.name}.${node.property.name}`,
142
131
  });
143
132
  }
144
- // Check for .length access (indicates size check)
145
133
  if (node.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
146
134
  node.property.name === 'length') {
147
- // Check if this is Records.length
148
135
  if (node.object.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
149
136
  node.object.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
150
137
  BATCH_SOURCE_PROPERTIES.has(node.object.property.name)) {
@@ -152,7 +139,6 @@ exports.noUnboundedBatchProcessing = (0, eslint_devkit_1.createRule)({
152
139
  }
153
140
  }
154
141
  },
155
- // Detect slice/splice (limiting)
156
142
  CallExpression(node) {
157
143
  if (!currentHandlerNode)
158
144
  return;
@@ -161,13 +147,11 @@ exports.noUnboundedBatchProcessing = (0, eslint_devkit_1.createRule)({
161
147
  ['slice', 'splice', 'take', 'chunk'].includes(node.callee.property.name)) {
162
148
  hasBatchSizeCheck = true;
163
149
  }
164
- // Also detect top-level function calls: chunk(arr, n), take(arr, n)
165
150
  if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
166
151
  ['slice', 'splice', 'take', 'chunk'].includes(node.callee.name)) {
167
152
  hasBatchSizeCheck = true;
168
153
  }
169
154
  },
170
- // Detect size comparisons
171
155
  BinaryExpression(node) {
172
156
  if (!currentHandlerNode)
173
157
  return;