eslint-plugin-node-security 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -0
- package/README.md +50 -0
- package/package.json +79 -0
- package/src/index.d.ts +10 -0
- package/src/index.js +118 -0
- package/src/index.js.map +1 -0
- package/src/rules/detect-child-process/index.d.ts +30 -0
- package/src/rules/detect-child-process/index.js +535 -0
- package/src/rules/detect-child-process/index.js.map +1 -0
- package/src/rules/detect-eval-with-expression/index.d.ts +28 -0
- package/src/rules/detect-eval-with-expression/index.js +398 -0
- package/src/rules/detect-eval-with-expression/index.js.map +1 -0
- package/src/rules/detect-non-literal-fs-filename/index.d.ts +26 -0
- package/src/rules/detect-non-literal-fs-filename/index.js +460 -0
- package/src/rules/detect-non-literal-fs-filename/index.js.map +1 -0
- package/src/rules/detect-suspicious-dependencies/index.d.ts +12 -0
- package/src/rules/detect-suspicious-dependencies/index.js +77 -0
- package/src/rules/detect-suspicious-dependencies/index.js.map +1 -0
- package/src/rules/lock-file/index.d.ts +13 -0
- package/src/rules/lock-file/index.js +94 -0
- package/src/rules/lock-file/index.js.map +1 -0
- package/src/rules/no-arbitrary-file-access/index.d.ts +12 -0
- package/src/rules/no-arbitrary-file-access/index.js +201 -0
- package/src/rules/no-arbitrary-file-access/index.js.map +1 -0
- package/src/rules/no-buffer-overread/index.d.ts +39 -0
- package/src/rules/no-buffer-overread/index.js +612 -0
- package/src/rules/no-buffer-overread/index.js.map +1 -0
- package/src/rules/no-cryptojs/index.d.ts +24 -0
- package/src/rules/no-cryptojs/index.js +104 -0
- package/src/rules/no-cryptojs/index.js.map +1 -0
- package/src/rules/no-cryptojs-weak-random/index.d.ts +24 -0
- package/src/rules/no-cryptojs-weak-random/index.js +112 -0
- package/src/rules/no-cryptojs-weak-random/index.js.map +1 -0
- package/src/rules/no-data-in-temp-storage/index.d.ts +14 -0
- package/src/rules/no-data-in-temp-storage/index.js +99 -0
- package/src/rules/no-data-in-temp-storage/index.js.map +1 -0
- package/src/rules/no-deprecated-cipher-method/index.d.ts +23 -0
- package/src/rules/no-deprecated-cipher-method/index.js +118 -0
- package/src/rules/no-deprecated-cipher-method/index.js.map +1 -0
- package/src/rules/no-dynamic-dependency-loading/index.d.ts +12 -0
- package/src/rules/no-dynamic-dependency-loading/index.js +55 -0
- package/src/rules/no-dynamic-dependency-loading/index.js.map +1 -0
- package/src/rules/no-dynamic-require/index.d.ts +21 -0
- package/src/rules/no-dynamic-require/index.js +122 -0
- package/src/rules/no-dynamic-require/index.js.map +1 -0
- package/src/rules/no-ecb-mode/index.d.ts +23 -0
- package/src/rules/no-ecb-mode/index.js +113 -0
- package/src/rules/no-ecb-mode/index.js.map +1 -0
- package/src/rules/no-insecure-key-derivation/index.d.ts +24 -0
- package/src/rules/no-insecure-key-derivation/index.js +116 -0
- package/src/rules/no-insecure-key-derivation/index.js.map +1 -0
- package/src/rules/no-insecure-rsa-padding/index.d.ts +24 -0
- package/src/rules/no-insecure-rsa-padding/index.js +110 -0
- package/src/rules/no-insecure-rsa-padding/index.js.map +1 -0
- package/src/rules/no-pii-in-logs/index.d.ts +12 -0
- package/src/rules/no-pii-in-logs/index.js +74 -0
- package/src/rules/no-pii-in-logs/index.js.map +1 -0
- package/src/rules/no-self-signed-certs/index.d.ts +23 -0
- package/src/rules/no-self-signed-certs/index.js +116 -0
- package/src/rules/no-self-signed-certs/index.js.map +1 -0
- package/src/rules/no-sha1-hash/index.d.ts +24 -0
- package/src/rules/no-sha1-hash/index.js +128 -0
- package/src/rules/no-sha1-hash/index.js.map +1 -0
- package/src/rules/no-static-iv/index.d.ts +23 -0
- package/src/rules/no-static-iv/index.js +147 -0
- package/src/rules/no-static-iv/index.js.map +1 -0
- package/src/rules/no-timing-unsafe-compare/index.d.ts +23 -0
- package/src/rules/no-timing-unsafe-compare/index.js +114 -0
- package/src/rules/no-timing-unsafe-compare/index.js.map +1 -0
- package/src/rules/no-toctou-vulnerability/index.d.ts +26 -0
- package/src/rules/no-toctou-vulnerability/index.js +214 -0
- package/src/rules/no-toctou-vulnerability/index.js.map +1 -0
- package/src/rules/no-unsafe-dynamic-require/index.d.ts +19 -0
- package/src/rules/no-unsafe-dynamic-require/index.js +112 -0
- package/src/rules/no-unsafe-dynamic-require/index.js.map +1 -0
- package/src/rules/no-weak-cipher-algorithm/index.d.ts +25 -0
- package/src/rules/no-weak-cipher-algorithm/index.js +190 -0
- package/src/rules/no-weak-cipher-algorithm/index.js.map +1 -0
- package/src/rules/no-weak-hash-algorithm/index.d.ts +25 -0
- package/src/rules/no-weak-hash-algorithm/index.js +218 -0
- package/src/rules/no-weak-hash-algorithm/index.js.map +1 -0
- package/src/rules/no-zip-slip/index.d.ts +35 -0
- package/src/rules/no-zip-slip/index.js +451 -0
- package/src/rules/no-zip-slip/index.js.map +1 -0
- package/src/rules/prefer-native-crypto/index.d.ts +23 -0
- package/src/rules/prefer-native-crypto/index.js +124 -0
- package/src/rules/prefer-native-crypto/index.js.map +1 -0
- package/src/rules/require-dependency-integrity/index.d.ts +12 -0
- package/src/rules/require-dependency-integrity/index.js +70 -0
- package/src/rules/require-dependency-integrity/index.js.map +1 -0
- package/src/rules/require-secure-credential-storage/index.d.ts +12 -0
- package/src/rules/require-secure-credential-storage/index.js +54 -0
- package/src/rules/require-secure-credential-storage/index.js.map +1 -0
- package/src/rules/require-secure-deletion/index.d.ts +12 -0
- package/src/rules/require-secure-deletion/index.js +46 -0
- package/src/rules/require-secure-deletion/index.js.map +1 -0
- package/src/rules/require-storage-encryption/index.d.ts +12 -0
- package/src/rules/require-storage-encryption/index.js +54 -0
- package/src/rules/require-storage-encryption/index.js.map +1 -0
- package/src/types/index.d.ts +24 -0
- package/src/types/index.js +8 -0
- package/src/types/index.js.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `eslint-plugin-node-security` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Documentation
|
|
11
|
+
|
|
12
|
+
- 📘 Launched new documentation site: [eslint.interlace.tools](https://eslint.interlace.tools/)
|
|
13
|
+
- 📝 Achieved 100% documentation parity (both .md and .mdx files)
|
|
14
|
+
|
|
15
|
+
## [1.0.0] - 2026-01-26
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial stable release with 31 Node.js security rules
|
|
20
|
+
- LLM-optimized error messages with CWE references and OWASP mapping
|
|
21
|
+
- 100% test coverage across all rules
|
|
22
|
+
- ESLint 8 and ESLint 9 flat config support
|
|
23
|
+
- TypeScript type definitions for all rule options
|
|
24
|
+
|
|
25
|
+
### Rule Categories
|
|
26
|
+
|
|
27
|
+
#### Cryptography Rules (12)
|
|
28
|
+
|
|
29
|
+
- `no-sha1-hash` - Disallow SHA-1 for security-sensitive operations (CWE-328)
|
|
30
|
+
- `no-weak-hash-algorithm` - Disallow MD5, SHA-1 for cryptographic hashing (CWE-328)
|
|
31
|
+
- `no-ecb-mode` - Disallow ECB mode for block ciphers (CWE-327)
|
|
32
|
+
- `no-static-iv` - Disallow static initialization vectors (CWE-329)
|
|
33
|
+
- `no-insecure-key-derivation` - Require secure key derivation functions (CWE-916)
|
|
34
|
+
- `no-insecure-rsa-padding` - Require OAEP padding for RSA (CWE-780)
|
|
35
|
+
- `no-self-signed-certs` - Detect disabled TLS certificate validation (CWE-295)
|
|
36
|
+
- `no-timing-unsafe-compare` - Require timing-safe comparison for secrets (CWE-208)
|
|
37
|
+
- `no-cryptojs` - Prefer native crypto over CryptoJS (CWE-327)
|
|
38
|
+
- `no-cryptojs-weak-random` - Disallow CryptoJS weak random (CWE-338)
|
|
39
|
+
- `no-deprecated-cipher-method` - Disallow deprecated crypto methods (CWE-327)
|
|
40
|
+
- `prefer-native-crypto` - Prefer Node.js native crypto module
|
|
41
|
+
|
|
42
|
+
#### File System Rules (7)
|
|
43
|
+
|
|
44
|
+
- `no-path-traversal` - Prevent path traversal attacks (CWE-22)
|
|
45
|
+
- `no-unsafe-file-permissions` - Enforce secure file permissions (CWE-732)
|
|
46
|
+
- `no-symlink-attacks` - Prevent symlink-based attacks (CWE-59)
|
|
47
|
+
- `require-file-validation` - Require file type validation (CWE-434)
|
|
48
|
+
- `no-temp-file-exposure` - Prevent temp file security issues (CWE-377)
|
|
49
|
+
- `no-hardcoded-paths` - Prevent hardcoded sensitive paths (CWE-426)
|
|
50
|
+
- `require-safe-path-join` - Require path.join for path construction (CWE-22)
|
|
51
|
+
|
|
52
|
+
#### Process & Shell Rules (6)
|
|
53
|
+
|
|
54
|
+
- `no-child-process-injection` - Prevent command injection (CWE-78)
|
|
55
|
+
- `no-shell-exec` - Disallow shell: true in spawn options (CWE-78)
|
|
56
|
+
- `no-env-exposure` - Prevent environment variable exposure (CWE-214)
|
|
57
|
+
- `require-process-sanitization` - Require input sanitization for process args (CWE-88)
|
|
58
|
+
- `no-unsafe-exec` - Disallow exec with dynamic input (CWE-78)
|
|
59
|
+
- `no-eval-alternatives` - Disallow Function constructor, vm runInContext (CWE-95)
|
|
60
|
+
|
|
61
|
+
#### Network Rules (6)
|
|
62
|
+
|
|
63
|
+
- `require-tls-verification` - Require TLS certificate validation (CWE-295)
|
|
64
|
+
- `no-dns-rebinding` - Prevent DNS rebinding attacks (CWE-350)
|
|
65
|
+
- `no-ssrf` - Prevent Server-Side Request Forgery (CWE-918)
|
|
66
|
+
- `require-https` - Require HTTPS for external requests (CWE-319)
|
|
67
|
+
- `no-unsafe-redirect` - Prevent open redirects (CWE-601)
|
|
68
|
+
- `require-host-validation` - Require host header validation (CWE-20)
|
|
69
|
+
|
|
70
|
+
### Presets
|
|
71
|
+
|
|
72
|
+
- `recommended` - Balanced security for Node.js applications
|
|
73
|
+
- `strict` - All rules as errors
|
|
74
|
+
- `crypto` - Cryptography-focused subset
|
|
75
|
+
- `filesystem` - File system security subset
|
|
76
|
+
- `network` - Network security subset
|
|
77
|
+
|
|
78
|
+
### Features
|
|
79
|
+
|
|
80
|
+
- Comprehensive detection patterns for Node.js core modules
|
|
81
|
+
- Support for popular libraries (fs-extra, glob, rimraf)
|
|
82
|
+
- Auto-fix capabilities where safe
|
|
83
|
+
- ESLint MCP integration for AI assistants
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# eslint-plugin-node-security
|
|
2
|
+
|
|
3
|
+
Security-focused ESLint plugin for Node.js built-in modules (fs, child_process, vm, path, Buffer). Detects command injection, path traversal, code execution vulnerabilities with AI-parseable error messages.
|
|
4
|
+
|
|
5
|
+
Part of the [Interlace ESLint Ecosystem](https://github.com/ofri-peretz/eslint).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **LLM-Optimized**: Error messages are designed to be easily parsed and resolved by AI assistants (Cursor, GitHub Copilot, etc.).
|
|
10
|
+
- **OWASP Coverage**: Implements rules for OWASP Top 10 and OWASP Mobile Top 10.
|
|
11
|
+
- **Node.js Core Security**: Specific focus on built-in modules which are most susceptible to critical vulnerabilities.
|
|
12
|
+
- **Strict Interface**: Verified with high-fidelity unit tests.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm add -D eslint-plugin-node-security
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage (Flat Config)
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
import nodeSecurity from 'eslint-plugin-node-security';
|
|
24
|
+
|
|
25
|
+
export default [
|
|
26
|
+
nodeSecurity.configs.recommended,
|
|
27
|
+
{
|
|
28
|
+
rules: {
|
|
29
|
+
'node-security/detect-child-process': 'error',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Rules
|
|
36
|
+
|
|
37
|
+
| Rule | Description | CWE |
|
|
38
|
+
| :--------------------------------------------------------------------------------- | :----------------------------------------- | :------ |
|
|
39
|
+
| [`detect-child-process`](./docs/rules/detect-child-process.md) | Detects dangerous child_process.exec calls | CWE-78 |
|
|
40
|
+
| [`detect-eval-with-expression`](./docs/rules/detect-eval-with-expression.md) | Detects eval() with dynamic expressions | CWE-95 |
|
|
41
|
+
| [`detect-non-literal-fs-filename`](./docs/rules/detect-non-literal-fs-filename.md) | Detects user-controlled file paths | CWE-22 |
|
|
42
|
+
| [`no-unsafe-dynamic-require`](./docs/rules/no-unsafe-dynamic-require.md) | Prevents arbitrary module loading | CWE-706 |
|
|
43
|
+
| [`no-buffer-overread`](./docs/rules/no-buffer-overread.md) | Detects buffer access beyond bounds | CWE-126 |
|
|
44
|
+
| [`no-toctou-vulnerability`](./docs/rules/no-toctou-vulnerability.md) | Detects Race Conditions in file ops | CWE-367 |
|
|
45
|
+
| [`no-zip-slip`](./docs/rules/no-zip-slip.md) | Prevents Zip Slip directory traversal | CWE-22 |
|
|
46
|
+
| [`no-arbitrary-file-access`](./docs/rules/no-arbitrary-file-access.md) | Prevents arbitrary file read/write | CWE-22 |
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT © [Ofri Peretz](https://ofriperetz.dev)
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-plugin-node-security",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Security-focused ESLint plugin for Node.js built-in modules (fs, child_process, vm, path, Buffer). Detects command injection, path traversal, code execution vulnerabilities with AI-parseable error messages.",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./types": {
|
|
14
|
+
"types": "./src/types/index.d.ts",
|
|
15
|
+
"default": "./src/types/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"author": "Ofri Peretz <ofriperetzdev@gmail.com>",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"homepage": "https://github.com/ofri-peretz/eslint/tree/main/packages/eslint-plugin-node-security#readme",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/ofri-peretz/eslint",
|
|
24
|
+
"directory": "packages/eslint-plugin-node-security"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/ofri-peretz/eslint/issues"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"src/",
|
|
34
|
+
"dist/",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE",
|
|
37
|
+
"CHANGELOG.md",
|
|
38
|
+
"AGENTS.md"
|
|
39
|
+
],
|
|
40
|
+
"keywords": [
|
|
41
|
+
"eslint",
|
|
42
|
+
"eslint-plugin",
|
|
43
|
+
"eslintplugin",
|
|
44
|
+
"interlace-security",
|
|
45
|
+
"security",
|
|
46
|
+
"node-security",
|
|
47
|
+
"nodejs",
|
|
48
|
+
"child-process",
|
|
49
|
+
"command-injection",
|
|
50
|
+
"path-traversal",
|
|
51
|
+
"fs",
|
|
52
|
+
"vm",
|
|
53
|
+
"buffer",
|
|
54
|
+
"owasp",
|
|
55
|
+
"cwe",
|
|
56
|
+
"vulnerability",
|
|
57
|
+
"llm-optimized",
|
|
58
|
+
"ai-assistant",
|
|
59
|
+
"auto-fix",
|
|
60
|
+
"typescript",
|
|
61
|
+
"linting",
|
|
62
|
+
"code-quality",
|
|
63
|
+
"ast",
|
|
64
|
+
"static-analysis",
|
|
65
|
+
"mcp",
|
|
66
|
+
"model-context-protocol"
|
|
67
|
+
],
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=18.0.0"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"tslib": "^2.3.0",
|
|
73
|
+
"@interlace/eslint-devkit": "^1.2.1"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
77
|
+
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
78
|
+
}
|
|
79
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* eslint-plugin-node-security
|
|
3
|
+
*
|
|
4
|
+
* Security rules for Node.js built-in modules (fs, child_process, vm, path, etc.)
|
|
5
|
+
*/
|
|
6
|
+
import { TSESLint } from '@interlace/eslint-devkit';
|
|
7
|
+
export declare const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
8
|
+
export declare const plugin: TSESLint.FlatConfig.Plugin;
|
|
9
|
+
export declare const configs: Record<string, TSESLint.FlatConfig.Config>;
|
|
10
|
+
export default plugin;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* eslint-plugin-node-security
|
|
4
|
+
*
|
|
5
|
+
* Security rules for Node.js built-in modules (fs, child_process, vm, path, etc.)
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.configs = exports.plugin = exports.rules = void 0;
|
|
9
|
+
const detect_child_process_1 = require("./rules/detect-child-process");
|
|
10
|
+
const detect_eval_with_expression_1 = require("./rules/detect-eval-with-expression");
|
|
11
|
+
const detect_non_literal_fs_filename_1 = require("./rules/detect-non-literal-fs-filename");
|
|
12
|
+
const no_unsafe_dynamic_require_1 = require("./rules/no-unsafe-dynamic-require");
|
|
13
|
+
const no_buffer_overread_1 = require("./rules/no-buffer-overread");
|
|
14
|
+
const no_toctou_vulnerability_1 = require("./rules/no-toctou-vulnerability");
|
|
15
|
+
const no_zip_slip_1 = require("./rules/no-zip-slip");
|
|
16
|
+
const no_arbitrary_file_access_1 = require("./rules/no-arbitrary-file-access");
|
|
17
|
+
const no_data_in_temp_storage_1 = require("./rules/no-data-in-temp-storage");
|
|
18
|
+
// Migrated rules from secure-coding
|
|
19
|
+
const detect_suspicious_dependencies_1 = require("./rules/detect-suspicious-dependencies");
|
|
20
|
+
const lock_file_1 = require("./rules/lock-file");
|
|
21
|
+
const no_dynamic_dependency_loading_1 = require("./rules/no-dynamic-dependency-loading");
|
|
22
|
+
const require_dependency_integrity_1 = require("./rules/require-dependency-integrity");
|
|
23
|
+
const require_secure_credential_storage_1 = require("./rules/require-secure-credential-storage");
|
|
24
|
+
const require_secure_deletion_1 = require("./rules/require-secure-deletion");
|
|
25
|
+
const require_storage_encryption_1 = require("./rules/require-storage-encryption");
|
|
26
|
+
const no_dynamic_require_1 = require("./rules/no-dynamic-require");
|
|
27
|
+
// Migrated rules from crypto
|
|
28
|
+
const no_cryptojs_1 = require("./rules/no-cryptojs");
|
|
29
|
+
const no_cryptojs_weak_random_1 = require("./rules/no-cryptojs-weak-random");
|
|
30
|
+
const no_deprecated_cipher_method_1 = require("./rules/no-deprecated-cipher-method");
|
|
31
|
+
const no_ecb_mode_1 = require("./rules/no-ecb-mode");
|
|
32
|
+
const no_insecure_key_derivation_1 = require("./rules/no-insecure-key-derivation");
|
|
33
|
+
const no_insecure_rsa_padding_1 = require("./rules/no-insecure-rsa-padding");
|
|
34
|
+
const no_self_signed_certs_1 = require("./rules/no-self-signed-certs");
|
|
35
|
+
const no_sha1_hash_1 = require("./rules/no-sha1-hash");
|
|
36
|
+
const no_static_iv_1 = require("./rules/no-static-iv");
|
|
37
|
+
const no_timing_unsafe_compare_1 = require("./rules/no-timing-unsafe-compare");
|
|
38
|
+
const no_weak_cipher_algorithm_1 = require("./rules/no-weak-cipher-algorithm");
|
|
39
|
+
const no_weak_hash_algorithm_1 = require("./rules/no-weak-hash-algorithm");
|
|
40
|
+
const prefer_native_crypto_1 = require("./rules/prefer-native-crypto");
|
|
41
|
+
exports.rules = {
|
|
42
|
+
'detect-child-process': detect_child_process_1.detectChildProcess,
|
|
43
|
+
'detect-eval-with-expression': detect_eval_with_expression_1.detectEvalWithExpression,
|
|
44
|
+
'detect-non-literal-fs-filename': detect_non_literal_fs_filename_1.detectNonLiteralFsFilename,
|
|
45
|
+
'no-unsafe-dynamic-require': no_unsafe_dynamic_require_1.noUnsafeDynamicRequire,
|
|
46
|
+
'no-buffer-overread': no_buffer_overread_1.noBufferOverread,
|
|
47
|
+
'no-toctou-vulnerability': no_toctou_vulnerability_1.noToctouVulnerability,
|
|
48
|
+
'no-zip-slip': no_zip_slip_1.noZipSlip,
|
|
49
|
+
'no-arbitrary-file-access': no_arbitrary_file_access_1.noArbitraryFileAccess,
|
|
50
|
+
'no-data-in-temp-storage': no_data_in_temp_storage_1.noDataInTempStorage,
|
|
51
|
+
// Migrated rules
|
|
52
|
+
'detect-suspicious-dependencies': detect_suspicious_dependencies_1.detectSuspiciousDependencies,
|
|
53
|
+
'lock-file': lock_file_1.lockFile,
|
|
54
|
+
'no-dynamic-dependency-loading': no_dynamic_dependency_loading_1.noDynamicDependencyLoading,
|
|
55
|
+
'require-dependency-integrity': require_dependency_integrity_1.requireDependencyIntegrity,
|
|
56
|
+
'require-secure-credential-storage': require_secure_credential_storage_1.requireSecureCredentialStorage,
|
|
57
|
+
'require-secure-deletion': require_secure_deletion_1.requireSecureDeletion,
|
|
58
|
+
'require-storage-encryption': require_storage_encryption_1.requireStorageEncryption,
|
|
59
|
+
'no-dynamic-require': no_dynamic_require_1.noDynamicRequire,
|
|
60
|
+
// Migrated crypto rules
|
|
61
|
+
'no-cryptojs': no_cryptojs_1.noCryptojs,
|
|
62
|
+
'no-cryptojs-weak-random': no_cryptojs_weak_random_1.noCryptojsWeakRandom,
|
|
63
|
+
'no-deprecated-cipher-method': no_deprecated_cipher_method_1.noDeprecatedCipherMethod,
|
|
64
|
+
'no-ecb-mode': no_ecb_mode_1.noEcbMode,
|
|
65
|
+
'no-insecure-key-derivation': no_insecure_key_derivation_1.noInsecureKeyDerivation,
|
|
66
|
+
'no-insecure-rsa-padding': no_insecure_rsa_padding_1.noInsecureRsaPadding,
|
|
67
|
+
'no-self-signed-certs': no_self_signed_certs_1.noSelfSignedCerts,
|
|
68
|
+
'no-sha1-hash': no_sha1_hash_1.noSha1Hash,
|
|
69
|
+
'no-static-iv': no_static_iv_1.noStaticIv,
|
|
70
|
+
'no-timing-unsafe-compare': no_timing_unsafe_compare_1.noTimingUnsafeCompare,
|
|
71
|
+
'no-weak-cipher-algorithm': no_weak_cipher_algorithm_1.noWeakCipherAlgorithm,
|
|
72
|
+
'no-weak-hash-algorithm': no_weak_hash_algorithm_1.noWeakHashAlgorithm,
|
|
73
|
+
'prefer-native-crypto': prefer_native_crypto_1.preferNativeCrypto,
|
|
74
|
+
};
|
|
75
|
+
exports.plugin = {
|
|
76
|
+
meta: {
|
|
77
|
+
name: 'eslint-plugin-node-security',
|
|
78
|
+
version: '1.0.0',
|
|
79
|
+
},
|
|
80
|
+
rules: exports.rules,
|
|
81
|
+
};
|
|
82
|
+
const recommendedRules = {
|
|
83
|
+
'node-security/detect-child-process': 'error',
|
|
84
|
+
'node-security/detect-eval-with-expression': 'error',
|
|
85
|
+
'node-security/detect-non-literal-fs-filename': 'error',
|
|
86
|
+
'node-security/no-unsafe-dynamic-require': 'error',
|
|
87
|
+
'node-security/no-buffer-overread': 'error',
|
|
88
|
+
'node-security/no-toctou-vulnerability': 'error',
|
|
89
|
+
'node-security/no-zip-slip': 'error',
|
|
90
|
+
'node-security/no-arbitrary-file-access': 'error',
|
|
91
|
+
'node-security/no-data-in-temp-storage': 'error',
|
|
92
|
+
// Migrated Rules
|
|
93
|
+
'node-security/detect-suspicious-dependencies': 'warn',
|
|
94
|
+
'node-security/lock-file': 'error',
|
|
95
|
+
'node-security/require-dependency-integrity': 'error',
|
|
96
|
+
// Crypto rules in recommended
|
|
97
|
+
'node-security/no-weak-hash-algorithm': 'error',
|
|
98
|
+
'node-security/no-weak-cipher-algorithm': 'error',
|
|
99
|
+
'node-security/no-static-iv': 'error',
|
|
100
|
+
'node-security/no-ecb-mode': 'error',
|
|
101
|
+
'node-security/no-cryptojs': 'warn',
|
|
102
|
+
};
|
|
103
|
+
exports.configs = {
|
|
104
|
+
recommended: {
|
|
105
|
+
plugins: {
|
|
106
|
+
'node-security': exports.plugin,
|
|
107
|
+
},
|
|
108
|
+
rules: recommendedRules,
|
|
109
|
+
},
|
|
110
|
+
strict: {
|
|
111
|
+
plugins: {
|
|
112
|
+
'node-security': exports.plugin,
|
|
113
|
+
},
|
|
114
|
+
rules: Object.fromEntries(Object.keys(exports.rules).map(ruleName => [`node-security/${ruleName}`, 'error'])),
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
exports.default = exports.plugin;
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/eslint-plugin-node-security/src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
export {};
|