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
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { uniqueBy } from '../util.js';
|
|
2
2
|
import { appCode, at, emptyOutput, isRouteLike, notApplicable, serverCode, where } from './common.js';
|
|
3
3
|
const OTHER_PROVIDERS = {
|
|
4
|
-
'@lemonsqueezy/lemonsqueezy.js': 'Lemon Squeezy',
|
|
5
|
-
'@paddle/paddle-node-sdk': 'Paddle',
|
|
6
|
-
'@paddle/paddle-js': 'Paddle',
|
|
7
4
|
'@polar-sh/sdk': 'Polar',
|
|
8
5
|
dodopayments: 'Dodo Payments',
|
|
9
6
|
'@paypal/paypal-js': 'PayPal',
|
|
@@ -37,6 +34,121 @@ function unverifiedFinding(loc) {
|
|
|
37
34
|
};
|
|
38
35
|
}
|
|
39
36
|
const GLOBAL_JSON_PARSER = /\.use\s*\(\s*(?:["'`][^"'`]*["'`]\s*,\s*)?(?:express|bodyParser)\.json\s*\(/;
|
|
37
|
+
/**
|
|
38
|
+
* Is a webhook verified? Yes when its code runs the check itself, or calls a helper that does
|
|
39
|
+
* (an exported function in a non-route file, like lib/webhooks.ts).
|
|
40
|
+
*/
|
|
41
|
+
function verifier(ctx, server, verifyRe) {
|
|
42
|
+
const verified = ctx.findCode(verifyRe, server);
|
|
43
|
+
const names = new Set();
|
|
44
|
+
const helperFiles = uniqueBy(verified, (m) => m.file.path)
|
|
45
|
+
.map((m) => m.file)
|
|
46
|
+
.filter((f) => !isRouteLike(f));
|
|
47
|
+
for (const f of helperFiles) {
|
|
48
|
+
for (const h of ctx.codeOf(f).matchAll(/export\s+(?:async\s+)?function\s+(\w+)|export\s+const\s+(\w+)\s*=/g)) {
|
|
49
|
+
names.add((h[1] ?? h[2]));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const helperRe = names.size ? new RegExp(`\\b(?:${[...names].join('|')})\\s*\\(`) : null;
|
|
53
|
+
return {
|
|
54
|
+
matches: verified,
|
|
55
|
+
test: (content) => verifyRe.test(content) || (helperRe?.test(content) ?? false),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** The signature covers the exact raw text, so verifying JSON.stringify(parsedBody) fails for real webhooks. */
|
|
59
|
+
const SIGNS_PARSED_JSON = /(?:\.update|unmarshal|isSignatureValid)\s*\(\s*JSON\.stringify\s*\(/;
|
|
60
|
+
const LEMON_EVENTS_RE = /\b(?:order_(?:created|refunded)|subscription_(?:created|updated|cancelled|resumed|expired|paused|unpaused|payment_(?:success|failed|recovered|refunded))|license_key_(?:created|updated))\b|meta\.event_name/;
|
|
61
|
+
const LEMON_SQUEEZY = {
|
|
62
|
+
name: 'Lemon Squeezy',
|
|
63
|
+
prefix: 'lemonsqueezy',
|
|
64
|
+
isWebhookCode: (c) => LEMON_EVENTS_RE.test(c) || (/x-signature/i.test(c) && /lemon[\s_-]?squeezy/i.test(c)),
|
|
65
|
+
locate: new RegExp(`${LEMON_EVENTS_RE.source}|x-signature`, 'i'),
|
|
66
|
+
verify: /createHmac\s*\(\s*["'`]sha256["'`]|crypto\.subtle\.(?:verify|sign)\s*\(/,
|
|
67
|
+
unverifiedFix: (loc) => `My Lemon Squeezy webhook handler (${where(loc)}) does not check the X-Signature header. Please update it to:\n` +
|
|
68
|
+
`1. Read the raw request body as text (not parsed JSON).\n` +
|
|
69
|
+
`2. Compute an HMAC-SHA256 hex digest of that raw body with process.env.LEMONSQUEEZY_WEBHOOK_SECRET.\n` +
|
|
70
|
+
`3. Compare it with the X-Signature header using crypto.timingSafeEqual, and return 401 if they differ.\n` +
|
|
71
|
+
`4. Only then handle the event (meta.event_name), and make it safe if the same event arrives twice.\n` +
|
|
72
|
+
`Tell me where to set the signing secret (Lemon Squeezy → Settings → Webhooks) and how to send a test event.`,
|
|
73
|
+
parsedFix: (loc) => `In ${where(loc)} my Lemon Squeezy webhook computes its signature over JSON.stringify of the parsed body. The signature is made over the exact raw text, so real webhooks fail the check. ` +
|
|
74
|
+
`Please read the raw body with "await request.text()" (or express.raw on this route), compute the HMAC-SHA256 of that text with LEMONSQUEEZY_WEBHOOK_SECRET, compare it with X-Signature using timingSafeEqual, and only parse the JSON afterwards.`,
|
|
75
|
+
noWebhookFix: `My app sells through Lemon Squeezy but has no webhook. Please add a webhook endpoint that: reads the raw body and checks the X-Signature header (an HMAC-SHA256 of the raw body with LEMONSQUEEZY_WEBHOOK_SECRET, compared with timingSafeEqual); ` +
|
|
76
|
+
`handles order_created (give the customer access), subscription_updated, subscription_cancelled and subscription_expired (change or remove access) and subscription_payment_failed; ` +
|
|
77
|
+
`and is safe if the same event arrives twice. Move any "unlock the feature" logic from the thank-you page into this webhook. Explain how to register it in Lemon Squeezy → Settings → Webhooks.`,
|
|
78
|
+
};
|
|
79
|
+
const PADDLE_EVENTS_RE = /paddle-signature|webhooks\.unmarshal|isSignatureValid|EventName\.\w+|\b(?:transaction|subscription|customer|adjustment)\.(?:completed|paid|created|updated|canceled|activated|past_due|payment_failed|trialing|resumed|paused)\b/i;
|
|
80
|
+
const PADDLE = {
|
|
81
|
+
name: 'Paddle',
|
|
82
|
+
prefix: 'paddle',
|
|
83
|
+
isWebhookCode: (c, path) => PADDLE_EVENTS_RE.test(c) && (/paddle/i.test(c) || /paddle/i.test(path)),
|
|
84
|
+
locate: PADDLE_EVENTS_RE,
|
|
85
|
+
verify: /webhooks\.unmarshal\s*\(|\.isSignatureValid\s*\(|createHmac\s*\(\s*["'`]sha256["'`]|crypto\.subtle\.(?:verify|sign)\s*\(/,
|
|
86
|
+
unverifiedFix: (loc) => `My Paddle webhook handler (${where(loc)}) does not check the Paddle-Signature header. Please update it to:\n` +
|
|
87
|
+
`1. Read the raw request body as text (not parsed JSON).\n` +
|
|
88
|
+
`2. Verify it with paddle.webhooks.unmarshal(rawBody, process.env.PADDLE_WEBHOOK_SECRET, signature) from @paddle/paddle-node-sdk, where signature is the "paddle-signature" header.\n` +
|
|
89
|
+
`3. Return 400 if verification fails, and only handle the event after it passes.\n` +
|
|
90
|
+
`4. Make the handler safe if Paddle sends the same event twice (check the event id or whether the order was already processed).\n` +
|
|
91
|
+
`Tell me where to find the webhook secret key (Paddle → Developer tools → Notifications) and how to send a test event.`,
|
|
92
|
+
parsedFix: (loc) => `In ${where(loc)} my Paddle webhook verifies the signature over JSON.stringify of the parsed body. Paddle signs the exact raw text, so real webhooks fail the check. ` +
|
|
93
|
+
`Please read the raw body with "await request.text()" (or express.raw on this route), pass that text to paddle.webhooks.unmarshal with the paddle-signature header and PADDLE_WEBHOOK_SECRET, and use the event it returns.`,
|
|
94
|
+
noWebhookFix: `My app takes payments with Paddle but has no webhook. Please add a webhook endpoint that: verifies the paddle-signature header with paddle.webhooks.unmarshal(rawBody, PADDLE_WEBHOOK_SECRET, signature); ` +
|
|
95
|
+
`handles transaction.completed (give the customer access), subscription.updated and subscription.canceled (change or remove access) and transaction.payment_failed; ` +
|
|
96
|
+
`and is safe if the same event arrives twice. Move any "unlock the feature" logic from the success page into this webhook. Explain how to add a notification destination in Paddle → Developer tools → Notifications.`,
|
|
97
|
+
};
|
|
98
|
+
/** Signature checks for Lemon Squeezy and Paddle webhooks, the same way as for Stripe. */
|
|
99
|
+
function checkWebhooks(ctx, out, server, p) {
|
|
100
|
+
const hints = ctx.files.filter((f) => server(f) && p.isWebhookCode(ctx.codeOf(f), f.path));
|
|
101
|
+
const routes = hints.filter((f) => isRouteLike(f) && READS_BODY.test(f.content));
|
|
102
|
+
const v = verifier(ctx, server, p.verify);
|
|
103
|
+
/** The first line in a file that matches, or just the file. */
|
|
104
|
+
const pointAt = (file, re) => {
|
|
105
|
+
const m = ctx.findCode(re, (x) => x.path === file.path, 1)[0];
|
|
106
|
+
return m ? at(m) : { file: file.path };
|
|
107
|
+
};
|
|
108
|
+
const unverified = (loc) => ({
|
|
109
|
+
id: `${p.prefix}-webhook-unverified`,
|
|
110
|
+
severity: 'critical',
|
|
111
|
+
title: `Your ${p.name} webhook doesn't check that messages really come from ${p.name}`,
|
|
112
|
+
why: `Anyone can send a fake "payment succeeded" message to your webhook URL and get your product for free. ${p.name} signs every webhook; your code has to check that signature.`,
|
|
113
|
+
location: loc,
|
|
114
|
+
fixPrompt: p.unverifiedFix(loc),
|
|
115
|
+
});
|
|
116
|
+
const parsed = (loc) => ({
|
|
117
|
+
id: `${p.prefix}-webhook-parsed-body`,
|
|
118
|
+
severity: 'warning',
|
|
119
|
+
title: `${p.name} webhook checks the signature of re-encoded JSON instead of the raw body`,
|
|
120
|
+
why: `${p.name} signs the exact text it sends. JSON.stringify of the parsed body is never quite the same text, so every real webhook fails the check: customers pay, but your app never finds out.`,
|
|
121
|
+
location: loc,
|
|
122
|
+
fixPrompt: p.parsedFix(loc),
|
|
123
|
+
});
|
|
124
|
+
if (routes.length) {
|
|
125
|
+
const bad = routes.filter((f) => !v.test(ctx.codeOf(f)));
|
|
126
|
+
for (const f of bad)
|
|
127
|
+
out.findings.push(unverified(pointAt(f, p.locate)));
|
|
128
|
+
for (const f of routes) {
|
|
129
|
+
if (!bad.includes(f) && SIGNS_PARSED_JSON.test(ctx.codeOf(f))) {
|
|
130
|
+
out.findings.push(parsed(pointAt(f, SIGNS_PARSED_JSON)));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (!bad.length)
|
|
134
|
+
out.passed.push(`${p.name} webhooks check the signature, so fake payment messages are rejected`);
|
|
135
|
+
}
|
|
136
|
+
else if (v.matches.length && hints.length) {
|
|
137
|
+
out.passed.push(`${p.name} webhooks check the signature, so fake payment messages are rejected`);
|
|
138
|
+
}
|
|
139
|
+
else if (hints.length) {
|
|
140
|
+
out.findings.push(unverified(pointAt(hints[0], p.locate)));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
out.findings.push({
|
|
144
|
+
id: `${p.prefix}-no-webhook`,
|
|
145
|
+
severity: 'warning',
|
|
146
|
+
title: `No ${p.name} webhook found`,
|
|
147
|
+
why: `If you unlock features from the "thank you" page, customers who close the tab after paying get nothing, and people who cancel or whose card fails keep access. Webhooks tell your server what really happened.`,
|
|
148
|
+
fixPrompt: p.noWebhookFix,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
40
152
|
function parsedBodyFinding(loc, globalParser = false) {
|
|
41
153
|
return {
|
|
42
154
|
id: 'stripe-webhook-parsed-body',
|
|
@@ -64,6 +176,12 @@ export const paymentsCheck = {
|
|
|
64
176
|
'stripe-webhook-parsed-body',
|
|
65
177
|
'stripe-no-webhook',
|
|
66
178
|
'razorpay-unverified',
|
|
179
|
+
'lemonsqueezy-webhook-unverified',
|
|
180
|
+
'lemonsqueezy-webhook-parsed-body',
|
|
181
|
+
'lemonsqueezy-no-webhook',
|
|
182
|
+
'paddle-webhook-unverified',
|
|
183
|
+
'paddle-webhook-parsed-body',
|
|
184
|
+
'paddle-no-webhook',
|
|
67
185
|
'other-provider-webhooks',
|
|
68
186
|
'live-test-purchase',
|
|
69
187
|
'failed-and-cancelled',
|
|
@@ -74,12 +192,16 @@ export const paymentsCheck = {
|
|
|
74
192
|
const stripeClient = ctx.usesAny(['@stripe/stripe-js', '@stripe/react-stripe-js']);
|
|
75
193
|
const stripeLinks = ctx.find(/https:\/\/buy\.stripe\.com\//, appCode, 1).length > 0;
|
|
76
194
|
const razorpay = ctx.uses('razorpay') || ctx.find(/checkout\.razorpay\.com/, appCode, 1).length > 0;
|
|
195
|
+
const lemon = ctx.uses('@lemonsqueezy/lemonsqueezy.js') ||
|
|
196
|
+
ctx.find(/\.lemonsqueezy\.com\/(?:checkout|buy)\/|api\.lemonsqueezy\.com/, appCode, 1).length > 0;
|
|
197
|
+
const paddle = ctx.usesAny(['@paddle/paddle-node-sdk', '@paddle/paddle-js']) ||
|
|
198
|
+
ctx.find(/cdn\.paddle\.com\/paddle\//, appCode, 1).length > 0;
|
|
77
199
|
const others = [
|
|
78
200
|
...new Set(Object.entries(OTHER_PROVIDERS)
|
|
79
201
|
.filter(([pkg]) => ctx.uses(pkg))
|
|
80
202
|
.map(([, name]) => name)),
|
|
81
203
|
];
|
|
82
|
-
if (!stripeServer && !stripeClient && !stripeLinks && !razorpay && !others.length) {
|
|
204
|
+
if (!stripeServer && !stripeClient && !stripeLinks && !razorpay && !lemon && !paddle && !others.length) {
|
|
83
205
|
return notApplicable('No payment provider found');
|
|
84
206
|
}
|
|
85
207
|
const out = emptyOutput();
|
|
@@ -167,6 +289,11 @@ export const paymentsCheck = {
|
|
|
167
289
|
});
|
|
168
290
|
}
|
|
169
291
|
}
|
|
292
|
+
// ---- Lemon Squeezy and Paddle ----
|
|
293
|
+
if (lemon)
|
|
294
|
+
checkWebhooks(ctx, out, server, LEMON_SQUEEZY);
|
|
295
|
+
if (paddle)
|
|
296
|
+
checkWebhooks(ctx, out, server, PADDLE);
|
|
170
297
|
if (others.length) {
|
|
171
298
|
out.manual.push({
|
|
172
299
|
id: 'other-provider-webhooks',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isCodeFile, isEnvPath, isRealEnvPath } from '../project.js';
|
|
2
|
-
import { decodeJwtPayload, looksLikePlaceholder, mask } from '../util.js';
|
|
2
|
+
import { decodeJwtPayload, lineTextAt, looksLikePlaceholder, mask } from '../util.js';
|
|
3
3
|
import { at, emptyOutput, where } from './common.js';
|
|
4
4
|
function looksRandom(value, kind) {
|
|
5
5
|
const hasDigit = /\d/.test(value);
|
|
@@ -132,7 +132,86 @@ const KEY_PATTERNS = [
|
|
|
132
132
|
envName: 'PRIVATE_KEY',
|
|
133
133
|
rotate: 'wherever this key was created (Google Cloud, Firebase, Apple, etc.)',
|
|
134
134
|
},
|
|
135
|
+
{
|
|
136
|
+
id: 'paddle-live-key',
|
|
137
|
+
name: 'Paddle live API key',
|
|
138
|
+
re: /\bpdl_live_apikey_[A-Za-z0-9_]{30,}/g,
|
|
139
|
+
severity: 'critical',
|
|
140
|
+
envName: 'PADDLE_API_KEY',
|
|
141
|
+
rotate: 'Paddle → Developer tools → Authentication → API keys',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 'paddle-sandbox-key',
|
|
145
|
+
name: 'Paddle sandbox API key',
|
|
146
|
+
re: /\bpdl_sdbx_apikey_[A-Za-z0-9_]{30,}/g,
|
|
147
|
+
severity: 'warning',
|
|
148
|
+
envName: 'PADDLE_API_KEY',
|
|
149
|
+
rotate: 'Paddle sandbox → Developer tools → Authentication → API keys',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: 'convex-deploy-key',
|
|
153
|
+
name: 'Convex deploy key',
|
|
154
|
+
re: /\b(?:prod|preview|dev):[a-z0-9]+(?:-[a-z0-9]+)*(?::[a-z0-9-]+)?\|[A-Za-z0-9+/=_-]{30,}/g,
|
|
155
|
+
severity: 'critical',
|
|
156
|
+
envName: 'CONVEX_DEPLOY_KEY',
|
|
157
|
+
rotate: 'Convex dashboard → your deployment → Settings → Deploy keys',
|
|
158
|
+
mustLookRandom: 'mixed',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
// Appwrite keys are long hex strings (newer ones start with "standard_"); passed to setKey() they are unmistakable.
|
|
162
|
+
id: 'appwrite-api-key',
|
|
163
|
+
name: 'Appwrite API key',
|
|
164
|
+
re: /(?<=\.setKey\(\s*["'`])(?:standard_)?[a-f0-9]{64,}(?=["'`])|\bstandard_[a-f0-9]{64,}/g,
|
|
165
|
+
severity: 'critical',
|
|
166
|
+
envName: 'APPWRITE_API_KEY',
|
|
167
|
+
rotate: 'Appwrite Console → your project → Overview → Integrations → API keys',
|
|
168
|
+
mustLookRandom: 'digits-letters',
|
|
169
|
+
},
|
|
135
170
|
];
|
|
171
|
+
/**
|
|
172
|
+
* Clerk secret keys use the same sk_live_ / sk_test_ prefixes as Stripe. A key is Clerk's when
|
|
173
|
+
* its line says so (CLERK_SECRET_KEY, clerkClient...) or when the app uses Clerk and not Stripe.
|
|
174
|
+
*/
|
|
175
|
+
const CLERK_KEYS = {
|
|
176
|
+
'stripe-live-key': {
|
|
177
|
+
id: 'clerk-secret-key',
|
|
178
|
+
name: 'Clerk secret key',
|
|
179
|
+
re: /\bsk_live_[0-9a-zA-Z]{20,}/g,
|
|
180
|
+
severity: 'critical',
|
|
181
|
+
envName: 'CLERK_SECRET_KEY',
|
|
182
|
+
rotate: 'Clerk Dashboard → API keys → Secret keys',
|
|
183
|
+
},
|
|
184
|
+
'stripe-test-key': {
|
|
185
|
+
id: 'clerk-test-secret-key',
|
|
186
|
+
name: 'Clerk development secret key',
|
|
187
|
+
re: /\bsk_test_[0-9a-zA-Z]{20,}/g,
|
|
188
|
+
severity: 'warning',
|
|
189
|
+
envName: 'CLERK_SECRET_KEY',
|
|
190
|
+
rotate: 'Clerk Dashboard → API keys → Secret keys (development instance)',
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
const STRIPE_PACKAGES = ['stripe', '@stripe/stripe-js', '@stripe/react-stripe-js'];
|
|
194
|
+
/** The pattern to report a match as: Stripe's, unless the key turns out to be Clerk's. */
|
|
195
|
+
function keyKind(ctx, p, m) {
|
|
196
|
+
const clerk = CLERK_KEYS[p.id];
|
|
197
|
+
if (!clerk || !m.match[0].startsWith('sk_'))
|
|
198
|
+
return p;
|
|
199
|
+
const line = lineTextAt(m.file.content, m.index);
|
|
200
|
+
if (/clerk/i.test(line))
|
|
201
|
+
return clerk;
|
|
202
|
+
if (/stripe/i.test(line))
|
|
203
|
+
return p;
|
|
204
|
+
return ctx.uses('@clerk/') && !ctx.usesAny(STRIPE_PACKAGES) ? clerk : p;
|
|
205
|
+
}
|
|
206
|
+
/** Not in KEY_PATTERNS: a Lemon Squeezy key is a JWT, so only its context tells it apart. */
|
|
207
|
+
const LEMON_SQUEEZY_KEY = {
|
|
208
|
+
id: 'lemonsqueezy-api-key',
|
|
209
|
+
name: 'Lemon Squeezy API key',
|
|
210
|
+
re: /\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
|
|
211
|
+
severity: 'critical',
|
|
212
|
+
envName: 'LEMONSQUEEZY_API_KEY',
|
|
213
|
+
rotate: 'Lemon Squeezy → Settings → API',
|
|
214
|
+
};
|
|
136
215
|
/** Every real-looking API key in a piece of text (placeholders like "sk_live_xxxx" are skipped). */
|
|
137
216
|
export function matchKeys(text) {
|
|
138
217
|
const out = [];
|
|
@@ -155,7 +234,7 @@ const LOCAL_HOST_RE = /^(localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.interna
|
|
|
155
234
|
const WEAK_PLACEHOLDER_PW = /^(password|pass|postgres|root|secret|admin|pwd|user|mysql|test)$/i;
|
|
156
235
|
const JWT_RE = /\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g;
|
|
157
236
|
const PUBLIC_VAR_RE = /\b(NEXT_PUBLIC_|VITE_|REACT_APP_|EXPO_PUBLIC_|NUXT_PUBLIC_|GATSBY_|PUBLIC_)([A-Z0-9_]+)/g;
|
|
158
|
-
const SENSITIVE_PART = /(SECRET|SERVICE_ROLE|PRIVATE|PASSWORD|PASSWD|OPENAI|ANTHROPIC|CLAUDE|GEMINI|GROQ|MISTRAL|DEEPSEEK|OPENROUTER|PERPLEXITY|REPLICATE|HUGGING|HF_TOKEN|COHERE|TOGETHER|ELEVENLABS|RESEND|SENDGRID|MAILGUN|POSTMARK|TWILIO_AUTH|AUTH_TOKEN|ACCESS_TOKEN|ADMIN_KEY)/;
|
|
237
|
+
const SENSITIVE_PART = /(SECRET|SERVICE_ROLE|PRIVATE|PASSWORD|PASSWD|OPENAI|ANTHROPIC|CLAUDE|GEMINI|GROQ|MISTRAL|DEEPSEEK|OPENROUTER|PERPLEXITY|REPLICATE|HUGGING|HF_TOKEN|COHERE|TOGETHER|ELEVENLABS|RESEND|SENDGRID|MAILGUN|POSTMARK|TWILIO_AUTH|AUTH_TOKEN|ACCESS_TOKEN|ADMIN_KEY|LEMONSQUEEZY|LEMON_SQUEEZY|PADDLE_API|CONVEX_DEPLOY|APPWRITE_API|APPWRITE_KEY)/;
|
|
159
238
|
const DB_PART = /(DATABASE_URL|DB_URL|POSTGRES_URL|MONGODB_URI|MONGO_URI)/;
|
|
160
239
|
// Settings that only mention a sensitive word, like VITE_PASSWORD_MIN_LENGTH.
|
|
161
240
|
const SAFE_SUFFIX = /(_URL|_URI|_ENDPOINT|_MODEL|_BASE|_HOST|_REGION|_VERSION|_ENABLED|_ID|_NAME|_LENGTH|_MIN|_MAX|_LIMIT|_COUNT|_TIMEOUT|_MODE|_LABEL|_TITLE|_TEXT|_PATH|_LINK)$/;
|
|
@@ -171,12 +250,15 @@ const notRealEnv = (f) => !isRealEnvPath(f.path);
|
|
|
171
250
|
function hardcodedFinding(ctx, p, m) {
|
|
172
251
|
const client = ctx.isClient(m.file);
|
|
173
252
|
const shown = p.id === 'private-key' ? '-----BEGIN … PRIVATE KEY-----' : mask(m.match[0]);
|
|
253
|
+
const shipped = ctx.isMobileFile(m.file.path)
|
|
254
|
+
? `This file is built into your app, and anyone who installs it can unpack the app and copy the key (${shown}).`
|
|
255
|
+
: `This file is sent to every visitor's browser, so anyone can copy the key (${shown}) and use your account.`;
|
|
174
256
|
return {
|
|
175
257
|
id: p.id,
|
|
176
258
|
severity: client ? 'critical' : p.severity,
|
|
177
259
|
title: `${capitalize(p.name)} is written directly in your code`,
|
|
178
260
|
why: client
|
|
179
|
-
?
|
|
261
|
+
? shipped
|
|
180
262
|
: `Anyone who can see your code (GitHub, collaborators, AI tools) can copy this key (${shown}) and use your account. Keys belong in environment variables.`,
|
|
181
263
|
location: at(m),
|
|
182
264
|
fixPrompt: `In ${where(at(m))} there is a hard-coded ${p.name} (it starts with "${shown}"). Please:\n` +
|
|
@@ -195,6 +277,8 @@ export const secretsCheck = {
|
|
|
195
277
|
weight: 3,
|
|
196
278
|
ids: [
|
|
197
279
|
...KEY_PATTERNS.map((p) => p.id),
|
|
280
|
+
...Object.values(CLERK_KEYS).map((p) => p.id),
|
|
281
|
+
'lemonsqueezy-api-key',
|
|
198
282
|
'database-password',
|
|
199
283
|
'supabase-service-role-key',
|
|
200
284
|
'public-secret-variable',
|
|
@@ -214,13 +298,14 @@ export const secretsCheck = {
|
|
|
214
298
|
continue;
|
|
215
299
|
if (p.mustLookRandom && !looksRandom(m.match[0], p.mustLookRandom))
|
|
216
300
|
continue;
|
|
217
|
-
const
|
|
301
|
+
const kind = keyKind(ctx, p, m);
|
|
302
|
+
const key = `${kind.id}|${m.file.path}`;
|
|
218
303
|
if (seen.has(key))
|
|
219
304
|
continue;
|
|
220
305
|
seen.add(key);
|
|
221
306
|
if (++hardcoded > 10)
|
|
222
307
|
break;
|
|
223
|
-
out.findings.push(hardcodedFinding(ctx,
|
|
308
|
+
out.findings.push(hardcodedFinding(ctx, kind, m));
|
|
224
309
|
}
|
|
225
310
|
}
|
|
226
311
|
// 2. Database connection strings with real passwords
|
|
@@ -251,8 +336,17 @@ export const secretsCheck = {
|
|
|
251
336
|
// 3. Supabase service_role keys (they bypass all database security)
|
|
252
337
|
for (const m of ctx.find(JWT_RE, notRealEnv)) {
|
|
253
338
|
const payload = decodeJwtPayload(m.match[0]);
|
|
254
|
-
if (payload?.role !== 'service_role')
|
|
339
|
+
if (payload?.role !== 'service_role') {
|
|
340
|
+
if (!/lemon[\s_-]?squeezy/i.test(lineTextAt(m.file.content, m.index)))
|
|
341
|
+
continue;
|
|
342
|
+
const key = `lemonsqueezy|${m.file.path}`;
|
|
343
|
+
if (seen.has(key))
|
|
344
|
+
continue;
|
|
345
|
+
seen.add(key);
|
|
346
|
+
hardcoded++;
|
|
347
|
+
out.findings.push(hardcodedFinding(ctx, LEMON_SQUEEZY_KEY, m));
|
|
255
348
|
continue;
|
|
349
|
+
}
|
|
256
350
|
const key = `service-role|${m.file.path}`;
|
|
257
351
|
if (seen.has(key))
|
|
258
352
|
continue;
|
|
@@ -299,7 +393,9 @@ export const secretsCheck = {
|
|
|
299
393
|
id: 'public-secret-variable',
|
|
300
394
|
severity: 'critical',
|
|
301
395
|
title: `Secret exposed through the public variable ${name}`,
|
|
302
|
-
why:
|
|
396
|
+
why: prefix === 'EXPO_PUBLIC_'
|
|
397
|
+
? 'Anything starting with EXPO_PUBLIC_ is built into your app, so anyone who installs it can read it. That prefix is only for values that are safe to be public.'
|
|
398
|
+
: `Anything starting with ${prefix} gets copied into your website's JavaScript, so every visitor can read it. That prefix is only for values that are safe to be public.`,
|
|
303
399
|
location: loc,
|
|
304
400
|
fixPrompt: `My app has an environment variable called ${name} (see ${where(loc)}). Because it starts with ${prefix}, it is bundled into the browser code and anyone can read it. Please:\n` +
|
|
305
401
|
`1. Rename it to a server-only name without the ${prefix} prefix.\n` +
|
package/dist/src/cli.js
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
import { appendFileSync, existsSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
4
4
|
import { applyBaseline, BASELINE_FILE, loadBaseline, writeBaseline } from './baseline.js';
|
|
5
|
-
import { createDemoProject } from './demo.js';
|
|
5
|
+
import { createDemoProject, removeOnSignal } from './demo.js';
|
|
6
6
|
import { renderFixes } from './fixes.js';
|
|
7
|
+
import { explainGitHubError, postPrFeedback, prContextFromEnv } from './github.js';
|
|
7
8
|
import { failingFindings } from './grade.js';
|
|
8
9
|
import { DEFAULT_HISTORY_DEPTH } from './history.js';
|
|
9
10
|
import { CATEGORY_IDS, runDoctor } from './index.js';
|
|
10
11
|
import { runInit } from './init.js';
|
|
11
12
|
import { runLiveScan } from './live.js';
|
|
13
|
+
import { runMcpServer } from './mcp.js';
|
|
12
14
|
import { bold, dim, renderReport } from './report.js';
|
|
13
15
|
import { renderSarif } from './sarif.js';
|
|
14
16
|
import { renderStepSummary } from './summary.js';
|
|
@@ -20,6 +22,7 @@ const HELP = `
|
|
|
20
22
|
npx launch-doctor [folder] [options]
|
|
21
23
|
npx launch-doctor init [folder] Create .launchdoctorignore and a GitHub Actions workflow
|
|
22
24
|
npx launch-doctor scan <url> Check your deployed site (exposed files, source maps, open Supabase tables, headers)
|
|
25
|
+
npx launch-doctor mcp Start an MCP server so Claude Code, Cursor and other AI tools can run checks
|
|
23
26
|
|
|
24
27
|
${bold('Options')}
|
|
25
28
|
--domain <domain> Domain you send email from (checks SPF / DKIM / DMARC)
|
|
@@ -27,6 +30,7 @@ const HELP = `
|
|
|
27
30
|
--no-file Don't write the fix prompts file
|
|
28
31
|
--json Print the full report as JSON (no fix file unless --out is given)
|
|
29
32
|
--sarif <file> Also write a SARIF 2.1.0 file (for GitHub code scanning)
|
|
33
|
+
--pr-comment On a GitHub pull request, post a summary comment and inline fix prompts
|
|
30
34
|
--offline Skip network checks (email DNS)
|
|
31
35
|
--ci Exit with code 1 on findings at or above --fail-on (no fix file unless --out)
|
|
32
36
|
--fail-on <level> With --ci, the lowest severity that fails: critical (default) or warning
|
|
@@ -52,6 +56,8 @@ const HELP = `
|
|
|
52
56
|
|
|
53
57
|
${bold('GitHub Actions')}
|
|
54
58
|
When GITHUB_STEP_SUMMARY is set, a Markdown summary is added to the job summary page.
|
|
59
|
+
When GITHUB_OUTPUT is set, the grade, score and counts are saved as step outputs.
|
|
60
|
+
--pr-comment needs GITHUB_TOKEN and "permissions: pull-requests: write".
|
|
55
61
|
|
|
56
62
|
${bold('Examples')}
|
|
57
63
|
npx launch-doctor
|
|
@@ -65,6 +71,7 @@ function parseArgs(argv) {
|
|
|
65
71
|
offline: false,
|
|
66
72
|
ci: false,
|
|
67
73
|
failOn: 'critical',
|
|
74
|
+
prComment: false,
|
|
68
75
|
updateBaseline: false,
|
|
69
76
|
baseline: true,
|
|
70
77
|
history: false,
|
|
@@ -93,6 +100,8 @@ function parseArgs(argv) {
|
|
|
93
100
|
args.ci = true;
|
|
94
101
|
else if (a === '--demo')
|
|
95
102
|
args.demo = true;
|
|
103
|
+
else if (a === '--pr-comment')
|
|
104
|
+
args.prComment = true;
|
|
96
105
|
else if (a === '--no-file')
|
|
97
106
|
args.writeFile = false;
|
|
98
107
|
else if (a === '--update-baseline')
|
|
@@ -194,6 +203,31 @@ function init(argv) {
|
|
|
194
203
|
for (const f of skipped)
|
|
195
204
|
process.stdout.write(` skipped ${f} ${dim('(already exists)')}\n`);
|
|
196
205
|
}
|
|
206
|
+
const MCP_HELP = `
|
|
207
|
+
${bold('launch-doctor mcp')} - an MCP server for Claude Code, Cursor and other AI coding tools
|
|
208
|
+
|
|
209
|
+
${bold('Usage')}
|
|
210
|
+
npx launch-doctor mcp Your AI tool starts this itself and talks to it over stdin and stdout
|
|
211
|
+
|
|
212
|
+
${bold('Tools it offers')}
|
|
213
|
+
scan_project Check a project folder: grade, findings with fix prompts, and the checklist
|
|
214
|
+
scan_url Check a deployed site from the outside
|
|
215
|
+
list_checks List the categories and finding ids
|
|
216
|
+
|
|
217
|
+
${bold('Set it up')}
|
|
218
|
+
Claude Code claude mcp add launch-doctor -- npx -y launch-doctor mcp
|
|
219
|
+
Cursor add to .cursor/mcp.json:
|
|
220
|
+
{ "mcpServers": { "launch-doctor": { "command": "npx", "args": ["-y", "launch-doctor", "mcp"] } } }
|
|
221
|
+
`;
|
|
222
|
+
async function mcp(argv) {
|
|
223
|
+
if (argv.some((a) => a === '-h' || a === '--help')) {
|
|
224
|
+
process.stdout.write(MCP_HELP);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (argv.length)
|
|
228
|
+
fail(`mcp doesn't take options (got ${argv.join(' ')}). Run "launch-doctor mcp --help" for setup.`);
|
|
229
|
+
await runMcpServer();
|
|
230
|
+
}
|
|
197
231
|
const SCAN_HELP = `
|
|
198
232
|
${bold('launch-doctor scan')} - check your deployed site from the outside
|
|
199
233
|
|
|
@@ -290,6 +324,7 @@ async function scan(argv) {
|
|
|
290
324
|
// the summary is optional
|
|
291
325
|
}
|
|
292
326
|
}
|
|
327
|
+
writeStepOutputs(report);
|
|
293
328
|
if (json)
|
|
294
329
|
process.stdout.write(`${JSON.stringify(report, null, 2)}
|
|
295
330
|
`);
|
|
@@ -298,11 +333,53 @@ async function scan(argv) {
|
|
|
298
333
|
if (ci && failingFindings(report, failOn).length > 0)
|
|
299
334
|
process.exitCode = 1;
|
|
300
335
|
}
|
|
336
|
+
/** On GitHub Actions, save the grade and counts as step outputs (steps.<id>.outputs.grade and so on). */
|
|
337
|
+
function writeStepOutputs(report) {
|
|
338
|
+
const file = process.env.GITHUB_OUTPUT;
|
|
339
|
+
if (!file)
|
|
340
|
+
return;
|
|
341
|
+
const lines = [
|
|
342
|
+
`grade=${report.grade}`,
|
|
343
|
+
`score=${report.score}`,
|
|
344
|
+
`critical=${report.counts.critical}`,
|
|
345
|
+
`warnings=${report.counts.warning}`,
|
|
346
|
+
];
|
|
347
|
+
try {
|
|
348
|
+
appendFileSync(file, `${lines.join('\n')}\n`);
|
|
349
|
+
}
|
|
350
|
+
catch (err) {
|
|
351
|
+
process.stderr.write(`${dim(`Couldn't write the GitHub step outputs: ${err.message}`)}\n`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/** --pr-comment: post the results to the pull request. Never fails the run; problems are explained on stderr. */
|
|
355
|
+
async function commentOnPr(report, root) {
|
|
356
|
+
const ctx = prContextFromEnv(root);
|
|
357
|
+
if (typeof ctx === 'string') {
|
|
358
|
+
process.stderr.write(`\n ${dim(`--pr-comment: skipped, ${ctx}.`)}\n`);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
const r = await postPrFeedback(report, ctx);
|
|
363
|
+
const parts = [`summary comment ${r.summary}`, `${r.posted} new inline comment${r.posted === 1 ? '' : 's'}`];
|
|
364
|
+
if (r.alreadyPosted)
|
|
365
|
+
parts.push(`${r.alreadyPosted} already posted earlier`);
|
|
366
|
+
if (r.overLimit)
|
|
367
|
+
parts.push(`${r.overLimit} more listed in the summary only`);
|
|
368
|
+
process.stderr.write(`\n ${dim(`Pull request #${ctx.number}: ${parts.join(', ')}.`)}\n`);
|
|
369
|
+
if (r.inlineError)
|
|
370
|
+
process.stderr.write(` ${dim(r.inlineError)}\n`);
|
|
371
|
+
}
|
|
372
|
+
catch (err) {
|
|
373
|
+
process.stderr.write(`\n ${dim(explainGitHubError(err))}\n`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
301
376
|
async function main() {
|
|
302
377
|
if (process.argv[2] === 'init')
|
|
303
378
|
return init(process.argv.slice(3));
|
|
304
379
|
if (process.argv[2] === 'scan')
|
|
305
380
|
return scan(process.argv.slice(3));
|
|
381
|
+
if (process.argv[2] === 'mcp')
|
|
382
|
+
return mcp(process.argv.slice(3));
|
|
306
383
|
const args = parseArgs(process.argv.slice(2));
|
|
307
384
|
if (args.help) {
|
|
308
385
|
process.stdout.write(HELP);
|
|
@@ -312,10 +389,15 @@ async function main() {
|
|
|
312
389
|
process.stdout.write(`${version()}\n`);
|
|
313
390
|
return;
|
|
314
391
|
}
|
|
392
|
+
let stopDemoCleanup;
|
|
315
393
|
if (args.demo) {
|
|
316
394
|
if (args.path)
|
|
317
395
|
fail('--demo scans a built-in sample app, so leave out the folder');
|
|
318
|
-
|
|
396
|
+
// Ctrl+C mid-scan would otherwise skip the finally below and leave the folder in the temp directory.
|
|
397
|
+
let demoDir;
|
|
398
|
+
stopDemoCleanup = removeOnSignal(() => demoDir);
|
|
399
|
+
demoDir = createDemoProject();
|
|
400
|
+
args.path = demoDir;
|
|
319
401
|
args.offline = true;
|
|
320
402
|
if (!args.out)
|
|
321
403
|
args.writeFile = false;
|
|
@@ -339,8 +421,10 @@ async function main() {
|
|
|
339
421
|
}
|
|
340
422
|
finally {
|
|
341
423
|
// The demo project lives in a temp folder; always clean it up, even if the scan throws.
|
|
342
|
-
if (args.demo)
|
|
424
|
+
if (args.demo) {
|
|
343
425
|
rmSync(root, { recursive: true, force: true });
|
|
426
|
+
stopDemoCleanup?.();
|
|
427
|
+
}
|
|
344
428
|
}
|
|
345
429
|
if (report.filesScanned === 0) {
|
|
346
430
|
fail(`No project files found in ${root}. Run this inside your app's folder.`);
|
|
@@ -391,6 +475,9 @@ async function main() {
|
|
|
391
475
|
process.stderr.write(`${dim(`Couldn't write the GitHub step summary: ${err.message}`)}\n`);
|
|
392
476
|
}
|
|
393
477
|
}
|
|
478
|
+
writeStepOutputs(report);
|
|
479
|
+
if (args.prComment)
|
|
480
|
+
await commentOnPr(report, root);
|
|
394
481
|
if (args.json)
|
|
395
482
|
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
396
483
|
else
|
package/dist/src/demo.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove demo folders that killed runs left in the temp folder. Only folders named
|
|
3
|
+
* launch-doctor-demo-* that are over an hour old are touched, so a demo running in
|
|
4
|
+
* another terminal right now is left alone. Returns how many were removed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sweepStaleDemos(now?: number, dir?: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* Delete the demo folder if the run is stopped with Ctrl+C (SIGINT), SIGTERM or SIGHUP.
|
|
9
|
+
* Register it before creating the folder: signal handlers run between JavaScript tasks,
|
|
10
|
+
* so the folder name is always known by the time one runs.
|
|
11
|
+
* Returns a function that removes the handlers again once the run has cleaned up normally.
|
|
12
|
+
*/
|
|
13
|
+
export declare function removeOnSignal(getDir: () => string | undefined): () => void;
|
|
1
14
|
/** Writes a small "weekend project" with the classic launch mistakes and returns its folder. */
|
|
2
15
|
export declare function createDemoProject(): string;
|
package/dist/src/demo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { mkdirSync, mkdtempSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
/** A random-looking (but fake) key, generated at runtime so no key-shaped string ships in the package. */
|
|
@@ -15,9 +15,65 @@ function fakeKey(prefix, length, seed) {
|
|
|
15
15
|
}
|
|
16
16
|
return prefix + out;
|
|
17
17
|
}
|
|
18
|
+
const DEMO_PREFIX = 'launch-doctor-demo-';
|
|
19
|
+
/** A demo folder older than this was left behind by a run that was killed before it could clean up. */
|
|
20
|
+
const STALE_DEMO_MS = 60 * 60 * 1000;
|
|
21
|
+
/**
|
|
22
|
+
* Remove demo folders that killed runs left in the temp folder. Only folders named
|
|
23
|
+
* launch-doctor-demo-* that are over an hour old are touched, so a demo running in
|
|
24
|
+
* another terminal right now is left alone. Returns how many were removed.
|
|
25
|
+
*/
|
|
26
|
+
export function sweepStaleDemos(now = Date.now(), dir = tmpdir()) {
|
|
27
|
+
let removed = 0;
|
|
28
|
+
let names;
|
|
29
|
+
try {
|
|
30
|
+
names = readdirSync(dir);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
for (const name of names) {
|
|
36
|
+
if (!name.startsWith(DEMO_PREFIX))
|
|
37
|
+
continue;
|
|
38
|
+
const path = join(dir, name);
|
|
39
|
+
try {
|
|
40
|
+
const stat = statSync(path);
|
|
41
|
+
if (!stat.isDirectory() || now - stat.mtimeMs < STALE_DEMO_MS)
|
|
42
|
+
continue;
|
|
43
|
+
rmSync(path, { recursive: true, force: true });
|
|
44
|
+
removed++;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// in use or already gone: leave it
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return removed;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Delete the demo folder if the run is stopped with Ctrl+C (SIGINT), SIGTERM or SIGHUP.
|
|
54
|
+
* Register it before creating the folder: signal handlers run between JavaScript tasks,
|
|
55
|
+
* so the folder name is always known by the time one runs.
|
|
56
|
+
* Returns a function that removes the handlers again once the run has cleaned up normally.
|
|
57
|
+
*/
|
|
58
|
+
export function removeOnSignal(getDir) {
|
|
59
|
+
const codes = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };
|
|
60
|
+
const handler = (signal) => {
|
|
61
|
+
const dir = getDir();
|
|
62
|
+
if (dir)
|
|
63
|
+
rmSync(dir, { recursive: true, force: true });
|
|
64
|
+
process.exit(codes[signal] ?? 1);
|
|
65
|
+
};
|
|
66
|
+
for (const signal of Object.keys(codes))
|
|
67
|
+
process.once(signal, handler);
|
|
68
|
+
return () => {
|
|
69
|
+
for (const signal of Object.keys(codes))
|
|
70
|
+
process.removeListener(signal, handler);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
18
73
|
/** Writes a small "weekend project" with the classic launch mistakes and returns its folder. */
|
|
19
74
|
export function createDemoProject() {
|
|
20
|
-
|
|
75
|
+
sweepStaleDemos();
|
|
76
|
+
const dir = mkdtempSync(join(tmpdir(), DEMO_PREFIX));
|
|
21
77
|
const openaiKey = fakeKey(['sk', 'proj', ''].join('-'), 40, 3);
|
|
22
78
|
const stripeKey = fakeKey(['sk', 'live', ''].join('_'), 28, 7);
|
|
23
79
|
const files = {
|
package/dist/src/detect.js
CHANGED
|
@@ -47,6 +47,8 @@ export function detectDatabase(ctx) {
|
|
|
47
47
|
['better-sqlite3', 'SQLite'],
|
|
48
48
|
['sqlite3', 'SQLite'],
|
|
49
49
|
['convex', 'Convex'],
|
|
50
|
+
['appwrite', 'Appwrite'],
|
|
51
|
+
['node-appwrite', 'Appwrite'],
|
|
50
52
|
['@vercel/postgres', 'Vercel Postgres'],
|
|
51
53
|
['typeorm', 'TypeORM'],
|
|
52
54
|
['sequelize', 'Sequelize'],
|
|
@@ -79,7 +81,8 @@ export function detectPayments(ctx) {
|
|
|
79
81
|
'@paypal/checkout-server-sdk',
|
|
80
82
|
'cashfree-pg',
|
|
81
83
|
'@cashfreepayments/cashfree-js',
|
|
82
|
-
]) ||
|
|
84
|
+
]) ||
|
|
85
|
+
ctx.find(/https:\/\/buy\.stripe\.com\/|checkout\.razorpay\.com|\.lemonsqueezy\.com\/(?:checkout|buy)\/|cdn\.paddle\.com\/paddle\//, appCode, 1).length > 0);
|
|
83
86
|
}
|
|
84
87
|
/** Analytics that set cookies (cookieless tools like Plausible are left out on purpose). */
|
|
85
88
|
export function detectCookieAnalytics(ctx) {
|
package/dist/src/fixes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shortWhere } from './checks/common.js';
|
|
2
|
-
import { plural } from './util.js';
|
|
2
|
+
import { ISSUES_URL, plural } from './util.js';
|
|
3
3
|
function fence(text) {
|
|
4
4
|
// Use a fence longer than any backtick run inside the prompt.
|
|
5
5
|
const longest = Math.max(2, ...(text.match(/`+/g) ?? []).map((m) => m.length));
|
|
@@ -62,6 +62,6 @@ export function renderFixes(report) {
|
|
|
62
62
|
out.push(`- [ ] **${m.title}** - ${m.how}`);
|
|
63
63
|
out.push('');
|
|
64
64
|
}
|
|
65
|
-
out.push('---', '', `_Generated by [Launch Doctor](https://www.npmjs.com/package/launch-doctor) v${report.version}. Safe to delete or add to .gitignore._`, '');
|
|
65
|
+
out.push('---', '', `_Generated by [Launch Doctor](https://www.npmjs.com/package/launch-doctor) v${report.version}. Safe to delete or add to .gitignore._`, '', `_A finding that is wrong, or a problem it missed? Please [report it](${ISSUES_URL}). Launch Doctor reads code with pattern rules, so it can make mistakes both ways._`, '');
|
|
66
66
|
return out.join('\n');
|
|
67
67
|
}
|