launch-doctor 0.2.1 → 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.
- package/CHANGELOG.md +105 -4
- package/LICENSE +1 -0
- package/README.md +239 -39
- package/dist/src/access.d.ts +52 -0
- package/dist/src/access.js +482 -0
- package/dist/src/baseline.d.ts +6 -3
- package/dist/src/baseline.js +15 -8
- package/dist/src/changed.d.ts +12 -0
- package/dist/src/changed.js +34 -0
- package/dist/src/checks/access.d.ts +7 -0
- package/dist/src/checks/access.js +868 -0
- package/dist/src/checks/costs.d.ts +8 -0
- package/dist/src/checks/costs.js +54 -11
- package/dist/src/checks/database.js +201 -6
- package/dist/src/checks/first-impressions.js +247 -117
- package/dist/src/checks/legal.js +29 -13
- package/dist/src/checks/monitoring.js +47 -15
- package/dist/src/checks/payments.js +141 -6
- package/dist/src/checks/secrets.d.ts +8 -0
- package/dist/src/checks/secrets.js +185 -16
- package/dist/src/checks/supabase-storage.d.ts +31 -0
- package/dist/src/checks/supabase-storage.js +216 -0
- package/dist/src/cli.js +201 -12
- package/dist/src/demo.d.ts +13 -0
- package/dist/src/demo.js +59 -2
- package/dist/src/detect.d.ts +1 -1
- package/dist/src/detect.js +5 -2
- package/dist/src/fixes.js +10 -7
- package/dist/src/git.d.ts +25 -0
- package/dist/src/git.js +121 -0
- package/dist/src/github.d.ts +90 -0
- package/dist/src/github.js +330 -0
- package/dist/src/history.js +17 -3
- package/dist/src/hook.d.ts +13 -0
- package/dist/src/hook.js +96 -0
- package/dist/src/hooks-setup.d.ts +24 -0
- package/dist/src/hooks-setup.js +187 -0
- package/dist/src/ignore.d.ts +36 -0
- package/dist/src/ignore.js +164 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +30 -3
- package/dist/src/init.d.ts +1 -1
- package/dist/src/init.js +2 -2
- package/dist/src/live.d.ts +9 -0
- package/dist/src/live.js +73 -22
- package/dist/src/mcp.d.ts +140 -0
- package/dist/src/mcp.js +386 -0
- package/dist/src/net-guard.d.ts +34 -0
- package/dist/src/net-guard.js +144 -0
- package/dist/src/project.d.ts +42 -5
- package/dist/src/project.js +237 -107
- package/dist/src/report.d.ts +4 -0
- package/dist/src/report.js +23 -1
- package/dist/src/routes.d.ts +10 -0
- package/dist/src/routes.js +21 -4
- package/dist/src/safe-fs.d.ts +19 -0
- package/dist/src/safe-fs.js +77 -0
- package/dist/src/sanitize.d.ts +17 -0
- package/dist/src/sanitize.js +90 -0
- package/dist/src/sarif.js +1 -1
- package/dist/src/summary.d.ts +7 -0
- package/dist/src/summary.js +26 -17
- package/dist/src/types.d.ts +26 -0
- package/dist/src/util.d.ts +2 -0
- package/dist/src/util.js +2 -0
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -2,12 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
**A pre-launch checkup for vibe-coded apps: one command, an A-F grade, and a fix prompt for every problem.**
|
|
4
4
|
|
|
5
|
-
[](https://github.com/SHARAJ379/Launch-Doctor/actions/workflows/ci.yml)
|
|
6
6
|
[](https://www.npmjs.com/package/launch-doctor)
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
|
|
10
|
-
Launch Doctor
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
*A sample app full of mistakes scores an F with six critical issues; a prepared app scores an A.*
|
|
13
|
+
|
|
14
|
+
Launch Doctor scans your project for common problems that hurt apps after launch: leaked API keys, databases anyone can read, endpoints that let one user reach another user's data, 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.
|
|
15
|
+
|
|
16
|
+
## Read this first
|
|
17
|
+
|
|
18
|
+
Launch Doctor is a **quick checklist with teeth, not a security audit**. Please trust it accordingly:
|
|
19
|
+
|
|
20
|
+
- **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.
|
|
21
|
+
- **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.
|
|
22
|
+
- **A grade A means "none of the problems we look for were found"**, not "your app is secure".
|
|
23
|
+
- **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).
|
|
24
|
+
|
|
25
|
+
The full list is in [What it cannot do](#what-it-cannot-do).
|
|
11
26
|
|
|
12
27
|
## Quick start
|
|
13
28
|
|
|
@@ -27,18 +42,21 @@ Initialize configuration and GitHub Actions files:
|
|
|
27
42
|
npx launch-doctor init
|
|
28
43
|
```
|
|
29
44
|
|
|
30
|
-
Requires Node.js 22 or newer.
|
|
45
|
+
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
46
|
|
|
32
47
|
## Example output
|
|
33
48
|
|
|
49
|
+
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).
|
|
50
|
+
|
|
34
51
|
```
|
|
35
|
-
Launch Doctor v0.
|
|
36
|
-
Checked my-weekend-saas ·
|
|
52
|
+
Launch Doctor v0.4.0
|
|
53
|
+
Checked my-weekend-saas · 13 files · Vite, React, Supabase, Stripe, OpenAI
|
|
37
54
|
|
|
38
55
|
Overall grade F Not ready to launch: fix 6 critical issues first
|
|
39
56
|
|
|
40
57
|
F Secrets & keys 2 critical · 1 to fix · 1 to check
|
|
41
58
|
F Database & backups 2 critical · 1 to check
|
|
59
|
+
B Access control 1 to fix · 1 to check
|
|
42
60
|
F Payments 1 critical · 2 to check
|
|
43
61
|
F AI & API costs 1 critical · 1 to fix · 1 to check
|
|
44
62
|
B Email delivery 1 to fix · 3 to check
|
|
@@ -59,8 +77,6 @@ Requires Node.js 22 or newer.
|
|
|
59
77
|
so every visitor can read it. That prefix is only for values that are safe
|
|
60
78
|
to be public.
|
|
61
79
|
...
|
|
62
|
-
|
|
63
|
-
Fix prompts saved to LAUNCH_FIXES.md
|
|
64
80
|
```
|
|
65
81
|
|
|
66
82
|
## Project workflow
|
|
@@ -78,10 +94,11 @@ flowchart TD
|
|
|
78
94
|
LoadContext --> DetectStack["3. Technology Stack & Environment Detection"]
|
|
79
95
|
DetectStack --> ChecksSuite
|
|
80
96
|
|
|
81
|
-
subgraph ChecksSuite["4. Evaluation across
|
|
97
|
+
subgraph ChecksSuite["4. Evaluation across 9 Check Modules"]
|
|
82
98
|
direction TB
|
|
83
99
|
C1["Secrets & Keys Scan"]
|
|
84
100
|
C2["Database Security & RLS"]
|
|
101
|
+
C2b["Access Control & Ownership"]
|
|
85
102
|
C3["Payment Webhooks & Verification"]
|
|
86
103
|
C4["AI Endpoints & Cost Controls"]
|
|
87
104
|
C5["Email DNS & Configuration"]
|
|
@@ -111,11 +128,11 @@ flowchart TD
|
|
|
111
128
|
1. **Argument parsing and validation (`src/cli.ts`):**
|
|
112
129
|
Evaluates CLI flags, path arguments, targeted categories (`--only`, `--skip`), severity thresholds (`--fail-on`), output destinations (`--out`, `--sarif`), and runtime modifiers (`--ci`, `--offline`, `--history`, `--demo`).
|
|
113
130
|
2. **Project ingestion and tree traversal (`src/project.ts`):**
|
|
114
|
-
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.
|
|
131
|
+
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. Limits: files over 1 MB are skipped, at most 20,000 files are read, and reading stops after 128 MB of text in total; the report says when either limit is hit (`truncated` and `byteLimitReached` in `--json`).
|
|
115
132
|
3. **Stack and environment detection (`src/detect.ts`, `src/comments.ts`):**
|
|
116
|
-
Identifies frameworks (Next.js, Vite, React, Vue, Express
|
|
133
|
+
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
134
|
4. **Multi-category check execution (`src/checks/`):**
|
|
118
|
-
Runs audits across all
|
|
135
|
+
Runs audits across all 9 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
136
|
5. **Suppression and baseline matching (`src/baseline.ts`):**
|
|
120
137
|
Applies inline `launch-doctor-ignore <id>` comments and `.launchdoctorignore` path or id rules. If `.launchdoctor-baseline.json` is present and baseline mode is active, matches existing findings by ID, relative file path, and line content fingerprint.
|
|
121
138
|
6. **Scoring and grading engine (`src/grade.ts`):**
|
|
@@ -141,7 +158,7 @@ flowchart LR
|
|
|
141
158
|
ReScan --> Check
|
|
142
159
|
Check -- "Clean (Grade A or Baseline)" --> Commit["6. Commit & Push Code"]
|
|
143
160
|
Commit --> CI["7. CI/CD PR Gate (--ci)"]
|
|
144
|
-
CI --> Deploy["8.
|
|
161
|
+
CI --> Deploy["8. Deploy (and check the manual checklist)"]
|
|
145
162
|
```
|
|
146
163
|
|
|
147
164
|
1. **Pre-flight scan:** Before shipping changes or merging a branch, run `npx launch-doctor` in your workspace.
|
|
@@ -155,20 +172,25 @@ flowchart LR
|
|
|
155
172
|
|
|
156
173
|
| Category | What it catches | Severity range |
|
|
157
174
|
|---|---|---|
|
|
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
|
-
|
|
|
175
|
+
| 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 |
|
|
176
|
+
| Database & backups (`database`) | Supabase tables without Row Level Security; policies that let anyone write (`using (true)`); write policies open to any signed-in user; read policies that let any signed-in user read every row (`for select to authenticated using (true)`); public Supabase Storage buckets (in SQL migrations, `supabase/config.toml` or `createBucket`) whose names suggest private files, and storage policies that let signed-out visitors upload, replace or delete files; 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 |
|
|
177
|
+
| Access control (`access`) | Next.js Server Actions and API routes (Next.js, Express, tRPC, FastAPI, Flask, Django) that change data without checking who is calling, in apps that have accounts; signed-in handlers that load or change a record by an id from the request with no owner filter, owner comparison, permission helper or admin check (an IDOR); roles or plans read from Supabase `user_metadata` or Clerk `unsafeMetadata`, which users can edit; whole request bodies saved to the database (mass assignment) and DRF serializers with `fields = "__all__"`; admin checks that only exist in browser code; JWTs decoded without verifying, or the `none` algorithm; `supabase.auth.getSession()` trusted in server code | Warning to critical |
|
|
178
|
+
| 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
179
|
| 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
180
|
| 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 |
|
|
181
|
+
| 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 |
|
|
182
|
+
| 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 |
|
|
183
|
+
| 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
184
|
|
|
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,
|
|
185
|
+
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.
|
|
186
|
+
|
|
187
|
+
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
188
|
|
|
169
189
|
## Live site scan
|
|
170
190
|
|
|
171
|
-
`npx launch-doctor scan https://myapp.com` checks your deployed site the
|
|
191
|
+
`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.
|
|
192
|
+
|
|
193
|
+
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
194
|
|
|
173
195
|
| Category | What it catches | Severity range |
|
|
174
196
|
|---|---|---|
|
|
@@ -184,7 +206,7 @@ The report uses the same grades and `--json`, `--ci`, `--fail-on`, `--out` and `
|
|
|
184
206
|
- Any critical finding caps the category at 39, which is an F.
|
|
185
207
|
- Without a critical finding the score never drops below 40, so warnings alone cannot produce an F.
|
|
186
208
|
- **Overall score** is the weighted average of the categories that ran:
|
|
187
|
-
- Weights: secrets (3), database (3), payments (3), costs (2), email (1), monitoring (1), legal (1), and first impressions (1).
|
|
209
|
+
- Weights: secrets (3), database (3), access control (3), payments (3), costs (2), email (1), monitoring (1), legal (1), and first impressions (1).
|
|
188
210
|
- Categories that do not apply, or are skipped with `--only` / `--skip`, are excluded.
|
|
189
211
|
- **Caps on the overall score:**
|
|
190
212
|
- Any critical finding anywhere caps the overall score at 39 (F).
|
|
@@ -196,8 +218,10 @@ The report uses the same grades and `--json`, `--ci`, `--fail-on`, `--out` and `
|
|
|
196
218
|
|
|
197
219
|
```
|
|
198
220
|
npx launch-doctor [folder] [options]
|
|
199
|
-
npx launch-doctor init [folder]
|
|
221
|
+
npx launch-doctor init [folder] [--hooks]
|
|
200
222
|
npx launch-doctor scan <url> [options]
|
|
223
|
+
npx launch-doctor mcp
|
|
224
|
+
npx launch-doctor hook <claude|cursor>
|
|
201
225
|
```
|
|
202
226
|
|
|
203
227
|
| Flag | Default | Description |
|
|
@@ -208,6 +232,7 @@ npx launch-doctor scan <url> [options]
|
|
|
208
232
|
| `--no-file` | off | Don't write the fix prompts file |
|
|
209
233
|
| `--json` | off | Print the full report as JSON (no fix file unless `--out` is given) |
|
|
210
234
|
| `--sarif <file>` | off | Also write a SARIF 2.1.0 file for GitHub code scanning |
|
|
235
|
+
| `--pr-comment` | off | On a GitHub pull request, post a summary comment and inline fix prompts (see [Pull request comments](#pull-request-comments)) |
|
|
211
236
|
| `--offline` | off | Skip network checks (email DNS) |
|
|
212
237
|
| `--ci` | off | Exit with code 1 on findings at or above `--fail-on` (no fix file unless `--out`) |
|
|
213
238
|
| `--fail-on <level>` | `critical` | With `--ci`, the lowest severity that fails: `critical` or `warning` |
|
|
@@ -217,14 +242,20 @@ npx launch-doctor scan <url> [options]
|
|
|
217
242
|
| `--history-depth <n>` | `500` | How many commits `--history` reads |
|
|
218
243
|
| `--update-baseline` | off | Save today's findings to `.launchdoctor-baseline.json` as accepted |
|
|
219
244
|
| `--no-baseline` | off | Ignore `.launchdoctor-baseline.json` and show every finding |
|
|
245
|
+
| `--config-from <ref>` | off | Read `.launchdoctorignore` and `.launchdoctor-baseline.json` from this git ref (branch, tag or commit) instead of the folder, and ignore inline `launch-doctor-ignore` comments on lines changed since that ref. The GitHub Action passes the pull request's base commit |
|
|
246
|
+
| `--changed` | off | Only report on files changed since the last commit (edited, staged or new). Fast, for hooks. See [Hooks and fast mode](#hooks-and-fast-mode) |
|
|
247
|
+
| `--staged` | off | Only report on files staged for the next commit. For a pre-commit hook |
|
|
220
248
|
| `--demo` | off | Scan a built-in sample app full of mistakes |
|
|
221
249
|
| `-h`, `--help` | | Show help |
|
|
222
250
|
| `-v`, `--version` | | Show the version |
|
|
223
251
|
| `init [folder]` | `.` | Create `.launchdoctorignore` and `.github/workflows/launch-doctor.yml` (never overwrites) |
|
|
252
|
+
| `init --hooks` | `.` | Set up the Claude Code, Cursor and git pre-commit hooks (merges into existing files, never overwrites) |
|
|
253
|
+
| `hook <claude|cursor>` | | What the Claude Code and Cursor hooks run. Reads the tool's JSON from stdin; you don't run it yourself |
|
|
224
254
|
| `scan <url>` | | Check your deployed site from the outside (see [Live site scan](#live-site-scan)) |
|
|
255
|
+
| `mcp` | | Start an MCP server so AI coding tools can run checks themselves (see [MCP server](#mcp-server)) |
|
|
225
256
|
| `--no-db` | off | With `scan`, don't test Supabase tables with the public key found in the page |
|
|
226
257
|
|
|
227
|
-
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.
|
|
258
|
+
Category ids for `--only` and `--skip`: `secrets`, `database`, `access`, `payments`, `costs`, `email`, `monitoring`, `legal`, `first-impressions`. Skipped categories show as "skipped" and don't count toward the grade.
|
|
228
259
|
|
|
229
260
|
**Exit codes**
|
|
230
261
|
|
|
@@ -248,7 +279,7 @@ scripts/seed.ts
|
|
|
248
279
|
**/*.fixture.ts
|
|
249
280
|
```
|
|
250
281
|
|
|
251
|
-
A plain word without path characters represents a finding id. Anything containing `/`, `*`, or `.`, or matching an existing file or folder on disk, is treated as a path pattern. Finding ids that do not correspond to any known check produce a warning to catch typos.
|
|
282
|
+
A plain word without path characters represents a finding id. Anything containing `/`, `*`, or `.`, or matching an existing file or folder on disk, is treated as a path pattern. Finding ids that do not correspond to any known check produce a warning to catch typos. Only the first 1,000 entries are used; if the file has more, the report says how many were skipped (and `--json` has `ignoreLinesSkipped`). The file is read only when it is a regular file in the project, not a symlink.
|
|
252
283
|
|
|
253
284
|
### Inline ignores
|
|
254
285
|
|
|
@@ -285,8 +316,8 @@ jobs:
|
|
|
285
316
|
check:
|
|
286
317
|
runs-on: ubuntu-latest
|
|
287
318
|
steps:
|
|
288
|
-
- uses: actions/checkout@
|
|
289
|
-
- uses: actions/setup-node@
|
|
319
|
+
- uses: actions/checkout@v7
|
|
320
|
+
- uses: actions/setup-node@v7
|
|
290
321
|
with:
|
|
291
322
|
node-version: 22
|
|
292
323
|
- run: npx launch-doctor --ci
|
|
@@ -294,6 +325,7 @@ jobs:
|
|
|
294
325
|
|
|
295
326
|
- **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
327
|
- **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`.
|
|
328
|
+
- **Step outputs:** When `GITHUB_OUTPUT` is set, the `grade`, `score`, `critical` and `warnings` values are saved as step outputs.
|
|
297
329
|
- **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
330
|
|
|
299
331
|
```yaml
|
|
@@ -309,6 +341,41 @@ jobs:
|
|
|
309
341
|
sarif_file: launch-doctor.sarif
|
|
310
342
|
```
|
|
311
343
|
|
|
344
|
+
### Pull request comments
|
|
345
|
+
|
|
346
|
+
The Launch Doctor GitHub Action reviews each pull request like a teammate would:
|
|
347
|
+
|
|
348
|
+
- **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.
|
|
349
|
+
- **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.
|
|
350
|
+
- 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).
|
|
351
|
+
- `.launchdoctorignore` and `.launchdoctor-baseline.json` are read from the base branch (with `--config-from`), not from the pull request, so a pull request can't silence its own findings by adding lines to them. An ignore or baseline change takes effect once it is merged. Inline `launch-doctor-ignore` comments on lines the pull request adds or changes are ignored too (so are all comments in files it adds); comments that were already on the base branch keep working, even if the pull request moves them down the file. To accept a finding, merge the comment (or the ignore line) first.
|
|
352
|
+
|
|
353
|
+
```yaml
|
|
354
|
+
name: Launch Doctor
|
|
355
|
+
on: [pull_request]
|
|
356
|
+
permissions:
|
|
357
|
+
contents: read
|
|
358
|
+
pull-requests: write
|
|
359
|
+
jobs:
|
|
360
|
+
check:
|
|
361
|
+
runs-on: ubuntu-latest
|
|
362
|
+
steps:
|
|
363
|
+
- uses: actions/checkout@v7
|
|
364
|
+
- uses: SHARAJ379/Launch-Doctor@v0
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
| Input | Default | Description |
|
|
368
|
+
|---|---|---|
|
|
369
|
+
| `path` | `.` | Folder to check, relative to the repository root |
|
|
370
|
+
| `fail-on` | `critical` | Lowest severity that fails the check: `critical`, `warning` or `never` |
|
|
371
|
+
| `comment` | `true` | Post the summary and inline comments on pull requests |
|
|
372
|
+
| `args` | | Extra options, for example `--offline --skip legal` |
|
|
373
|
+
| `github-token` | `${{ github.token }}` | Token used for the comments |
|
|
374
|
+
|
|
375
|
+
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.
|
|
376
|
+
|
|
377
|
+
Using the CLI directly instead? Add `--pr-comment` and pass the token: `npx launch-doctor --ci --pr-comment` with `env: GITHUB_TOKEN: ${{ github.token }}`.
|
|
378
|
+
|
|
312
379
|
## Using with AI coding tools
|
|
313
380
|
|
|
314
381
|
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 +395,165 @@ Fix the issues in LAUNCH_FIXES.md one at a time, starting with the critical ones
|
|
|
328
395
|
4. Review and accept the code edit.
|
|
329
396
|
5. Re-run `npx launch-doctor` to observe your score improve.
|
|
330
397
|
|
|
398
|
+
### Hooks and fast mode
|
|
399
|
+
|
|
400
|
+
An MCP tool only runs when the AI decides to call it. Hooks run every time, so problems are caught while the AI is still working on the file:
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
npx launch-doctor init --hooks
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
This sets up three things, merging into files you already have (it never replaces them, and a settings file that isn't valid JSON is left alone):
|
|
407
|
+
|
|
408
|
+
| Where | What it does |
|
|
409
|
+
|---|---|
|
|
410
|
+
| `.claude/settings.json` | A Claude Code `PostToolUse` hook. After Claude writes or edits a file, Launch Doctor checks that one file. If it finds a problem, Claude gets the problem and the fix prompt straight away (exit code 2), so it can fix it in the same turn. |
|
|
411
|
+
| `.cursor/hooks.json` | A Cursor `stop` hook. When the agent finishes, Launch Doctor checks the files changed since the last commit and, if it finds problems, sends them back to the agent as a follow-up message. (Cursor's `afterFileEdit` hook is not used: its documentation doesn't say that its output reaches the agent.) |
|
|
412
|
+
| `.git/hooks/pre-commit` (or wherever `core.hooksPath` points) | Checks the staged files before each commit. Only critical problems stop the commit; it prints nothing when all is well. Skip it once with `git commit --no-verify`. If the tool itself fails (for example npx can't reach npm), you see the error and the commit goes ahead. An existing shell hook keeps its content and the check is added at the top; a hook written in another language is left alone. |
|
|
413
|
+
|
|
414
|
+
The hooks run `npx --yes "launch-doctor@^X.Y.0"`, pinned to the minor version that wrote them (for example `launch-doctor@^0.4.0`), so a hook never silently starts running a newer minor or major release. npx uses your installed copy if it matches, and otherwise downloads it from npm the first time. To move to a newer version, edit the version in the hook files or delete the Launch Doctor entries and run `init --hooks` again. Everything else stays local.
|
|
415
|
+
|
|
416
|
+
**`--changed` and `--staged`** are the fast mode the hooks use. You can run them yourself too:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
npx launch-doctor --changed # edited, staged and new files since the last commit
|
|
420
|
+
npx launch-doctor --staged --ci # what the next commit will contain; exit code 1 on critical problems
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
The whole project is still read, so checks that look across files (is there a middleware, does this route check who is calling) keep working. Then only findings *in the changed files* are reported. The email DNS lookups are skipped, `LAUNCH_FIXES.md` is not written (unless you pass `--out`), and the report says that it covers only some files. The grade is for those files, not for the project. `--changed` and `--staged` can't be combined with `--update-baseline`, `--pr-comment` or `--history`.
|
|
424
|
+
|
|
425
|
+
**What fast mode can miss compared with a full scan:**
|
|
426
|
+
- Problems with no single file: no error tracking, no privacy policy, no rate limiting, a missing `.env` entry in `.gitignore`, and the "check yourself" list.
|
|
427
|
+
- Problems that appear in a file you didn't touch because of a change elsewhere. If you delete the middleware that protected your API routes, the routes are reported as unprotected only when they are in the changed set.
|
|
428
|
+
- The Claude Code hook checks one file at a time, so it won't mention an older problem in another file.
|
|
429
|
+
- `--staged` reads the files as they are on disk. If you staged only part of a file (`git add -p`), the unstaged part is checked too.
|
|
430
|
+
- Deleted files are not checked, and files git ignores are not reported.
|
|
431
|
+
|
|
432
|
+
Run a full `npx launch-doctor` before you launch, and keep `--ci` on pull requests (see [CI integration](#ci-integration)).
|
|
433
|
+
|
|
434
|
+
### MCP server
|
|
435
|
+
|
|
436
|
+
`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.
|
|
437
|
+
|
|
438
|
+
**Claude Code:**
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
claude mcp add launch-doctor -- npx -y launch-doctor mcp
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**Cursor** (`.cursor/mcp.json`) and other tools that use the same format:
|
|
445
|
+
|
|
446
|
+
```json
|
|
447
|
+
{
|
|
448
|
+
"mcpServers": {
|
|
449
|
+
"launch-doctor": { "command": "npx", "args": ["-y", "launch-doctor", "mcp"] }
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
Then ask: *"Run Launch Doctor on this project and fix the critical findings one at a time."*
|
|
455
|
+
|
|
456
|
+
| Tool | What it does |
|
|
457
|
+
|---|---|
|
|
458
|
+
| `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`. |
|
|
459
|
+
| `scan_url` | Checks a deployed site from the outside, like `launch-doctor scan <url>`. Options: `url`, `skipDatabase`. |
|
|
460
|
+
| `list_checks` | Lists the categories and every finding id, for `only`, `skip` and `.launchdoctorignore`. |
|
|
461
|
+
|
|
462
|
+
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.
|
|
463
|
+
|
|
331
464
|
## Privacy and network use
|
|
332
465
|
|
|
333
466
|
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
467
|
|
|
335
468
|
- **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
|
|
469
|
+
- **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. When the address you give is a public site, the scan never sends a request to a private or local network address (your router, the cloud metadata address, `localhost`), even if the page or a redirect points there; you can still scan your own dev server by giving its address. See [SECURITY.md](SECURITY.md) for the details and one known gap.
|
|
470
|
+
- **No telemetry:** Launch Doctor does not collect usage data or phone home.
|
|
337
471
|
- **Git history analysis (`--history`):** Runs local `git log` commands directly on your system without network requests.
|
|
472
|
+
- **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.
|
|
473
|
+
- **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`, which only accepts public sites.
|
|
474
|
+
- **Hooks (`init --hooks`):** the hooks themselves make no network requests beyond `npx --yes "launch-doctor@^X.Y.0"`, which downloads the package from the npm registry the first time if it isn't installed. `--changed` and `--staged` skip the email DNS lookups.
|
|
338
475
|
- **Package installation:** standard `npx` retrieval via the npm registry.
|
|
339
476
|
|
|
340
|
-
##
|
|
477
|
+
## What it cannot do
|
|
341
478
|
|
|
342
|
-
Launch Doctor
|
|
479
|
+
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.
|
|
343
480
|
|
|
344
|
-
|
|
345
|
-
-
|
|
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.
|
|
481
|
+
**Fast mode and hooks check less than a full scan**
|
|
482
|
+
- `--changed`, `--staged` and the hooks report only on the files that changed, so project-wide problems and anything caused by a change in another file are missed. See [Hooks and fast mode](#hooks-and-fast-mode) for the list. They are a safety net while you work, not a replacement for a full run before launch.
|
|
348
483
|
|
|
349
|
-
|
|
484
|
+
**It doesn't see your running app or your production settings**
|
|
485
|
+
- 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.
|
|
486
|
+
- 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). The same goes for Storage buckets made public in the dashboard: you get a checklist item to review them.
|
|
487
|
+
- 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.
|
|
488
|
+
|
|
489
|
+
**It doesn't do a full security review**
|
|
490
|
+
- Its authorization checks (the `access` category) look for specific, common patterns, not every way access control can fail. They follow one handler at a time: a sign-in check, an owner filter or a permission check done somewhere they can't see (a shared data-access layer, a database rule set up in a dashboard, an ORM extension) is invisible to them, so they may raise a false alarm. Endpoints that are meant to be public (sign-in, webhooks, `subscribe`, `contact_submit`, `newsletter_signup`, `join_waitlist` and similar forms) are skipped by name or URL, but only when the name is the action itself: `subscribers_delete`, `contacts_export` or `feedback_admin_list`, or anything else that also says delete, update, edit, export, list, admin, remove or all, is still checked. A handler that compares the wrong ids, checks the wrong role, or writes something harmless-looking next to the real query may pass. Express handlers are only analysed when they are written inside the `app.get(...)` / `router.post(...)` call; handlers defined in another file and registered by name are not followed. Sign-in middleware added with `app.use(...)` covers only the routes registered after it in the same file; middleware registered in another file is not tracked. A sign-in helper only counts when it appears in the code (an import alone doesn't count), but a call whose result is never checked still counts. Apart from that, the access-control rules it understands are Supabase RLS in SQL files, Firebase rules files, Appwrite permissions, and whether Convex functions check who is calling.
|
|
491
|
+
- It doesn't look for XSS, SQL injection, CSRF, SSRF or similar code-level vulnerabilities.
|
|
492
|
+
- It doesn't check your dependencies for known vulnerabilities. Use `npm audit`, `pip-audit` or Dependabot for that.
|
|
493
|
+
- It is not a penetration test, and its legal-page checks are reminders, not legal advice.
|
|
494
|
+
|
|
495
|
+
**It decides by patterns, so it can be wrong both ways**
|
|
496
|
+
- 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).
|
|
497
|
+
- Route analysis follows local imports 2 levels deep. Dynamic imports and unusual route shapes may not be followed.
|
|
498
|
+
- API-only backends can get legal-page warnings (privacy policy, terms) that may not apply to them.
|
|
499
|
+
- A folder with very little code (for example only a README) can get an A, because there was nothing to find.
|
|
500
|
+
|
|
501
|
+
**Coverage depends on your stack**
|
|
502
|
+
- **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.
|
|
503
|
+
- **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).
|
|
504
|
+
- **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.
|
|
505
|
+
- **Basic:** Ruby, PHP and Go are scanned for hard-coded secrets and a few patterns, but their frameworks and dependency files are not understood.
|
|
506
|
+
|
|
507
|
+
**It skips some files**
|
|
508
|
+
- `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`).
|
|
509
|
+
- Files over 1 MB, minified `.min.js` files, source maps and binary files.
|
|
510
|
+
- Everything after the first 20,000 files, or after 128 MB of text in total (the report says when either happens).
|
|
511
|
+
- Symlinks, FIFOs and other special files.
|
|
512
|
+
|
|
513
|
+
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.
|
|
514
|
+
|
|
515
|
+
## How it is tested
|
|
516
|
+
|
|
517
|
+
- 334 automated tests run on every change, on Windows, macOS and Linux, with Node.js 22 and 24.
|
|
518
|
+
- A stress-test harness (`scripts/stress/`, see [CONTRIBUTING.md](CONTRIBUTING.md#stress-tests)) runs Launch Doctor against hostile inputs: repositories whose git settings try to run programs, symlink loops and FIFOs, files built to make a regular expression backtrack, terminal escape sequences, hostile servers for `scan`, and MCP requests to private addresses. Before 0.4.0 it found 10 security problems; each is fixed and has a regression test, and the whole suite now passes on Windows and Linux.
|
|
519
|
+
- 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).
|
|
520
|
+
- 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.
|
|
521
|
+
- The access-control category (new in 0.4.0) has 49 tests of its own, covering each rule and the correct patterns it must accept. It was also run on eight public open-source apps: Vercel's AI Chatbot, Taxonomy, Vercel's Next.js Subscription Payments starter, Next.js SaaS Starter, BoxyHQ SaaS Starter Kit, Documenso, the FastAPI full-stack template and OWASP Juice Shop. That turned up false alarms with six causes: admin-only FastAPI routes, admin-only tRPC procedures, a cookie mistaken for a database write, ownership checked by an earlier query in the same handler, ownership left to a helper called with the user's id, and a browser token library in a frontend it doesn't recognise. Each cause was fixed and has a regression test. What remains is one finding on a FastAPI route that has no sign-in check but is only mounted in local development, and one on Juice Shop decoding a token to show the login time; both match what the code does. It did not find Juice Shop's deliberate basket IDOR, because those handlers are registered from another file. A code review before merging found ten more problems (findings it should have raised but didn't, Python findings pointing at the wrong line, and a passed line shown for apps where nothing was checked); each is fixed and has a test.
|
|
522
|
+
- A test set of 50 public open-source apps (Next.js, AI chat apps, Vite and React, SvelteKit, Remix, Express, FastAPI, Django, Flask, Firebase and a Stripe sample) is scanned whenever a rule changes, and the results are compared with a saved snapshot, so each change shows exactly which findings it added or removed. The apps are cloned at pinned commits by `scripts/corpus.mjs` and none of their code is stored in this repository (see [CONTRIBUTING.md](CONTRIBUTING.md#testing-against-real-apps)). The first run turned up 13 causes of false alarms, such as a committed `.env` that only held placeholders being called critical, Stripe webhooks verified in Python or Ruby being called unverified, and Supabase's public local-development keys being called leaked service keys. Each was fixed and has a regression test (`test/real-app-false-alarms.test.ts`). I read every critical finding and every access-control finding on those apps; the common project-wide warnings (no error tracking, no privacy policy and similar) were only spot-checked, so some false alarms in them may remain. Many of the apps are starters and samples that are not meant to be launched as they are, so a low grade for one of them is often right.
|
|
523
|
+
- Every bug fix gets a regression test, so the same mistake doesn't come back.
|
|
524
|
+
- 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.
|
|
525
|
+
|
|
526
|
+
## Found a wrong finding?
|
|
527
|
+
|
|
528
|
+
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.
|
|
529
|
+
|
|
530
|
+
Meanwhile you can silence a finding with `.launchdoctorignore` or an inline `launch-doctor-ignore` comment (see [Configuration](#configuration)).
|
|
350
531
|
|
|
351
532
|
## Roadmap
|
|
352
533
|
|
|
534
|
+
Planned work, in no fixed order and without dates:
|
|
535
|
+
|
|
353
536
|
- [x] Live URL inspection (`launch-doctor scan <url>`: exposed `.env`, source maps, security headers, open Supabase tables via anonymous key)
|
|
354
|
-
- [
|
|
355
|
-
- [
|
|
356
|
-
- [
|
|
357
|
-
- [
|
|
537
|
+
- [x] GitHub Action that posts a summary and inline fix prompts on pull requests ([Pull request comments](#pull-request-comments))
|
|
538
|
+
- [x] Model Context Protocol (MCP) server for direct Claude Code and Cursor integration ([MCP server](#mcp-server))
|
|
539
|
+
- [x] Extended provider coverage (Clerk, Convex, Appwrite, Lemon Squeezy, Paddle)
|
|
540
|
+
- [x] Mobile framework support (Expo, React Native)
|
|
541
|
+
|
|
542
|
+
## Using it as a library (experimental)
|
|
543
|
+
|
|
544
|
+
The package can also be imported. This API is **experimental**: the names and signatures below keep working through 0.5.0, and any change after that is announced in the changelog first.
|
|
545
|
+
|
|
546
|
+
```ts
|
|
547
|
+
import { runDoctor, renderReport, renderFixes } from 'launch-doctor';
|
|
548
|
+
|
|
549
|
+
const report = await runDoctor('./my-app', { offline: true });
|
|
550
|
+
console.log(report.grade, report.counts);
|
|
551
|
+
process.stdout.write(renderReport(report));
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
- `runDoctor(folder, options)` returns the same report as `--json`. The options include `offline`, `only`, `skip`, `onlyFiles`, `configFrom`, `history`, `baseline`, `maxFiles` and `maxBytes`.
|
|
555
|
+
- `renderReport(report)`, `renderFixes(report)` (the text of `LAUNCH_FIXES.md`), `renderPrComment(...)`, `postPrFeedback(...)` and `prContextFromEnv(...)` are the renderers the CLI and the GitHub Action use.
|
|
556
|
+
- `ProjectContext`, `CHECKS`, `CATEGORY_IDS()` and `isInlineIgnored()` give lower-level access, and the report types are exported too.
|
|
358
557
|
|
|
359
558
|
## Contributing
|
|
360
559
|
|
|
@@ -365,8 +564,9 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for local environment setup, architecture
|
|
|
365
564
|
Thanks to everyone who has helped build Launch Doctor. Contributors are listed here once their pull request is merged.
|
|
366
565
|
|
|
367
566
|
- [@SHARAJ379](https://github.com/SHARAJ379): creator and maintainer
|
|
567
|
+
- [@namaysingh3925](https://github.com/namaysingh3925): early development (many early commits were made from his machine)
|
|
368
568
|
|
|
369
|
-
Want to be on this list?
|
|
569
|
+
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
570
|
|
|
371
571
|
## Security
|
|
372
572
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ProjectContext, SourceFile } from './project.js';
|
|
2
|
+
/**
|
|
3
|
+
* The places where a request from the outside world runs code: Next.js Server Actions and route
|
|
4
|
+
* handlers, Express-style routes, tRPC procedures, and FastAPI / Flask / Django views.
|
|
5
|
+
* The access-control check looks at each one separately.
|
|
6
|
+
*/
|
|
7
|
+
export type UnitKind = 'action' | 'route' | 'express' | 'trpc' | 'python';
|
|
8
|
+
export interface Unit {
|
|
9
|
+
kind: UnitKind;
|
|
10
|
+
file: SourceFile;
|
|
11
|
+
/** Function name, or the procedure key for tRPC. Empty when it has none. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Upper-case HTTP method; 'ANY' when it can't be told (Django views, Pages Router default exports). */
|
|
14
|
+
method: string;
|
|
15
|
+
/** URL path when known ("/api/notes/:id"). */
|
|
16
|
+
urlPath: string | null;
|
|
17
|
+
/** The parameter list, without the parentheses. */
|
|
18
|
+
params: string;
|
|
19
|
+
/** Source text of the whole function (comments blanked out). */
|
|
20
|
+
text: string;
|
|
21
|
+
/** Index of `text` in the file. */
|
|
22
|
+
start: number;
|
|
23
|
+
line: number;
|
|
24
|
+
/** True when the parameters come straight from the caller (Server Action arguments, tRPC input, Python view arguments). */
|
|
25
|
+
paramsFromCaller: boolean;
|
|
26
|
+
/** A sign-in check that sits outside the body: a wrapper, route middleware, a protected procedure, a decorator. */
|
|
27
|
+
authOutside: boolean;
|
|
28
|
+
/** Only admins can reach it (an admin wrapper, middleware, procedure or dependency), so it may touch anyone's records. */
|
|
29
|
+
adminOnly: boolean;
|
|
30
|
+
/** Code of local modules this function reaches through imports. */
|
|
31
|
+
reachedCode: string;
|
|
32
|
+
/** Code of the same file outside every unit (helpers defined next to it). */
|
|
33
|
+
shared: string;
|
|
34
|
+
}
|
|
35
|
+
/** A whole file of Server Actions: "use server" is its first statement. */
|
|
36
|
+
export declare const FILE_USE_SERVER: RegExp;
|
|
37
|
+
/**
|
|
38
|
+
* The body of a function whose parameter list opens at `paren`: skips a return type annotation
|
|
39
|
+
* (`: Promise<{ ok: boolean }>`) and an arrow. Returns [start, end) of the body, or null.
|
|
40
|
+
*/
|
|
41
|
+
export declare function bodyAfterParams(code: string, paren: number): {
|
|
42
|
+
start: number;
|
|
43
|
+
end: number;
|
|
44
|
+
} | null;
|
|
45
|
+
/** Decorators and parameters that sign the caller in. */
|
|
46
|
+
export declare const PY_AUTH_DECORATOR: RegExp;
|
|
47
|
+
/**
|
|
48
|
+
* Every request entry point in server code.
|
|
49
|
+
* `isServer` says which files run on the server; `projectPythonAuth` is true when sign-in is enforced
|
|
50
|
+
* for every Python view project-wide (Django's LoginRequiredMiddleware, a FastAPI router included with dependencies).
|
|
51
|
+
*/
|
|
52
|
+
export declare function findUnits(ctx: ProjectContext, isServer: (f: SourceFile) => boolean, isRoute: (f: SourceFile) => boolean, projectPythonAuth: boolean): Unit[];
|