deployready 0.1.2 → 0.2.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.
Files changed (44) hide show
  1. package/README.md +52 -17
  2. package/dist/active/accessControl.js +25 -0
  3. package/dist/active/accessControl.js.map +1 -0
  4. package/dist/active/httpAdapter.js +54 -0
  5. package/dist/active/httpAdapter.js.map +1 -0
  6. package/dist/active/jwt.js +48 -0
  7. package/dist/active/jwt.js.map +1 -0
  8. package/dist/active/requestPlan.js +52 -0
  9. package/dist/active/requestPlan.js.map +1 -0
  10. package/dist/active/runner.js +156 -0
  11. package/dist/active/runner.js.map +1 -0
  12. package/dist/active/tamper.js +81 -0
  13. package/dist/active/tamper.js.map +1 -0
  14. package/dist/active/tokenHelp.js +33 -0
  15. package/dist/active/tokenHelp.js.map +1 -0
  16. package/dist/active/types.js +3 -0
  17. package/dist/active/types.js.map +1 -0
  18. package/dist/agent/FixManager.js +25 -2
  19. package/dist/agent/FixManager.js.map +1 -1
  20. package/dist/agent/lineFixers.js +29 -0
  21. package/dist/agent/lineFixers.js.map +1 -0
  22. package/dist/analysis/VulnerabilityDetector.js +24 -0
  23. package/dist/analysis/VulnerabilityDetector.js.map +1 -1
  24. package/dist/analysis/rls.js +32 -0
  25. package/dist/analysis/rls.js.map +1 -0
  26. package/dist/analysis/rules.js +76 -0
  27. package/dist/analysis/rules.js.map +1 -1
  28. package/dist/cli/Commands.js +76 -2
  29. package/dist/cli/Commands.js.map +1 -1
  30. package/dist/cli/InteractiveShell.js +60 -11
  31. package/dist/cli/InteractiveShell.js.map +1 -1
  32. package/dist/core/CiGate.js +50 -0
  33. package/dist/core/CiGate.js.map +1 -1
  34. package/dist/core/Orchestrator.js +65 -4
  35. package/dist/core/Orchestrator.js.map +1 -1
  36. package/dist/deploy/PlatformRecommender.js +110 -0
  37. package/dist/deploy/PlatformRecommender.js.map +1 -0
  38. package/dist/ui/DeploymentGuide.js +107 -29
  39. package/dist/ui/DeploymentGuide.js.map +1 -1
  40. package/dist/ui/HtmlReporter.js +66 -26
  41. package/dist/ui/HtmlReporter.js.map +1 -1
  42. package/dist/utils/FileWalker.js +1 -1
  43. package/dist/utils/FileWalker.js.map +1 -1
  44. package/package.json +1 -1
package/README.md CHANGED
@@ -1,34 +1,37 @@
1
1
  # DeployReady
2
2
 
3
- > Local-first, AI-optional production-readiness scanner. It runs 30+ structured tests against your code **and** your running localhost app, gives you a 0–100 readiness score, and **optionally** sends only the structured findings report — never your source code — to an AI model for deeper analysis.
3
+ > **Ship with confidence.** Catch security and deploy-blocking issues before you ship — run 30+ structured tests across your code **and** your running app, get a 0–100 readiness score, and apply **AI-powered fixes**, all in one command.
4
4
 
5
5
  ```bash
6
- npx deployready analyze ./my-app
6
+ npx deployready@latest analyze ./my-app
7
7
  ```
8
8
 
9
+ > _Privacy:_ scanning runs locally. Only a redacted findings report is ever sent to an AI — after you approve it, never your source code — and you can use a local model (Ollama) to keep everything 100% offline.
10
+
9
11
  ## Install
10
12
 
11
13
  **Run without installing** (recommended — always works, nothing to set up):
12
14
 
13
15
  ```bash
14
- npx deployready ./my-app
16
+ npx deployready@latest ./my-app
15
17
  ```
16
18
 
17
- **Or install globally** if you use it often (lets you drop the `npx` prefix):
19
+ **Or install globally** if you run it often (faster, but you must update it yourself):
18
20
 
19
21
  ```bash
20
22
  npm install -g deployready
21
23
  deployready ./my-app
24
+ # update later with: npm i -g deployready@latest
22
25
  ```
23
26
 
24
- Requires Node.js >= 18. Every command below is shown with `npx`; if you installed globally, just drop the `npx`.
27
+ Requires Node.js >= 18. The `@latest` tag ensures you always get the newest version — plain `npx deployready` can reuse a cached older copy. Every command below is shown with `npx deployready@latest`; if you installed globally, use `deployready` instead.
25
28
 
26
29
  ## Quick start
27
30
 
28
31
  Run it inside your project to open an interactive, guided session — no commands to memorize, just pick a number:
29
32
 
30
33
  ```bash
31
- npx deployready ./my-app # or just: npx deployready
34
+ npx deployready@latest ./my-app # or just: npx deployready@latest
32
35
  ```
33
36
 
34
37
  ```
@@ -61,22 +64,22 @@ deployready › exit
61
64
  |---|---|
62
65
  | `scan` · `parse` · `dynamic` · `ai` | run the whole pipeline, or one step at a time |
63
66
  | `issues [crit\|warn\|info]` · `show <n>` | list findings (optionally filtered) · show one in detail |
64
- | `fix <n>` | auto-fix where safe; otherwise an AI-proposed diff you approve (creates a backup); otherwise guidance |
67
+ | `fix <n>` | deterministic auto-fix where safe (weak hashes, disabled TLS verification, `yaml.load`, `verify=False`, Flask `debug=True`, gitignore `.env`); otherwise an AI-proposed diff you approve (creates a backup); otherwise guidance |
65
68
  | `verify <n>` | re-run the relevant checks to confirm a fix actually resolved the issue |
66
69
  | `done <n>` · `ignore <n>` | mark fixed / ignored — the score recomputes immediately |
67
70
  | `score` · `status` | show the current readiness score / session state |
68
- | `deploy [aws\|do]` | deployment walkthrough for your stack |
71
+ | `deploy [platform]` | recommend a host for this project (no arg) or print a step-by-step guide for a chosen one (`aws`, `do`, `vercel`, `render`, `railway`, `fly`, `netlify`) |
69
72
  | `export` · `open` | write `deployready-report.md` · open the HTML dashboard |
70
73
  | `config` · `help` · `menu` · `clear` · `exit` | session utilities |
71
74
 
72
75
  ## One-shot (CI / scripting)
73
76
 
74
77
  ```bash
75
- npx deployready init # first-time setup (pick model, store key)
76
- npx deployready analyze ./my-app # single non-interactive scan, prints results
77
- npx deployready analyze . --no-ai --no-dynamic # static only, fully offline
78
- npx deployready report ./my-app # scan and export the markdown report
79
- npx deployready config # show the active config (secrets never printed)
78
+ npx deployready@latest init # first-time setup (pick model, store key)
79
+ npx deployready@latest analyze ./my-app # single non-interactive scan, prints results
80
+ npx deployready@latest analyze . --no-ai --no-dynamic # static only, fully offline
81
+ npx deployready@latest report ./my-app # scan and export the markdown report
82
+ npx deployready@latest config # show the active config (secrets never printed)
80
83
  ```
81
84
 
82
85
  **Flags for `analyze`:**
@@ -91,23 +94,55 @@ npx deployready config # show the active config (secr
91
94
  | `--html` / `--open` | write an HTML dashboard / and open it in your browser |
92
95
  | `--json` | print a machine-readable JSON report (implies `--yes`) |
93
96
  | `--fail-on <severity>` | exit non-zero if findings at/above `critical \| warning \| info \| none` exist |
97
+ | `--baseline <file>` | gate only on findings **not** in the baseline file (existing issues are grandfathered) |
98
+ | `--write-baseline <file>` | write the current findings to a baseline file and exit `0` (accept current state) |
99
+ | `--active` | run **active** authenticated authorization tests (needs `--token`; consented, loopback-only, GET-only) |
100
+ | `--token <jwt>` | bearer JWT for the active scan (your logged-in test user) |
101
+ | `--token-b <jwt>` | a second user's JWT — enables tenant / IDOR isolation tests |
94
102
  | `-v, --verbose` | verbose debug output |
95
103
 
96
104
  **CI gate:** exit codes are `0` (clean), `2` (gate failed), `1` (tool error).
97
105
 
98
106
  ```bash
99
- npx deployready analyze . --no-ai --no-dynamic --fail-on critical
107
+ npx deployready@latest analyze . --no-ai --no-dynamic --fail-on critical
108
+ ```
109
+
110
+ **Grandfather existing issues (baseline):** adopt the current findings once, then fail the
111
+ build only on *new* ones — so you can turn the gate on for an existing codebase without
112
+ drowning in pre-existing debt:
113
+
114
+ ```bash
115
+ npx deployready@latest analyze . --no-ai --no-dynamic --write-baseline .deployready-baseline.json # once
116
+ npx deployready@latest analyze . --no-ai --no-dynamic --baseline .deployready-baseline.json --fail-on warning # in CI
100
117
  ```
101
118
 
102
119
  A ready-to-copy GitHub Action is in [`docs/github-action-example.yml`](docs/github-action-example.yml).
103
120
 
121
+ ### Active (authenticated) testing — "try to hack it"
122
+
123
+ With your app running locally, DeployReady can act as a logged-in user and try to break access control — the checks you'd otherwise do by hand in Burp/Postman:
124
+
125
+ ```bash
126
+ npx deployready@latest analyze . --active --token "<your-JWT>" --token-b "<second-user-JWT>"
127
+ ```
128
+
129
+ - **Broken object-level auth (IDOR/BOLA)** — swaps resource ids to reach another user's data.
130
+ - **Broken tenant isolation** — swaps `org_id`/tenant to reach another tenant's data.
131
+ - **Privilege escalation** — forges a `role: admin` claim and checks whether a forbidden route opens up.
132
+ - **JWT not verified** — checks whether the server accepts a forged `alg:none` token.
133
+
134
+ It is **opt-in and consented**, **loopback-only**, and **GET-only** (it never writes). Need a token? Run `--active` without one and DeployReady prints step-by-step instructions for grabbing your JWT from the browser.
135
+
104
136
  ## What it checks
105
137
 
106
138
  - **Static analysis** — Babel-based AST parsing (pure JS, no native build) for JavaScript/TypeScript, plus Python. Dependency graph, route-mount resolution across files, and stack detection (Express, Next.js, Fastify, NestJS, Koa, FastAPI, Flask, Django, Laravel).
107
- - **Secrets & vulnerabilities** — hardcoded credentials, `eval`/command/SQL injection, XSS sinks, weak crypto, insecure randomness, disabled TLS verification, committed `.env`, log injection — each mapped to **OWASP Top 10 (2025)** and **CWE**.
139
+ - **Secrets & vulnerabilities** — hardcoded credentials, `eval`/command/SQL injection, XSS sinks, weak crypto, insecure randomness, disabled TLS verification, JWT `none` algorithm, insecure cookies, unsafe deserialization, insecure temp files, committed `.env`, log injection — each mapped to **OWASP Top 10 (2025)** and **CWE**.
140
+ - **Access control & transport** — Row-Level Security disabled or never enabled on a table, Supabase `service_role` key used in app code (RLS bypass), and insecure cleartext `http://` endpoints.
108
141
  - **Live dynamic testing** — detects your running localhost app and checks for auth bypass, exposed admin routes, secrets in responses, wildcard CORS, missing security headers, missing rate limiting, slow endpoints, missing cache headers, and version/stack-trace leaks.
142
+ - **Active authorization testing** (opt-in, `--active`) — acts as a logged-in user to find broken object-level auth (IDOR/BOLA), broken tenant isolation, privilege escalation (forged `role`), and unverified JWTs (`alg:none`).
109
143
  - **Readiness score (0–100)** with a critical / warning / info breakdown.
110
- - **Reports** — terminal output, markdown export, and an HTML dashboard.
144
+ - **Deployment recommendation** — suggests where to host based on your stack, size, and whether you're frontend / backend / full-stack, flags when to split frontend and backend across platforms, and marks suitable free tiers.
145
+ - **Reports** — terminal output, markdown export, and a branded HTML dashboard.
111
146
 
112
147
  ## How it works
113
148
 
@@ -120,7 +155,7 @@ Only the **structured findings JSON** is ever sent to an AI — and only after y
120
155
 
121
156
  ## AI models (optional)
122
157
 
123
- DeployReady works fully offline with no AI. To enable deeper analysis, configure one via `npx deployready init`:
158
+ DeployReady works fully offline with no AI. To enable deeper analysis, configure one via `npx deployready@latest init`:
124
159
 
125
160
  | Model | Notes |
126
161
  |---|---|
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classifyAuthzResult = classifyAuthzResult;
4
+ function classifyAuthzResult(input) {
5
+ const { status, gotForeignData } = input;
6
+ if (status === 401 || status === 403) {
7
+ return { verdict: 'denied', reason: `Access correctly denied (HTTP ${status}).` };
8
+ }
9
+ if (status === 404) {
10
+ return { verdict: 'denied', reason: 'Resource not exposed to this identity (HTTP 404).' };
11
+ }
12
+ if (status >= 200 && status < 300) {
13
+ return gotForeignData
14
+ ? {
15
+ verdict: 'broken',
16
+ reason: `Tampered request returned HTTP ${status} with another identity's data — access control failed.`,
17
+ }
18
+ : {
19
+ verdict: 'inconclusive',
20
+ reason: `HTTP ${status} returned, but no clear foreign data in the response — verify manually.`,
21
+ };
22
+ }
23
+ return { verdict: 'inconclusive', reason: `HTTP ${status} — inconclusive; the endpoint may have errored.` };
24
+ }
25
+ //# sourceMappingURL=accessControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessControl.js","sourceRoot":"","sources":["../../src/active/accessControl.ts"],"names":[],"mappings":";;AAeA,kDAqBC;AArBD,SAAgB,mBAAmB,CAAC,KAAkD;IACpF,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAEzC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,iCAAiC,MAAM,IAAI,EAAE,CAAC;IACpF,CAAC;IACD,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,mDAAmD,EAAE,CAAC;IAC5F,CAAC;IACD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;QAClC,OAAO,cAAc;YACnB,CAAC,CAAC;gBACE,OAAO,EAAE,QAAQ;gBACjB,MAAM,EAAE,kCAAkC,MAAM,wDAAwD;aACzG;YACH,CAAC,CAAC;gBACE,OAAO,EAAE,cAAc;gBACvB,MAAM,EAAE,QAAQ,MAAM,yEAAyE;aAChG,CAAC;IACR,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,MAAM,iDAAiD,EAAE,CAAC;AAC9G,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildUrl = buildUrl;
7
+ exports.createActiveHttpAdapter = createActiveHttpAdapter;
8
+ /**
9
+ * The real network transport for the active scan (Phase 5a) — the ONE place that
10
+ * actually sends requests, so it carries the safety rails:
11
+ * - loopback-only target (SSRF/scope guard, same bar as the dynamic suite),
12
+ * re-checked on every derived URL so a request can never leave the host;
13
+ * - dry-run that sends nothing;
14
+ * - hard timeout, no redirects, response-size cap.
15
+ *
16
+ * It returns the minimal `ActiveResponse` the runner needs. Consent + the request
17
+ * budget live above this (Orchestrator + runner).
18
+ */
19
+ const axios_1 = __importDefault(require("axios"));
20
+ const httpClient_1 = require("../dynamic/httpClient");
21
+ const TIMEOUT_MS = 8000;
22
+ const MAX_BODY = 5 * 1024 * 1024;
23
+ /** Build an absolute URL from base + path (+ query). Pure. */
24
+ function buildUrl(baseUrl, path, query) {
25
+ const url = new URL(path, baseUrl);
26
+ if (query) {
27
+ for (const [k, v] of Object.entries(query))
28
+ url.searchParams.set(k, String(v));
29
+ }
30
+ return url.toString();
31
+ }
32
+ function createActiveHttpAdapter(opts) {
33
+ (0, httpClient_1.assertLoopback)(opts.baseUrl); // scope is fixed to this loopback host
34
+ const timeout = opts.timeoutMs ?? TIMEOUT_MS;
35
+ return async (req) => {
36
+ const url = buildUrl(opts.baseUrl, req.path, req.query);
37
+ (0, httpClient_1.assertLoopback)(url); // defense in depth: never leave the loopback host
38
+ if (opts.dryRun)
39
+ return { status: 0, bodyText: '' };
40
+ const res = await axios_1.default.request({
41
+ url,
42
+ method: req.method,
43
+ headers: { 'User-Agent': 'DeployReady-Scanner/0.1', ...req.headers },
44
+ data: req.body,
45
+ timeout,
46
+ maxRedirects: 0,
47
+ validateStatus: () => true,
48
+ maxContentLength: MAX_BODY,
49
+ });
50
+ const bodyText = typeof res.data === 'string' ? res.data : JSON.stringify(res.data ?? '');
51
+ return { status: res.status, bodyText };
52
+ };
53
+ }
54
+ //# sourceMappingURL=httpAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpAdapter.js","sourceRoot":"","sources":["../../src/active/httpAdapter.ts"],"names":[],"mappings":";;;;;AAmBA,4BAMC;AASD,0DAuBC;AAzDD;;;;;;;;;;GAUG;AACH,kDAA0B;AAC1B,sDAAuD;AAGvD,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjC,8DAA8D;AAC9D,SAAgB,QAAQ,CAAC,OAAe,EAAE,IAAY,EAAE,KAAuC;IAC7F,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AASD,SAAgB,uBAAuB,C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amperClaimsKeepSig = tamperClaimsKeepSig;
6
+ function decodeSegment(seg) {
7
+ return JSON.parse(Buffer.from(seg, 'base64url').toString('utf8'));
8
+ }
9
+ function encodeSegment(obj) {
10
+ return Buffer.from(JSON.stringify(obj), 'utf8').toString('base64url');
11
+ }
12
+ function isPlainObject(v) {
13
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
14
+ }
15
+ /** Decode a JWT's header + payload. Returns null if it isn't a valid JWT shape. */
16
+ function decodeJwt(token) {
17
+ const parts = token.split('.');
18
+ if (parts.length !== 3)
19
+ return null;
20
+ try {
21
+ const header = decodeSegment(parts[0]);
22
+ const payload = decodeSegment(parts[1]);
23
+ if (!isPlainObject(header) || !isPlainObject(payload))
24
+ return null;
25
+ return { header, payload, signature: parts[2] };
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ /** Forge an `alg:"none"` token (empty signature), optionally patching claims. */
32
+ function forgeNoneAlg(token, claimPatch = {}) {
33
+ const d = decodeJwt(token);
34
+ if (!d)
35
+ return null;
36
+ const header = { ...d.header, alg: 'none' };
37
+ const payload = { ...d.payload, ...claimPatch };
38
+ return `${encodeSegment(header)}.${encodeSegment(payload)}.`;
39
+ }
40
+ /** Mutate claims but keep the original header + signature unchanged. */
41
+ function tamperClaimsKeepSig(token, patch) {
42
+ const d = decodeJwt(token);
43
+ if (!d)
44
+ return null;
45
+ const payload = { ...d.payload, ...patch };
46
+ return `${encodeSegment(d.header)}.${encodeSegment(payload)}.${d.signature}`;
47
+ }
48
+ //# sourceMappingURL=jwt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/active/jwt.ts"],"names":[],"mappings":";;AAiCA,8BAWC;AAGD,oCAMC;AAGD,kDAKC;AAzCD,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAA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AM,OAAO,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC;IAChD,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC;AAC/D,CAAC;AAED,wEAAwE;AACxE,SAAgB,mBAAmB,CAAC,KAAa,EAAE,KAA8B;IAC/E,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,OAAO,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;IAC3C,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildActiveRequests = buildActiveRequests;
4
+ const PARAM_RE = /^(?::(.+)|\{(.+)\})$/; // :name or {name}
5
+ const TENANT_PARAM_RE = /^(?:org|organization|tenant|team|company|workspace)/i;
6
+ const ID_PARAM_RE = /(?:^id$|_?id$|^uid$|^user$)/i;
7
+ function userClaim(claims) {
8
+ for (const v of [claims.sub, claims.user_id, claims.uid, claims.id]) {
9
+ if (typeof v === 'string' || typeof v === 'number')
10
+ return v;
11
+ }
12
+ return null;
13
+ }
14
+ function tenantClaim(claims) {
15
+ for (const v of [claims.org_id, claims.organization_id, claims.tenant_id, claims.tenant, claims.workspace_id]) {
16
+ if (typeof v === 'string' || typeof v === 'number')
17
+ return v;
18
+ }
19
+ return null;
20
+ }
21
+ /** Resolve a single path, or null if a param can't be filled. */
22
+ function resolvePath(path, claims) {
23
+ const out = [];
24
+ for (const seg of path.split('/')) {
25
+ const m = PARAM_RE.exec(seg);
26
+ if (!m) {
27
+ out.push(seg);
28
+ continue;
29
+ }
30
+ const name = m[1] ?? m[2] ?? '';
31
+ const value = TENANT_PARAM_RE.test(name) ? tenantClaim(claims) : ID_PARAM_RE.test(name) ? userClaim(claims) : null;
32
+ if (value === null)
33
+ return null; // unfillable param → skip the route
34
+ out.push(String(value));
35
+ }
36
+ return out.join('/');
37
+ }
38
+ function buildActiveRequests(routes, claims) {
39
+ const seen = new Set();
40
+ const requests = [];
41
+ for (const route of routes) {
42
+ if (route.method.toUpperCase() !== 'GET')
43
+ continue; // safe reads only
44
+ const path = resolvePath(route.path, claims);
45
+ if (path === null || seen.has(path))
46
+ continue;
47
+ seen.add(path);
48
+ requests.push({ method: 'GET', path });
49
+ }
50
+ return requests;
51
+ }
52
+ //# sourceMappingURL=requestPlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestPlan.js","sourceRoot":"","sources":["../../src/active/requestPlan.ts"],"names":[],"mappings":";;AAiDA,kDAWC;AA9CD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,CAAC,kBAAkB;AAC3D,MAAM,eAAe,GAAG,sDAAsD,CAAC;AAC/E,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAEnD,SAAS,SAAS,CAAC,MAA+B;IAChD,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;QACpE,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAAC,MAA+B;IAClD,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QA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CAAC,WAAW,EAAE,KAAK,KAAK;YAAE,SAAS,CAAC,kBAAkB;QACtE,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAC9C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runActiveScan = runActiveScan;
4
+ /**
5
+ * Consented active-scan runner (Phase 5a/5b).
6
+ *
7
+ * Replays real, authenticated requests with a tampered identity to prove broken
8
+ * access control. The HTTP transport is INJECTED (`HttpFn`) so the engine is
9
+ * pure-logic and fully unit-testable, and so the one place that actually touches
10
+ * the network (the real adapter) carries all the safety rails: explicit consent,
11
+ * single-host scope, request budget, and traffic redaction.
12
+ *
13
+ * Checks implemented here:
14
+ * - jwt-not-verified — server accepts a forged alg:none token (CWE-347)
15
+ * - bola-idor — A can read another user's object (CWE-639)
16
+ * - tenant-isolation-broken — A can read another tenant's data (CWE-639)
17
+ *
18
+ * It never sends a tampered request to an endpoint the test user can't already
19
+ * reach (non-2xx baseline), and it honours `maxRequests`.
20
+ */
21
+ const finding_1 = require("../utils/finding");
22
+ const jwt_1 = require("./jwt");
23
+ const tamper_1 = require("./tamper");
24
+ const accessControl_1 = require("./accessControl");
25
+ const BUDGET_DEFAULT = 200;
26
+ /** Claims we try to set to impersonate an admin during escalation tests. */
27
+ const ADMIN_CLAIMS = { role: 'admin', is_admin: true, isAdmin: true, admin: true };
28
+ function bearer(token) {
29
+ return { Authorization: `Bearer ${token}` };
30
+ }
31
+ function is2xx(status) {
32
+ return status >= 200 && status < 300;
33
+ }
34
+ /** Pull the value of `point`'s category from another identity's JWT claims. */
35
+ function foreignValueFor(category, claims) {
36
+ const candidates = category === 'tenant-id'
37
+ ? [claims.org_id, claims.organization_id, claims.tenant_id, claims.tenant, claims.workspace_id]
38
+ : [claims.sub, claims.user_id, claims.uid, claims.id];
39
+ for (const v of candidates) {
40
+ if (typeof v === 'string' || typeof v === 'number')
41
+ return v;
42
+ }
43
+ return null;
44
+ }
45
+ /**
46
+ * A 403 endpoint: see whether forging an admin role (with the signature kept, or
47
+ * via alg:none) flips it to a 2xx — which proves the server trusts the client's
48
+ * role claim instead of verifying it.
49
+ */
50
+ async function tryEscalate(req, token, send, hasBudget) {
51
+ const variants = [(0, jwt_1.tamperClaimsKeepSig)(token, ADMIN_CLAIMS), (0, jwt_1.forgeNoneAlg)(token, ADMIN_CLAIMS)];
52
+ for (const variant of variants) {
53
+ if (!variant || !hasBudget())
54
+ continue;
55
+ const r = await send(req, variant);
56
+ if (is2xx(r.status)) {
57
+ return (0, finding_1.makeFinding)({
58
+ rule: 'privilege-escalation',
59
+ title: 'Privilege escalation via forged role claim',
60
+ severity: 'critical',
61
+ category: 'security',
62
+ source: 'dynamic',
63
+ endpoint: req.path,
64
+ owasp: 'A01:2025',
65
+ cwe: 'CWE-269',
66
+ description: `${req.path} returned 403 for the test user but 200 once the token's role was changed to "admin" — the server trusts the client-supplied role instead of verifying it.`,
67
+ recommendation: 'Derive authorization from a server-verified token (validate the signature) and never trust role/claims that the client can modify.',
68
+ });
69
+ }
70
+ }
71
+ return null;
72
+ }
73
+ async function runActiveScan(config, http) {
74
+ const findings = [];
75
+ const budget = config.maxRequests ?? BUDGET_DEFAULT;
76
+ let used = 0;
77
+ const send = (req, token) => {
78
+ used++;
79
+ return http({ method: req.method, path: req.path, query: req.query, body: req.body, headers: bearer(token) });
80
+ };
81
+ const bClaims = config.tokenB ? (0, jwt_1.decodeJwt)(config.tokenB)?.payload ?? null : null;
82
+ let jwtReported = false;
83
+ for (const req of config.requests) {
84
+ if (used >= budget)
85
+ break;
86
+ // Baseline as the real test user.
87
+ const baseline = await send(req, config.token);
88
+ // Forbidden for this user? Try to escalate via a forged admin role claim.
89
+ if (baseline.status === 403 && used < budget) {
90
+ const escalated = await tryEscalate(req, config.token, send, () => used < budget);
91
+ if (escalated)
92
+ findings.push(escalated);
93
+ continue;
94
+ }
95
+ // Only the remaining checks need an endpoint A can actually reach.
96
+ if (!is2xx(baseline.status))
97
+ continue;
98
+ // --- JWT verification: does the server accept a forged alg:none token? ---
99
+ if (!jwtReported && used < budget) {
100
+ const forged = (0, jwt_1.forgeNoneAlg)(config.token);
101
+ if (forged) {
102
+ const r = await send(req, forged);
103
+ if (is2xx(r.status)) {
104
+ findings.push((0, finding_1.makeFinding)({
105
+ rule: 'jwt-not-verified',
106
+ title: 'JWT signature not verified (alg:none accepted)',
107
+ severity: 'critical',
108
+ category: 'security',
109
+ source: 'dynamic',
110
+ endpoint: req.path,
111
+ owasp: 'A02:2025',
112
+ cwe: 'CWE-347',
113
+ description: `${req.path} accepted a forged "alg:none" token — the server does not verify JWT signatures, so anyone can mint a valid-looking token.`,
114
+ recommendation: 'Verify the JWT signature server-side and reject the "none" algorithm; pin the allowed algorithms (e.g. RS256/HS256).',
115
+ }));
116
+ jwtReported = true;
117
+ }
118
+ }
119
+ }
120
+ // --- Cross-access (IDOR / tenant): request B's resource while authed as A ---
121
+ if (bClaims) {
122
+ for (const point of (0, tamper_1.findInjectionPoints)(req)) {
123
+ if (used >= budget)
124
+ break;
125
+ const foreign = foreignValueFor(point.category, bClaims);
126
+ if (foreign === null || String(foreign) === String(point.value))
127
+ continue;
128
+ const tampered = (0, tamper_1.applyInjection)(req, point, foreign);
129
+ const r = await send(tampered, config.token);
130
+ const gotForeignData = r.bodyText.includes(String(foreign));
131
+ const { verdict } = (0, accessControl_1.classifyAuthzResult)({ status: r.status, gotForeignData });
132
+ if (verdict !== 'broken')
133
+ continue;
134
+ const isTenant = point.category === 'tenant-id';
135
+ findings.push((0, finding_1.makeFinding)({
136
+ rule: isTenant ? 'tenant-isolation-broken' : 'bola-idor',
137
+ title: isTenant
138
+ ? 'Cross-tenant data access (broken tenant isolation)'
139
+ : 'Broken object-level authorization (IDOR / BOLA)',
140
+ severity: 'critical',
141
+ category: 'security',
142
+ source: 'dynamic',
143
+ endpoint: req.path,
144
+ owasp: 'A01:2025',
145
+ cwe: 'CWE-639',
146
+ description: `Setting ${point.label}=${foreign} (another identity's value) and calling ${req.path} as the test user returned HTTP ${r.status} containing that identity's data.`,
147
+ recommendation: isTenant
148
+ ? 'Scope every query by the authenticated tenant derived from the session — never trust a tenant id supplied in the request.'
149
+ : 'Enforce per-object ownership checks server-side; never authorize access based on an id supplied by the client.',
150
+ }));
151
+ }
152
+ }
153
+ }
154
+ return findings;
155
+ }
156
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/active/runner.ts"],"names":[],"mappings":";;AA2GA,sCA2FC;AAtMD;;;;;;;;;;;;;;;;GAgBG;AACH,8CAA+C;AAC/C,+BAAqE;AACrE,qCAA+D;AAC/D,mDAAsD;AA6BtD,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,4EAA4E;AAC5E,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAEnF,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,KAAK,CAAC,MAAc;IAC3B,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC;AACvC,CAAC;AAED,+EAA+E;AAC/E,SAAS,eAAe,CAAC,QAAmC,EAAE,MAA+B;IAC3F,MAAM,UAAU,GACd,QAAQ,KAAK,WAAW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AED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findInjectionPoints = findInjectionPoints;
4
+ exports.applyInjection = applyInjection;
5
+ /** Keys that denote a tenant/organization boundary. */
6
+ const TENANT_KEY_RE = /^(?:org|organization|tenant|team|company|workspace)(?:[-_]?id)?$/i;
7
+ /** Keys that denote an object/owner id. */
8
+ const OBJECT_ID_KEY_RE = /(?:^id$|_id$|^uid$|Id$)/;
9
+ /** A value that looks like an id worth swapping: number, numeric string, or UUID. */
10
+ function looksLikeId(value) {
11
+ if (typeof value === 'number')
12
+ return true;
13
+ if (typeof value !== 'string')
14
+ return false;
15
+ return /^\d+$/.test(value) || /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
16
+ }
17
+ /** Categorize a key name, or null if it isn't identity-bearing. */
18
+ function categorize(key) {
19
+ if (TENANT_KEY_RE.test(key))
20
+ return 'tenant-id';
21
+ if (OBJECT_ID_KEY_RE.test(key))
22
+ return 'object-id';
23
+ return null;
24
+ }
25
+ function isPlainObject(v) {
26
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
27
+ }
28
+ function findInjectionPoints(spec) {
29
+ const points = [];
30
+ // Path: any segment that looks like a bare id is an object id.
31
+ const parts = spec.path.split('/');
32
+ parts.forEach((seg, i) => {
33
+ if (seg && looksLikeId(seg)) {
34
+ points.push({ location: 'path', category: 'object-id', field: String(i), value: seg, label: `path segment "${seg}"` });
35
+ }
36
+ });
37
+ // Query: classify by key name.
38
+ for (const [key, value] of Object.entries(spec.query ?? {})) {
39
+ const category = categorize(key);
40
+ if (category)
41
+ points.push({ location: 'query', category, field: key, value, label: `query.${key}` });
42
+ }
43
+ // Body: walk a JSON object, classify by key name, address via dotted path.
44
+ if (isPlainObject(spec.body)) {
45
+ walkBody(spec.body, '', points);
46
+ }
47
+ return points;
48
+ }
49
+ function walkBody(obj, prefix, out) {
50
+ for (const [key, value] of Object.entries(obj)) {
51
+ const dotted = prefix ? `${prefix}.${key}` : key;
52
+ if (isPlainObject(value)) {
53
+ walkBody(value, dotted, out);
54
+ continue;
55
+ }
56
+ const category = categorize(key);
57
+ if (category && (typeof value === 'string' || typeof value === 'number')) {
58
+ out.push({ location: 'body', category, field: dotted, value, label: `body.${dotted}` });
59
+ }
60
+ }
61
+ }
62
+ /** Return a new spec with `point` set to `newValue`. Does not mutate `spec`. */
63
+ function applyInjection(spec, point, newValue) {
64
+ if (point.location === 'path') {
65
+ const parts = spec.path.split('/');
66
+ parts[Number(point.field)] = String(newValue);
67
+ return { ...spec, path: parts.join('/') };
68
+ }
69
+ if (point.location === 'query') {
70
+ return { ...spec, query: { ...(spec.query ?? {}), [point.field]: newValue } };
71
+ }
72
+ // body — clone and set by dotted path.
73
+ const body = JSON.parse(JSON.stringify(spec.body ?? {}));
74
+ const keys = point.field.split('.');
75
+ let cursor = body;
76
+ for (let i = 0; i < keys.length - 1; i++)
77
+ cursor = cursor[keys[i]];
78
+ cursor[keys[keys.length - 1]] = newValue;
79
+ return { ...spec, body };
80
+ }
81
+ //# sourceMappingURL=tamper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tamper.js","sourceRoot":"","sources":["../../src/active/tamper.ts"],"names":[],"mappings":";;AAiCA,kDAuBC;AAiBD,wCAgBC;AA/ED,uDAAuD;AACvD,MAAM,aAAa,GAAG,mEAAmE,CAAC;AAC1F,2CAA2C;AAC3C,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAEnD,qFAAqF;AACrF,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,iEAAiE,CAAC,IAA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AI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5C,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAC/B,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC;IAChF,CAAC;IACD,uCAAuC;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAA4B,CAAC;IACpF,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,MAAM,GAA4B,IAAI,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE;QAAE,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAE,CAA4B,CAAC;IAC/F,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,GAAG,QAAQ,CAAC;IAC1C,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jwtRetrievalSteps = jwtRetrievalSteps;
4
+ exports.renderTokenHelp = renderTokenHelp;
5
+ /**
6
+ * Minimal, friendly instructions for a user who doesn't know how to get the
7
+ * JWT/bearer token an active scan needs. Shown when `--active` is requested
8
+ * without a `--token` (and via `help`). Pure text, no I/O.
9
+ */
10
+ function jwtRetrievalSteps() {
11
+ return [
12
+ 'Open your app in a browser and log in as a test user.',
13
+ 'Open DevTools (F12, or Ctrl/Cmd+Shift+I) and click the "Network" tab.',
14
+ 'Do something in the app (or refresh) so requests appear, then click one that hits your API/backend.',
15
+ 'In that request\'s "Headers" → "Request Headers", find "Authorization: Bearer <long string>" and copy the long string (that is your JWT).',
16
+ 'No Authorization header? Check "Application/Storage" → Local Storage or Cookies for a value like "token", "access_token", or "jwt".',
17
+ 'Pass it to DeployReady: --token "<paste-the-token-here>" (add --token-b "<second user>" to test tenant isolation).',
18
+ ];
19
+ }
20
+ function renderTokenHelp() {
21
+ const steps = jwtRetrievalSteps()
22
+ .map((s, i) => ` ${i + 1}. ${s}`)
23
+ .join('\n');
24
+ return [
25
+ 'To run an active (authenticated) scan, DeployReady needs a login token so it can act as a',
26
+ 'real user and then try to reach data it should not. Here is how to get one:',
27
+ '',
28
+ steps,
29
+ '',
30
+ 'Note: tokens expire — if you start seeing 401s, grab a fresh one and run again.',
31
+ ].join('\n');
32
+ }
33
+ //# sourceMappingURL=tokenHelp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenHelp.js","sourceRoot":"","sources":["../../src/active/tokenHelp.ts"],"names":[],"mappings":";;AAKA,8CASC;AAED,0CAYC;AA5BD;;;;GAIG;AACH,SAAgB,iBAAiB;IAC/B,OAAO;QACL,uDAAuD;QACvD,uEAAuE;QACvE,qGAAqG;QACrG,2IAA2I;QAC3I,qIAAqI;QACrI,qHAAqH;KACtH,CAAC;AACJ,CAAC;AAED,SAAgB,eAAe;IAC7B,MAAM,KAAK,GAAG,iBAAiB,EAAE;SAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;SACjC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO;QACL,2FAA2F;QAC3F,6EAA6E;QAC7E,EAAE;QACF,KAAK;QACL,EAAE;QACF,iFAAiF;KAClF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}