eslint-plugin-secure-coding 3.0.1 → 3.0.3
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/AGENTS.md +1 -1
- package/README.md +41 -206
- package/package.json +6 -5
- package/src/index.d.ts +2 -2
- package/src/index.js +29 -263
- package/src/rules/detect-non-literal-regexp/index.d.ts +3 -1
- package/src/rules/detect-object-injection/index.d.ts +3 -1
- package/src/rules/detect-object-injection/index.js +63 -0
- package/src/rules/detect-weak-password-validation/index.d.ts +3 -1
- package/src/rules/no-directive-injection/index.d.ts +3 -1
- package/src/rules/no-electron-security-issues/index.d.ts +3 -1
- package/src/rules/no-format-string-injection/index.d.ts +3 -1
- package/src/rules/no-graphql-injection/index.d.ts +10 -1
- package/src/rules/no-graphql-injection/index.js +294 -38
- package/src/rules/no-hardcoded-credentials/index.d.ts +3 -1
- package/src/rules/no-hardcoded-session-tokens/index.d.ts +3 -1
- package/src/rules/no-improper-sanitization/index.d.ts +3 -1
- package/src/rules/no-improper-type-validation/index.d.ts +3 -1
- package/src/rules/no-insecure-comparison/index.d.ts +3 -1
- package/src/rules/no-insecure-comparison/index.js +9 -0
- package/src/rules/no-ldap-injection/index.d.ts +3 -1
- package/src/rules/no-missing-authentication/index.d.ts +3 -1
- package/src/rules/no-missing-authentication/index.js +0 -1
- package/src/rules/no-pii-in-logs/index.d.ts +3 -1
- package/src/rules/no-privilege-escalation/index.d.ts +3 -1
- package/src/rules/no-redos-vulnerable-regex/index.d.ts +3 -1
- package/src/rules/no-sensitive-data-exposure/index.d.ts +3 -1
- package/src/rules/no-sensitive-data-exposure/index.js +33 -18
- package/src/rules/no-unchecked-loop-condition/index.d.ts +3 -1
- package/src/rules/no-unlimited-resource-allocation/index.d.ts +3 -1
- package/src/rules/no-unsafe-deserialization/index.d.ts +3 -1
- package/src/rules/no-unsafe-regex-construction/index.d.ts +3 -1
- package/src/rules/no-weak-password-recovery/index.d.ts +3 -1
- package/src/rules/no-xpath-injection/index.d.ts +3 -1
- package/src/rules/no-xpath-injection/index.js +26 -2
- package/src/rules/no-xxe-injection/index.d.ts +3 -1
- package/src/rules/require-backend-authorization/index.d.ts +3 -1
- package/src/rules/require-secure-defaults/index.d.ts +3 -1
- package/src/types/index.d.ts +5 -52
- package/src/rules/detect-child-process/index.d.ts +0 -28
- package/src/rules/detect-child-process/index.js +0 -534
- package/src/rules/detect-eval-with-expression/index.d.ts +0 -26
- package/src/rules/detect-eval-with-expression/index.js +0 -397
- package/src/rules/detect-mixed-content/index.d.ts +0 -10
- package/src/rules/detect-mixed-content/index.js +0 -45
- package/src/rules/detect-non-literal-fs-filename/index.d.ts +0 -24
- package/src/rules/detect-non-literal-fs-filename/index.js +0 -459
- package/src/rules/detect-suspicious-dependencies/index.d.ts +0 -10
- package/src/rules/detect-suspicious-dependencies/index.js +0 -76
- package/src/rules/no-allow-arbitrary-loads/index.d.ts +0 -10
- package/src/rules/no-allow-arbitrary-loads/index.js +0 -48
- package/src/rules/no-arbitrary-file-access/index.d.ts +0 -10
- package/src/rules/no-arbitrary-file-access/index.js +0 -200
- package/src/rules/no-buffer-overread/index.d.ts +0 -37
- package/src/rules/no-buffer-overread/index.js +0 -611
- package/src/rules/no-clickjacking/index.d.ts +0 -34
- package/src/rules/no-clickjacking/index.js +0 -401
- package/src/rules/no-client-side-auth-logic/index.d.ts +0 -10
- package/src/rules/no-client-side-auth-logic/index.js +0 -74
- package/src/rules/no-credentials-in-query-params/index.d.ts +0 -10
- package/src/rules/no-credentials-in-query-params/index.js +0 -62
- package/src/rules/no-data-in-temp-storage/index.d.ts +0 -10
- package/src/rules/no-data-in-temp-storage/index.js +0 -69
- package/src/rules/no-debug-code-in-production/index.d.ts +0 -10
- package/src/rules/no-debug-code-in-production/index.js +0 -54
- package/src/rules/no-disabled-certificate-validation/index.d.ts +0 -10
- package/src/rules/no-disabled-certificate-validation/index.js +0 -66
- package/src/rules/no-dynamic-dependency-loading/index.d.ts +0 -10
- package/src/rules/no-dynamic-dependency-loading/index.js +0 -54
- package/src/rules/no-exposed-debug-endpoints/index.d.ts +0 -10
- package/src/rules/no-exposed-debug-endpoints/index.js +0 -67
- package/src/rules/no-exposed-sensitive-data/index.d.ts +0 -28
- package/src/rules/no-exposed-sensitive-data/index.js +0 -345
- package/src/rules/no-http-urls/index.d.ts +0 -15
- package/src/rules/no-http-urls/index.js +0 -119
- package/src/rules/no-insecure-redirects/index.d.ts +0 -24
- package/src/rules/no-insecure-redirects/index.js +0 -221
- package/src/rules/no-insecure-websocket/index.d.ts +0 -10
- package/src/rules/no-insecure-websocket/index.js +0 -66
- package/src/rules/no-missing-cors-check/index.d.ts +0 -26
- package/src/rules/no-missing-cors-check/index.js +0 -404
- package/src/rules/no-missing-csrf-protection/index.d.ts +0 -28
- package/src/rules/no-missing-csrf-protection/index.js +0 -185
- package/src/rules/no-missing-security-headers/index.d.ts +0 -24
- package/src/rules/no-missing-security-headers/index.js +0 -223
- package/src/rules/no-password-in-url/index.d.ts +0 -10
- package/src/rules/no-password-in-url/index.js +0 -55
- package/src/rules/no-permissive-cors/index.d.ts +0 -10
- package/src/rules/no-permissive-cors/index.js +0 -74
- package/src/rules/no-sensitive-data-in-analytics/index.d.ts +0 -10
- package/src/rules/no-sensitive-data-in-analytics/index.js +0 -66
- package/src/rules/no-sensitive-data-in-cache/index.d.ts +0 -10
- package/src/rules/no-sensitive-data-in-cache/index.js +0 -53
- package/src/rules/no-toctou-vulnerability/index.d.ts +0 -24
- package/src/rules/no-toctou-vulnerability/index.js +0 -213
- package/src/rules/no-tracking-without-consent/index.d.ts +0 -10
- package/src/rules/no-tracking-without-consent/index.js +0 -72
- package/src/rules/no-unencrypted-transmission/index.d.ts +0 -28
- package/src/rules/no-unencrypted-transmission/index.js +0 -241
- package/src/rules/no-unescaped-url-parameter/index.d.ts +0 -26
- package/src/rules/no-unescaped-url-parameter/index.js +0 -360
- package/src/rules/no-unsafe-dynamic-require/index.d.ts +0 -17
- package/src/rules/no-unsafe-dynamic-require/index.js +0 -111
- package/src/rules/no-unvalidated-deeplinks/index.d.ts +0 -10
- package/src/rules/no-unvalidated-deeplinks/index.js +0 -67
- package/src/rules/no-unvalidated-user-input/index.d.ts +0 -26
- package/src/rules/no-unvalidated-user-input/index.js +0 -425
- package/src/rules/no-verbose-error-messages/index.d.ts +0 -10
- package/src/rules/no-verbose-error-messages/index.js +0 -73
- package/src/rules/no-zip-slip/index.d.ts +0 -33
- package/src/rules/no-zip-slip/index.js +0 -450
- package/src/rules/require-code-minification/index.d.ts +0 -10
- package/src/rules/require-code-minification/index.js +0 -48
- package/src/rules/require-csp-headers/index.d.ts +0 -10
- package/src/rules/require-csp-headers/index.js +0 -69
- package/src/rules/require-data-minimization/index.d.ts +0 -10
- package/src/rules/require-data-minimization/index.js +0 -55
- package/src/rules/require-dependency-integrity/index.d.ts +0 -10
- package/src/rules/require-dependency-integrity/index.js +0 -69
- package/src/rules/require-https-only/index.d.ts +0 -10
- package/src/rules/require-https-only/index.js +0 -67
- package/src/rules/require-mime-type-validation/index.d.ts +0 -10
- package/src/rules/require-mime-type-validation/index.js +0 -71
- package/src/rules/require-network-timeout/index.d.ts +0 -10
- package/src/rules/require-network-timeout/index.js +0 -57
- package/src/rules/require-package-lock/index.d.ts +0 -10
- package/src/rules/require-package-lock/index.js +0 -64
- package/src/rules/require-secure-credential-storage/index.d.ts +0 -10
- package/src/rules/require-secure-credential-storage/index.js +0 -53
- package/src/rules/require-secure-deletion/index.d.ts +0 -10
- package/src/rules/require-secure-deletion/index.js +0 -45
- package/src/rules/require-storage-encryption/index.d.ts +0 -10
- package/src/rules/require-storage-encryption/index.js +0 -53
- package/src/rules/require-url-validation/index.d.ts +0 -10
- package/src/rules/require-url-validation/index.js +0 -77
|
@@ -9,11 +9,23 @@ exports.noSensitiveDataExposure = void 0;
|
|
|
9
9
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
10
|
const eslint_devkit_2 = require("@interlace/eslint-devkit");
|
|
11
11
|
/**
|
|
12
|
-
* Check if string contains sensitive data patterns
|
|
12
|
+
* Check if string contains sensitive data patterns.
|
|
13
|
+
* Handles camelCase (secretKey), snake_case (secret_key), and plain text.
|
|
13
14
|
*/
|
|
14
15
|
function containsSensitiveData(text, patterns) {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
// Normalize camelCase → space separated for matching (secretKey → secret key)
|
|
17
|
+
const normalized = text
|
|
18
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
19
|
+
.toLowerCase();
|
|
20
|
+
for (const pattern of patterns) {
|
|
21
|
+
const escaped = pattern.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
22
|
+
// Allow spaces or underscores as word separators (e.g. 'credit card' matches 'credit_card')
|
|
23
|
+
const flexPattern = escaped.replace(/[_ ]/g, '[_ ]');
|
|
24
|
+
if (new RegExp(`\\b${flexPattern}\\b`, 'i').test(normalized)) {
|
|
25
|
+
return pattern;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
17
29
|
}
|
|
18
30
|
exports.noSensitiveDataExposure = (0, eslint_devkit_2.createRule)({
|
|
19
31
|
name: 'no-sensitive-data-exposure',
|
|
@@ -65,7 +77,7 @@ exports.noSensitiveDataExposure = (0, eslint_devkit_2.createRule)({
|
|
|
65
77
|
sensitivePatterns: {
|
|
66
78
|
type: 'array',
|
|
67
79
|
items: { type: 'string' },
|
|
68
|
-
default: ['password', 'secret', 'token', '
|
|
80
|
+
default: ['password', 'passwd', 'secret', 'token', 'access_token', 'auth_token', 'ssn', 'credit_card', 'creditcard', 'api_key', 'apikey', 'secret_key', 'private_key', 'encryption_key'],
|
|
69
81
|
description: 'Sensitive data patterns',
|
|
70
82
|
},
|
|
71
83
|
checkConsoleLog: {
|
|
@@ -90,14 +102,14 @@ exports.noSensitiveDataExposure = (0, eslint_devkit_2.createRule)({
|
|
|
90
102
|
},
|
|
91
103
|
defaultOptions: [
|
|
92
104
|
{
|
|
93
|
-
sensitivePatterns: ['password', 'secret', 'token', '
|
|
105
|
+
sensitivePatterns: ['password', 'passwd', 'secret', 'token', 'access_token', 'auth_token', 'ssn', 'credit_card', 'creditcard', 'api_key', 'apikey', 'secret_key', 'private_key', 'encryption_key'],
|
|
94
106
|
checkConsoleLog: true,
|
|
95
107
|
checkErrorMessages: true,
|
|
96
108
|
checkApiResponses: true,
|
|
97
109
|
},
|
|
98
110
|
],
|
|
99
111
|
create(context, [options = {}]) {
|
|
100
|
-
const { sensitivePatterns = ['password', 'secret', 'token', '
|
|
112
|
+
const { sensitivePatterns = ['password', 'passwd', 'secret', 'token', 'access_token', 'auth_token', 'ssn', 'credit_card', 'creditcard', 'api_key', 'apikey', 'secret_key', 'private_key', 'encryption_key'], checkConsoleLog = true, checkErrorMessages = true, } = options || {};
|
|
101
113
|
/**
|
|
102
114
|
* Check CallExpression for logging calls with sensitive data
|
|
103
115
|
*/
|
|
@@ -134,13 +146,14 @@ exports.noSensitiveDataExposure = (0, eslint_devkit_2.createRule)({
|
|
|
134
146
|
for (const arg of node.arguments) {
|
|
135
147
|
if (arg.type === 'Literal' && typeof arg.value === 'string') {
|
|
136
148
|
const text = arg.value;
|
|
137
|
-
|
|
149
|
+
const matchedPattern = containsSensitiveData(text, sensitivePatterns);
|
|
150
|
+
if (matchedPattern) {
|
|
138
151
|
context.report({
|
|
139
152
|
node: arg,
|
|
140
153
|
messageId: 'sensitiveDataExposure',
|
|
141
154
|
data: {
|
|
142
155
|
context: 'logs',
|
|
143
|
-
dataType:
|
|
156
|
+
dataType: matchedPattern,
|
|
144
157
|
},
|
|
145
158
|
suggest: [
|
|
146
159
|
{ messageId: 'redactData', fix: () => null },
|
|
@@ -152,14 +165,14 @@ exports.noSensitiveDataExposure = (0, eslint_devkit_2.createRule)({
|
|
|
152
165
|
}
|
|
153
166
|
}
|
|
154
167
|
else if (arg.type === 'Identifier' && arg.name) {
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
168
|
+
const matchedPattern2 = containsSensitiveData(arg.name, sensitivePatterns);
|
|
169
|
+
if (matchedPattern2) {
|
|
157
170
|
context.report({
|
|
158
171
|
node: arg,
|
|
159
172
|
messageId: 'sensitiveDataExposure',
|
|
160
173
|
data: {
|
|
161
174
|
context: 'logs',
|
|
162
|
-
dataType:
|
|
175
|
+
dataType: matchedPattern2,
|
|
163
176
|
},
|
|
164
177
|
suggest: [
|
|
165
178
|
{ messageId: 'redactData', fix: () => null },
|
|
@@ -185,13 +198,14 @@ exports.noSensitiveDataExposure = (0, eslint_devkit_2.createRule)({
|
|
|
185
198
|
for (const arg of node.arguments) {
|
|
186
199
|
if (arg.type === 'Literal' && typeof arg.value === 'string') {
|
|
187
200
|
const text = arg.value;
|
|
188
|
-
|
|
201
|
+
const matchedErrPattern = containsSensitiveData(text, sensitivePatterns);
|
|
202
|
+
if (matchedErrPattern) {
|
|
189
203
|
context.report({
|
|
190
204
|
node: arg,
|
|
191
205
|
messageId: 'sensitiveDataExposure',
|
|
192
206
|
data: {
|
|
193
207
|
context: 'error messages',
|
|
194
|
-
dataType:
|
|
208
|
+
dataType: matchedErrPattern,
|
|
195
209
|
},
|
|
196
210
|
suggest: [
|
|
197
211
|
{ messageId: 'redactData', fix: () => null },
|
|
@@ -206,13 +220,14 @@ exports.noSensitiveDataExposure = (0, eslint_devkit_2.createRule)({
|
|
|
206
220
|
// Check left side if it's a literal
|
|
207
221
|
if (arg.left && arg.left.type === 'Literal' && typeof arg.left.value === 'string') {
|
|
208
222
|
const leftText = arg.left.value;
|
|
209
|
-
|
|
223
|
+
const leftMatchedPattern = containsSensitiveData(leftText, sensitivePatterns);
|
|
224
|
+
if (leftMatchedPattern) {
|
|
210
225
|
context.report({
|
|
211
226
|
node: arg.left,
|
|
212
227
|
messageId: 'sensitiveDataExposure',
|
|
213
228
|
data: {
|
|
214
229
|
context: 'error messages',
|
|
215
|
-
dataType:
|
|
230
|
+
dataType: leftMatchedPattern,
|
|
216
231
|
},
|
|
217
232
|
suggest: [
|
|
218
233
|
{ messageId: 'redactData', fix: () => null },
|
|
@@ -225,14 +240,14 @@ exports.noSensitiveDataExposure = (0, eslint_devkit_2.createRule)({
|
|
|
225
240
|
}
|
|
226
241
|
// Check right side if it's an identifier
|
|
227
242
|
if (arg.right && arg.right.type === 'Identifier' && arg.right.name) {
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
243
|
+
const rightMatchedPattern = containsSensitiveData(arg.right.name, sensitivePatterns);
|
|
244
|
+
if (rightMatchedPattern) {
|
|
230
245
|
context.report({
|
|
231
246
|
node: arg.right,
|
|
232
247
|
messageId: 'sensitiveDataExposure',
|
|
233
248
|
data: {
|
|
234
249
|
context: 'error messages',
|
|
235
|
-
dataType:
|
|
250
|
+
dataType: rightMatchedPattern,
|
|
236
251
|
},
|
|
237
252
|
suggest: [
|
|
238
253
|
{ messageId: 'redactData', fix: () => null },
|
|
@@ -32,5 +32,7 @@ export interface Options extends SecurityRuleOptions {
|
|
|
32
32
|
maxRecursionDepth?: number;
|
|
33
33
|
}
|
|
34
34
|
type RuleOptions = [Options?];
|
|
35
|
-
export declare const noUncheckedLoopCondition: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
35
|
+
export declare const noUncheckedLoopCondition: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
36
38
|
export {};
|
|
@@ -32,5 +32,7 @@ export interface Options extends SecurityRuleOptions {
|
|
|
32
32
|
requireResourceValidation?: boolean;
|
|
33
33
|
}
|
|
34
34
|
type RuleOptions = [Options?];
|
|
35
|
-
export declare const noUnlimitedResourceAllocation: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
35
|
+
export declare const noUnlimitedResourceAllocation: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
36
38
|
export {};
|
|
@@ -34,5 +34,7 @@ export interface Options extends SecurityRuleOptions {
|
|
|
34
34
|
validationFunctions?: string[];
|
|
35
35
|
}
|
|
36
36
|
type RuleOptions = [Options?];
|
|
37
|
-
export declare const noUnsafeDeserialization: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
37
|
+
export declare const noUnsafeDeserialization: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
38
40
|
export {};
|
|
@@ -24,5 +24,7 @@ export interface Options {
|
|
|
24
24
|
maxPatternLength?: number;
|
|
25
25
|
}
|
|
26
26
|
type RuleOptions = [Options?];
|
|
27
|
-
export declare const noUnsafeRegexConstruction: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
27
|
+
export declare const noUnsafeRegexConstruction: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
28
30
|
export {};
|
|
@@ -32,5 +32,7 @@ export interface Options extends SecurityRuleOptions {
|
|
|
32
32
|
secureTokenFunctions?: string[];
|
|
33
33
|
}
|
|
34
34
|
type RuleOptions = [Options?];
|
|
35
|
-
export declare const noWeakPasswordRecovery: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
35
|
+
export declare const noWeakPasswordRecovery: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
36
38
|
export {};
|
|
@@ -33,5 +33,7 @@ export interface Options extends SecurityRuleOptions {
|
|
|
33
33
|
xpathValidationFunctions?: string[];
|
|
34
34
|
}
|
|
35
35
|
type RuleOptions = [Options?];
|
|
36
|
-
export declare const noXpathInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
36
|
+
export declare const noXpathInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
37
|
+
name: string;
|
|
38
|
+
};
|
|
37
39
|
export {};
|
|
@@ -355,8 +355,32 @@ exports.noXpathInjection = (0, eslint_devkit_1.createRule)({
|
|
|
355
355
|
// Check template literals for XPath expressions
|
|
356
356
|
TemplateLiteral(node) {
|
|
357
357
|
const fullText = sourceCode.getText(node);
|
|
358
|
-
//
|
|
359
|
-
|
|
358
|
+
// Skip common non-XPath patterns
|
|
359
|
+
// URLs and API endpoints
|
|
360
|
+
if (/https?:\/\//.test(fullText) || /^[`'"]\s*\/api\//.test(fullText)) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
// File paths (start with / or contain common path patterns)
|
|
364
|
+
if (/^[`'"]\s*\/home\//.test(fullText) || /^[`'"]\s*\/usr\//.test(fullText) || /^[`'"]\s*\/tmp\//.test(fullText)) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
// CSS selectors
|
|
368
|
+
if (/\[data-[\w-]+/.test(fullText) || /\[class=/.test(fullText) || /\[id=/.test(fullText)) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
// Search/query strings
|
|
372
|
+
if (/\?.*=/.test(fullText) && !/\[@/.test(fullText)) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
// Check if this looks like an ACTUAL XPath expression
|
|
376
|
+
// Must have XPath-specific syntax, not just forward slashes
|
|
377
|
+
const hasXpathSyntax = /\/\/\w+/.test(fullText) || // //element
|
|
378
|
+
/\[@\w+/.test(fullText) || // [@attr
|
|
379
|
+
/\[contains\(/.test(fullText) || // [contains(
|
|
380
|
+
/\[text\(\)/.test(fullText) || // [text()
|
|
381
|
+
/\/child::/.test(fullText) || // /child::
|
|
382
|
+
/\/descendant::/.test(fullText); // /descendant::
|
|
383
|
+
if (!hasXpathSyntax) {
|
|
360
384
|
return;
|
|
361
385
|
}
|
|
362
386
|
// Check for interpolation in XPath-like expressions
|
|
@@ -30,5 +30,7 @@ export interface Options {
|
|
|
30
30
|
xmlValidationFunctions?: string[];
|
|
31
31
|
}
|
|
32
32
|
type RuleOptions = [Options?];
|
|
33
|
-
export declare const noXxeInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
33
|
+
export declare const noXxeInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
34
36
|
export {};
|
|
@@ -6,5 +6,7 @@
|
|
|
6
6
|
export interface Options {
|
|
7
7
|
}
|
|
8
8
|
type RuleOptions = [Options?];
|
|
9
|
-
export declare const requireBackendAuthorization: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
9
|
+
export declare const requireBackendAuthorization: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
10
12
|
export {};
|
|
@@ -6,5 +6,7 @@
|
|
|
6
6
|
export interface Options {
|
|
7
7
|
}
|
|
8
8
|
type RuleOptions = [Options?];
|
|
9
|
-
export declare const requireSecureDefaults: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
9
|
+
export declare const requireSecureDefaults: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
10
12
|
export {};
|
package/src/types/index.d.ts
CHANGED
|
@@ -7,28 +7,13 @@
|
|
|
7
7
|
* eslint-plugin-secure-coding Type Exports
|
|
8
8
|
*
|
|
9
9
|
* Barrel file that exports all security rule Options types with consistent naming.
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import type { NoHardcodedCredentialsOptions } from 'eslint-plugin-secure-coding/types';
|
|
14
|
-
*
|
|
15
|
-
* const config: NoHardcodedCredentialsOptions = {
|
|
16
|
-
* ignorePatterns: ['test/*'],
|
|
17
|
-
* };
|
|
18
|
-
* ```
|
|
19
10
|
*/
|
|
20
|
-
import type { Options as DetectEvalWithExpressionOptions } from '../rules/detect-eval-with-expression';
|
|
21
|
-
import type { Options as DetectChildProcessOptions } from '../rules/detect-child-process';
|
|
22
|
-
import type { Options as NoUnsafeDynamicRequireOptions } from '../rules/no-unsafe-dynamic-require';
|
|
23
11
|
import type { Options as NoGraphqlInjectionOptions } from '../rules/no-graphql-injection';
|
|
24
12
|
import type { Options as NoXxeInjectionOptions } from '../rules/no-xxe-injection';
|
|
25
13
|
import type { Options as NoXpathInjectionOptions } from '../rules/no-xpath-injection';
|
|
26
14
|
import type { Options as NoLdapInjectionOptions } from '../rules/no-ldap-injection';
|
|
27
15
|
import type { Options as NoDirectiveInjectionOptions } from '../rules/no-directive-injection';
|
|
28
16
|
import type { Options as NoFormatStringInjectionOptions } from '../rules/no-format-string-injection';
|
|
29
|
-
import type { Options as DetectNonLiteralFsFilenameOptions } from '../rules/detect-non-literal-fs-filename';
|
|
30
|
-
import type { Options as NoZipSlipOptions } from '../rules/no-zip-slip';
|
|
31
|
-
import type { Options as NoToctouVulnerabilityOptions } from '../rules/no-toctou-vulnerability';
|
|
32
17
|
import type { Options as DetectNonLiteralRegexpOptions } from '../rules/detect-non-literal-regexp';
|
|
33
18
|
import type { Options as NoRedosVulnerableRegexOptions } from '../rules/no-redos-vulnerable-regex';
|
|
34
19
|
import type { Options as NoUnsafeRegexConstructionOptions } from '../rules/no-unsafe-regex-construction';
|
|
@@ -36,52 +21,28 @@ import type { Options as DetectObjectInjectionOptions } from '../rules/detect-ob
|
|
|
36
21
|
import type { Options as NoUnsafeDeserializationOptions } from '../rules/no-unsafe-deserialization';
|
|
37
22
|
import type { Options as NoHardcodedCredentialsOptions } from '../rules/no-hardcoded-credentials';
|
|
38
23
|
import type { Options as NoInsecureComparisonOptions } from '../rules/no-insecure-comparison';
|
|
39
|
-
import type { Options as NoUnvalidatedUserInputOptions } from '../rules/no-unvalidated-user-input';
|
|
40
|
-
import type { Options as NoUnescapedUrlParameterOptions } from '../rules/no-unescaped-url-parameter';
|
|
41
24
|
import type { Options as NoImproperSanitizationOptions } from '../rules/no-improper-sanitization';
|
|
42
25
|
import type { Options as NoImproperTypeValidationOptions } from '../rules/no-improper-type-validation';
|
|
43
26
|
import type { Options as NoMissingAuthenticationOptions } from '../rules/no-missing-authentication';
|
|
44
27
|
import type { Options as NoPrivilegeEscalationOptions } from '../rules/no-privilege-escalation';
|
|
45
28
|
import type { Options as NoWeakPasswordRecoveryOptions } from '../rules/no-weak-password-recovery';
|
|
46
|
-
import type { Options as
|
|
47
|
-
import type { Options as NoMissingCorsCheckOptions } from '../rules/no-missing-cors-check';
|
|
48
|
-
import type { Options as NoMissingSecurityHeadersOptions } from '../rules/no-missing-security-headers';
|
|
49
|
-
import type { Options as NoInsecureRedirectsOptions } from '../rules/no-insecure-redirects';
|
|
50
|
-
import type { Options as NoUnencryptedTransmissionOptions } from '../rules/no-unencrypted-transmission';
|
|
51
|
-
import type { Options as NoClickjackingOptions } from '../rules/no-clickjacking';
|
|
52
|
-
import type { Options as NoExposedSensitiveDataOptions } from '../rules/no-exposed-sensitive-data';
|
|
29
|
+
import type { Options as RequireBackendAuthorizationOptions } from '../rules/require-backend-authorization';
|
|
53
30
|
import type { Options as NoSensitiveDataExposureOptions } from '../rules/no-sensitive-data-exposure';
|
|
54
|
-
import type { Options as
|
|
31
|
+
import type { Options as NoPiiInLogsOptions } from '../rules/no-pii-in-logs';
|
|
55
32
|
import type { Options as NoUnlimitedResourceAllocationOptions } from '../rules/no-unlimited-resource-allocation';
|
|
56
33
|
import type { Options as NoUncheckedLoopConditionOptions } from '../rules/no-unchecked-loop-condition';
|
|
57
34
|
import type { Options as NoElectronSecurityIssuesOptions } from '../rules/no-electron-security-issues';
|
|
58
|
-
export type {
|
|
35
|
+
export type { NoGraphqlInjectionOptions, NoXxeInjectionOptions, NoXpathInjectionOptions, NoLdapInjectionOptions, NoDirectiveInjectionOptions, NoFormatStringInjectionOptions, DetectNonLiteralRegexpOptions, NoRedosVulnerableRegexOptions, NoUnsafeRegexConstructionOptions, DetectObjectInjectionOptions, NoUnsafeDeserializationOptions, NoHardcodedCredentialsOptions, NoInsecureComparisonOptions, NoImproperSanitizationOptions, NoImproperTypeValidationOptions, NoMissingAuthenticationOptions, NoPrivilegeEscalationOptions, NoWeakPasswordRecoveryOptions, NoPiiInLogsOptions, RequireBackendAuthorizationOptions, NoSensitiveDataExposureOptions, NoUnlimitedResourceAllocationOptions, NoUncheckedLoopConditionOptions, NoElectronSecurityIssuesOptions, };
|
|
59
36
|
/**
|
|
60
37
|
* Combined type for all security rule options
|
|
61
|
-
* Useful for creating unified configuration objects
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const config: AllSecurityRulesOptions = {
|
|
66
|
-
* 'no-hardcoded-credentials': {
|
|
67
|
-
* ignorePatterns: ['test/*'],
|
|
68
|
-
* },
|
|
69
|
-
* };
|
|
70
|
-
* ```
|
|
71
38
|
*/
|
|
72
39
|
export type AllSecurityRulesOptions = {
|
|
73
|
-
'detect-eval-with-expression'?: DetectEvalWithExpressionOptions;
|
|
74
|
-
'detect-child-process'?: DetectChildProcessOptions;
|
|
75
|
-
'no-unsafe-dynamic-require'?: NoUnsafeDynamicRequireOptions;
|
|
76
40
|
'no-graphql-injection'?: NoGraphqlInjectionOptions;
|
|
77
41
|
'no-xxe-injection'?: NoXxeInjectionOptions;
|
|
78
42
|
'no-xpath-injection'?: NoXpathInjectionOptions;
|
|
79
43
|
'no-ldap-injection'?: NoLdapInjectionOptions;
|
|
80
44
|
'no-directive-injection'?: NoDirectiveInjectionOptions;
|
|
81
45
|
'no-format-string-injection'?: NoFormatStringInjectionOptions;
|
|
82
|
-
'detect-non-literal-fs-filename'?: DetectNonLiteralFsFilenameOptions;
|
|
83
|
-
'no-zip-slip'?: NoZipSlipOptions;
|
|
84
|
-
'no-toctou-vulnerability'?: NoToctouVulnerabilityOptions;
|
|
85
46
|
'detect-non-literal-regexp'?: DetectNonLiteralRegexpOptions;
|
|
86
47
|
'no-redos-vulnerable-regex'?: NoRedosVulnerableRegexOptions;
|
|
87
48
|
'no-unsafe-regex-construction'?: NoUnsafeRegexConstructionOptions;
|
|
@@ -89,22 +50,14 @@ export type AllSecurityRulesOptions = {
|
|
|
89
50
|
'no-unsafe-deserialization'?: NoUnsafeDeserializationOptions;
|
|
90
51
|
'no-hardcoded-credentials'?: NoHardcodedCredentialsOptions;
|
|
91
52
|
'no-insecure-comparison'?: NoInsecureComparisonOptions;
|
|
92
|
-
'no-unvalidated-user-input'?: NoUnvalidatedUserInputOptions;
|
|
93
|
-
'no-unescaped-url-parameter'?: NoUnescapedUrlParameterOptions;
|
|
94
53
|
'no-improper-sanitization'?: NoImproperSanitizationOptions;
|
|
95
54
|
'no-improper-type-validation'?: NoImproperTypeValidationOptions;
|
|
96
55
|
'no-missing-authentication'?: NoMissingAuthenticationOptions;
|
|
97
56
|
'no-privilege-escalation'?: NoPrivilegeEscalationOptions;
|
|
98
57
|
'no-weak-password-recovery'?: NoWeakPasswordRecoveryOptions;
|
|
99
|
-
'no-
|
|
100
|
-
'
|
|
101
|
-
'no-missing-security-headers'?: NoMissingSecurityHeadersOptions;
|
|
102
|
-
'no-insecure-redirects'?: NoInsecureRedirectsOptions;
|
|
103
|
-
'no-unencrypted-transmission'?: NoUnencryptedTransmissionOptions;
|
|
104
|
-
'no-clickjacking'?: NoClickjackingOptions;
|
|
105
|
-
'no-exposed-sensitive-data'?: NoExposedSensitiveDataOptions;
|
|
58
|
+
'no-pii-in-logs'?: NoPiiInLogsOptions;
|
|
59
|
+
'require-backend-authorization'?: RequireBackendAuthorizationOptions;
|
|
106
60
|
'no-sensitive-data-exposure'?: NoSensitiveDataExposureOptions;
|
|
107
|
-
'no-buffer-overread'?: NoBufferOverreadOptions;
|
|
108
61
|
'no-unlimited-resource-allocation'?: NoUnlimitedResourceAllocationOptions;
|
|
109
62
|
'no-unchecked-loop-condition'?: NoUncheckedLoopConditionOptions;
|
|
110
63
|
'no-electron-security-issues'?: NoElectronSecurityIssuesOptions;
|
|
@@ -1,28 +0,0 @@
|
|
|
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: detect-child-process
|
|
8
|
-
* Detects instances of child_process & non-literal exec() calls
|
|
9
|
-
* LLM-optimized with comprehensive command injection prevention guidance
|
|
10
|
-
*
|
|
11
|
-
* @see https://owasp.org/www-community/attacks/Command_Injection
|
|
12
|
-
* @see https://cwe.mitre.org/data/definitions/78.html
|
|
13
|
-
*/
|
|
14
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
-
type MessageIds = 'childProcessCommandInjection' | 'useExecFile' | 'useSpawn' | 'useSaferLibrary' | 'validateInput' | 'useShellFalse' | 'strategyValidate' | 'strategySanitize' | 'strategyRestrict';
|
|
16
|
-
export interface Options {
|
|
17
|
-
/** Allow exec() with literal strings. Default: false (stricter) */
|
|
18
|
-
allowLiteralStrings?: boolean;
|
|
19
|
-
/** Allow spawn() with literal arguments. Default: false (stricter) */
|
|
20
|
-
allowLiteralSpawn?: boolean;
|
|
21
|
-
/** Additional child_process methods to check */
|
|
22
|
-
additionalMethods?: string[];
|
|
23
|
-
/** Strategy for fixing command injection: 'validate', 'sanitize', 'restrict', or 'auto' */
|
|
24
|
-
strategy?: 'validate' | 'sanitize' | 'restrict' | 'auto';
|
|
25
|
-
}
|
|
26
|
-
type RuleOptions = [Options?];
|
|
27
|
-
export declare const detectChildProcess: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
|
|
28
|
-
export {};
|