deployready 0.2.0 → 0.4.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 (187) hide show
  1. package/README.md +166 -40
  2. package/SECURITY.md +34 -0
  3. package/dist/active/accessControl.js +62 -10
  4. package/dist/active/accessControl.js.map +1 -1
  5. package/dist/active/httpAdapter.js +13 -6
  6. package/dist/active/httpAdapter.js.map +1 -1
  7. package/dist/active/mutationProbe.js +132 -0
  8. package/dist/active/mutationProbe.js.map +1 -0
  9. package/dist/active/requestPlan.js +52 -26
  10. package/dist/active/requestPlan.js.map +1 -1
  11. package/dist/active/runner.js +121 -23
  12. package/dist/active/runner.js.map +1 -1
  13. package/dist/active/scope.js +74 -0
  14. package/dist/active/scope.js.map +1 -0
  15. package/dist/active/tamper.js +17 -4
  16. package/dist/active/tamper.js.map +1 -1
  17. package/dist/agent/FileEditor.js +122 -20
  18. package/dist/agent/FileEditor.js.map +1 -1
  19. package/dist/agent/FixManager.js +120 -6
  20. package/dist/agent/FixManager.js.map +1 -1
  21. package/dist/agent/context.js +199 -0
  22. package/dist/agent/context.js.map +1 -0
  23. package/dist/agent/fixPrompt.js +31 -0
  24. package/dist/agent/fixPrompt.js.map +1 -0
  25. package/dist/ai/CliHandler.js +80 -0
  26. package/dist/ai/CliHandler.js.map +1 -0
  27. package/dist/ai/ModelRouter.js +45 -4
  28. package/dist/ai/ModelRouter.js.map +1 -1
  29. package/dist/ai/PromptBuilder.js +7 -3
  30. package/dist/ai/PromptBuilder.js.map +1 -1
  31. package/dist/ai/cli/argv.js +67 -0
  32. package/dist/ai/cli/argv.js.map +1 -0
  33. package/dist/ai/cli/env.js +46 -0
  34. package/dist/ai/cli/env.js.map +1 -0
  35. package/dist/ai/cli/errors.js +15 -0
  36. package/dist/ai/cli/errors.js.map +1 -0
  37. package/dist/ai/cli/parseOutput.js +151 -0
  38. package/dist/ai/cli/parseOutput.js.map +1 -0
  39. package/dist/ai/cli/providers.js +30 -0
  40. package/dist/ai/cli/providers.js.map +1 -0
  41. package/dist/ai/cli/ready.js +121 -0
  42. package/dist/ai/cli/ready.js.map +1 -0
  43. package/dist/ai/cli/resolve.js +108 -0
  44. package/dist/ai/cli/resolve.js.map +1 -0
  45. package/dist/ai/cli/runCli.js +265 -0
  46. package/dist/ai/cli/runCli.js.map +1 -0
  47. package/dist/ai/parseAiResponse.js +24 -11
  48. package/dist/ai/parseAiResponse.js.map +1 -1
  49. package/dist/ai/verifyAiFindings.js +106 -0
  50. package/dist/ai/verifyAiFindings.js.map +1 -0
  51. package/dist/analysis/ScoreCalculator.js +22 -2
  52. package/dist/analysis/ScoreCalculator.js.map +1 -1
  53. package/dist/analysis/SeverityScorer.js +7 -1
  54. package/dist/analysis/SeverityScorer.js.map +1 -1
  55. package/dist/analysis/VulnerabilityDetector.js +271 -41
  56. package/dist/analysis/VulnerabilityDetector.js.map +1 -1
  57. package/dist/analysis/idor.js +261 -0
  58. package/dist/analysis/idor.js.map +1 -0
  59. package/dist/analysis/rls.js +81 -15
  60. package/dist/analysis/rls.js.map +1 -1
  61. package/dist/analysis/routeAuth.js +93 -0
  62. package/dist/analysis/routeAuth.js.map +1 -0
  63. package/dist/analysis/rules.js +98 -2
  64. package/dist/analysis/rules.js.map +1 -1
  65. package/dist/cli/Commands.js +75 -6
  66. package/dist/cli/Commands.js.map +1 -1
  67. package/dist/cli/InteractiveShell.js +149 -28
  68. package/dist/cli/InteractiveShell.js.map +1 -1
  69. package/dist/cli/Onboarding.js +13 -1
  70. package/dist/cli/Onboarding.js.map +1 -1
  71. package/dist/cli/cliSetup.js +48 -0
  72. package/dist/cli/cliSetup.js.map +1 -0
  73. package/dist/config/ConfigManager.js +11 -0
  74. package/dist/config/ConfigManager.js.map +1 -1
  75. package/dist/core/CiGate.js +38 -16
  76. package/dist/core/CiGate.js.map +1 -1
  77. package/dist/core/Orchestrator.js +207 -25
  78. package/dist/core/Orchestrator.js.map +1 -1
  79. package/dist/core/Verifier.js +239 -15
  80. package/dist/core/Verifier.js.map +1 -1
  81. package/dist/dynamic/APIAnalyzer.js +5 -0
  82. package/dist/dynamic/APIAnalyzer.js.map +1 -1
  83. package/dist/dynamic/DynamicTester.js +92 -8
  84. package/dist/dynamic/DynamicTester.js.map +1 -1
  85. package/dist/dynamic/EndpointMapper.js +54 -24
  86. package/dist/dynamic/EndpointMapper.js.map +1 -1
  87. package/dist/dynamic/LocalhostDetector.js +11 -23
  88. package/dist/dynamic/LocalhostDetector.js.map +1 -1
  89. package/dist/dynamic/PerformanceTester.js +12 -0
  90. package/dist/dynamic/PerformanceTester.js.map +1 -1
  91. package/dist/dynamic/SecurityTester.js +100 -11
  92. package/dist/dynamic/SecurityTester.js.map +1 -1
  93. package/dist/dynamic/adminEvidence.js +47 -0
  94. package/dist/dynamic/adminEvidence.js.map +1 -0
  95. package/dist/dynamic/advertised.js +293 -0
  96. package/dist/dynamic/advertised.js.map +1 -0
  97. package/dist/dynamic/catchAll.js +57 -0
  98. package/dist/dynamic/catchAll.js.map +1 -0
  99. package/dist/dynamic/commonPaths/evidence.js +112 -0
  100. package/dist/dynamic/commonPaths/evidence.js.map +1 -0
  101. package/dist/dynamic/commonPaths/prober.js +217 -0
  102. package/dist/dynamic/commonPaths/prober.js.map +1 -0
  103. package/dist/dynamic/commonPaths/signatures.js +381 -0
  104. package/dist/dynamic/commonPaths/signatures.js.map +1 -0
  105. package/dist/dynamic/proof.js +79 -0
  106. package/dist/dynamic/proof.js.map +1 -0
  107. package/dist/firebase/conditions.js +61 -0
  108. package/dist/firebase/conditions.js.map +1 -0
  109. package/dist/firebase/index.js +31 -0
  110. package/dist/firebase/index.js.map +1 -0
  111. package/dist/firebase/rtdbParser.js +96 -0
  112. package/dist/firebase/rtdbParser.js.map +1 -0
  113. package/dist/firebase/rules.js +171 -0
  114. package/dist/firebase/rules.js.map +1 -0
  115. package/dist/firebase/rulesParser.js +193 -0
  116. package/dist/firebase/rulesParser.js.map +1 -0
  117. package/dist/firebase/static.js +179 -0
  118. package/dist/firebase/static.js.map +1 -0
  119. package/dist/mcp/analyzeFix.js +62 -0
  120. package/dist/mcp/analyzeFix.js.map +1 -0
  121. package/dist/mcp/fixes.js +69 -0
  122. package/dist/mcp/fixes.js.map +1 -0
  123. package/dist/mcp/readiness.js +21 -0
  124. package/dist/mcp/readiness.js.map +1 -0
  125. package/dist/mcp/server.js +77 -0
  126. package/dist/mcp/server.js.map +1 -0
  127. package/dist/mcp/supabase.js +65 -0
  128. package/dist/mcp/supabase.js.map +1 -0
  129. package/dist/mcp/tools.js +186 -0
  130. package/dist/mcp/tools.js.map +1 -0
  131. package/dist/parser/CodeParser.js +138 -28
  132. package/dist/parser/CodeParser.js.map +1 -1
  133. package/dist/parser/adapters/BabelAdapter.js +558 -27
  134. package/dist/parser/adapters/BabelAdapter.js.map +1 -1
  135. package/dist/parser/adapters/PythonAdapter.js +360 -14
  136. package/dist/parser/adapters/PythonAdapter.js.map +1 -1
  137. package/dist/parser/adapters/authMiddleware.js +256 -0
  138. package/dist/parser/adapters/authMiddleware.js.map +1 -0
  139. package/dist/parser/adapters/nest.js +162 -0
  140. package/dist/parser/adapters/nest.js.map +1 -0
  141. package/dist/parser/miniYaml.js +308 -0
  142. package/dist/parser/miniYaml.js.map +1 -0
  143. package/dist/parser/nextRoutes.js +204 -0
  144. package/dist/parser/nextRoutes.js.map +1 -0
  145. package/dist/parser/openapi.js +180 -0
  146. package/dist/parser/openapi.js.map +1 -0
  147. package/dist/parser/pathUtil.js +22 -0
  148. package/dist/parser/pathUtil.js.map +1 -0
  149. package/dist/supabase/guard.js +95 -0
  150. package/dist/supabase/guard.js.map +1 -0
  151. package/dist/supabase/http.js +113 -0
  152. package/dist/supabase/http.js.map +1 -0
  153. package/dist/supabase/index.js +156 -0
  154. package/dist/supabase/index.js.map +1 -0
  155. package/dist/supabase/keys.js +56 -0
  156. package/dist/supabase/keys.js.map +1 -0
  157. package/dist/supabase/live.js +397 -0
  158. package/dist/supabase/live.js.map +1 -0
  159. package/dist/supabase/static.js +213 -0
  160. package/dist/supabase/static.js.map +1 -0
  161. package/dist/ui/ExportManager.js +71 -3
  162. package/dist/ui/ExportManager.js.map +1 -1
  163. package/dist/ui/HtmlReporter.js +78 -5
  164. package/dist/ui/HtmlReporter.js.map +1 -1
  165. package/dist/ui/IssuePresenter.js +68 -5
  166. package/dist/ui/IssuePresenter.js.map +1 -1
  167. package/dist/ui/Sarif.js +101 -0
  168. package/dist/ui/Sarif.js.map +1 -0
  169. package/dist/ui/badge.js +60 -0
  170. package/dist/ui/badge.js.map +1 -0
  171. package/dist/ui/commonPathSection.js +42 -0
  172. package/dist/ui/commonPathSection.js.map +1 -0
  173. package/dist/utils/FileWalker.js +128 -16
  174. package/dist/utils/FileWalker.js.map +1 -1
  175. package/dist/utils/GitIgnore.js +162 -0
  176. package/dist/utils/GitIgnore.js.map +1 -0
  177. package/dist/utils/finding.js +5 -0
  178. package/dist/utils/finding.js.map +1 -1
  179. package/dist/utils/logger.js +4 -0
  180. package/dist/utils/logger.js.map +1 -1
  181. package/dist/utils/redact.js +2 -1
  182. package/dist/utils/redact.js.map +1 -1
  183. package/dist/utils/sanitize.js +30 -0
  184. package/dist/utils/sanitize.js.map +1 -0
  185. package/docs/sample-config.json +2 -1
  186. package/package.json +18 -6
  187. package/skills/deployready/SKILL.md +55 -0
package/README.md CHANGED
@@ -1,49 +1,80 @@
1
1
  # DeployReady
2
2
 
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.
3
+ DeployReady is a local security and production-readiness scanner for apps built with AI coding tools. It reads your code, optionally tests your app running on localhost, and gives a 0-100 readiness score with fixes.
4
4
 
5
5
  ```bash
6
- npx deployready@latest analyze ./my-app
6
+ npx deployready@latest
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.
9
+ Requires Node.js 18 or later. Use `@latest` because plain `npx deployready` can reuse a cached older copy. To install globally instead: `npm install -g deployready`, then run `deployready`.
10
10
 
11
- ## Install
11
+ <p align="center">
12
+ <img src="docs/screenshots/report.png" alt="DeployReady HTML report for the bundled sample app: readiness score 38/100, 4 critical and 3 warning findings" width="720">
13
+ </p>
14
+
15
+ <p align="center"><sub>HTML report (<code>--html</code>) for the deliberately vulnerable <a href="tests/sample-app"><code>tests/sample-app</code></a>.</sub></p>
12
16
 
13
- **Run without installing** (recommended — always works, nothing to set up):
17
+ ## Quick start (about 60 seconds)
14
18
 
15
19
  ```bash
16
- npx deployready@latest ./my-app
17
- ```
20
+ # 1. Scan. Static only, fully offline:
21
+ npx deployready@latest analyze ./my-app --no-ai --no-dynamic
18
22
 
19
- **Or install globally** if you run it often (faster, but you must update it yourself):
23
+ # 2. Apply the safe, deterministic fixes (backups are written first):
24
+ npx deployready@latest analyze ./my-app --no-ai --no-dynamic --fix
25
+ # in the interactive session the same thing is: fix --all
20
26
 
21
- ```bash
22
- npm install -g deployready
23
- deployready ./my-app
24
- # update later with: npm i -g deployready@latest
27
+ # 3. Let your coding agent scan, fix and verify in a loop (Claude Code):
28
+ claude mcp add deployready -- npx -y deployready@latest mcp
25
29
  ```
26
30
 
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.
31
+ Run `npx deployready@latest` with no arguments to open the guided interactive session instead.
32
+
33
+ <p align="center">
34
+ <img src="docs/scan-demo.svg" alt="Animated terminal recording of DeployReady 0.4.0 scanning a deliberately vulnerable Flask app: 3 critical and 1 warning (score 48/100), analyze --fix applies 2 safe fixes (score 60/100), then a fix prompt for the hardcoded SECRET_KEY is printed" width="720">
35
+ </p>
36
+
37
+ <p align="center"><sub>A real run on <a href="benchmark/corpus/vibe/flask-debug-sqli-tp"><code>benchmark/corpus/vibe/flask-debug-sqli-tp</code></a> (paths shortened, repeated lines elided). Only the two findings with a safe deterministic fix are changed; the rest are left for you or your coding agent.</sub></p>
38
+
39
+ ## What it checks, and what it doesn't
28
40
 
29
- ## Quick start
41
+ **Checks**
30
42
 
31
- Run it inside your project to open an interactive, guided session — no commands to memorize, just pick a number:
43
+ - Static analysis of JavaScript/TypeScript and Python: hardcoded secrets, `eval`, command and SQL injection, XSS sinks, weak crypto, disabled TLS verification, insecure cookies, JWT `none`, unsafe deserialization, committed `.env`. Findings map to OWASP Top 10 (2025) and CWE.
44
+ - Access control patterns: routes without an auth check, Supabase tables without Row-Level Security, `service_role` keys in client code.
45
+ - Live checks against your app on localhost: auth bypass, exposed admin routes, secrets in responses, CORS, security headers, rate limiting.
46
+ - Opt-in active (authenticated) tests and Supabase checks, described below.
47
+ - Firebase security rules (static only): open or test-mode Firestore/Storage/Realtime Database rules, sign-in-only rules on user-owned paths, and committed service account keys. See [`docs/FIREBASE.md`](docs/FIREBASE.md).
48
+
49
+ **Does not**
50
+
51
+ - It is not a penetration test or a substitute for a code review. A score of 100 means none of these checks fired, not that the app is secure.
52
+ - Static analysis has false positives and false negatives. Business-logic flaws, most authorization design errors, and anything in languages other than JS/TS/Python are out of reach.
53
+ - Live tests only cover routes your code or OpenAPI file defines, plus links your running app advertises. Paths are not guessed unless you opt in to the common-path probe.
54
+ - AI-generated findings are marked unverified and never change the score or the CI gate.
55
+ - Supabase checks are read-only, so write exposure (INSERT/UPDATE/DELETE policies) is not tested.
56
+ - Firebase checks read the rules files in your repo only. They do not connect to Firebase, so deployed rules and Auth settings are not verified. The public web config `apiKey` is not flagged.
57
+
58
+ Test coverage numbers are in [`docs/COVERAGE.md`](docs/COVERAGE.md).
59
+
60
+ ## Score badge
32
61
 
33
62
  ```bash
34
- npx deployready@latest ./my-app # or just: npx deployready@latest
63
+ npx deployready@latest badge . # prints a markdown badge
64
+ npx deployready@latest badge . --write-svg badge.svg # also writes a local SVG, no network
35
65
  ```
36
66
 
37
- ```
38
- What would you like to do?
39
- 1 Scan this project now (recommended)
40
- 2 Set up or change the AI model
41
- 3 How does DeployReady work?
42
- 4 Go to the command prompt
43
- 5 Exit
67
+ The command runs a static scan and prints, for example:
68
+
69
+ ```markdown
70
+ ![DeployReady score](https://img.shields.io/badge/DeployReady-87%2F100-green)
44
71
  ```
45
72
 
46
- After each action it suggests your next step (e.g. “type `fix 1` to fix the top issue”). Type `menu` anytime to bring the guide back.
73
+ Colors: 90-100 bright green, 75-89 green, 60-74 yellow, 40-59 orange, below 40 red. The badge is a snapshot; regenerate it when the score changes.
74
+
75
+ ## Install
76
+
77
+ See the top of this page. Every command here is written as `npx deployready@latest ...`; with a global install, use `deployready ...`.
47
78
 
48
79
  ## Interactive commands
49
80
 
@@ -65,6 +96,7 @@ deployready › exit
65
96
  | `scan` · `parse` · `dynamic` · `ai` | run the whole pipeline, or one step at a time |
66
97
  | `issues [crit\|warn\|info]` · `show <n>` | list findings (optionally filtered) · show one in detail |
67
98
  | `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 |
99
+ | `fix --all` | apply every safe deterministic fix above in one go: one confirmation, a backup per change, each one re-verified. AI-proposed fixes are never run in bulk |
68
100
  | `verify <n>` | re-run the relevant checks to confirm a fix actually resolved the issue |
69
101
  | `done <n>` · `ignore <n>` | mark fixed / ignored — the score recomputes immediately |
70
102
  | `score` · `status` | show the current readiness score / session state |
@@ -79,6 +111,7 @@ npx deployready@latest init # first-time setup (pic
79
111
  npx deployready@latest analyze ./my-app # single non-interactive scan, prints results
80
112
  npx deployready@latest analyze . --no-ai --no-dynamic # static only, fully offline
81
113
  npx deployready@latest report ./my-app # scan and export the markdown report
114
+ npx deployready@latest badge ./my-app # print a markdown score badge
82
115
  npx deployready@latest config # show the active config (secrets never printed)
83
116
  ```
84
117
 
@@ -87,6 +120,7 @@ npx deployready@latest config # show the active confi
87
120
  | Flag | Effect |
88
121
  |---|---|
89
122
  | `-y, --yes` | auto-approve all prompts (non-interactive) |
123
+ | `--fix` | apply the safe deterministic fixes (backed up), re-scan, and report the new score; works with `--json` and `--fail-on` (asks once unless `--yes`/`--json`) |
90
124
  | `--no-dynamic` | skip live localhost testing |
91
125
  | `--no-ai` | skip AI analysis (local results only) |
92
126
  | `--aggressive` | enable aggressive tests (rate-limit burst) |
@@ -96,9 +130,11 @@ npx deployready@latest config # show the active confi
96
130
  | `--fail-on <severity>` | exit non-zero if findings at/above `critical \| warning \| info \| none` exist |
97
131
  | `--baseline <file>` | gate only on findings **not** in the baseline file (existing issues are grandfathered) |
98
132
  | `--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) |
133
+ | `--active` | run **active** authenticated authorization tests (needs `--token`; consented, loopback-only unless `--i-own-this-target`) |
100
134
  | `--token <jwt>` | bearer JWT for the active scan (your logged-in test user) |
101
135
  | `--token-b <jwt>` | a second user's JWT — enables tenant / IDOR isolation tests |
136
+ | `--active-url <url>` | base URL for the active scan (default: the app found on localhost) |
137
+ | `--i-own-this-target <host>` | confirm you own a non-loopback host so active probes may target it (repeatable, exact host) |
102
138
  | `-v, --verbose` | verbose debug output |
103
139
 
104
140
  **CI gate:** exit codes are `0` (clean), `2` (gate failed), `1` (tool error).
@@ -116,7 +152,79 @@ npx deployready@latest analyze . --no-ai --no-dynamic --write-baseline .deployre
116
152
  npx deployready@latest analyze . --no-ai --no-dynamic --baseline .deployready-baseline.json --fail-on warning # in CI
117
153
  ```
118
154
 
119
- A ready-to-copy GitHub Action is in [`docs/github-action-example.yml`](docs/github-action-example.yml).
155
+ **GitHub Action:** gate pull requests, get a sticky PR comment and code-scanning alerts (SARIF) with one step. Needs `security-events: write` and `pull-requests: write`:
156
+
157
+ ```yaml
158
+ permissions: { contents: read, security-events: write, pull-requests: write }
159
+ steps:
160
+ - uses: actions/checkout@v4
161
+ - uses: BelsoftSolutions/deployready@v0.4.0
162
+ with: { fail-on: critical }
163
+ ```
164
+
165
+ Details in [`docs/GITHUB-ACTION.md`](docs/GITHUB-ACTION.md); a full example is in [`docs/github-action-example.yml`](docs/github-action-example.yml). Locally, `--sarif <file>` writes a SARIF 2.1.0 report.
166
+
167
+ ### Fix in one command (`--fix`)
168
+
169
+ ```bash
170
+ npx deployready@latest analyze . --no-ai --no-dynamic --fix --yes # apply safe fixes, re-scan, print the new score
171
+ npx deployready@latest analyze . --no-ai --no-dynamic --fix --json --fail-on critical
172
+ ```
173
+
174
+ `--fix` only applies deterministic fixes (for example adding `.env` to `.gitignore`, or swapping a weak hash for SHA-256). Every change is backed up first. With `--json`, the report gains a `fix` block (`applied`, `skipped`, `scoreBefore`, `scoreAfter`) and `--fail-on` gates on the post-fix result.
175
+
176
+ ## Use it from your coding agent (MCP)
177
+
178
+ `deployready mcp` is a local stdio [MCP](https://modelcontextprotocol.io) server. Your own coding agent (Claude Code, Cursor, Codex, Windsurf) scans, fixes, and has DeployReady verify, in a loop. Nothing leaves your machine, and the server never calls an AI model itself.
179
+
180
+ | Tool | What it does |
181
+ |---|---|
182
+ | `scan(path?, dynamic?)` | findings (id, rule, severity, file, line, evidence, proof) plus the score |
183
+ | `get_finding(id)` | full detail, fix guidance (recommendation, OWASP, CWE) and the whole file with the line marked |
184
+ | `apply_safe_fixes(path?)` | runs the deterministic fixes; returns applied/skipped with backup paths |
185
+ | `verify(id)` | re-checks one finding: `fixed`, `still-present` or `inconclusive`, with the reason |
186
+ | `score(path?)` | re-scans; score plus a ready/not-ready verdict (ready = no open critical findings) |
187
+ | `supabase_check(path?, live?, crossUser?)` | Supabase checks; live checks only for a local or proven-owned project, credentials from env only (see docs/SUPABASE.md) |
188
+
189
+ The loop: `scan` -> `apply_safe_fixes` -> fix the rest with the agent's own edits (using `get_finding`) -> `verify` each -> `score`.
190
+
191
+ **Claude Code**
192
+
193
+ ```bash
194
+ claude mcp add deployready -- npx -y deployready@latest mcp
195
+ ```
196
+
197
+ **Live and active findings need test tokens.** `scan(dynamic: true)` and `verify` for live findings (including the token-based IDOR / JWT / escalation checks) read the test identities from the MCP server's environment: `DEPLOYREADY_TOKEN` (and `DEPLOYREADY_TOKEN_B` for the second identity). The tools accept no secrets as arguments, and tokens are never logged or echoed (proofs show `$TOKEN` placeholders). Without them, active findings stay `inconclusive`.
198
+
199
+ ```bash
200
+ claude mcp add deployready -e DEPLOYREADY_TOKEN=<test-user-jwt> -e DEPLOYREADY_TOKEN_B=<second-user-jwt> -- npx -y deployready@latest mcp
201
+ ```
202
+
203
+ The interactive shell's `verify` reads the same two variables.
204
+
205
+ A ready-made Claude Code skill that teaches the loop is in [`skills/deployready/SKILL.md`](skills/deployready/SKILL.md) (copy it to `.claude/skills/deployready/`).
206
+
207
+ **Cursor** (`.cursor/mcp.json`)
208
+
209
+ ```json
210
+ {
211
+ "mcpServers": {
212
+ "deployready": { "command": "npx", "args": ["-y", "deployready@latest", "mcp"] }
213
+ }
214
+ }
215
+ ```
216
+
217
+ **Any other MCP client** (Codex, Windsurf, ...): add the same server to its `mcpServers` config.
218
+
219
+ ```json
220
+ {
221
+ "mcpServers": {
222
+ "deployready": { "command": "npx", "args": ["-y", "deployready@latest", "mcp", "/path/to/project"] }
223
+ }
224
+ }
225
+ ```
226
+
227
+ The optional trailing path sets the default project for tool calls (default: the current directory).
120
228
 
121
229
  ### Active (authenticated) testing — "try to hack it"
122
230
 
@@ -130,19 +238,23 @@ npx deployready@latest analyze . --active --token "<your-JWT>" --token-b "<secon
130
238
  - **Broken tenant isolation** — swaps `org_id`/tenant to reach another tenant's data.
131
239
  - **Privilege escalation** — forges a `role: admin` claim and checks whether a forbidden route opens up.
132
240
  - **JWT not verified** — checks whether the server accepts a forged `alg:none` token.
241
+ - **Unauthenticated write routes** — sends each discovered `DELETE`/`PATCH` route once with **no credentials**, aimed at a record id that cannot exist (`__deployready_probe_<random>__`), with no body. A `2xx` (when a random-path control does not also answer `2xx`) means the route handles writes for anonymous callers; `401`/`403` means auth is enforced; anything else is not reported.
242
+
243
+ It is **opt-in and consented** and **loopback-only**. The tampering checks are GET-only. The write-route probe never addresses real data: it only probes routes whose every path parameter can be filled with a non-existent id, skips routes without a parameter (e.g. `DELETE /api/session`), skips `PUT` (often an upsert, so it could create data), and never runs on a non-loopback host. Need a token? Run `--active` without one and DeployReady prints step-by-step instructions for grabbing your JWT from the browser.
244
+
245
+ Every live finding carries **proof**: a copy-pasteable `curl` command (your tokens appear only as `$TOKEN` / `$TOKEN_B`), the status, a truncated response and the control request that shows the endpoint otherwise works, all redacted. It appears in `show`, the terminal report, the markdown/HTML reports and `--json`. `verify` reports `fixed` only with proof (the attack fails **and** a control request still works); otherwise it says `inconclusive` and why.
133
246
 
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.
247
+ To run active probes against a host you own that is not on your machine (e.g. staging), name it explicitly: `--active-url https://staging.example.com --i-own-this-target staging.example.com` (repeatable; or `"ownedTargets": ["staging.example.com"]` in your config). Only that exact host is allowed — no wildcards or subdomains — and the write-route probe still stays loopback-only.
135
248
 
136
- ## What it checks
249
+ ### Route discovery (on by default, nothing guessed)
137
250
 
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).
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.
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`).
143
- - **Readiness score (0–100)** with a critical / warning / info breakdown.
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.
251
+ **OpenAPI/Swagger from disk.** DeployReady reads `openapi.*` / `swagger.*` (JSON or block-style YAML) files in your project and treats their paths as routes, with the spec's `security` as the guard evidence. No request is needed to read them, and it works for stacks without a code parser.
252
+
253
+ **Advertised links.** From pages it already fetched from those routes, DeployReady also follows up to 25 same-origin GET links your running app advertises (`<a>`, `<link>`, `Link:` headers, and a `robots.txt`/`sitemap.xml`/OpenAPI document only if your project or a response points at it), one level deep, never logout/delete-style links. Details: [`docs/ROUTE-DISCOVERY.md`](docs/ROUTE-DISCOVERY.md).
254
+
255
+ ### Common-path probe (opt-in)
256
+
257
+ By default the live tests never guess paths. With `--probe-common-paths` (or `"probeCommonPaths": true` in your config, interactive runs only) DeployReady also requests a fixed list of 16 well-known paths such as `/.env` and `/.git/config` from your local app, at most 20 GET requests, after showing you the list and asking first. A path is reported only when its content proves it (a `200` alone is never enough), and findings are labelled as guessed, lower confidence, in their own report section. In `--yes`, `--json` and CI only the explicit flag enables it. Details: [`docs/COMMON-PATH-PROBE.md`](docs/COMMON-PATH-PROBE.md).
146
258
 
147
259
  ## How it works
148
260
 
@@ -159,17 +271,31 @@ DeployReady works fully offline with no AI. To enable deeper analysis, configure
159
271
 
160
272
  | Model | Notes |
161
273
  |---|---|
162
- | Claude (Anthropic) | Set `ANTHROPIC_API_KEY` or store via `init`. Default: `claude-sonnet-4-6`. |
163
- | OpenAI | Set `OPENAI_API_KEY` or store via `init`. |
274
+ | Claude API (Anthropic) | Set `ANTHROPIC_API_KEY` or store via `init`. Default: `claude-sonnet-4-6`. |
275
+ | OpenAI API | Set `OPENAI_API_KEY` or store via `init`. |
164
276
  | Ollama (local) | Fully offline, no key — nothing leaves your machine. |
277
+ | Claude (CLI login) | Uses your own installed `claude` CLI and **your own Claude plan** — no API key. See below. |
278
+ | Codex (CLI login) | Uses your own installed `codex` CLI and **your own ChatGPT/OpenAI plan** — no API key. See below. |
279
+
280
+ ### CLI-login providers (Claude / Codex)
281
+
282
+ Choose these in `init` (or in the interactive menu under "Set up or change the AI model") if you already use the `claude` or `codex` command-line tool and prefer that login to an API key.
283
+
284
+ - **Login status** is read from the CLI itself (`claude auth status`, `codex login status`). If the CLI is installed but not logged in, DeployReady offers to run the CLI's own login command (`claude auth login` / `codex login`) in your terminal. You sign in inside that tool: DeployReady never sees, reads, copies or stores your token or the CLI's auth files.
285
+ - **Your plan's rules apply, not the API terms.** Data is handled under the data policy of your own plan and counts against your plan's usage allowance. The consent prompt says so before anything is sent.
286
+ - **Same data as the API providers:** only the redacted structured findings report (or, for `fix`, one redacted snippet you confirm first). Never your source files.
287
+ - **Text in, text out.** The CLI is started with its tools disabled, from an empty temporary folder, with a minimal environment, and its answer is treated as untrusted text. It is never asked to edit your files. When you accept a fix, DeployReady applies it with its own editor: a backup is written to `.deployready/backups/` first, the path is confined to your project and the result is syntax-checked.
288
+ - AI findings stay marked unverified and never change your score or the CI gate.
289
+ - **Codex can be switched off.** To disable the Codex provider, set `"codexEnabled": false` in `~/.deployready/config.json`; it then refuses to run and sends nothing. The Claude provider has no such switch.
290
+ - These providers are meant for interactive, local use. Each call uses your own plan allowance.
165
291
 
166
292
  ## Security & privacy
167
293
 
168
- DeployReady reads your code, probes your ports, and holds your keys — so it's built to a high bar:
294
+ To report a vulnerability in DeployReady itself, see [SECURITY.md](SECURITY.md). DeployReady reads your code, probes your ports and can hold API keys, so:
169
295
 
170
296
  - API keys are read from environment variables first and **never logged**; the on-disk config is written with `0600` permissions.
171
297
  - All terminal output and any AI payload pass through a central **secret redactor**.
172
- - Dynamic testing is **loopback-only** and **GET-only** by default; aggressive tests require explicit consent.
298
+ - Dynamic testing is **loopback-only** and **GET-only** by default; aggressive tests require explicit consent. It only requests routes your code (or your OpenAPI/Swagger file) defines, plus up to 25 same-origin paths your running app itself advertises in pages it already served (links, `Link:` headers, and a `robots.txt`/`sitemap.xml`/OpenAPI document only if your project or one of those responses points at it; one level deep, never logout/delete-style links) — it never guesses paths like `/admin` or `/.env`, and never invents ids for routes with path parameters (those are listed as "could not check"). Use `--verbose` to see every request decision.
173
299
  - File scanning is confined to the project root, with symlink/traversal protection and size caps.
174
300
 
175
301
  ## Configuration
package/SECURITY.md ADDED
@@ -0,0 +1,34 @@
1
+ # Security policy
2
+
3
+ ## Reporting a vulnerability in DeployReady
4
+
5
+ Please report security issues privately, not in public issues.
6
+
7
+ Use GitHub private vulnerability reporting: open the repository's **Security** tab, choose **Report a vulnerability** (or go to <https://github.com/BelsoftSolutions/deployready/security/advisories/new>). If you cannot use GitHub, open a public issue that says only that you need a private contact channel, without details.
8
+
9
+ <!-- TODO(maintainers): add a security contact email here if one is set up. -->
10
+
11
+ Include the version (`deployready --version`), what you did, and what you expected. Reports about the tool itself are in scope: for example secret leakage in output or AI payloads, scanning or probing outside the intended target, path traversal out of the project root, or unsafe handling of AI/CLI provider output. Findings that DeployReady reports about *your* project are not vulnerabilities in DeployReady.
12
+
13
+ ## Supported versions
14
+
15
+ | Version | Supported |
16
+ |---|---|
17
+ | 0.4.x | yes |
18
+ | < 0.4 | no, please upgrade |
19
+
20
+ ## What leaves your machine
21
+
22
+ - Scanning, scoring, reports, fixes and the MCP server run locally. The MCP server never calls an AI model itself.
23
+ - AI analysis is optional and off with `--no-ai`. When enabled and after you approve, only a redacted, structured findings report is sent to the provider you chose (Claude API, OpenAI API, or your own `claude`/`codex` CLI login). For `fix`, one redacted snippet that you confirm first may be sent. Source files are not sent. With Ollama, nothing leaves your machine.
24
+ - Live checks only contact the target you point them at (see below). Supabase live checks contact your Supabase project, and, with an access token, `api.supabase.com` to prove ownership.
25
+ - API keys are read from environment variables first and are not logged; the on-disk config (`~/.deployready/config.json`) is written with `0600` permissions. All terminal output and AI payloads pass through a secret redactor, which is pattern-based and not a guarantee.
26
+
27
+ ## Safety model of live tests
28
+
29
+ - **Dynamic tests** target a server on loopback and are GET-only by default. Only routes your code or OpenAPI file defines (plus a bounded set of links your app advertises) are requested; aggressive tests need explicit consent.
30
+ - **Active tests** (`--active`) need your token and run against loopback. A non-loopback host is allowed only if you name that exact host with `--i-own-this-target` (no wildcards or subdomains). The tampering checks are GET-only. The unauthenticated write-route probe stays loopback-only, targets ids that cannot exist, skips `PUT`, and sends no body.
31
+ - **Supabase tests** (`--supabase`) are read-only: no insert, update or delete is ever sent, and no RPC function is invoked. Against a hosted project they run only after you prove ownership with the service-role key or an access token; a loopback URL (`supabase start`) needs no proof. Details: [docs/SUPABASE.md](docs/SUPABASE.md).
32
+ - **Common-path probe** is opt-in, at most 20 GET requests to a printed fixed list.
33
+
34
+ Only run active or Supabase tests against systems you own or are authorized to test.
@@ -1,25 +1,77 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bodiesEqual = bodiesEqual;
3
4
  exports.classifyAuthzResult = classifyAuthzResult;
5
+ function canonicalize(text) {
6
+ const trimmed = text.trim();
7
+ try {
8
+ return JSON.stringify(sortKeys(JSON.parse(trimmed)));
9
+ }
10
+ catch {
11
+ return trimmed;
12
+ }
13
+ }
14
+ function sortKeys(v) {
15
+ if (Array.isArray(v))
16
+ return v.map(sortKeys);
17
+ if (typeof v === 'object' && v !== null) {
18
+ return Object.fromEntries(Object.entries(v)
19
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
20
+ .map(([k, val]) => [k, sortKeys(val)]));
21
+ }
22
+ return v;
23
+ }
24
+ /** Equality of two response bodies: JSON deep-equal ignoring key order, else trimmed text. */
25
+ function bodiesEqual(a, b) {
26
+ return canonicalize(a) === canonicalize(b);
27
+ }
28
+ /** Empty / `{}` / `[]` / `null` carry no data, so matching them proves nothing. */
29
+ function isTrivialBody(text) {
30
+ return ['', '{}', '[]', 'null', '""'].includes(canonicalize(text));
31
+ }
32
+ function is2xx(status) {
33
+ return status >= 200 && status < 300;
34
+ }
4
35
  function classifyAuthzResult(input) {
5
- const { status, gotForeignData } = input;
36
+ const { status, bodyText, ownBaselineBody, ownerBaseline, foreignValue } = input;
6
37
  if (status === 401 || status === 403) {
7
38
  return { verdict: 'denied', reason: `Access correctly denied (HTTP ${status}).` };
8
39
  }
9
40
  if (status === 404) {
10
41
  return { verdict: 'denied', reason: 'Resource not exposed to this identity (HTTP 404).' };
11
42
  }
12
- if (status >= 200 && status < 300) {
13
- return gotForeignData
14
- ? {
43
+ if (!is2xx(status)) {
44
+ return { verdict: 'inconclusive', reason: `HTTP ${status} — inconclusive; the endpoint may have errored.` };
45
+ }
46
+ if (bodiesEqual(bodyText, ownBaselineBody)) {
47
+ return {
48
+ verdict: 'inconclusive',
49
+ reason: `HTTP ${status} returned the test user's own data — the swapped value was ignored.`,
50
+ };
51
+ }
52
+ if (ownerBaseline && is2xx(ownerBaseline.status)) {
53
+ if (!isTrivialBody(bodyText) && bodiesEqual(bodyText, ownerBaseline.bodyText)) {
54
+ return {
15
55
  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.`,
56
+ proof: 'owner-baseline',
57
+ reason: `Tampered request returned HTTP ${status} with exactly what the owning identity receives — access control failed.`,
21
58
  };
59
+ }
60
+ return {
61
+ verdict: 'inconclusive',
62
+ reason: `HTTP ${status} returned, but it differs from what the owning identity receives — verify manually.`,
63
+ };
64
+ }
65
+ if (bodyText.includes(String(foreignValue))) {
66
+ return {
67
+ verdict: 'broken',
68
+ proof: 'echo',
69
+ reason: `Tampered request returned HTTP ${status} containing the other identity's value — access control failed (no owner baseline to confirm).`,
70
+ };
22
71
  }
23
- return { verdict: 'inconclusive', reason: `HTTP ${status} — inconclusive; the endpoint may have errored.` };
72
+ return {
73
+ verdict: 'inconclusive',
74
+ reason: `HTTP ${status} returned, but no clear foreign data in the response — verify manually.`,
75
+ };
24
76
  }
25
77
  //# sourceMappingURL=accessControl.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"accessControl.js","sourceRoot":"","sources":["../../src/active/accessControl.ts"],"names":[],"mappings":";;AAqDA,kCAEC;AAWD,kDA6CC;AAh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;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,QAAQ,MAAM,qFAAqF;SAC5G,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;QAC5C,OAAO;YACL,OAAO,EAAE,QAAQ;YACjB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,kCAAkC,MAAM,gGAAgG;SACjJ,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,QAAQ,MAAM,yEAAyE;KAChG,CAAC;AACJ,CAAC"}
@@ -8,8 +8,10 @@ exports.createActiveHttpAdapter = createActiveHttpAdapter;
8
8
  /**
9
9
  * The real network transport for the active scan (Phase 5a) — the ONE place that
10
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;
11
+ * - loopback-only target by default (SSRF/scope guard, same bar as the
12
+ * dynamic suite); a non-loopback host only when the user explicitly confirmed
13
+ * they own it (`ownedHosts`), re-checked on every derived URL so a request
14
+ * can never leave the host;
13
15
  * - dry-run that sends nothing;
14
16
  * - hard timeout, no redirects, response-size cap.
15
17
  *
@@ -17,7 +19,7 @@ exports.createActiveHttpAdapter = createActiveHttpAdapter;
17
19
  * budget live above this (Orchestrator + runner).
18
20
  */
19
21
  const axios_1 = __importDefault(require("axios"));
20
- const httpClient_1 = require("../dynamic/httpClient");
22
+ const scope_1 = require("./scope");
21
23
  const TIMEOUT_MS = 8000;
22
24
  const MAX_BODY = 5 * 1024 * 1024;
23
25
  /** Build an absolute URL from base + path (+ query). Pure. */
@@ -30,11 +32,16 @@ function buildUrl(baseUrl, path, query) {
30
32
  return url.toString();
31
33
  }
32
34
  function createActiveHttpAdapter(opts) {
33
- (0, httpClient_1.assertLoopback)(opts.baseUrl); // scope is fixed to this loopback host
35
+ const owned = opts.ownedHosts ?? [];
36
+ const base = (0, scope_1.assertActiveTarget)(opts.baseUrl, owned); // scope is fixed to this host
34
37
  const timeout = opts.timeoutMs ?? TIMEOUT_MS;
35
38
  return async (req) => {
36
39
  const url = buildUrl(opts.baseUrl, req.path, req.query);
37
- (0, httpClient_1.assertLoopback)(url); // defense in depth: never leave the loopback host
40
+ // Defense in depth: never leave the base host, even if a path is absolute.
41
+ const target = (0, scope_1.assertActiveTarget)(url, owned);
42
+ if (target.host !== base.host) {
43
+ throw new Error(`Refusing to send an active probe to ${target.host}: outside the scan target ${base.host}.`);
44
+ }
38
45
  if (opts.dryRun)
39
46
  return { status: 0, bodyText: '' };
40
47
  const res = await axios_1.default.request({
@@ -48,7 +55,7 @@ function createActiveHttpAdapter(opts) {
48
55
  maxContentLength: MAX_BODY,
49
56
  });
50
57
  const bodyText = typeof res.data === 'string' ? res.data : JSON.stringify(res.data ?? '');
51
- return { status: res.status, bodyText };
58
+ return { status: res.status, bodyText, url };
52
59
  };
53
60
  }
54
61
  //# sourceMappingURL=httpAdapter.js.map
@@ -1 +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,CA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,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,CAAC,IAAI,6BAA6B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC/G,CAAC;QAED,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QAEpD,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC,OAAO,CAAC;YAC9B,GAAG;YACH,MAAM,EAAE,GAAG,CAAC,MAAe;YAC3B,OAAO,EAAE,EAAE,YAAY,EAAE,yBAAyB,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE;YACpE,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,OAAO;YACP,YAAY,EAAE,CAAC;YACf,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI;YAC1B,gBAAgB,EAAE,QAAQ;SAC3B,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC1F,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MUTATION_RULE = void 0;
4
+ exports.probeValue = probeValue;
5
+ exports.planMutationProbes = planMutationProbes;
6
+ exports.runMutationProbes = runMutationProbes;
7
+ /**
8
+ * Unauthenticated-mutation probe: does a discovered DELETE / PATCH route accept
9
+ * a request with NO credentials?
10
+ *
11
+ * Safety design (it never touches real data):
12
+ * - Only runs inside the consented active scan, and only against a loopback
13
+ * target (never an owned remote host, even with --i-own-this-target).
14
+ * - Only routes with at least one path parameter are probed, and EVERY
15
+ * parameter is filled with a value that cannot exist
16
+ * (`__deployready_probe_<random>__`), so the request addresses no real
17
+ * record. Routes without a parameter (e.g. `DELETE /api/session`) would act
18
+ * on real state and are skipped.
19
+ * - No request body is sent.
20
+ * - PUT is skipped: many APIs treat PUT as an upsert, so even a non-existent id
21
+ * could create a record.
22
+ *
23
+ * Verdict, per route:
24
+ * - 401 / 403 → authentication is enforced: nothing reported.
25
+ * - 2xx → the server handled a write for an anonymous caller. Reported,
26
+ * unless a control request (same method, random non-existent
27
+ * path) also answers 2xx — then it's a catch-all and proves nothing.
28
+ * - anything else (404, 405, 5xx, no response) → inconclusive, not reported:
29
+ * a 404 may simply mean the lookup ran before the auth check.
30
+ */
31
+ const crypto_1 = require("crypto");
32
+ const finding_1 = require("../utils/finding");
33
+ const proof_1 = require("../dynamic/proof");
34
+ exports.MUTATION_RULE = 'unauthenticated-mutation';
35
+ const PROBED_METHODS = new Set(['DELETE', 'PATCH']);
36
+ const PARAM_RE = /^(?::([A-Za-z0-9_]+)\??|\{([^{}/]+)\})$/;
37
+ const PATTERN_SEGMENT = /[:{}<>*()?+[\]\\]/;
38
+ /** Build the probe value. Exported for tests. */
39
+ function probeValue() {
40
+ return `__deployready_probe_${(0, crypto_1.randomBytes)(4).toString('hex')}__`;
41
+ }
42
+ function planMutationProbes(routes, value = probeValue()) {
43
+ const targets = [];
44
+ const skipped = [];
45
+ const seen = new Set();
46
+ for (const r of routes) {
47
+ const method = r.method.toUpperCase();
48
+ if (method === 'PUT') {
49
+ skipped.push({ method, path: r.path, reason: 'PUT may upsert, so even a non-existent id could create data' });
50
+ continue;
51
+ }
52
+ if (!PROBED_METHODS.has(method))
53
+ continue;
54
+ const key = `${method} ${r.path}`;
55
+ if (seen.has(key))
56
+ continue;
57
+ seen.add(key);
58
+ let params = 0;
59
+ let bad = false;
60
+ const out = r.path.split('/').map((seg) => {
61
+ if (PARAM_RE.test(seg)) {
62
+ params++;
63
+ return value;
64
+ }
65
+ if (PATTERN_SEGMENT.test(seg))
66
+ bad = true;
67
+ return seg;
68
+ });
69
+ if (bad || !r.path.startsWith('/')) {
70
+ skipped.push({ method, path: r.path, reason: 'path is a pattern, not a concrete route' });
71
+ }
72
+ else if (params === 0) {
73
+ skipped.push({ method, path: r.path, reason: 'no path parameter to point at a non-existent record, so a request could change real data' });
74
+ }
75
+ else {
76
+ targets.push({ method, route: r.path, path: out.join('/') });
77
+ }
78
+ }
79
+ return { targets, skipped };
80
+ }
81
+ function is2xx(s) {
82
+ return s !== undefined && s >= 200 && s < 300;
83
+ }
84
+ async function safeSend(http, method, path) {
85
+ try {
86
+ return await http({ method, path, headers: {} });
87
+ }
88
+ catch {
89
+ return null;
90
+ }
91
+ }
92
+ async function runMutationProbes(targets, http, opts = {}) {
93
+ const findings = [];
94
+ const controls = new Map();
95
+ for (const t of targets) {
96
+ const r = await safeSend(http, t.method, t.path);
97
+ const obs = { method: t.method, route: t.route, trigger: r?.status };
98
+ if (!r || !is2xx(r.status)) {
99
+ opts.onObserve?.(obs);
100
+ continue;
101
+ }
102
+ // Control: same method on a random path that cannot exist (sent once per method).
103
+ if (!controls.has(t.method)) {
104
+ controls.set(t.method, await safeSend(http, t.method, `/${probeValue()}`));
105
+ }
106
+ const control = controls.get(t.method) ?? null;
107
+ obs.control = control?.status;
108
+ opts.onObserve?.(obs);
109
+ if (!control || is2xx(control.status))
110
+ continue; // catch-all or no control: proves nothing
111
+ findings.push((0, finding_1.makeFinding)({
112
+ rule: exports.MUTATION_RULE,
113
+ title: `${t.method} route accepts requests without authentication`,
114
+ severity: 'critical',
115
+ category: 'security',
116
+ source: 'dynamic',
117
+ endpoint: `${t.method} ${t.route}`,
118
+ owasp: 'A01:2025',
119
+ cwe: 'CWE-306',
120
+ description: `${t.method} ${t.route} answered HTTP ${r.status} to a request with no credentials (aimed at a record id that does not exist, so no real data was touched). The route handles writes for anonymous callers.`,
121
+ recommendation: 'Put authentication (and an ownership/role check) in front of every route that changes data, and return 401/403 before looking up the record.',
122
+ proof: (0, proof_1.buildProof)({
123
+ request: { method: t.method, url: r.url ?? (0, proof_1.absoluteUrl)(opts.baseUrl, t.path) },
124
+ status: r.status,
125
+ response: r.bodyText,
126
+ control: `Same method on a random non-existent path: HTTP ${control.status}, so this is the route's own answer, not a catch-all.`,
127
+ }),
128
+ }));
129
+ }
130
+ return findings;
131
+ }
132
+ //# sourceMappingURL=mutationProbe.js.map