eslint-plugin-lambda-security 1.2.9 → 1.2.10
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/package.json +5 -12
- package/src/index.d.ts +17 -30
- package/src/index.js +1 -24
- package/src/oxlint.d.ts +17 -20
- package/src/oxlint.js +0 -18
- package/src/rules/no-env-logging/index.js +0 -23
- package/src/rules/no-error-swallowing/index.js +1 -27
- package/src/rules/no-exposed-debug-endpoints/index.js +0 -13
- package/src/rules/no-exposed-error-details/index.js +0 -17
- package/src/rules/no-hardcoded-credentials-sdk/index.js +4 -43
- package/src/rules/no-missing-authorization-check/index.js +0 -31
- package/src/rules/no-overly-permissive-iam-policy/index.js +0 -17
- package/src/rules/no-permissive-cors-middy/index.js +0 -16
- package/src/rules/no-permissive-cors-response/index.js +19 -41
- package/src/rules/no-secrets-in-env/index.js +0 -18
- package/src/rules/no-unbounded-batch-processing/index.js +4 -20
- package/src/rules/no-unvalidated-event-body/index.js +19 -86
- package/src/rules/no-user-controlled-requests/index.js +2 -48
- package/src/rules/require-timeout-handling/index.js +0 -20
- package/AGENTS.md +0 -106
- package/CHANGELOG.md +0 -203
- package/src/rules/no-env-logging/index.d.ts +0 -23
- package/src/rules/no-error-swallowing/index.d.ts +0 -26
- package/src/rules/no-exposed-debug-endpoints/index.d.ts +0 -14
- package/src/rules/no-exposed-error-details/index.d.ts +0 -24
- package/src/rules/no-hardcoded-credentials-sdk/index.d.ts +0 -24
- package/src/rules/no-missing-authorization-check/index.d.ts +0 -26
- package/src/rules/no-overly-permissive-iam-policy/index.d.ts +0 -24
- package/src/rules/no-permissive-cors-middy/index.d.ts +0 -24
- package/src/rules/no-permissive-cors-response/index.d.ts +0 -26
- package/src/rules/no-secrets-in-env/index.d.ts +0 -26
- package/src/rules/no-unbounded-batch-processing/index.d.ts +0 -26
- package/src/rules/no-unvalidated-event-body/index.d.ts +0 -26
- package/src/rules/no-user-controlled-requests/index.d.ts +0 -24
- package/src/rules/require-timeout-handling/index.d.ts +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-lambda-security",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10",
|
|
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",
|
|
@@ -10,10 +10,6 @@
|
|
|
10
10
|
"types": "./src/index.d.ts",
|
|
11
11
|
"default": "./src/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./types": {
|
|
14
|
-
"types": "./src/types/index.d.ts",
|
|
15
|
-
"default": "./src/types/index.js"
|
|
16
|
-
},
|
|
17
13
|
"./oxlint": {
|
|
18
14
|
"types": "./src/oxlint.d.ts",
|
|
19
15
|
"default": "./src/oxlint.js"
|
|
@@ -24,7 +20,7 @@
|
|
|
24
20
|
"homepage": "https://eslint.interlace.tools/docs/security/plugin-lambda-security?utm_source=npm&utm_medium=referral&utm_campaign=eslint-plugin-lambda-security",
|
|
25
21
|
"repository": {
|
|
26
22
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/ofri-peretz/eslint",
|
|
23
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git",
|
|
28
24
|
"directory": "packages/eslint-plugin-lambda-security"
|
|
29
25
|
},
|
|
30
26
|
"bugs": {
|
|
@@ -35,11 +31,8 @@
|
|
|
35
31
|
},
|
|
36
32
|
"files": [
|
|
37
33
|
"src/",
|
|
38
|
-
"dist/",
|
|
39
34
|
"README.md",
|
|
40
|
-
"LICENSE"
|
|
41
|
-
"CHANGELOG.md",
|
|
42
|
-
"AGENTS.md"
|
|
35
|
+
"LICENSE"
|
|
43
36
|
],
|
|
44
37
|
"keywords": [
|
|
45
38
|
"eslint",
|
|
@@ -79,7 +72,7 @@
|
|
|
79
72
|
},
|
|
80
73
|
"dependencies": {
|
|
81
74
|
"tslib": "^2.3.0",
|
|
82
|
-
"@interlace/eslint-devkit": "^1.
|
|
75
|
+
"@interlace/eslint-devkit": "^1.6.0"
|
|
83
76
|
},
|
|
84
77
|
"peerDependencies": {
|
|
85
78
|
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
@@ -113,6 +106,6 @@
|
|
|
113
106
|
},
|
|
114
107
|
"funding": {
|
|
115
108
|
"type": "github",
|
|
116
|
-
"url": "https://github.com/ofri-peretz/eslint"
|
|
109
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git"
|
|
117
110
|
}
|
|
118
111
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* - SAS-4: Security Misconfiguration ✅ (no-permissive-cors-*)
|
|
19
|
-
* - SAS-5: Broken Access Control ✅ (no-missing-authorization-check, no-overly-permissive-iam-policy)
|
|
20
|
-
* - SAS-6: Insufficient Logging ✅ (no-error-swallowing)
|
|
21
|
-
* - SAS-7: Denial of Service ✅ (require-timeout-handling, no-unbounded-batch-processing)
|
|
22
|
-
* - SAS-8: Server-Side Request Forgery ✅ (no-user-controlled-requests)
|
|
23
|
-
* - SAS-9: Functions Misconfiguration ✅ (no-exposed-error-details)
|
|
24
|
-
* - SAS-10: Improper Crypto ➡️ (Use eslint-plugin-node-security)
|
|
25
|
-
*/
|
|
26
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
27
|
-
export declare const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
28
|
-
export declare const plugin: TSESLint.FlatConfig.Plugin;
|
|
29
|
-
export declare const configs: Record<string, TSESLint.FlatConfig.Config>;
|
|
30
|
-
export default plugin;
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
package/src/index.js
CHANGED
|
@@ -1,59 +1,40 @@
|
|
|
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.configs = exports.plugin = exports.rules = void 0;
|
|
9
|
-
// Original P0 Critical Rules
|
|
10
4
|
const no_hardcoded_credentials_sdk_1 = require("./rules/no-hardcoded-credentials-sdk");
|
|
11
5
|
const no_permissive_cors_response_1 = require("./rules/no-permissive-cors-response");
|
|
12
6
|
const no_permissive_cors_middy_1 = require("./rules/no-permissive-cors-middy");
|
|
13
7
|
const no_secrets_in_env_1 = require("./rules/no-secrets-in-env");
|
|
14
8
|
const no_env_logging_1 = require("./rules/no-env-logging");
|
|
15
|
-
// SAS-1: Injection
|
|
16
9
|
const no_unvalidated_event_body_1 = require("./rules/no-unvalidated-event-body");
|
|
17
|
-
// SAS-5: Broken Access Control
|
|
18
10
|
const no_missing_authorization_check_1 = require("./rules/no-missing-authorization-check");
|
|
19
11
|
const no_overly_permissive_iam_policy_1 = require("./rules/no-overly-permissive-iam-policy");
|
|
20
|
-
// SAS-6: Insufficient Logging
|
|
21
12
|
const no_error_swallowing_1 = require("./rules/no-error-swallowing");
|
|
22
|
-
// SAS-7: Denial of Service
|
|
23
13
|
const require_timeout_handling_1 = require("./rules/require-timeout-handling");
|
|
24
14
|
const no_unbounded_batch_processing_1 = require("./rules/no-unbounded-batch-processing");
|
|
25
|
-
// SAS-8: Server-Side Request Forgery
|
|
26
15
|
const no_user_controlled_requests_1 = require("./rules/no-user-controlled-requests");
|
|
27
|
-
// SAS-9: Functions Misconfiguration
|
|
28
16
|
const no_exposed_error_details_1 = require("./rules/no-exposed-error-details");
|
|
29
17
|
const no_exposed_debug_endpoints_1 = require("./rules/no-exposed-debug-endpoints");
|
|
30
18
|
exports.rules = {
|
|
31
|
-
// Original rules
|
|
32
19
|
'no-hardcoded-credentials-sdk': no_hardcoded_credentials_sdk_1.noHardcodedCredentialsSdk,
|
|
33
20
|
'no-permissive-cors-response': no_permissive_cors_response_1.noPermissiveCorsResponse,
|
|
34
21
|
'no-permissive-cors-middy': no_permissive_cors_middy_1.noPermissiveCorsMidly,
|
|
35
22
|
'no-secrets-in-env': no_secrets_in_env_1.noSecretsInEnv,
|
|
36
23
|
'no-env-logging': no_env_logging_1.noEnvLogging,
|
|
37
|
-
// SAS-1: Injection
|
|
38
24
|
'no-unvalidated-event-body': no_unvalidated_event_body_1.noUnvalidatedEventBody,
|
|
39
|
-
// SAS-5: Broken Access Control
|
|
40
25
|
'no-missing-authorization-check': no_missing_authorization_check_1.noMissingAuthorizationCheck,
|
|
41
26
|
'no-overly-permissive-iam-policy': no_overly_permissive_iam_policy_1.noOverlyPermissiveIamPolicy,
|
|
42
|
-
// SAS-6: Insufficient Logging
|
|
43
27
|
'no-error-swallowing': no_error_swallowing_1.noErrorSwallowing,
|
|
44
|
-
// SAS-7: Denial of Service
|
|
45
28
|
'require-timeout-handling': require_timeout_handling_1.requireTimeoutHandling,
|
|
46
29
|
'no-unbounded-batch-processing': no_unbounded_batch_processing_1.noUnboundedBatchProcessing,
|
|
47
|
-
// SAS-8: SSRF
|
|
48
30
|
'no-user-controlled-requests': no_user_controlled_requests_1.noUserControlledRequests,
|
|
49
|
-
// SAS-9: Functions Misconfiguration
|
|
50
31
|
'no-exposed-error-details': no_exposed_error_details_1.noExposedErrorDetails,
|
|
51
32
|
'no-exposed-debug-endpoints': no_exposed_debug_endpoints_1.noExposedDebugEndpoints,
|
|
52
33
|
};
|
|
53
34
|
exports.plugin = {
|
|
54
35
|
meta: {
|
|
55
36
|
name: 'eslint-plugin-lambda-security',
|
|
56
|
-
version: '1.2.
|
|
37
|
+
version: '1.2.10',
|
|
57
38
|
},
|
|
58
39
|
rules: exports.rules,
|
|
59
40
|
};
|
|
@@ -63,19 +44,16 @@ exports.configs = {
|
|
|
63
44
|
'lambda-security': exports.plugin,
|
|
64
45
|
},
|
|
65
46
|
rules: {
|
|
66
|
-
// Critical: Always error
|
|
67
47
|
'lambda-security/no-hardcoded-credentials-sdk': 'error',
|
|
68
48
|
'lambda-security/no-permissive-cors-response': 'error',
|
|
69
49
|
'lambda-security/no-permissive-cors-middy': 'error',
|
|
70
50
|
'lambda-security/no-secrets-in-env': 'error',
|
|
71
51
|
'lambda-security/no-user-controlled-requests': 'error',
|
|
72
52
|
'lambda-security/no-overly-permissive-iam-policy': 'error',
|
|
73
|
-
// High: Warn in recommended
|
|
74
53
|
'lambda-security/no-unvalidated-event-body': 'warn',
|
|
75
54
|
'lambda-security/no-missing-authorization-check': 'warn',
|
|
76
55
|
'lambda-security/no-exposed-error-details': 'warn',
|
|
77
56
|
'lambda-security/no-exposed-debug-endpoints': 'error',
|
|
78
|
-
// Medium: Warn in recommended
|
|
79
57
|
'lambda-security/no-env-logging': 'warn',
|
|
80
58
|
'lambda-security/no-error-swallowing': 'warn',
|
|
81
59
|
'lambda-security/require-timeout-handling': 'warn',
|
|
@@ -87,7 +65,6 @@ exports.configs = {
|
|
|
87
65
|
'lambda-security': exports.plugin,
|
|
88
66
|
},
|
|
89
67
|
rules: {
|
|
90
|
-
// All rules as errors in strict mode
|
|
91
68
|
'lambda-security/no-hardcoded-credentials-sdk': 'error',
|
|
92
69
|
'lambda-security/no-permissive-cors-response': 'error',
|
|
93
70
|
'lambda-security/no-permissive-cors-middy': 'error',
|
package/src/oxlint.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
import { plugin } from './index';
|
|
20
|
-
export = plugin;
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
package/src/oxlint.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
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
|
-
/**
|
|
8
|
-
* oxlint sub-export.
|
|
9
|
-
*
|
|
10
|
-
* Consumers wire oxlint to this entry via:
|
|
11
|
-
* { "jsPlugins": ["eslint-plugin-lambda-security/oxlint"] }
|
|
12
|
-
*
|
|
13
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-lambda-security/oxlint')` and reads
|
|
14
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
15
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
16
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
17
|
-
*
|
|
18
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
19
|
-
*/
|
|
20
2
|
const index_1 = require("./index");
|
|
21
3
|
module.exports = index_1.plugin;
|
|
@@ -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.noEnvLogging = void 0;
|
|
9
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
-
// Logging function names
|
|
11
5
|
const LOGGING_FUNCTIONS = new Set(['log', 'info', 'warn', 'error', 'debug', 'trace']);
|
|
12
6
|
exports.noEnvLogging = (0, eslint_devkit_1.createRule)({
|
|
13
7
|
name: 'no-env-logging',
|
|
@@ -58,11 +52,7 @@ exports.noEnvLogging = (0, eslint_devkit_1.createRule)({
|
|
|
58
52
|
return {};
|
|
59
53
|
}
|
|
60
54
|
const sourceCode = context.sourceCode;
|
|
61
|
-
/**
|
|
62
|
-
* Check if a node is process.env or process.env access
|
|
63
|
-
*/
|
|
64
55
|
function isProcessEnv(node) {
|
|
65
|
-
// Direct process.env
|
|
66
56
|
if (node.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
|
|
67
57
|
node.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
68
58
|
node.object.name === 'process' &&
|
|
@@ -72,16 +62,10 @@ exports.noEnvLogging = (0, eslint_devkit_1.createRule)({
|
|
|
72
62
|
}
|
|
73
63
|
return false;
|
|
74
64
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Check if a node contains process.env
|
|
77
|
-
*/
|
|
78
65
|
function containsProcessEnv(node) {
|
|
79
66
|
const text = sourceCode.getText(node);
|
|
80
67
|
return text.includes('process.env');
|
|
81
68
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Check if this is a console/logger call
|
|
84
|
-
*/
|
|
85
69
|
function isLoggingCall(node) {
|
|
86
70
|
if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression) {
|
|
87
71
|
const obj = node.callee.object;
|
|
@@ -91,11 +75,9 @@ exports.noEnvLogging = (0, eslint_devkit_1.createRule)({
|
|
|
91
75
|
const methodName = prop.name;
|
|
92
76
|
if (!LOGGING_FUNCTIONS.has(methodName))
|
|
93
77
|
return false;
|
|
94
|
-
// console.log, console.info, etc.
|
|
95
78
|
if (obj.type === eslint_devkit_1.AST_NODE_TYPES.Identifier && obj.name === 'console') {
|
|
96
79
|
return true;
|
|
97
80
|
}
|
|
98
|
-
// logger.log, log.info, etc.
|
|
99
81
|
if (obj.type === eslint_devkit_1.AST_NODE_TYPES.Identifier && /log(ger)?/i.test(obj.name)) {
|
|
100
82
|
return true;
|
|
101
83
|
}
|
|
@@ -106,9 +88,7 @@ exports.noEnvLogging = (0, eslint_devkit_1.createRule)({
|
|
|
106
88
|
CallExpression(node) {
|
|
107
89
|
if (!isLoggingCall(node))
|
|
108
90
|
return;
|
|
109
|
-
// Check each argument for process.env
|
|
110
91
|
for (const arg of node.arguments) {
|
|
111
|
-
// Direct process.env logging
|
|
112
92
|
if (isProcessEnv(arg)) {
|
|
113
93
|
context.report({
|
|
114
94
|
node: arg,
|
|
@@ -116,11 +96,8 @@ exports.noEnvLogging = (0, eslint_devkit_1.createRule)({
|
|
|
116
96
|
suggest: [{ messageId: 'removeEnvLogging', fix: () => null }],
|
|
117
97
|
});
|
|
118
98
|
}
|
|
119
|
-
// process.env inside template literal or string concatenation
|
|
120
99
|
else if (containsProcessEnv(arg)) {
|
|
121
|
-
// Don't flag if it's just a specific env var access like process.env.AWS_REGION
|
|
122
100
|
const text = sourceCode.getText(arg);
|
|
123
|
-
// Flag if it's the entire process.env object
|
|
124
101
|
if (/process\.env\s*[,)\]]/.test(text) || /JSON\.stringify\s*\(\s*process\.env\s*\)/.test(text)) {
|
|
125
102
|
context.report({
|
|
126
103
|
node: arg,
|
|
@@ -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.noErrorSwallowing = void 0;
|
|
9
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -63,29 +58,20 @@ exports.noErrorSwallowing = (0, eslint_devkit_1.createRule)({
|
|
|
63
58
|
if (allowInTests && isTestFile) {
|
|
64
59
|
return {};
|
|
65
60
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Check if a catch block has any logging
|
|
68
|
-
*/
|
|
69
61
|
function hasLogging(block) {
|
|
70
62
|
const sourceCode = context.sourceCode;
|
|
71
63
|
const blockText = sourceCode.getText(block);
|
|
72
|
-
// console.log/error/warn/info/debug
|
|
73
64
|
if (/console\.\s*(log|error|warn|info|debug)\s*\(/.test(blockText)) {
|
|
74
65
|
return true;
|
|
75
66
|
}
|
|
76
|
-
// logger.error, winston.error, pino.error, bunyan.error, log.error
|
|
77
67
|
if (/(logger|log|winston|pino|bunyan)\.\s*(error|warn|info|debug|log)\s*\(/.test(blockText)) {
|
|
78
68
|
return true;
|
|
79
69
|
}
|
|
80
|
-
// Direct function call: logError(), reportError(), warnUser()
|
|
81
70
|
if (/\b(log|error|warn)\w*\s*\(/.test(blockText)) {
|
|
82
71
|
return true;
|
|
83
72
|
}
|
|
84
73
|
return false;
|
|
85
74
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Check if block has comments indicating intentional swallowing
|
|
88
|
-
*/
|
|
89
75
|
function hasIntentionalComment(node) {
|
|
90
76
|
if (!allowWithComment)
|
|
91
77
|
return false;
|
|
@@ -93,22 +79,15 @@ exports.noErrorSwallowing = (0, eslint_devkit_1.createRule)({
|
|
|
93
79
|
const comments = sourceCode.getCommentsInside(node.body);
|
|
94
80
|
return comments.some((comment) => /intentional|expected|ignore|suppress|handled|silent/i.test(comment.value));
|
|
95
81
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Check if catch has throw/rethrow
|
|
98
|
-
*/
|
|
99
82
|
function hasThrow(block) {
|
|
100
83
|
return block.body.some((stmt) => stmt.type === eslint_devkit_1.AST_NODE_TYPES.ThrowStatement);
|
|
101
84
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Check if catch has return (might be valid in some contexts)
|
|
104
|
-
*/
|
|
105
85
|
function hasReturn(block) {
|
|
106
86
|
return block.body.some((stmt) => stmt.type === eslint_devkit_1.AST_NODE_TYPES.ReturnStatement);
|
|
107
87
|
}
|
|
108
88
|
return {
|
|
109
89
|
CatchClause(node) {
|
|
110
90
|
const body = node.body;
|
|
111
|
-
// Empty catch block
|
|
112
91
|
if (body.body.length === 0) {
|
|
113
92
|
if (!hasIntentionalComment(node)) {
|
|
114
93
|
context.report({
|
|
@@ -129,22 +108,17 @@ exports.noErrorSwallowing = (0, eslint_devkit_1.createRule)({
|
|
|
129
108
|
}
|
|
130
109
|
return;
|
|
131
110
|
}
|
|
132
|
-
// Has throw - OK, error is propagated
|
|
133
111
|
if (hasThrow(body)) {
|
|
134
112
|
return;
|
|
135
113
|
}
|
|
136
|
-
// Check if there's logging
|
|
137
114
|
if (!hasLogging(body)) {
|
|
138
|
-
// If there's a return with error context, that's also OK
|
|
139
115
|
if (hasReturn(body)) {
|
|
140
|
-
// Check if return includes error info
|
|
141
116
|
const returnStmt = body.body.find((s) => s.type === eslint_devkit_1.AST_NODE_TYPES.ReturnStatement);
|
|
142
117
|
if (returnStmt?.argument) {
|
|
143
|
-
// Check if return includes status 500 or error body
|
|
144
118
|
const sourceCode = context.sourceCode;
|
|
145
119
|
const returnText = sourceCode.getText(returnStmt.argument);
|
|
146
120
|
if (/500|error|fail/i.test(returnText)) {
|
|
147
|
-
return;
|
|
121
|
+
return;
|
|
148
122
|
}
|
|
149
123
|
}
|
|
150
124
|
}
|
|
@@ -1,14 +1,6 @@
|
|
|
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.noExposedDebugEndpoints = void 0;
|
|
9
|
-
/**
|
|
10
|
-
* @fileoverview Detect debug endpoints without auth in AWS Lambda handlers
|
|
11
|
-
*/
|
|
12
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
13
5
|
const DEFAULT_DEBUG_PATHS = ['/debug', '/__debug__', '/admin', '/_admin', '/test', '/health'];
|
|
14
6
|
exports.noExposedDebugEndpoints = (0, eslint_devkit_1.createRule)({
|
|
@@ -69,7 +61,6 @@ exports.noExposedDebugEndpoints = (0, eslint_devkit_1.createRule)({
|
|
|
69
61
|
node.value.type === 'Literal' && typeof node.value.value === 'string') {
|
|
70
62
|
const path = node.value.value.toLowerCase();
|
|
71
63
|
if (debugPaths.some(dp => path.includes(dp.toLowerCase()))) {
|
|
72
|
-
// Check if it's inside an 'http' or 'httpApi' block
|
|
73
64
|
let parent = node.parent;
|
|
74
65
|
while (parent) {
|
|
75
66
|
if (parent.type === 'Property' && parent.key.type === 'Identifier' &&
|
|
@@ -83,13 +74,11 @@ exports.noExposedDebugEndpoints = (0, eslint_devkit_1.createRule)({
|
|
|
83
74
|
}
|
|
84
75
|
},
|
|
85
76
|
BinaryExpression(node) {
|
|
86
|
-
// Detect event.path === '/debug' or event.rawPath.includes('/admin')
|
|
87
77
|
if (node.operator === '===' || node.operator === '==' || node.operator === '!==' || node.operator === '!=') {
|
|
88
78
|
const checkNode = (side) => {
|
|
89
79
|
if (side.type === 'Literal' && typeof side.value === 'string') {
|
|
90
80
|
const val = side.value.toLowerCase();
|
|
91
81
|
if (debugPaths.some(dp => val.includes(dp.toLowerCase()))) {
|
|
92
|
-
// Check if the other side is an event property
|
|
93
82
|
const other = side === node.left ? node.right : node.left;
|
|
94
83
|
if (other.type === 'MemberExpression' &&
|
|
95
84
|
other.object.type === 'Identifier' &&
|
|
@@ -109,7 +98,6 @@ exports.noExposedDebugEndpoints = (0, eslint_devkit_1.createRule)({
|
|
|
109
98
|
if (typeof node.value === 'string') {
|
|
110
99
|
const path = node.value.toLowerCase();
|
|
111
100
|
if (debugPaths.some(dp => path === dp.toLowerCase())) {
|
|
112
|
-
// Avoid double reporting if it's already in a BinaryExpression path check
|
|
113
101
|
const parent = node.parent;
|
|
114
102
|
if (parent && parent.type === 'BinaryExpression' &&
|
|
115
103
|
(parent.left === node || parent.right === node)) {
|
|
@@ -120,7 +108,6 @@ exports.noExposedDebugEndpoints = (0, eslint_devkit_1.createRule)({
|
|
|
120
108
|
return;
|
|
121
109
|
}
|
|
122
110
|
}
|
|
123
|
-
// Avoid double reporting for Serverless config check handled by Property listener
|
|
124
111
|
if (parent && parent.type === 'Property' && parent.key.type === 'Identifier' && parent.key.name === 'path') {
|
|
125
112
|
return;
|
|
126
113
|
}
|
|
@@ -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.noExposedErrorDetails = void 0;
|
|
9
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
-
// Properties that expose internal details
|
|
11
5
|
const SENSITIVE_ERROR_PROPERTIES = new Set([
|
|
12
6
|
'stack',
|
|
13
7
|
'stackTrace',
|
|
@@ -72,19 +66,12 @@ exports.noExposedErrorDetails = (0, eslint_devkit_1.createRule)({
|
|
|
72
66
|
if (allowInTests && isTestFile) {
|
|
73
67
|
return {};
|
|
74
68
|
}
|
|
75
|
-
// Track if we're inside a return statement that looks like API response
|
|
76
69
|
let insideApiResponse = false;
|
|
77
|
-
/**
|
|
78
|
-
* Check if this return looks like an API Gateway response
|
|
79
|
-
*/
|
|
80
70
|
function isApiResponse(node) {
|
|
81
71
|
return node.properties.some((prop) => prop.type === eslint_devkit_1.AST_NODE_TYPES.Property &&
|
|
82
72
|
prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
83
73
|
['statusCode', 'body', 'headers'].includes(prop.key.name));
|
|
84
74
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Check if member expression accesses sensitive property
|
|
87
|
-
*/
|
|
88
75
|
function getSensitiveProperty(node) {
|
|
89
76
|
if (node.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
90
77
|
if (SENSITIVE_ERROR_PROPERTIES.has(node.property.name)) {
|
|
@@ -108,9 +95,7 @@ exports.noExposedErrorDetails = (0, eslint_devkit_1.createRule)({
|
|
|
108
95
|
return;
|
|
109
96
|
const sensitiveProperty = getSensitiveProperty(node);
|
|
110
97
|
if (sensitiveProperty) {
|
|
111
|
-
// Check if this is in a body property or response
|
|
112
98
|
const parent = node.parent;
|
|
113
|
-
// error.stack in response
|
|
114
99
|
if (parent?.type === eslint_devkit_1.AST_NODE_TYPES.Property ||
|
|
115
100
|
parent?.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression) {
|
|
116
101
|
context.report({
|
|
@@ -129,7 +114,6 @@ exports.noExposedErrorDetails = (0, eslint_devkit_1.createRule)({
|
|
|
129
114
|
}
|
|
130
115
|
}
|
|
131
116
|
},
|
|
132
|
-
// JSON.stringify(error) - stringifying entire error object
|
|
133
117
|
CallExpression(node) {
|
|
134
118
|
if (!insideApiResponse)
|
|
135
119
|
return;
|
|
@@ -140,7 +124,6 @@ exports.noExposedErrorDetails = (0, eslint_devkit_1.createRule)({
|
|
|
140
124
|
node.callee.property.name === 'stringify') {
|
|
141
125
|
const arg = node.arguments[0];
|
|
142
126
|
if (arg?.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
143
|
-
// Check if it looks like an error variable
|
|
144
127
|
if (/error|err|e|exception/i.test(arg.name)) {
|
|
145
128
|
context.report({
|
|
146
129
|
node,
|