launch-doctor 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/README.md +155 -30
- package/dist/src/checks/costs.d.ts +1 -0
- package/dist/src/checks/costs.js +40 -5
- package/dist/src/checks/database.js +122 -3
- package/dist/src/checks/first-impressions.js +227 -117
- package/dist/src/checks/legal.js +27 -13
- package/dist/src/checks/monitoring.js +39 -10
- package/dist/src/checks/payments.js +131 -4
- package/dist/src/checks/secrets.js +103 -7
- package/dist/src/cli.js +90 -3
- package/dist/src/demo.d.ts +13 -0
- package/dist/src/demo.js +58 -2
- package/dist/src/detect.js +4 -1
- package/dist/src/fixes.js +2 -2
- package/dist/src/github.d.ts +80 -0
- package/dist/src/github.js +288 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/init.d.ts +1 -1
- package/dist/src/init.js +2 -2
- package/dist/src/mcp.d.ts +140 -0
- package/dist/src/mcp.js +381 -0
- package/dist/src/project.d.ts +8 -0
- package/dist/src/project.js +102 -6
- package/dist/src/report.d.ts +2 -0
- package/dist/src/report.js +12 -1
- package/dist/src/summary.d.ts +3 -0
- package/dist/src/summary.js +17 -13
- package/dist/src/types.d.ts +2 -0
- package/dist/src/util.d.ts +2 -0
- package/dist/src/util.js +2 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-11-27
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- GitHub Action (`uses: SHARAJ379/launch-doctor@v0`): runs the checkup on pull requests, posts inline comments with fix prompts on the lines the pull request adds, and keeps one summary comment up to date. Inputs: `path`, `fail-on` (`critical`, `warning` or `never`), `comment`, `args`, `github-token`.
|
|
15
|
+
- `--pr-comment` posts the same pull request comments from the CLI. It never fails the run: outside a pull request, or without write access, it explains why it skipped.
|
|
16
|
+
- When `GITHUB_OUTPUT` is set, the grade, score, critical and warning counts are saved as step outputs.
|
|
17
|
+
- `launch-doctor mcp` runs a Model Context Protocol server, so Claude Code, Cursor and other AI tools can run the checkup themselves. Tools: `scan_project` (grade, findings with file, line and fix prompt, and the checklist), `scan_url` (the live site scan) and `list_checks`. Stdio only, no dependencies, protocol versions 2024-11-05 to 2025-11-25.
|
|
18
|
+
- Five more providers. Clerk: secret keys are told apart from Stripe's (same `sk_live_` prefix), and apps get a "switch to a production instance" checklist item. Paddle and Lemon Squeezy: webhooks that never verify the signature are critical, webhooks that sign re-encoded JSON or that are missing are warnings, and their API keys are found in code. Convex: deploy keys in code, and public mutations and actions that never check who is calling (in apps with accounts). Appwrite: API keys passed to `setKey()`, and permissions that let anyone (critical) or every signed-in user (warning) change data, in code and in `appwrite.json`.
|
|
19
|
+
- Mobile apps (Expo and React Native). Keys in app code are critical, since they ship inside the app, and `EXPO_PUBLIC_` variables are treated like `NEXT_PUBLIC_` ones. Monitoring looks for crash reporting (Sentry, Crashlytics, Instabug and others). Legal asks every store app for a privacy policy link. First impressions finds placeholder app IDs (`com.anonymous...`), cleartext HTTP on Android, `NSAllowsArbitraryLoads` on iOS and development addresses like `10.0.2.2`, and adds the store-readiness checklist (listing, privacy forms, a reviewer account, a release build on a real phone). Website-only checks no longer run on a mobile app, and a monorepo with both gets both.
|
|
20
|
+
- FastAPI, Flask, Django and Gemini are recognised and shown in the report header.
|
|
21
|
+
- Findings that have no file and line ("no rate limiting", "no error tracking") now say what Launch Doctor looked for, so you can check the claim yourself.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- The workflow written by `launch-doctor init` uses `actions/checkout@v7` and `actions/setup-node@v7`.
|
|
26
|
+
- The README now says plainly what Launch Doctor can and cannot do: a "Read this first" summary, a "What it cannot do" section (production settings, runtime errors, authorization logic, code-level vulnerabilities, dependency vulnerabilities, stack coverage and skipped files), how it is tested, and how to report a wrong finding. The live scan's network use is described fully: it also fetches the page's scripts and source maps, which may be on other domains.
|
|
27
|
+
- The terminal report and `LAUNCH_FIXES.md` end with a link for reporting wrong or missed findings.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- A separate git repository inside the project folder (a folder with its own `.git`, like a tool you cloned to try out) is no longer scanned as part of your app. Its findings used to drag your grade down. The report names what was left out, and `--json` lists it under `nestedRepos`. Submodules are still scanned, and a folder outside git is scanned as before.
|
|
32
|
+
- Stopping `--demo` with Ctrl+C (or SIGTERM/SIGHUP) no longer leaves its sample project in the temp folder, and `--demo` removes `launch-doctor-demo-*` folders over an hour old that earlier killed runs left behind.
|
|
33
|
+
- A hand-written rate limiter (for example a counter kept in your database or Redis that answers with HTTP 429) now counts as rate limiting. Passing on the AI provider's own `RateLimitError` still doesn't.
|
|
34
|
+
- A Paddle webhook that never imports the Paddle SDK (the dangerous, unverified kind) was reported as "no webhook"; it is now found when its file path names Paddle, and reported as unverified.
|
|
35
|
+
- The MCP server said "No problems found" when every finding was in the baseline, right under an F grade. It now says no new problems were found and that the grade still counts the accepted ones.
|
|
36
|
+
- Expo, React Native, Paddle, Lemon Squeezy and Appwrite are named in the report header.
|
|
37
|
+
- The rate-limit fix prompt suggests a library for your stack (slowapi for FastAPI, Flask-Limiter, django-ratelimit, express-rate-limit, @upstash/ratelimit for serverless...) instead of always @upstash/ratelimit, and first asks your AI tool to check for an existing limiter.
|
|
38
|
+
|
|
10
39
|
## [0.2.1] - 2026-11-27
|
|
11
40
|
|
|
12
41
|
### Fixed
|
|
@@ -71,7 +100,8 @@ First release.
|
|
|
71
100
|
- `.launchdoctorignore` for silencing findings by id or skipping paths.
|
|
72
101
|
- Support for JavaScript / TypeScript and Python projects.
|
|
73
102
|
|
|
74
|
-
[Unreleased]: https://github.com/SHARAJ379/launch-doctor/compare/v0.
|
|
103
|
+
[Unreleased]: https://github.com/SHARAJ379/launch-doctor/compare/v0.3.0...HEAD
|
|
104
|
+
[0.3.0]: https://github.com/SHARAJ379/launch-doctor/compare/v0.2.1...v0.3.0
|
|
75
105
|
[0.2.1]: https://github.com/SHARAJ379/launch-doctor/compare/v0.2.0...v0.2.1
|
|
76
106
|
[0.2.0]: https://github.com/SHARAJ379/launch-doctor/compare/v0.1.0...v0.2.0
|
|
77
107
|
[0.1.0]: https://github.com/SHARAJ379/launch-doctor/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -7,7 +7,18 @@
|
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
|
|
10
|
-
Launch Doctor scans your project for
|
|
10
|
+
Launch Doctor scans your project for common problems that hurt apps after launch: leaked API keys, databases anyone can read, payments that can be faked, emails that land in spam, AI endpoints that can run up your bill, missing legal pages, and leftover template defaults. It is built for developers who ship with AI coding tools (Claude Code, Cursor, Lovable, Bolt, Windsurf) and may not read every line of generated code. Every finding is explained in plain English and includes a prompt you can paste straight back into your AI assistant. It has no runtime dependencies, requires no account, sends no telemetry, and your code never leaves your machine.
|
|
11
|
+
|
|
12
|
+
## Read this first
|
|
13
|
+
|
|
14
|
+
Launch Doctor is a **quick checklist with teeth, not a security audit**. Please trust it accordingly:
|
|
15
|
+
|
|
16
|
+
- **It reads your code with pattern rules.** It does not run your app, log in, or understand your business logic. It will sometimes flag code that is fine (a false alarm) and sometimes miss a real problem.
|
|
17
|
+
- **It cannot see your production settings.** Environment variables in Vercel or Netlify, and settings in the Supabase, Firebase or Stripe dashboards, are invisible to it. A typo in a production key or URL will not be caught.
|
|
18
|
+
- **A grade A means "none of the problems we look for were found"**, not "your app is secure".
|
|
19
|
+
- **It is new.** Version 0.x, first released in November 2026, maintained by one person. The checks are tested (see [How it is tested](#how-it-is-tested)), but it has not yet been used on many real projects, so expect rough edges and please [report them](#found-a-wrong-finding).
|
|
20
|
+
|
|
21
|
+
The full list is in [What it cannot do](#what-it-cannot-do).
|
|
11
22
|
|
|
12
23
|
## Quick start
|
|
13
24
|
|
|
@@ -27,12 +38,14 @@ Initialize configuration and GitHub Actions files:
|
|
|
27
38
|
npx launch-doctor init
|
|
28
39
|
```
|
|
29
40
|
|
|
30
|
-
Requires Node.js 22 or newer.
|
|
41
|
+
Requires Node.js 22 or newer. That is the version range the automated tests cover (22 and 24). In a manual check it also ran on Node 18 and 20, but those versions are not tested on every change, so they are not officially supported.
|
|
31
42
|
|
|
32
43
|
## Example output
|
|
33
44
|
|
|
45
|
+
This is the `--demo` report, shortened. On a real project the last line tells you where `LAUNCH_FIXES.md` was saved (the demo doesn't write it).
|
|
46
|
+
|
|
34
47
|
```
|
|
35
|
-
Launch Doctor v0.
|
|
48
|
+
Launch Doctor v0.3.0
|
|
36
49
|
Checked my-weekend-saas · 12 files · Vite, React, Supabase, Stripe, OpenAI
|
|
37
50
|
|
|
38
51
|
Overall grade F Not ready to launch: fix 6 critical issues first
|
|
@@ -59,8 +72,6 @@ Requires Node.js 22 or newer.
|
|
|
59
72
|
so every visitor can read it. That prefix is only for values that are safe
|
|
60
73
|
to be public.
|
|
61
74
|
...
|
|
62
|
-
|
|
63
|
-
Fix prompts saved to LAUNCH_FIXES.md
|
|
64
75
|
```
|
|
65
76
|
|
|
66
77
|
## Project workflow
|
|
@@ -113,7 +124,7 @@ flowchart TD
|
|
|
113
124
|
2. **Project ingestion and tree traversal (`src/project.ts`):**
|
|
114
125
|
Walks the project root, automatically skipping `node_modules`, build artifacts (`dist`, `build`, `.next`), binary formats, and hidden folders (except `.github`). Ingests package manifests (`package.json`, `requirements.txt`, `pyproject.toml`), git status, and `.launchdoctorignore` patterns.
|
|
115
126
|
3. **Stack and environment detection (`src/detect.ts`, `src/comments.ts`):**
|
|
116
|
-
Identifies frameworks (Next.js, Vite, React, Vue, Express
|
|
127
|
+
Identifies frameworks (Next.js, Vite, React, Vue, Express, FastAPI, Flask, Django), server routes, database configurations (Supabase, Firebase, Prisma), payment gateways (Stripe, Razorpay), error trackers (Sentry, PostHog), and email services. Prepares a comment-stripped view of source files so commented-out code is not mistaken for active protection.
|
|
117
128
|
4. **Multi-category check execution (`src/checks/`):**
|
|
118
129
|
Runs audits across all 8 categories. If `--history` is enabled, an incremental git commit walker inspects the last `n` commits (default 500) for secrets that were removed from HEAD but remain exposed in commit history.
|
|
119
130
|
5. **Suppression and baseline matching (`src/baseline.ts`):**
|
|
@@ -141,7 +152,7 @@ flowchart LR
|
|
|
141
152
|
ReScan --> Check
|
|
142
153
|
Check -- "Clean (Grade A or Baseline)" --> Commit["6. Commit & Push Code"]
|
|
143
154
|
Commit --> CI["7. CI/CD PR Gate (--ci)"]
|
|
144
|
-
CI --> Deploy["8.
|
|
155
|
+
CI --> Deploy["8. Deploy (and check the manual checklist)"]
|
|
145
156
|
```
|
|
146
157
|
|
|
147
158
|
1. **Pre-flight scan:** Before shipping changes or merging a branch, run `npx launch-doctor` in your workspace.
|
|
@@ -155,20 +166,24 @@ flowchart LR
|
|
|
155
166
|
|
|
156
167
|
| Category | What it catches | Severity range |
|
|
157
168
|
|---|---|---|
|
|
158
|
-
| Secrets & keys (`secrets`) | Stripe, OpenAI, Anthropic, OpenRouter, Groq, Hugging Face, Supabase, AWS, GitHub, Slack, SendGrid, and
|
|
159
|
-
| Database & backups (`database`) | Supabase tables without Row Level Security; policies that let anyone write (`using (true)`); write policies open to any signed-in user; Firebase test-mode or open rules; SQLite on serverless hosting; `prisma db push` / `--accept-data-loss` instead of migrations | Warning to critical |
|
|
160
|
-
| Payments (`payments`) | Stripe webhooks that don't verify the signature (each route checked separately); webhooks or global `express.json()` that parse the body before verifying; no webhook at all; Razorpay payments never verified on the server | Warning to critical |
|
|
169
|
+
| Secrets & keys (`secrets`) | Stripe, Clerk, OpenAI, Anthropic, OpenRouter, Groq, Hugging Face, Supabase, AWS, GitHub, Slack, SendGrid, Resend, Paddle, Convex, Appwrite, and Lemon Squeezy keys in code; Supabase `service_role` keys; private keys; database URLs with passwords; secrets in `NEXT_PUBLIC_` / `VITE_` / `EXPO_PUBLIC_` variables; keys in mobile app code (they ship inside the app); `.env` files committed or not in `.gitignore`; with `--history`, keys still in git history | Warning to critical |
|
|
170
|
+
| Database & backups (`database`) | Supabase tables without Row Level Security; policies that let anyone write (`using (true)`); write policies open to any signed-in user; Firebase test-mode or open rules; Convex mutations and actions anyone can call without signing in; Appwrite permissions that let anyone (or every signed-in user) change data; SQLite on serverless hosting; `prisma db push` / `--accept-data-loss` instead of migrations | Warning to critical |
|
|
171
|
+
| Payments (`payments`) | Stripe, Lemon Squeezy, and Paddle webhooks that don't verify the signature (each route checked separately); webhooks or global `express.json()` that parse the body before verifying, or sign re-encoded JSON; no webhook at all; Razorpay payments never verified on the server | Warning to critical |
|
|
161
172
|
| AI & API costs (`costs`) | Paid AI or SMS APIs called from the browser; `dangerouslyAllowBrowser: true`; AI endpoints with no login check (middleware only counts if it really blocks `/api`); no real rate limiter | Warning to critical |
|
|
162
173
|
| Email delivery (`email`) | Resend's test sender; personal Gmail SMTP; sender domains that don't exist; missing SPF or DMARC (live DNS check); a checklist reminder when Supabase Auth still uses its built-in test mailer | Warning |
|
|
163
|
-
| Errors & monitoring (`monitoring`) | No error tracking (Sentry, PostHog, and others); no error boundary or `error.tsx`, so crashes show a blank page | Warning |
|
|
164
|
-
| Legal & trust (`legal`) | No privacy policy, terms, refund policy, or contact page; no way for users to delete their account; a checklist reminder about cookie consent when analytics set cookies | Warning |
|
|
165
|
-
| First impressions (`first-impressions`) | "Vite + React" / "Create Next App" titles and descriptions; Vite favicon; Lovable default meta tags; no description or social preview image; hard-coded `localhost` URLs | Warning |
|
|
174
|
+
| Errors & monitoring (`monitoring`) | No error tracking or crash reporting (Sentry, PostHog, Crashlytics, and others); no error boundary or `error.tsx`, so crashes show a blank page | Warning |
|
|
175
|
+
| Legal & trust (`legal`) | No privacy policy, terms, refund policy, or contact page; no way for users to delete their account; a store app with no privacy policy link; a checklist reminder about cookie consent when analytics set cookies | Warning |
|
|
176
|
+
| First impressions (`first-impressions`) | "Vite + React" / "Create Next App" titles and descriptions; Vite favicon; Lovable default meta tags; no description or social preview image; hard-coded `localhost` URLs. For mobile apps: placeholder app IDs (`com.anonymous...`), cleartext HTTP on Android, `NSAllowsArbitraryLoads` on iOS, development addresses like `10.0.2.2` | Warning |
|
|
166
177
|
|
|
167
|
-
Most categories also add **"check yourself"** items for things code cannot show, such as automated database backups, provider spending limits, a real test purchase,
|
|
178
|
+
Most categories also add **"check yourself"** items for things code cannot show, such as automated database backups, provider spending limits, a real test purchase, uptime monitoring, switching Clerk to a production instance, and the app store listing and privacy forms.
|
|
179
|
+
|
|
180
|
+
Monitoring, legal, and first impressions checks run on web apps (a frontend framework, server routes, or an `index.html`) and on mobile apps (Expo and React Native), which get mobile versions of them: crash reporting, a privacy policy link for the stores, app ID and network security settings, and a store-readiness checklist. Command-line tools and libraries skip them automatically. In a monorepo with a website and an app, both sets run. A folder inside your project that is a separate git repository (it has its own `.git` folder and isn't a submodule) is left out, and the report says so.
|
|
168
181
|
|
|
169
182
|
## Live site scan
|
|
170
183
|
|
|
171
|
-
`npx launch-doctor scan https://myapp.com` checks your deployed site the
|
|
184
|
+
`npx launch-doctor scan https://myapp.com` checks your deployed site from the outside for a few things attackers and bots look for first. It makes a few dozen ordinary `GET` requests (at most about 90, when Supabase tables are tested) and never changes anything. Only scan sites you own or are allowed to test.
|
|
185
|
+
|
|
186
|
+
What it looks at: your home page, up to 20 JavaScript files that page loads, their source maps, a fixed list of file paths (`/.env`, `/.git/...`, `backup.sql` and similar), and Supabase tables named in that JavaScript. It does not crawl other pages, log in, fill in forms, or call your API, and it only tests whether Supabase tables can be **read**, not written.
|
|
172
187
|
|
|
173
188
|
| Category | What it catches | Severity range |
|
|
174
189
|
|---|---|---|
|
|
@@ -198,6 +213,7 @@ The report uses the same grades and `--json`, `--ci`, `--fail-on`, `--out` and `
|
|
|
198
213
|
npx launch-doctor [folder] [options]
|
|
199
214
|
npx launch-doctor init [folder]
|
|
200
215
|
npx launch-doctor scan <url> [options]
|
|
216
|
+
npx launch-doctor mcp
|
|
201
217
|
```
|
|
202
218
|
|
|
203
219
|
| Flag | Default | Description |
|
|
@@ -208,6 +224,7 @@ npx launch-doctor scan <url> [options]
|
|
|
208
224
|
| `--no-file` | off | Don't write the fix prompts file |
|
|
209
225
|
| `--json` | off | Print the full report as JSON (no fix file unless `--out` is given) |
|
|
210
226
|
| `--sarif <file>` | off | Also write a SARIF 2.1.0 file for GitHub code scanning |
|
|
227
|
+
| `--pr-comment` | off | On a GitHub pull request, post a summary comment and inline fix prompts (see [Pull request comments](#pull-request-comments)) |
|
|
211
228
|
| `--offline` | off | Skip network checks (email DNS) |
|
|
212
229
|
| `--ci` | off | Exit with code 1 on findings at or above `--fail-on` (no fix file unless `--out`) |
|
|
213
230
|
| `--fail-on <level>` | `critical` | With `--ci`, the lowest severity that fails: `critical` or `warning` |
|
|
@@ -222,6 +239,7 @@ npx launch-doctor scan <url> [options]
|
|
|
222
239
|
| `-v`, `--version` | | Show the version |
|
|
223
240
|
| `init [folder]` | `.` | Create `.launchdoctorignore` and `.github/workflows/launch-doctor.yml` (never overwrites) |
|
|
224
241
|
| `scan <url>` | | Check your deployed site from the outside (see [Live site scan](#live-site-scan)) |
|
|
242
|
+
| `mcp` | | Start an MCP server so AI coding tools can run checks themselves (see [MCP server](#mcp-server)) |
|
|
225
243
|
| `--no-db` | off | With `scan`, don't test Supabase tables with the public key found in the page |
|
|
226
244
|
|
|
227
245
|
Category ids for `--only` and `--skip`: `secrets`, `database`, `payments`, `costs`, `email`, `monitoring`, `legal`, `first-impressions`. Skipped categories show as "skipped" and don't count toward the grade.
|
|
@@ -285,8 +303,8 @@ jobs:
|
|
|
285
303
|
check:
|
|
286
304
|
runs-on: ubuntu-latest
|
|
287
305
|
steps:
|
|
288
|
-
- uses: actions/checkout@
|
|
289
|
-
- uses: actions/setup-node@
|
|
306
|
+
- uses: actions/checkout@v7
|
|
307
|
+
- uses: actions/setup-node@v7
|
|
290
308
|
with:
|
|
291
309
|
node-version: 22
|
|
292
310
|
- run: npx launch-doctor --ci
|
|
@@ -294,6 +312,7 @@ jobs:
|
|
|
294
312
|
|
|
295
313
|
- **Severity gating:** By default, `--ci` exits with code 1 only on critical findings. Add `--fail-on warning` to fail builds on warnings as well.
|
|
296
314
|
- **Job summaries:** When running in GitHub Actions, Launch Doctor automatically writes a markdown summary (including overall grade, category scorecard, and itemized issues with their file and line) to the GitHub Actions job summary tab via `GITHUB_STEP_SUMMARY`.
|
|
315
|
+
- **Step outputs:** When `GITHUB_OUTPUT` is set, the `grade`, `score`, `critical` and `warnings` values are saved as step outputs.
|
|
297
316
|
- **Code scanning alerts:** Export findings to SARIF 2.1.0 format to populate alerts directly in your repository Security tab. The upload step needs permission to write security events, so add it to the job:
|
|
298
317
|
|
|
299
318
|
```yaml
|
|
@@ -309,6 +328,40 @@ jobs:
|
|
|
309
328
|
sarif_file: launch-doctor.sarif
|
|
310
329
|
```
|
|
311
330
|
|
|
331
|
+
### Pull request comments
|
|
332
|
+
|
|
333
|
+
The Launch Doctor GitHub Action reviews each pull request like a teammate would:
|
|
334
|
+
|
|
335
|
+
- **Inline comments** on the lines the pull request adds, each with the plain-English risk, a fix prompt you can paste into your AI tool, and the `launch-doctor-ignore` comment that silences it.
|
|
336
|
+
- **One summary comment** with the grade, what this pull request added, what was already in the project, and the category scorecard. It is edited in place on every push, not posted again.
|
|
337
|
+
- Findings that were already commented on are not repeated, findings in `.launchdoctor-baseline.json` are left out, and each run posts at most 20 inline comments (the rest are listed in the summary).
|
|
338
|
+
|
|
339
|
+
```yaml
|
|
340
|
+
name: Launch Doctor
|
|
341
|
+
on: [pull_request]
|
|
342
|
+
permissions:
|
|
343
|
+
contents: read
|
|
344
|
+
pull-requests: write
|
|
345
|
+
jobs:
|
|
346
|
+
check:
|
|
347
|
+
runs-on: ubuntu-latest
|
|
348
|
+
steps:
|
|
349
|
+
- uses: actions/checkout@v7
|
|
350
|
+
- uses: SHARAJ379/launch-doctor@v0
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
| Input | Default | Description |
|
|
354
|
+
|---|---|---|
|
|
355
|
+
| `path` | `.` | Folder to check, relative to the repository root |
|
|
356
|
+
| `fail-on` | `critical` | Lowest severity that fails the check: `critical`, `warning` or `never` |
|
|
357
|
+
| `comment` | `true` | Post the summary and inline comments on pull requests |
|
|
358
|
+
| `args` | | Extra options, for example `--offline --skip legal` |
|
|
359
|
+
| `github-token` | `${{ github.token }}` | Token used for the comments |
|
|
360
|
+
|
|
361
|
+
The action also sets the `grade`, `score`, `critical` and `warnings` outputs. Pull requests from forks get a read-only token, so they can't be commented on; the check still runs and the job summary still has the results.
|
|
362
|
+
|
|
363
|
+
Using the CLI directly instead? Add `--pr-comment` and pass the token: `npx launch-doctor --ci --pr-comment` with `env: GITHUB_TOKEN: ${{ github.token }}`.
|
|
364
|
+
|
|
312
365
|
## Using with AI coding tools
|
|
313
366
|
|
|
314
367
|
Launch Doctor outputs `LAUNCH_FIXES.md` directly into your project root. Each entry includes the exact file and line number, an explanation of the risk, and a tailored prompt ready to paste into your AI assistant. It also includes a single batch prompt at the top of the file.
|
|
@@ -328,33 +381,105 @@ Fix the issues in LAUNCH_FIXES.md one at a time, starting with the critical ones
|
|
|
328
381
|
4. Review and accept the code edit.
|
|
329
382
|
5. Re-run `npx launch-doctor` to observe your score improve.
|
|
330
383
|
|
|
384
|
+
### MCP server
|
|
385
|
+
|
|
386
|
+
`launch-doctor mcp` starts a [Model Context Protocol](https://modelcontextprotocol.io) server, so your AI assistant can run the checkup itself, read the findings and fix them without you copying anything.
|
|
387
|
+
|
|
388
|
+
**Claude Code:**
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
claude mcp add launch-doctor -- npx -y launch-doctor mcp
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
**Cursor** (`.cursor/mcp.json`) and other tools that use the same format:
|
|
395
|
+
|
|
396
|
+
```json
|
|
397
|
+
{
|
|
398
|
+
"mcpServers": {
|
|
399
|
+
"launch-doctor": { "command": "npx", "args": ["-y", "launch-doctor", "mcp"] }
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Then ask: *"Run Launch Doctor on this project and fix the critical findings one at a time."*
|
|
405
|
+
|
|
406
|
+
| Tool | What it does |
|
|
407
|
+
|---|---|
|
|
408
|
+
| `scan_project` | Checks a folder (default: the one the assistant works in). Returns the grade, every finding with its file, line, explanation and fix prompt, and the checklist of things to verify by hand. Options: `path`, `only`, `skip`, `offline`, `domain`, `history`, `includeBaseline`. |
|
|
409
|
+
| `scan_url` | Checks a deployed site from the outside, like `launch-doctor scan <url>`. Options: `url`, `skipDatabase`. |
|
|
410
|
+
| `list_checks` | Lists the categories and every finding id, for `only`, `skip` and `.launchdoctorignore`. |
|
|
411
|
+
|
|
412
|
+
The tools only read: nothing is written to your project, and results also come back as structured data for clients that use it. The server speaks MCP over stdio (protocol versions 2024-11-05 to 2025-11-25) and has no dependencies.
|
|
413
|
+
|
|
331
414
|
## Privacy and network use
|
|
332
415
|
|
|
333
416
|
Launch Doctor analyzes your codebase locally on your device. Your source code, findings, and credentials are never uploaded to any remote server. Detected secrets are masked in reports (for example, `sk_live_…exe9`).
|
|
334
417
|
|
|
335
418
|
- **Email DNS validation:** This is the only network check a folder scan performs. When your project sends transactional email and a domain is identified (either discovered in code or specified via `--domain`), Launch Doctor queries your system DNS resolver for NS and TXT records (including root SPF, `send.<domain>`, `_dmarc.<domain>`, and common DKIM selectors). No code or private data is transmitted. Pass `--offline` to disable DNS lookups entirely. The `--demo` command never touches the network.
|
|
336
|
-
- **Live site scan (`scan <url>`):** sends ordinary `GET` requests to the address you give and to Supabase when
|
|
419
|
+
- **Live site scan (`scan <url>`):** sends ordinary `GET` requests to the address you give, to the JavaScript files and source maps that page loads (which may be on another domain, such as a CDN), and to your Supabase project when the page uses one. For the Supabase test it sends the public anon key it found in your page back to your own Supabase project. Nothing else is sent, and nothing is uploaded.
|
|
420
|
+
- **No telemetry:** Launch Doctor does not collect usage data or phone home.
|
|
337
421
|
- **Git history analysis (`--history`):** Runs local `git log` commands directly on your system without network requests.
|
|
422
|
+
- **Pull request comments (`--pr-comment`):** calls the GitHub API with the workflow's token to read the pull request's changed files and post comments. It only runs on GitHub Actions and sends finding titles, explanations, fix prompts and file paths, never your source code.
|
|
423
|
+
- **MCP server (`mcp`):** talks to your AI tool over stdin and stdout only; it opens no port. Its tools make the same network calls as the CLI: email DNS lookups for `scan_project` (unless `offline`), and the requests to the site you name for `scan_url`.
|
|
338
424
|
- **Package installation:** standard `npx` retrieval via the npm registry.
|
|
339
425
|
|
|
340
|
-
##
|
|
426
|
+
## What it cannot do
|
|
427
|
+
|
|
428
|
+
Launch Doctor is useful because it is fast and specific. That also means it has clear blind spots. If any of these matter for your app, use another tool or a human review as well.
|
|
429
|
+
|
|
430
|
+
**It doesn't see your running app or your production settings**
|
|
431
|
+
- Production environment variables (Vercel, Netlify, Render and others) are invisible. A malformed URL, a wrong key or a bad model name in production will not be caught.
|
|
432
|
+
- Settings made in the Supabase, Firebase or Stripe dashboards are invisible. Tables created in the Supabase dashboard (rather than in SQL migrations in your repo) can't be checked for Row Level Security from the code, so you only get a reminder (`scan` can at least test whether they can be read on your live site).
|
|
433
|
+
- It doesn't run your app, call your API or read your logs (apart from the `GET` requests of `scan`), so errors that only happen at runtime are not found.
|
|
434
|
+
|
|
435
|
+
**It doesn't do a full security review**
|
|
436
|
+
- It doesn't check your own authorization logic, for example whether user A can open user B's order through your API. The only access-control rules it understands are Supabase RLS in SQL files, Firebase rules files, Appwrite permissions, and whether Convex functions check who is calling.
|
|
437
|
+
- It doesn't look for XSS, SQL injection, CSRF, SSRF or similar code-level vulnerabilities.
|
|
438
|
+
- It doesn't check your dependencies for known vulnerabilities. Use `npm audit`, `pip-audit` or Dependabot for that.
|
|
439
|
+
- It is not a penetration test, and its legal-page checks are reminders, not legal advice.
|
|
440
|
+
|
|
441
|
+
**It decides by patterns, so it can be wrong both ways**
|
|
442
|
+
- Logins, rate limiters and webhook checks are recognised by common names and libraries. Code written in an unusual way may be reported as missing (a false alarm), and code that only looks right may pass (a miss).
|
|
443
|
+
- Route analysis follows local imports 2 levels deep. Dynamic imports and unusual route shapes may not be followed.
|
|
444
|
+
- API-only backends can get legal-page warnings (privacy policy, terms) that may not apply to them.
|
|
445
|
+
- A folder with very little code (for example only a README) can get an A, because there was nothing to find.
|
|
446
|
+
|
|
447
|
+
**Coverage depends on your stack**
|
|
448
|
+
- **Deepest:** JavaScript and TypeScript web apps (Next.js, Vite/React, Express and similar), with Supabase, Firebase, Prisma, Stripe, Razorpay, and the common AI and email providers.
|
|
449
|
+
- **Good:** Python (FastAPI, Flask, Django): secrets, AI costs, Stripe webhooks, Supabase and the web-app checks. Clerk, Convex, Appwrite, Paddle and Lemon Squeezy have their own checks (new in 0.3.0, so less tried than the ones above).
|
|
450
|
+
- **Mobile (new in 0.3.0):** Expo and React Native apps get mobile versions of the checks. Launch Doctor reads the Expo config (`app.json`, `app.config.*`), `AndroidManifest.xml` and `Info.plist`; Gradle and Xcode project files are not read, and native Swift, Kotlin and Java code is not scanned at all.
|
|
451
|
+
- **Basic:** Ruby, PHP and Go are scanned for hard-coded secrets and a few patterns, but their frameworks and dependency files are not understood.
|
|
341
452
|
|
|
342
|
-
|
|
453
|
+
**It skips some files**
|
|
454
|
+
- `node_modules`, `dist`, `build`, `out`, `coverage`, `vendor`, `venv`, `target`, `generated` and a few other build or dependency folders, and hidden folders other than `.github` (such as `.venv` and `.next`).
|
|
455
|
+
- Files over 1 MB, minified `.min.js` files, source maps and binary files.
|
|
456
|
+
- Everything after the first 20,000 files (the report says when this happens).
|
|
343
457
|
|
|
344
|
-
|
|
345
|
-
- It cannot inspect third-party web dashboards. Settings configured via web consoles in Supabase, Firebase, Stripe, or cloud hosts appear on the "check yourself" manual checklist.
|
|
346
|
-
- JavaScript, TypeScript, and Python codebases receive the deepest static analysis coverage.
|
|
347
|
-
- Route analysis works per handler and follows local imports 2 levels deep. Dynamic imports and unusual route shapes may not be followed.
|
|
458
|
+
For apps that handle significant money or sensitive personal or health data, use Launch Doctor as a first pass and get a human security review.
|
|
348
459
|
|
|
349
|
-
|
|
460
|
+
## How it is tested
|
|
461
|
+
|
|
462
|
+
- 170 automated tests run on every change, on Windows, macOS and Linux, with Node.js 22 and 24.
|
|
463
|
+
- Every check that existed in 0.2 has been confirmed against a small project (or fake site) that contains exactly that problem, and every command in this README has been run (the `scan` examples against a local test site rather than a real one).
|
|
464
|
+
- The features new in 0.3.0 (the GitHub Action, the MCP server, mobile apps, and Clerk, Convex, Appwrite, Paddle and Lemon Squeezy) have their own tests and were spot-checked by hand, which found and fixed two bugs before release. They have been tried less than the older checks. Posting pull request comments is tested against a fake GitHub API; it has not yet run on many real pull requests.
|
|
465
|
+
- Every bug fix gets a regression test, so the same mistake doesn't come back.
|
|
466
|
+
- What hasn't happened yet is wide real-world use. Most false alarms are found when the tool meets code written differently from what it has seen, so your reports make the biggest difference.
|
|
467
|
+
|
|
468
|
+
## Found a wrong finding?
|
|
469
|
+
|
|
470
|
+
If Launch Doctor reports something that is fine, misses a real problem, or crashes, please open an issue: [report a false alarm](https://github.com/SHARAJ379/launch-doctor/issues/new?template=false_positive.yml) or [report a bug](https://github.com/SHARAJ379/launch-doctor/issues/new?template=bug_report.yml). A short code snippet that reproduces it (with any keys removed) is the most helpful thing you can include. Fixes are released as small patch versions.
|
|
471
|
+
|
|
472
|
+
Meanwhile you can silence a finding with `.launchdoctorignore` or an inline `launch-doctor-ignore` comment (see [Configuration](#configuration)).
|
|
350
473
|
|
|
351
474
|
## Roadmap
|
|
352
475
|
|
|
476
|
+
Planned work, in no fixed order and without dates:
|
|
477
|
+
|
|
353
478
|
- [x] Live URL inspection (`launch-doctor scan <url>`: exposed `.env`, source maps, security headers, open Supabase tables via anonymous key)
|
|
354
|
-
- [
|
|
355
|
-
- [
|
|
356
|
-
- [
|
|
357
|
-
- [
|
|
479
|
+
- [x] GitHub Action that posts a summary and inline fix prompts on pull requests ([Pull request comments](#pull-request-comments))
|
|
480
|
+
- [x] Model Context Protocol (MCP) server for direct Claude Code and Cursor integration ([MCP server](#mcp-server))
|
|
481
|
+
- [x] Extended provider coverage (Clerk, Convex, Appwrite, Lemon Squeezy, Paddle)
|
|
482
|
+
- [x] Mobile framework support (Expo, React Native)
|
|
358
483
|
|
|
359
484
|
## Contributing
|
|
360
485
|
|
|
@@ -366,7 +491,7 @@ Thanks to everyone who has helped build Launch Doctor. Contributors are listed h
|
|
|
366
491
|
|
|
367
492
|
- [@SHARAJ379](https://github.com/SHARAJ379): creator and maintainer
|
|
368
493
|
|
|
369
|
-
Want to be on this list?
|
|
494
|
+
Want to be on this list? Reporting a false alarm with a small example is a great first contribution, and issues labelled `good first issue` or `help wanted` are a good place to start once there are some.
|
|
370
495
|
|
|
371
496
|
## Security
|
|
372
497
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SourceFile } from '../project.js';
|
|
2
2
|
import type { Check } from '../types.js';
|
|
3
|
+
export declare function hasCustomLimiter(code: string): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* True when a Next.js-style middleware (or proxy) file blocks signed-out users AND runs on /api routes.
|
|
5
6
|
* Middleware that only refreshes the session (e.g. Supabase's updateSession) doesn't count.
|
package/dist/src/checks/costs.js
CHANGED
|
@@ -40,6 +40,33 @@ const RATE_LIMIT_PACKAGES = [
|
|
|
40
40
|
'koa-ratelimit',
|
|
41
41
|
];
|
|
42
42
|
const RATE_LIMIT_USAGE = /new\s+Ratelimit\s*\(|Ratelimit\.slidingWindow\s*\(|\brateLimit\s*\(\s*\{|new\s+RateLimiter\w*\s*\(|\blimiter\.(?:limit|consume|removeTokens)\s*\(|@limiter\.limit\s*\(|\barcjet\s*\(/;
|
|
43
|
+
/**
|
|
44
|
+
* A hand-written limiter: something named like a rate limit (not the provider's RateLimitError) together
|
|
45
|
+
* with a 429 "Too Many Requests" response. Many apps keep the counter in their own database or Redis.
|
|
46
|
+
*/
|
|
47
|
+
const CUSTOM_LIMIT_NAME = /rate[_-]?limit(?!\w*(?:Error|Exception))/i;
|
|
48
|
+
const TOO_MANY_REQUESTS = /\b429\b|HTTP_429|too[_ ]many[_ ]requests|TooManyRequests/i;
|
|
49
|
+
export function hasCustomLimiter(code) {
|
|
50
|
+
return CUSTOM_LIMIT_NAME.test(code) && TOO_MANY_REQUESTS.test(code);
|
|
51
|
+
}
|
|
52
|
+
/** The rate-limit library to suggest for this project's server framework. */
|
|
53
|
+
function rateLimitLibrary(ctx) {
|
|
54
|
+
if (ctx.uses('fastapi'))
|
|
55
|
+
return 'slowapi (made for FastAPI)';
|
|
56
|
+
if (ctx.uses('flask'))
|
|
57
|
+
return 'Flask-Limiter';
|
|
58
|
+
if (ctx.uses('django'))
|
|
59
|
+
return 'django-ratelimit';
|
|
60
|
+
if (ctx.uses('express'))
|
|
61
|
+
return 'express-rate-limit (with a Redis store if I run more than one server)';
|
|
62
|
+
if (ctx.uses('fastify'))
|
|
63
|
+
return '@fastify/rate-limit';
|
|
64
|
+
if (ctx.uses('hono'))
|
|
65
|
+
return 'hono-rate-limiter';
|
|
66
|
+
if (ctx.usesAny(['next', '@sveltejs/kit', 'nuxt', 'astro', '@remix-run/node']) || ctx.hasPath(/(^|\/)vercel\.json$/))
|
|
67
|
+
return '@upstash/ratelimit (works on Vercel and other serverless hosts)';
|
|
68
|
+
return 'a rate-limiting library that fits my stack';
|
|
69
|
+
}
|
|
43
70
|
/** Code in a middleware file that actually turns away signed-out requests. */
|
|
44
71
|
const MIDDLEWARE_BLOCKS = /\.protect\s*\(|status\s*:\s*401|NextResponse\.redirect\s*\(|\bredirect\s*\([^)]*["'`][^"'`]*\/(?:login|sign-?in)\b/i;
|
|
45
72
|
/**
|
|
@@ -171,9 +198,14 @@ export const costsCheck = {
|
|
|
171
198
|
out.passed.push('AI endpoints check who is calling');
|
|
172
199
|
// 3. Rate limiting: an imported rate-limit package, or code that really sets up a limiter.
|
|
173
200
|
// (Comments and "RateLimitError" handling don't count.)
|
|
174
|
-
const projectRateLimited = RATE_LIMIT_PACKAGES.some((p) => ctx.imported(p)) ||
|
|
201
|
+
const projectRateLimited = RATE_LIMIT_PACKAGES.some((p) => ctx.imported(p)) ||
|
|
202
|
+
ctx.findCode(RATE_LIMIT_USAGE, server, 1).length > 0 ||
|
|
203
|
+
ctx.files.some((f) => server(f) && hasCustomLimiter(ctx.codeOf(f)));
|
|
175
204
|
// With analysed handlers, a limiter only counts for a handler that can reach it (or that middleware covers).
|
|
176
|
-
const limitedHere = (h) =>
|
|
205
|
+
const limitedHere = (h) => {
|
|
206
|
+
const scope = evidenceOf(ctx, h).scope;
|
|
207
|
+
return RATE_LIMIT_USAGE.test(scope) || hasCustomLimiter(scope) || middlewareCovers(ctx, h, RATE_LIMIT_USAGE);
|
|
208
|
+
};
|
|
177
209
|
const unlimitedHandlers = aiHandlers.filter((h) => !limitedHere(h));
|
|
178
210
|
const legacyAiRoutes = aiRoutes.length > 0;
|
|
179
211
|
const rateLimited = aiHandlers.length
|
|
@@ -187,9 +219,12 @@ export const costsCheck = {
|
|
|
187
219
|
id: 'no-rate-limit',
|
|
188
220
|
severity: 'warning',
|
|
189
221
|
title: usesAI ? 'No rate limiting on your AI features' : 'No rate limiting on paid API calls',
|
|
190
|
-
why: 'One user — or one bot — can send thousands of requests a minute, and you pay for every one. A simple limit per user (say 20 a minute) protects your wallet.'
|
|
191
|
-
|
|
192
|
-
|
|
222
|
+
why: 'One user — or one bot — can send thousands of requests a minute, and you pay for every one. A simple limit per user (say 20 a minute) protects your wallet. ' +
|
|
223
|
+
'We looked for a rate-limit package being used, or your own limit check that answers with HTTP 429 "Too Many Requests", and found neither.',
|
|
224
|
+
fixPrompt: `Launch Doctor found no rate limiting on the endpoints in my app that call paid APIs (${usesAI ? 'AI' : 'SMS'}). First check whether I already limit requests somewhere it couldn't see ` +
|
|
225
|
+
`(for example in my database, Redis, a gateway or my host's settings); if I do, show me where and confirm it covers these endpoints. ` +
|
|
226
|
+
`If not, limit each signed-in user (and each IP address for signed-out visitors) to a sensible number of requests per minute and per day, ` +
|
|
227
|
+
`return a friendly "slow down" message with HTTP 429 when they hit it, and use ${rateLimitLibrary(ctx)}.`,
|
|
193
228
|
});
|
|
194
229
|
}
|
|
195
230
|
// 4. Things only the dashboards can show
|
|
@@ -1,6 +1,37 @@
|
|
|
1
|
-
import { detectDatabase } from '../detect.js';
|
|
1
|
+
import { detectAuth, detectDatabase } from '../detect.js';
|
|
2
|
+
import { isTestPath } from '../project.js';
|
|
2
3
|
import { lineAt, plural } from '../util.js';
|
|
3
|
-
import { emptyOutput, notApplicable, where } from './common.js';
|
|
4
|
+
import { appCode, at, emptyOutput, notApplicable, where } from './common.js';
|
|
5
|
+
// ---------- Convex ----------
|
|
6
|
+
/** Public Convex functions that can change data. internalMutation / internalAction can't be called from outside. */
|
|
7
|
+
const CONVEX_PUBLIC_WRITE = /export\s+const\s+(\w+)\s*=\s*(mutation|action)\s*\(/g;
|
|
8
|
+
/** Ways a Convex function finds out who is calling. */
|
|
9
|
+
const CONVEX_AUTH = /ctx\.auth\b|getAuthUserId\s*\(|getAuthSessionId\s*\(|\b(?:requireUser|requireAuth|getCurrentUser|getUserOrThrow|ensureUser|assertUser|currentUser|checkAuth|getViewer|mustGetCurrentUser|getMe)\w*\s*\(/;
|
|
10
|
+
const isConvexFunctionFile = (f) => /(^|\/)convex\/(?!_generated\/).+\.[cm]?[jt]s$/.test(f.path) && !isTestPath(f.path);
|
|
11
|
+
/** Public mutations and actions whose body never asks who the caller is. */
|
|
12
|
+
function unprotectedConvexFunctions(ctx) {
|
|
13
|
+
const out = [];
|
|
14
|
+
for (const f of ctx.files.filter(isConvexFunctionFile)) {
|
|
15
|
+
const code = ctx.codeOf(f);
|
|
16
|
+
const starts = [...code.matchAll(/^export\s/gm)].map((m) => m.index);
|
|
17
|
+
for (const m of code.matchAll(CONVEX_PUBLIC_WRITE)) {
|
|
18
|
+
const next = starts.find((i) => i > m.index) ?? code.length;
|
|
19
|
+
if (CONVEX_AUTH.test(code.slice(m.index, next)))
|
|
20
|
+
continue;
|
|
21
|
+
out.push({ name: m[1], loc: { file: f.path, line: lineAt(code, m.index) } });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
// ---------- Appwrite ----------
|
|
27
|
+
/** Document or collection permissions that let anyone (even signed-out visitors) write. */
|
|
28
|
+
const APPWRITE_OPEN = /Permission\.(write|create|update|delete)\s*\(\s*Role\.(any|guests)\s*\(\s*\)\s*\)/;
|
|
29
|
+
/** Update or delete rights for every signed-in user (create for everyone signed in is normal). */
|
|
30
|
+
const APPWRITE_USERS = /Permission\.(write|update|delete)\s*\(\s*Role\.users\s*\(\s*\)\s*\)/;
|
|
31
|
+
/** The same in appwrite.json (the Appwrite CLI config): "update(\"any\")". */
|
|
32
|
+
const APPWRITE_JSON_OPEN = /"(write|create|update|delete)\(\\"(any|guests)\\"\)"/;
|
|
33
|
+
const APPWRITE_JSON_USERS = /"(write|update|delete)\(\\"users\\"\)"/;
|
|
34
|
+
const isAppwriteConfig = (f) => /(^|\/)appwrite(?:\.config)?\.json$/.test(f.path);
|
|
4
35
|
/** Remove SQL comments but keep line numbers the same. */
|
|
5
36
|
function stripSqlComments(sql) {
|
|
6
37
|
return sql.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' ')).replace(/--[^\n]*/g, '');
|
|
@@ -80,6 +111,10 @@ export const databaseCheck = {
|
|
|
80
111
|
'supabase-rls-dashboard',
|
|
81
112
|
'firebase-open-rules',
|
|
82
113
|
'firebase-rules-console',
|
|
114
|
+
'convex-public-mutation',
|
|
115
|
+
'appwrite-open-permission',
|
|
116
|
+
'appwrite-signed-in-write',
|
|
117
|
+
'appwrite-permissions-console',
|
|
83
118
|
'sqlite-on-serverless',
|
|
84
119
|
'prisma-db-push',
|
|
85
120
|
'backups',
|
|
@@ -187,6 +222,86 @@ export const databaseCheck = {
|
|
|
187
222
|
out.passed.push('Firebase security rules are not wide open');
|
|
188
223
|
}
|
|
189
224
|
}
|
|
225
|
+
// ---- Convex: public functions that never check who is calling ----
|
|
226
|
+
if (dbs.includes('Convex')) {
|
|
227
|
+
const convexFiles = ctx.files.filter(isConvexFunctionFile);
|
|
228
|
+
// Only an app with accounts has a "who is calling" to check; a public guestbook may write without one.
|
|
229
|
+
const hasAccounts = !!detectAuth(ctx) ||
|
|
230
|
+
ctx.uses('@convex-dev/auth') ||
|
|
231
|
+
convexFiles.some((f) => /ctx\.auth\b|getAuthUserId\s*\(/.test(ctx.codeOf(f)));
|
|
232
|
+
const anyPublicWrite = convexFiles.some((f) => new RegExp(CONVEX_PUBLIC_WRITE.source).test(ctx.codeOf(f)));
|
|
233
|
+
const open = hasAccounts ? unprotectedConvexFunctions(ctx) : [];
|
|
234
|
+
if (open.length) {
|
|
235
|
+
const names = open.slice(0, 5).map((o) => o.name);
|
|
236
|
+
const more = open.length > 5 ? ` and ${open.length - 5} more` : '';
|
|
237
|
+
out.findings.push({
|
|
238
|
+
id: 'convex-public-mutation',
|
|
239
|
+
severity: 'warning',
|
|
240
|
+
title: `${plural(open.length, 'Convex function')} anyone can call without signing in: ${names.join(', ')}${more}`,
|
|
241
|
+
why: 'Every mutation and action exported from your convex/ folder is a public API. Your Convex URL is inside your app, so anyone can call these directly, signed in or not. These never check who is calling, so anyone can change data through them.',
|
|
242
|
+
location: open[0].loc,
|
|
243
|
+
fixPrompt: `These Convex functions never check who is calling: ${open.map((o) => `${o.name} (${where(o.loc)})`).join(', ')}. For each one:\n` +
|
|
244
|
+
`1. At the top of the handler, add: const identity = await ctx.auth.getUserIdentity(); if (!identity) throw new Error("Not signed in");\n` +
|
|
245
|
+
`2. Before changing a document, check that it belongs to the signed-in user.\n` +
|
|
246
|
+
`3. If a function is only called by other Convex functions, crons or the scheduler, make it an internalMutation or internalAction instead, so it can't be called from outside.\n` +
|
|
247
|
+
`Explain each change in one sentence.`,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
else if (hasAccounts && anyPublicWrite) {
|
|
251
|
+
out.passed.push('Convex mutations check who is calling');
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// ---- Appwrite permissions ----
|
|
255
|
+
if (dbs.includes('Appwrite')) {
|
|
256
|
+
const inCode = (re) => [
|
|
257
|
+
...ctx.findCode(re, appCode, 3),
|
|
258
|
+
...ctx.find(re === APPWRITE_OPEN ? APPWRITE_JSON_OPEN : APPWRITE_JSON_USERS, isAppwriteConfig, 3),
|
|
259
|
+
];
|
|
260
|
+
const open = inCode(APPWRITE_OPEN);
|
|
261
|
+
const signedIn = inCode(APPWRITE_USERS);
|
|
262
|
+
for (const m of open.slice(0, 3)) {
|
|
263
|
+
const action = m.match[1];
|
|
264
|
+
const who = m.match[2] === 'guests' ? 'signed-out visitors' : 'anyone';
|
|
265
|
+
const createOnly = action === 'create';
|
|
266
|
+
out.findings.push({
|
|
267
|
+
id: 'appwrite-open-permission',
|
|
268
|
+
severity: createOnly ? 'warning' : 'critical',
|
|
269
|
+
title: createOnly
|
|
270
|
+
? `Appwrite lets ${who} create documents (${action} for ${m.match[2]})`
|
|
271
|
+
: `Appwrite lets ${who} ${action === 'write' ? 'change and delete' : action} your data`,
|
|
272
|
+
why: createOnly
|
|
273
|
+
? 'Anyone, even people who are not signed in, can add documents here. Fine for something like a contact form, but bots can fill it with junk unless you add a captcha or rate limit.'
|
|
274
|
+
: 'This permission is granted to "any" (or guests), so anyone on the internet can use your public project ID to change or delete these documents, without signing in.',
|
|
275
|
+
location: at(m),
|
|
276
|
+
fixPrompt: `In ${where(at(m))} an Appwrite permission gives "${action}" to Role.${m.match[2]}(). ` +
|
|
277
|
+
`Please change it so only the document's owner can update or delete it (Permission.update(Role.user(userId)), Permission.delete(Role.user(userId))), ` +
|
|
278
|
+
`keep public read only if the data is meant to be public, and turn on "Document security" for the collection if documents need per-user permissions. Explain each permission in one sentence.`,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
for (const m of signedIn.slice(0, 3)) {
|
|
282
|
+
out.findings.push({
|
|
283
|
+
id: 'appwrite-signed-in-write',
|
|
284
|
+
severity: 'warning',
|
|
285
|
+
title: `Appwrite: any signed-in user can ${m.match[1] === 'write' ? 'change and delete' : m.match[1]} these documents`,
|
|
286
|
+
why: `The permission is granted to Role.users(), which means every account. Anyone who creates a free account can edit or delete other people's documents.`,
|
|
287
|
+
location: at(m),
|
|
288
|
+
fixPrompt: `In ${where(at(m))} an Appwrite permission gives "${m.match[1]}" to Role.users(), so every signed-in user can change every document. ` +
|
|
289
|
+
`Please give update and delete rights only to the owner (Role.user(userId)) when creating each document, with "Document security" turned on for the collection.`,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
const anyPermissions = ctx.findCode(/Permission\.\w+\s*\(\s*Role\./, appCode, 1).length > 0 ||
|
|
293
|
+
ctx.files.some((f) => isAppwriteConfig(f) && /\$permissions|"permissions"/.test(f.content));
|
|
294
|
+
if (!anyPermissions) {
|
|
295
|
+
out.manual.push({
|
|
296
|
+
id: 'appwrite-permissions-console',
|
|
297
|
+
title: 'Check your Appwrite collection and bucket permissions',
|
|
298
|
+
how: 'Open the Appwrite Console → Databases → each collection → Settings → Permissions (and Storage → each bucket). "Any" with create, update or delete lets anyone change your data; give those rights to users or to the document owner instead.',
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
else if (!open.length && !signedIn.length) {
|
|
302
|
+
out.passed.push("Appwrite permissions don't let anyone change other people's data");
|
|
303
|
+
}
|
|
304
|
+
}
|
|
190
305
|
// ---- SQLite on serverless hosting ----
|
|
191
306
|
const prismaSqlite = ctx.find(/provider\s*=\s*"sqlite"/, (f) => f.path.endsWith('.prisma'), 1)[0];
|
|
192
307
|
const sqliteLib = ctx.usesAny(['better-sqlite3', 'sqlite3']);
|
|
@@ -232,7 +347,11 @@ export const databaseCheck = {
|
|
|
232
347
|
? 'In Supabase → Database → Backups, check that backups exist for your plan (free projects may not include them). Download or restore one once to be sure it works.'
|
|
233
348
|
: dbs.includes('Firebase')
|
|
234
349
|
? 'Turn on scheduled Firestore backups (Google Cloud → Firestore → Disaster recovery), then restore one into a test project once.'
|
|
235
|
-
:
|
|
350
|
+
: dbs.includes('Convex')
|
|
351
|
+
? 'In the Convex dashboard → your production deployment → Backups, turn on periodic backups, then download or restore one once to be sure it works.'
|
|
352
|
+
: dbs.includes('Appwrite')
|
|
353
|
+
? 'Turn on database backups in the Appwrite Console (Databases → Backups), or back up your server volumes if you host Appwrite yourself, then restore one into a test project once.'
|
|
354
|
+
: 'Turn on automatic daily backups with your database host, then restore one into a test database once to prove it works.';
|
|
236
355
|
out.manual.push({ id: 'backups', title: 'Turn on automatic backups and test a restore', how });
|
|
237
356
|
return out;
|
|
238
357
|
},
|