faultmesh 1.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/README.md +98 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +105 -0
- package/dist/dashboard/app.js +998 -0
- package/dist/dashboard/index.html +291 -0
- package/dist/dashboard/styles.css +1120 -0
- package/dist/engine/ControlApi.d.ts +24 -0
- package/dist/engine/ControlApi.js +269 -0
- package/dist/engine/FaultMeshProxy.d.ts +16 -0
- package/dist/engine/FaultMeshProxy.js +167 -0
- package/dist/engine/TelemetryHub.d.ts +16 -0
- package/dist/engine/TelemetryHub.js +67 -0
- package/dist/engine/ToxicPipeline.d.ts +22 -0
- package/dist/engine/ToxicPipeline.js +67 -0
- package/dist/scorer/ResilienceScorer.d.ts +13 -0
- package/dist/scorer/ResilienceScorer.js +330 -0
- package/dist/scorer/SecurityAuditor.d.ts +13 -0
- package/dist/scorer/SecurityAuditor.js +428 -0
- package/dist/scorer/TrafficStormAuditor.d.ts +10 -0
- package/dist/scorer/TrafficStormAuditor.js +261 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +169 -0
- package/dist/toxics/BandwidthToxic.d.ts +11 -0
- package/dist/toxics/BandwidthToxic.js +36 -0
- package/dist/toxics/BaseToxic.d.ts +11 -0
- package/dist/toxics/BaseToxic.js +19 -0
- package/dist/toxics/CorruptToxic.d.ts +11 -0
- package/dist/toxics/CorruptToxic.js +53 -0
- package/dist/toxics/CutToxic.d.ts +9 -0
- package/dist/toxics/CutToxic.js +31 -0
- package/dist/toxics/LatencyToxic.d.ts +13 -0
- package/dist/toxics/LatencyToxic.js +40 -0
- package/dist/toxics/StatusToxic.d.ts +9 -0
- package/dist/toxics/StatusToxic.js +22 -0
- package/dist/types.d.ts +123 -0
- package/dist/types.js +4 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# FaultMesh
|
|
2
|
+
|
|
3
|
+
High-Precision Network & API Fault Injection Engine and Live Resilience Auditor.
|
|
4
|
+
|
|
5
|
+
FaultMesh is a zero-dependency, lightweight chaos engineering middleman proxy and automated API auditor. It sits between your clients (frontend, mobile apps, microservices) and your backend to simulate real-world network disasters and audit your API for resilience, security headers, data leakage, and DoS defense.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start (Zero Install)
|
|
10
|
+
|
|
11
|
+
Run FaultMesh with a single command against your local or remote backend:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx faultmesh --target http://localhost:8000
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
* **Control Dashboard:** `http://localhost:3000`
|
|
18
|
+
* **Middleman Chaos Proxy:** `http://127.0.0.1:3001`
|
|
19
|
+
* **Target Backend:** `http://localhost:8000`
|
|
20
|
+
|
|
21
|
+
If you omit `--target`, FaultMesh automatically boots an internal sample API on port `4000` so you can experiment right away:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx faultmesh
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## CLI Options
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
Usage:
|
|
33
|
+
npx faultmesh [options]
|
|
34
|
+
|
|
35
|
+
Options:
|
|
36
|
+
-t, --target <url> Target API URL to proxy and audit (e.g. http://localhost:8000)
|
|
37
|
+
If omitted, starts the built-in sample server on :4000
|
|
38
|
+
-p, --port <number> Control Dashboard port (default: 3000)
|
|
39
|
+
--proxy-port <num> Middleman chaos proxy port (default: 3001)
|
|
40
|
+
--mock-port <num> Port for sample server if no target is given (default: 4000)
|
|
41
|
+
-h, --help Show help message and exit
|
|
42
|
+
-v, --version Show version number and exit
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
npx faultmesh
|
|
46
|
+
npx faultmesh --target http://localhost:8000
|
|
47
|
+
npx faultmesh -t http://localhost:5000 -p 8080 --proxy-port 8081
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Core Capabilities
|
|
53
|
+
|
|
54
|
+
### 1. Automated 16-Point Audit Suite
|
|
55
|
+
FaultMesh executes automated, non-destructive probe batteries against your API and produces a scored diagnostic report card (Grade A+ to F, vulnerability descriptions, and concrete remediation steps).
|
|
56
|
+
|
|
57
|
+
* **Network Resilience Suite (5 Checks):**
|
|
58
|
+
* Latency / Timeout Ingestion (200ms - 5000ms delay handling)
|
|
59
|
+
* Bandwidth Choking (50 - 500 KB/s stream survival)
|
|
60
|
+
* TCP Connection Cut (kernel-level `ECONNRESET` recovery)
|
|
61
|
+
* Payload Truncation (malformed / partial JSON parsing safety)
|
|
62
|
+
* Server Outage Emulation (HTTP 503 circuit-breaking & backoff)
|
|
63
|
+
|
|
64
|
+
* **Security & Protocol Audit Suite (7 Checks):**
|
|
65
|
+
* Defensive Headers (`X-Content-Type-Options`, `X-Frame-Options`, `HSTS`)
|
|
66
|
+
* CORS Origin & Credential Safety (flags `Access-Control-Allow-Origin: *` with credentials)
|
|
67
|
+
* Query Parameter Secret Scanner (flags tokens and passwords in GET URLs)
|
|
68
|
+
* Outbound Response PII Scanner (scans for leaked API keys, tokens, and database hashes)
|
|
69
|
+
* Stack Trace Sanitization (ensures 500 errors do not expose file paths or DB schemas)
|
|
70
|
+
* Path Traversal Probing (passive `../../etc/passwd` path handling check)
|
|
71
|
+
* Safe Canary Syntax Probing (inert SQL quote balancing check without data mutation)
|
|
72
|
+
|
|
73
|
+
* **Traffic Storm & DoS Defense Suite (4 Checks):**
|
|
74
|
+
* Rate Limiting & HTTP 429 Backoff (detects missing rate limiters and `Retry-After` headers)
|
|
75
|
+
* Payload Size Limits & HTTP 413 (tests oversized body handling to prevent buffer OOM crashes)
|
|
76
|
+
* Slowloris Read Timeout Defense (tests resilience against slow byte-drip socket exhaustion)
|
|
77
|
+
* Idempotency Deduplication (tests duplicate transaction handling with idempotency keys)
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### 2. Interactive Chaos Proxy (Port 3001)
|
|
82
|
+
Point your frontend (React, Vue, iOS, Android) or HTTP client to `http://127.0.0.1:3001`.
|
|
83
|
+
Configure fault profiles on the dashboard to test how your frontend handles:
|
|
84
|
+
* Simulated 503 outages
|
|
85
|
+
* Artificial 2G/3G network latency
|
|
86
|
+
* Bandwidth throttling
|
|
87
|
+
* Broken connections and truncated responses
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### 3. Live Traffic Inspector
|
|
92
|
+
Inspect every HTTP request passing through the proxy in real time with status pills, measured latency, client IP, and active fault annotations.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT License.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { startFaultMesh } from './server.js';
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
function getVersion() {
|
|
10
|
+
try {
|
|
11
|
+
const pkgPath = path.resolve(__dirname, '../package.json');
|
|
12
|
+
if (fs.existsSync(pkgPath)) {
|
|
13
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
14
|
+
return pkg.version || '1.0.0';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// fallback if package.json not found
|
|
19
|
+
}
|
|
20
|
+
return '1.0.0';
|
|
21
|
+
}
|
|
22
|
+
function printHelp() {
|
|
23
|
+
console.log(`
|
|
24
|
+
+-------------------------------------------------------+
|
|
25
|
+
| FAULTMESH CLI |
|
|
26
|
+
| Network Resilience & Security Testing Suite |
|
|
27
|
+
+-------------------------------------------------------+
|
|
28
|
+
|
|
29
|
+
Usage:
|
|
30
|
+
faultmesh [options]
|
|
31
|
+
npx faultmesh [options]
|
|
32
|
+
|
|
33
|
+
Options:
|
|
34
|
+
-t, --target <url> Target API URL to proxy and audit (e.g. http://localhost:8000)
|
|
35
|
+
If omitted, starts the built-in sample mock server on :4000
|
|
36
|
+
-p, --port <number> Control Dashboard port (default: 3000)
|
|
37
|
+
--proxy-port <num> Middleman chaos proxy port (default: 3001)
|
|
38
|
+
--mock-port <num> Port for sample mock server if no target is given (default: 4000)
|
|
39
|
+
-h, --help Show this help message and exit
|
|
40
|
+
-v, --version Show version number and exit
|
|
41
|
+
|
|
42
|
+
Examples:
|
|
43
|
+
npx faultmesh
|
|
44
|
+
npx faultmesh --target http://localhost:8000
|
|
45
|
+
npx faultmesh -t http://localhost:5000 -p 8080 --proxy-port 8081
|
|
46
|
+
`);
|
|
47
|
+
}
|
|
48
|
+
async function run() {
|
|
49
|
+
let parsed;
|
|
50
|
+
try {
|
|
51
|
+
parsed = parseArgs({
|
|
52
|
+
options: {
|
|
53
|
+
target: { type: 'string', short: 't' },
|
|
54
|
+
port: { type: 'string', short: 'p', default: '3000' },
|
|
55
|
+
'proxy-port': { type: 'string', default: '3001' },
|
|
56
|
+
'mock-port': { type: 'string', default: '4000' },
|
|
57
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
58
|
+
version: { type: 'boolean', short: 'v', default: false },
|
|
59
|
+
},
|
|
60
|
+
allowPositionals: true,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
console.error(`Error: ${err.message}`);
|
|
65
|
+
console.error('Run "faultmesh --help" for usage instructions.');
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
const { values } = parsed;
|
|
69
|
+
if (values.help) {
|
|
70
|
+
printHelp();
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
if (values.version) {
|
|
74
|
+
console.log(`faultmesh v${getVersion()}`);
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
const dashboardPort = parseInt(values.port || '3000', 10);
|
|
78
|
+
const proxyPort = parseInt(values['proxy-port'] || '3001', 10);
|
|
79
|
+
const mockPort = parseInt(values['mock-port'] || '4000', 10);
|
|
80
|
+
const targetUrl = values.target;
|
|
81
|
+
if (isNaN(dashboardPort) || isNaN(proxyPort) || isNaN(mockPort)) {
|
|
82
|
+
console.error('Error: Port options must be valid numbers.');
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const instance = await startFaultMesh({
|
|
87
|
+
targetUrl,
|
|
88
|
+
dashboardPort,
|
|
89
|
+
proxyPort,
|
|
90
|
+
mockPort,
|
|
91
|
+
});
|
|
92
|
+
const shutdown = async () => {
|
|
93
|
+
console.log('\nShutting down FaultMesh...');
|
|
94
|
+
await instance.stop();
|
|
95
|
+
process.exit(0);
|
|
96
|
+
};
|
|
97
|
+
process.on('SIGINT', shutdown);
|
|
98
|
+
process.on('SIGTERM', shutdown);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
console.error('Failed to start FaultMesh:', err.message || err);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
run();
|