eslint-plugin-secure-coding 3.3.4 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +30 -37
- package/src/index.d.ts +17 -23
- package/src/index.js +2 -113
- package/src/oxlint.d.ts +17 -20
- package/src/oxlint.js +0 -18
- package/src/rules/detect-non-literal-regexp/index.js +5 -79
- package/src/rules/detect-object-injection/index.js +2 -221
- package/src/rules/detect-weak-password-validation/index.js +0 -12
- package/src/rules/no-directive-injection/index.js +0 -33
- package/src/rules/no-electron-security-issues/index.js +0 -41
- package/src/rules/no-format-string-injection/index.js +0 -82
- package/src/rules/no-graphql-injection/index.js +86 -151
- package/src/rules/no-hardcoded-credentials/index.js +142 -184
- package/src/rules/no-hardcoded-session-tokens/index.js +0 -11
- package/src/rules/no-improper-sanitization/index.js +0 -44
- package/src/rules/no-improper-type-validation/index.js +1 -51
- package/src/rules/no-insecure-comparison/index.js +39 -35
- package/src/rules/no-ldap-injection/index.js +8 -61
- package/src/rules/no-missing-authentication/index.js +2 -56
- package/src/rules/no-pii-in-logs/index.js +0 -13
- package/src/rules/no-privilege-escalation/index.js +2 -49
- package/src/rules/no-redos-vulnerable-regex/index.js +3 -49
- package/src/rules/no-sensitive-data-exposure/index.js +5 -29
- package/src/rules/no-template-injection/index.js +0 -6
- package/src/rules/no-unchecked-loop-condition/index.js +3 -99
- package/src/rules/no-unlimited-resource-allocation/index.js +2 -75
- package/src/rules/no-unsafe-deserialization/index.js +55 -66
- package/src/rules/no-unsafe-regex-construction/index.js +22 -62
- package/src/rules/no-weak-password-recovery/index.js +0 -43
- package/src/rules/no-xpath-injection/index.js +13 -75
- package/src/rules/no-xxe-injection/index.js +1 -47
- package/src/rules/require-backend-authorization/index.js +0 -10
- package/src/rules/require-secure-defaults/index.js +0 -10
- package/src/types/index.js +0 -5
- package/AGENTS.md +0 -131
- package/CHANGELOG.md +0 -311
- package/src/rules/detect-non-literal-regexp/index.d.ts +0 -28
- package/src/rules/detect-object-injection/index.d.ts +0 -35
- package/src/rules/detect-weak-password-validation/index.d.ts +0 -12
- package/src/rules/no-directive-injection/index.d.ts +0 -38
- package/src/rules/no-electron-security-issues/index.d.ts +0 -36
- package/src/rules/no-format-string-injection/index.d.ts +0 -44
- package/src/rules/no-graphql-injection/index.d.ts +0 -47
- package/src/rules/no-hardcoded-credentials/index.d.ts +0 -44
- package/src/rules/no-hardcoded-session-tokens/index.d.ts +0 -12
- package/src/rules/no-improper-sanitization/index.d.ts +0 -38
- package/src/rules/no-improper-type-validation/index.d.ts +0 -36
- package/src/rules/no-insecure-comparison/index.d.ts +0 -26
- package/src/rules/no-ldap-injection/index.d.ts +0 -53
- package/src/rules/no-missing-authentication/index.d.ts +0 -32
- package/src/rules/no-pii-in-logs/index.d.ts +0 -12
- package/src/rules/no-privilege-escalation/index.d.ts +0 -32
- package/src/rules/no-redos-vulnerable-regex/index.d.ts +0 -28
- package/src/rules/no-sensitive-data-exposure/index.d.ts +0 -30
- package/src/rules/no-template-injection/index.d.ts +0 -23
- package/src/rules/no-unchecked-loop-condition/index.d.ts +0 -38
- package/src/rules/no-unlimited-resource-allocation/index.d.ts +0 -38
- package/src/rules/no-unsafe-deserialization/index.d.ts +0 -40
- package/src/rules/no-unsafe-regex-construction/index.d.ts +0 -30
- package/src/rules/no-weak-password-recovery/index.d.ts +0 -38
- package/src/rules/no-xpath-injection/index.d.ts +0 -39
- package/src/rules/no-xxe-injection/index.d.ts +0 -36
- package/src/rules/require-backend-authorization/index.d.ts +0 -12
- package/src/rules/require-secure-defaults/index.d.ts +0 -12
|
@@ -1,38 +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: no-unchecked-loop-condition
|
|
8
|
-
* Detects unchecked loop conditions that could cause DoS (CWE-400, CWE-606)
|
|
9
|
-
*
|
|
10
|
-
* Loops with unchecked conditions can cause denial of service by consuming
|
|
11
|
-
* excessive CPU time or memory. This includes infinite loops, loops with
|
|
12
|
-
* user-controlled bounds, and loops without proper termination conditions.
|
|
13
|
-
*
|
|
14
|
-
* False Positive Reduction:
|
|
15
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
16
|
-
* - Safe loop patterns with clear termination
|
|
17
|
-
* - Development/debugging loops
|
|
18
|
-
* - JSDoc annotations (@safe-loop, @intentional)
|
|
19
|
-
* - Timeout protections
|
|
20
|
-
*/
|
|
21
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
22
|
-
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
23
|
-
type MessageIds = 'uncheckedLoopCondition' | 'infiniteLoop' | 'userControlledLoopBound' | 'missingLoopTermination' | 'largeLoopBound' | 'unsafeRecursion' | 'limitLoopIterations';
|
|
24
|
-
export interface Options extends SecurityRuleOptions {
|
|
25
|
-
/** Maximum allowed loop iterations for static analysis */
|
|
26
|
-
maxStaticIterations?: number;
|
|
27
|
-
/** Variables that contain user input */
|
|
28
|
-
userInputVariables?: string[];
|
|
29
|
-
/** Allow while(true) loops with breaks */
|
|
30
|
-
allowWhileTrueWithBreak?: boolean;
|
|
31
|
-
/** Maximum recursion depth to allow */
|
|
32
|
-
maxRecursionDepth?: number;
|
|
33
|
-
}
|
|
34
|
-
type RuleOptions = [Options?];
|
|
35
|
-
export declare const noUncheckedLoopCondition: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
36
|
-
name: string;
|
|
37
|
-
};
|
|
38
|
-
export {};
|
|
@@ -1,38 +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: no-unlimited-resource-allocation
|
|
8
|
-
* Detects unlimited resource allocation vulnerabilities (CWE-770)
|
|
9
|
-
*
|
|
10
|
-
* Unlimited resource allocation can cause denial of service by exhausting
|
|
11
|
-
* system resources like memory, file handles, or network connections.
|
|
12
|
-
* This rule detects patterns where resources are allocated without limits.
|
|
13
|
-
*
|
|
14
|
-
* False Positive Reduction:
|
|
15
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
16
|
-
* - Safe resource allocation patterns
|
|
17
|
-
* - Proper resource limits
|
|
18
|
-
* - JSDoc annotations (@limited-resource, @safe-allocation)
|
|
19
|
-
* - Resource cleanup patterns
|
|
20
|
-
*/
|
|
21
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
22
|
-
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
23
|
-
type MessageIds = 'unlimitedResourceAllocation' | 'unlimitedBufferAllocation' | 'unlimitedFileOperations' | 'unlimitedNetworkConnections' | 'unlimitedMemoryAllocation' | 'userControlledResourceSize' | 'missingResourceLimits' | 'resourceAllocationInLoop' | 'implementResourceLimits' | 'validateResourceSize' | 'useResourcePools' | 'strategyResourceManagement' | 'strategyRateLimiting' | 'strategyResourceCleanup';
|
|
24
|
-
export interface Options extends SecurityRuleOptions {
|
|
25
|
-
/** Maximum allowed resource size for static analysis */
|
|
26
|
-
maxResourceSize?: number;
|
|
27
|
-
/** Variables that contain user input */
|
|
28
|
-
userInputVariables?: string[];
|
|
29
|
-
/** Safe resource allocation functions */
|
|
30
|
-
safeResourceFunctions?: string[];
|
|
31
|
-
/** Require resource validation */
|
|
32
|
-
requireResourceValidation?: boolean;
|
|
33
|
-
}
|
|
34
|
-
type RuleOptions = [Options?];
|
|
35
|
-
export declare const noUnlimitedResourceAllocation: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
36
|
-
name: string;
|
|
37
|
-
};
|
|
38
|
-
export {};
|
|
@@ -1,40 +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: no-unsafe-deserialization
|
|
8
|
-
* Detects unsafe deserialization of untrusted data (CWE-502)
|
|
9
|
-
*
|
|
10
|
-
* Unsafe deserialization occurs when untrusted data is deserialized in a way that
|
|
11
|
-
* allows attackers to execute arbitrary code or manipulate application logic.
|
|
12
|
-
* This includes:
|
|
13
|
-
* - Using dangerous deserialization libraries
|
|
14
|
-
* - eval() or Function() on untrusted data
|
|
15
|
-
* - YAML/XML parsers that can execute code
|
|
16
|
-
* - Unsafe use of serialization libraries
|
|
17
|
-
*
|
|
18
|
-
* False Positive Reduction:
|
|
19
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
20
|
-
* - Safe deserialization patterns
|
|
21
|
-
* - Input validation and sanitization
|
|
22
|
-
* - JSDoc annotations (@safe, @validated)
|
|
23
|
-
* - Trusted deserialization libraries
|
|
24
|
-
*/
|
|
25
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
26
|
-
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
27
|
-
type MessageIds = 'unsafeDeserialization' | 'dangerousEvalUsage' | 'unsafeYamlParsing' | 'dangerousFunctionConstructor' | 'untrustedDeserializationInput' | 'useSafeDeserializer' | 'validateBeforeDeserialization' | 'avoidEval' | 'strategySafeLibraries' | 'strategyInputValidation' | 'strategySandboxing';
|
|
28
|
-
export interface Options extends SecurityRuleOptions {
|
|
29
|
-
/** Dangerous deserialization functions to detect */
|
|
30
|
-
dangerousFunctions?: string[];
|
|
31
|
-
/** Safe deserialization libraries */
|
|
32
|
-
safeLibraries?: string[];
|
|
33
|
-
/** Functions that validate input before deserialization */
|
|
34
|
-
validationFunctions?: string[];
|
|
35
|
-
}
|
|
36
|
-
type RuleOptions = [Options?];
|
|
37
|
-
export declare const noUnsafeDeserialization: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
38
|
-
name: string;
|
|
39
|
-
};
|
|
40
|
-
export {};
|
|
@@ -1,30 +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: no-unsafe-regex-construction
|
|
8
|
-
* Detects unsafe regex construction patterns (user input without escaping, dynamic flags)
|
|
9
|
-
* CWE-400: Uncontrolled Resource Consumption
|
|
10
|
-
*
|
|
11
|
-
* Extends detect-non-literal-regexp with pattern analysis
|
|
12
|
-
*
|
|
13
|
-
* @see https://cwe.mitre.org/data/definitions/400.html
|
|
14
|
-
* @see https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
|
|
15
|
-
*/
|
|
16
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
17
|
-
type MessageIds = 'unsafeRegexConstruction' | 'escapeUserInput' | 'validatePattern' | 'useSafeLibrary' | 'avoidDynamicFlags';
|
|
18
|
-
export interface Options {
|
|
19
|
-
/** Allow literal string patterns. Default: false */
|
|
20
|
-
allowLiterals?: boolean;
|
|
21
|
-
/** Trusted functions that escape input. Default: ['escapeRegex', 'escape', 'sanitize'] */
|
|
22
|
-
trustedEscapingFunctions?: string[];
|
|
23
|
-
/** Maximum pattern length for dynamic regex. Default: 100 */
|
|
24
|
-
maxPatternLength?: number;
|
|
25
|
-
}
|
|
26
|
-
type RuleOptions = [Options?];
|
|
27
|
-
export declare const noUnsafeRegexConstruction: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
28
|
-
name: string;
|
|
29
|
-
};
|
|
30
|
-
export {};
|
|
@@ -1,38 +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: no-weak-password-recovery
|
|
8
|
-
* Detects weak password recovery mechanisms (CWE-640)
|
|
9
|
-
*
|
|
10
|
-
* Weak password recovery mechanisms can allow attackers to reset passwords
|
|
11
|
-
* for other users, gain unauthorized access, or perform account takeover.
|
|
12
|
-
* This rule detects obvious vulnerabilities in password recovery logic.
|
|
13
|
-
*
|
|
14
|
-
* False Positive Reduction:
|
|
15
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
16
|
-
* - Proper recovery implementations
|
|
17
|
-
* - Rate limiting mechanisms
|
|
18
|
-
* - Secure token generation
|
|
19
|
-
* - JSDoc annotations (@secure-recovery, @rate-limited)
|
|
20
|
-
*/
|
|
21
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
22
|
-
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
23
|
-
type MessageIds = 'weakPasswordRecovery' | 'missingRateLimit' | 'predictableRecoveryToken' | 'unlimitedRecoveryAttempts' | 'insufficientTokenEntropy' | 'missingTokenExpiration' | 'recoveryLoggingSensitiveData' | 'weakRecoveryVerification' | 'tokenReuseVulnerability' | 'implementRateLimiting' | 'useCryptographicallySecureTokens' | 'implementTokenExpiration' | 'secureRecoveryFlow' | 'strategyMultiFactor' | 'strategyOutOfBandVerification' | 'strategyTimeBoundTokens';
|
|
24
|
-
export interface Options extends SecurityRuleOptions {
|
|
25
|
-
/** Minimum token entropy bits */
|
|
26
|
-
minTokenEntropy?: number;
|
|
27
|
-
/** Maximum token lifetime in hours */
|
|
28
|
-
maxTokenLifetimeHours?: number;
|
|
29
|
-
/** Recovery-related keywords */
|
|
30
|
-
recoveryKeywords?: string[];
|
|
31
|
-
/** Secure token generation functions */
|
|
32
|
-
secureTokenFunctions?: string[];
|
|
33
|
-
}
|
|
34
|
-
type RuleOptions = [Options?];
|
|
35
|
-
export declare const noWeakPasswordRecovery: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
36
|
-
name: string;
|
|
37
|
-
};
|
|
38
|
-
export {};
|
|
@@ -1,39 +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: no-xpath-injection
|
|
8
|
-
* Detects XPath injection vulnerabilities (CWE-643)
|
|
9
|
-
*
|
|
10
|
-
* XPath injection occurs when user input is improperly inserted into XPath
|
|
11
|
-
* queries, allowing attackers to:
|
|
12
|
-
* - Access unauthorized XML nodes and data
|
|
13
|
-
* - Extract sensitive information from XML documents
|
|
14
|
-
* - Perform XPath-based attacks and data exfiltration
|
|
15
|
-
* - Bypass authentication or authorization checks
|
|
16
|
-
*
|
|
17
|
-
* False Positive Reduction:
|
|
18
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
19
|
-
* - Safe XPath construction methods
|
|
20
|
-
* - Input validation and sanitization
|
|
21
|
-
* - JSDoc annotations (@xpath-safe, @validated)
|
|
22
|
-
* - Trusted XPath libraries
|
|
23
|
-
*/
|
|
24
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
25
|
-
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
26
|
-
type MessageIds = 'xpathInjection' | 'unsafeXpathConcatenation' | 'unvalidatedXpathInput' | 'dangerousXpathExpression' | 'useParameterizedXpath' | 'escapeXpathInput' | 'validateXpathQueries' | 'strategyParameterizedQueries' | 'strategyInputValidation' | 'strategySafeConstruction';
|
|
27
|
-
export interface Options extends SecurityRuleOptions {
|
|
28
|
-
/** XPath-related function names to check */
|
|
29
|
-
xpathFunctions?: string[];
|
|
30
|
-
/** Functions that safely construct XPath queries */
|
|
31
|
-
safeXpathConstructors?: string[];
|
|
32
|
-
/** Functions that validate/sanitize XPath input */
|
|
33
|
-
xpathValidationFunctions?: string[];
|
|
34
|
-
}
|
|
35
|
-
type RuleOptions = [Options?];
|
|
36
|
-
export declare const noXpathInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
37
|
-
name: string;
|
|
38
|
-
};
|
|
39
|
-
export {};
|
|
@@ -1,36 +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: no-xxe-injection
|
|
8
|
-
* Detects XML External Entity (XXE) injection vulnerabilities (CWE-611)
|
|
9
|
-
*
|
|
10
|
-
* XXE injection occurs when XML parsers process external entity references,
|
|
11
|
-
* allowing attackers to:
|
|
12
|
-
* - Read sensitive local files
|
|
13
|
-
* - Make HTTP requests to internal services
|
|
14
|
-
* - Cause DoS through entity expansion (billion laughs)
|
|
15
|
-
* - Perform SSRF attacks
|
|
16
|
-
*
|
|
17
|
-
* False Positive Reduction:
|
|
18
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
19
|
-
* - Safe XML libraries (libxmljs with secure config, xmldom with entity resolution disabled)
|
|
20
|
-
* - Proper parser configuration
|
|
21
|
-
* - JSDoc annotations (@safe, @xxe-safe)
|
|
22
|
-
* - Input validation and sanitization
|
|
23
|
-
*/
|
|
24
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
25
|
-
type MessageIds = 'xxeInjection' | 'unsafeXmlParser' | 'externalEntityEnabled' | 'untrustedXmlSource';
|
|
26
|
-
export interface Options {
|
|
27
|
-
/** Parser options that indicate safe configuration */
|
|
28
|
-
safeParserOptions?: string[];
|
|
29
|
-
/** Functions that validate/sanitize XML input */
|
|
30
|
-
xmlValidationFunctions?: string[];
|
|
31
|
-
}
|
|
32
|
-
type RuleOptions = [Options?];
|
|
33
|
-
export declare const noXxeInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
34
|
-
name: string;
|
|
35
|
-
};
|
|
36
|
-
export {};
|
|
@@ -1,12 +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
|
-
export interface Options {
|
|
7
|
-
}
|
|
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> & {
|
|
10
|
-
name: string;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
@@ -1,12 +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
|
-
export interface Options {
|
|
7
|
-
}
|
|
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> & {
|
|
10
|
-
name: string;
|
|
11
|
-
};
|
|
12
|
-
export {};
|