greenlitlab 0.2.0 → 0.2.1
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 +11 -0
- package/README.md +2 -0
- package/bin/greenlit.mjs +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/grade.mjs +130 -26
- package/src/severity.mjs +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 (9 November 2026)
|
|
4
|
+
|
|
5
|
+
- Reads all of an app's code: lazy-loaded pages (Vite and Next.js chunk lists), every import form, chains of any depth, scripts with `?v=` addresses, and scripts on the app's own CDN. It used to stop after two rounds, so most code in larger apps went unread.
|
|
6
|
+
- Says what it didn't read. If a check runs out of room it reports how many scripts were left. If none of the app's code could be read, it gives no grade instead of an A.
|
|
7
|
+
- Grades match the danger: one critical problem means D at best, one high problem means C at best (a leaked master key used to earn a C, and a public `.git` folder a B).
|
|
8
|
+
- An A or B no longer sounds like an all-clear when the database wasn't checked, and there's now a prompt that has your builder check the database, for people without a terminal.
|
|
9
|
+
- A builder's "website not found" page, served with status 200, is now reported as not found instead of graded A.
|
|
10
|
+
- Clear errors in the CLI too, including for an address that doesn't exist.
|
|
11
|
+
- Web: the script and stylesheet addresses carry the version, because the 4-hour browser cache otherwise left returning visitors on old code after a deploy.
|
|
12
|
+
- Web: progress and errors now appear under the box instead of off screen. Results refresh after 2 minutes instead of 10, and the limit is 30 checks an hour.
|
|
13
|
+
|
|
3
14
|
## 0.2.0 (8 November 2026)
|
|
4
15
|
|
|
5
16
|
- 18 more kinds of leaked keys: Supabase secret keys (sb_secret_) and access tokens, OpenRouter, xAI, Perplexity, Hugging Face, Replicate, Pinecone, GitLab, npm, Shopify, Brevo, Mailchimp, Mailgun, Telegram bots, secret Mapbox tokens, private keys and Google service-account JSON. `sk_live_` keys are named for Stripe, Clerk and similar.
|
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ npx greenlitlab myapp.lovable.app
|
|
|
24
24
|
| A public `.env` file or `.git` folder | your own app, `--mine` |
|
|
25
25
|
| Firebase Realtime Database and Firestore open to everyone | your own app, `--mine` |
|
|
26
26
|
|
|
27
|
+
Greenlit reads all of the app's own scripts, including lazy-loaded pages and the app's own CDN, and tells you if a check ran out of room or couldn't read the code. Grades follow the danger: one critical problem means D at best, one high problem means C at best.
|
|
28
|
+
|
|
27
29
|
The owner-only checks ask for a row count (Supabase), one file or document name (storage, Firebase), or the sign-up settings, never for data, and never write anything. They run only when you say the app is yours, because testing someone else's database without permission isn't OK.
|
|
28
30
|
|
|
29
31
|
## Commands
|
package/bin/greenlit.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import fs from "node:fs";
|
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { parseArgs } from "node:util";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
|
-
import { siteScan, compare, renderSite, allPrompts } from "../src/grade.mjs";
|
|
11
|
+
import { siteScan, compare, renderSite, allPrompts, explainError } from "../src/grade.mjs";
|
|
12
12
|
import { SEVERITY } from "../src/severity.mjs";
|
|
13
13
|
import { loadLast, saveRun } from "../src/history.mjs";
|
|
14
14
|
|
|
@@ -67,7 +67,7 @@ if (opt.version) {
|
|
|
67
67
|
result = await siteScan(target, { mine: opt.mine });
|
|
68
68
|
} catch (e) {
|
|
69
69
|
if (timer) (clearInterval(timer), process.stderr.write("\r\x1b[K"));
|
|
70
|
-
console.error(`greenlit: ${e.message}`);
|
|
70
|
+
console.error(`greenlit: ${explainError(e.message)}`);
|
|
71
71
|
process.exit(1);
|
|
72
72
|
}
|
|
73
73
|
if (timer) (clearInterval(timer), process.stderr.write("\r\x1b[K"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greenlitlab",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Is your AI-built app safe to launch? A grade from A to F for apps built with Lovable, Bolt, v0, Replit or Emergent, with a fix prompt for every problem.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/server.json
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
"description": "Grade apps built with Lovable, Bolt, v0 or Replit A to F, with a fix prompt for every problem.",
|
|
6
6
|
"websiteUrl": "https://greenlit.priberry.com",
|
|
7
7
|
"repository": { "url": "https://github.com/priberry-data/greenlitlab", "source": "github" },
|
|
8
|
-
"version": "0.2.
|
|
8
|
+
"version": "0.2.1",
|
|
9
9
|
"packages": [
|
|
10
10
|
{
|
|
11
11
|
"registryType": "npm",
|
|
12
12
|
"identifier": "greenlitlab",
|
|
13
|
-
"version": "0.2.
|
|
13
|
+
"version": "0.2.1",
|
|
14
14
|
"transport": { "type": "stdio" },
|
|
15
15
|
"packageArguments": [{ "type": "positional", "value": "mcp" }]
|
|
16
16
|
}
|
package/src/grade.mjs
CHANGED
|
@@ -120,6 +120,37 @@ async function get(url, { timeout = 15000, headers = {}, method = "GET", body =
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
// What went wrong, in words a non-developer can act on. Shared by the web check and the CLI.
|
|
124
|
+
export function explainError(message) {
|
|
125
|
+
const m = String(message);
|
|
126
|
+
const code = Number((m.match(/\((\d{3})\)$/) || [])[1]);
|
|
127
|
+
if (/look like a web address/.test(m)) return "That doesn't look like a web address. Try something like myapp.lovable.app.";
|
|
128
|
+
if (/isn't a web page/.test(m)) return "That address isn't a web page. Enter the address people open to use your app.";
|
|
129
|
+
if (code === 404) return "That address answered \"not found\". Check it's the live address of your app (open it in your browser first).";
|
|
130
|
+
if (code === 530) return "Nothing answers at that address. Check the spelling, and that the app is published.";
|
|
131
|
+
if (code === 401 || code === 403 || code === 429) return "That site turned the check away. It may be private, password-protected, or blocking automated visitors, so Greenlit can't grade it from here.";
|
|
132
|
+
if (code >= 500) return `That site had an error of its own (${code}). Open it in your browser to see if it's up, then try again.`;
|
|
133
|
+
if (/timed out/.test(m)) return "That site took too long to answer. Try again in a minute.";
|
|
134
|
+
return "Couldn't reach that site. Check the spelling, and that the app is published.";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// A script belongs to the app if it's on the same site (static.myapp.com for myapp.com) or on a hosting CDN.
|
|
138
|
+
// Scripts on anyone else's site (Stripe, analytics) are that company's code, not the app's.
|
|
139
|
+
const siteKey = (host) => {
|
|
140
|
+
const parts = host.toLowerCase().split(".");
|
|
141
|
+
const short = parts.length > 2 && parts.at(-1).length === 2 && /^(co|com|org|net|ac|gov|edu)$/.test(parts.at(-2));
|
|
142
|
+
return parts.slice(short ? -3 : -2).join(".");
|
|
143
|
+
};
|
|
144
|
+
const HOSTING_CDN = /(^|\.)(cloudfront\.net|azureedge\.net|b-cdn\.net|r2\.dev|fastly\.net|akamaized\.net|amazonaws\.com|storage\.googleapis\.com)$/i;
|
|
145
|
+
|
|
146
|
+
// Paths to other scripts mentioned inside a script or page: imports of every form, and the lists of lazy-loaded
|
|
147
|
+
// pages that Vite and Next.js keep ("assets/Page-abc.js", "static/chunks/abc.js"). This is where most of an app's code is.
|
|
148
|
+
const SCRIPT_REF = /["'`]((?:\.{0,2}\/|assets\/|_next\/|static\/chunks\/)[\w@.~\/-]+\.m?js(?:\?[^"'`\s]*)?)["'`]/g;
|
|
149
|
+
const resolveRef = (ref, from, origin) => (/^(assets|_next)\//.test(ref) ? safeUrl(ref, `${origin}/`) : ref.startsWith("static/chunks/") ? safeUrl(`/_next/${ref}`, origin) : safeUrl(ref, from));
|
|
150
|
+
|
|
151
|
+
// Builders and hosts often answer an address with nothing on it with a normal-looking page and status 200.
|
|
152
|
+
const DEAD_PAGE = /<title[^>]*>[^<]*(?:(?:website|site|page|project|app|application|deployment)\s+(?:was\s+|is\s+)?not\s+found|\b404\b)[^<]*<\/title>/i;
|
|
153
|
+
|
|
123
154
|
// --- fix prompts ---------------------------------------------------------------------------------
|
|
124
155
|
// Written for someone who can't read the code: what to do by hand first (revoking a key is something
|
|
125
156
|
// no AI builder can do for you), then one prompt to paste into the builder's chat.
|
|
@@ -167,8 +198,12 @@ const P = {
|
|
|
167
198
|
}),
|
|
168
199
|
framing: () => ({
|
|
169
200
|
first: null,
|
|
170
|
-
prompt: "Any other website can show my app inside a hidden frame and trick my users into clicking things (clickjacking). Add the response header `Content-Security-Policy: frame-ancestors 'self'` (or `X-Frame-Options: DENY`) in my host's header settings, redeploy, and confirm the header is there.",
|
|
201
|
+
prompt: "Any other website can show my app inside a hidden frame and trick my users into clicking things (clickjacking). Add the response header `Content-Security-Policy: frame-ancestors 'self'` (or `X-Frame-Options: DENY`) in my host's header settings, redeploy, and confirm the header is there. If this host doesn't let me set response headers, say so plainly instead of adding a meta tag, because a meta tag can't do this. Then tell me what my options are.",
|
|
171
202
|
}),
|
|
203
|
+
dbCheck: (db) =>
|
|
204
|
+
db === "Supabase"
|
|
205
|
+
? "Check my Supabase database and change nothing yet. For every table, tell me whether Row Level Security is on, and which policies let someone read or change rows without signing in, or read rows that aren't theirs. Do the same for my storage buckets. Also tell me whether anyone can sign up without confirming their email. End with a plain list of what is open to strangers, worst first."
|
|
206
|
+
: "Check my Firebase security rules and change nothing yet. For Firestore, Realtime Database and Storage, tell me which paths someone can read or change without signing in, or read when the data isn't theirs. End with a plain list of what is open to strangers, worst first.",
|
|
172
207
|
sourceMaps: () => ({
|
|
173
208
|
first: null,
|
|
174
209
|
prompt: "My production build publishes source maps, so anyone can read my app's original source code. Turn them off for production builds only (for Vite: build.sourcemap = false in vite.config), rebuild and redeploy. Don't change anything else.",
|
|
@@ -180,7 +215,8 @@ const P = {
|
|
|
180
215
|
};
|
|
181
216
|
|
|
182
217
|
// --- the check -----------------------------------------------------------------------------------
|
|
183
|
-
export async function siteScan(target, { mine = false, fetcher = fetch, maxScripts =
|
|
218
|
+
export async function siteScan(target, { mine = false, fetcher = fetch, maxScripts = 400, maxBytes = 8 * 1024 * 1024, maxTotalBytes = 200 * 1024 * 1024, deadlineMs = 120000, scriptTimeoutMs = 15000 } = {}) {
|
|
219
|
+
const deadline = Date.now() + deadlineMs;
|
|
184
220
|
const fetchOpts = (o = {}) => ({ max: maxBytes, ...o, fetcher });
|
|
185
221
|
const url = safeUrl(/^https?:\/\//i.test(String(target).trim()) ? String(target).trim() : `https://${String(target).trim()}`);
|
|
186
222
|
if (!url || !/^https?:$/.test(url.protocol) || !url.hostname.includes(".")) throw new Error(`"${target}" doesn't look like a web address`);
|
|
@@ -189,33 +225,76 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
189
225
|
|
|
190
226
|
const page = await get(url.href, fetchOpts());
|
|
191
227
|
if (!page.status || page.status >= 400) throw new Error(`could not load ${url.href} (${page.error || page.status})`);
|
|
192
|
-
const
|
|
228
|
+
const pageType = page.headers?.get("content-type") || "";
|
|
229
|
+
if (pageType && !/html/i.test(pageType)) throw new Error(`${url.href} isn't a web page`);
|
|
230
|
+
if (DEAD_PAGE.test(page.text)) throw new Error(`could not load ${url.href} (404)`);
|
|
231
|
+
const pageUrl = page.url || url.href;
|
|
232
|
+
const origin = new URL(pageUrl).origin;
|
|
233
|
+
const site = siteKey(new URL(origin).hostname);
|
|
193
234
|
const builder = detectBuilder(new URL(origin).host, page.text);
|
|
235
|
+
const isOwn = (href) => {
|
|
236
|
+
const h = new URL(href).hostname;
|
|
237
|
+
return siteKey(h) === site || HOSTING_CDN.test(h);
|
|
238
|
+
};
|
|
194
239
|
|
|
195
|
-
// Every script the page loads
|
|
240
|
+
// Every script that belongs to the app: the ones the page loads, then whatever those mention, until none are left.
|
|
196
241
|
const srcs = new Set();
|
|
197
|
-
const collect = (
|
|
198
|
-
for (const m of
|
|
199
|
-
|
|
242
|
+
const collect = (text, base) => {
|
|
243
|
+
for (const m of text.matchAll(SCRIPT_REF)) {
|
|
244
|
+
const u = resolveRef(m[1], base, origin);
|
|
245
|
+
if (u && /^https?:$/.test(u.protocol)) srcs.add(u.href);
|
|
246
|
+
}
|
|
200
247
|
};
|
|
201
|
-
|
|
248
|
+
for (const m of page.text.matchAll(/<script[^>]+src=["']([^"']+)["']/gi)) safeUrl(m[1], pageUrl) && srcs.add(safeUrl(m[1], pageUrl).href);
|
|
249
|
+
for (const m of page.text.matchAll(/<link[^>]+href=["']([^"']+\.m?js(?:\?[^"']*)?)["']/gi)) safeUrl(m[1], pageUrl) && srcs.add(safeUrl(m[1], pageUrl).href);
|
|
250
|
+
collect(page.text, pageUrl);
|
|
251
|
+
|
|
202
252
|
const bundles = [{ where: "the page itself", text: page.text }];
|
|
203
253
|
const seen = new Set();
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
254
|
+
let total = page.text.length;
|
|
255
|
+
let stopped = false;
|
|
256
|
+
let cut = 0;
|
|
257
|
+
let fetched = 0;
|
|
258
|
+
const retried = new Set();
|
|
259
|
+
const failed = new Set();
|
|
260
|
+
for (;;) {
|
|
261
|
+
const waiting = [...srcs].filter((src) => !seen.has(src) && isOwn(src));
|
|
262
|
+
if (!waiting.length) break;
|
|
263
|
+
const room = maxScripts - fetched;
|
|
264
|
+
if (room <= 0 || total >= maxTotalBytes || Date.now() > deadline) {
|
|
265
|
+
stopped = true;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
// Six at a time.
|
|
269
|
+
const batch = waiting.slice(0, Math.min(6, room));
|
|
207
270
|
for (const src of batch) seen.add(src);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
271
|
+
fetched += batch.length;
|
|
272
|
+
const got = await Promise.all(batch.map((src) => get(src, fetchOpts({ timeout: scriptTimeoutMs })).then((r) => ({ src, r }))));
|
|
273
|
+
for (const { src, r } of got) {
|
|
274
|
+
// A file that wouldn't load isn't the same as a file that doesn't exist: try once more, then count it as unread.
|
|
275
|
+
if (r.status === 0 || r.status === 429 || r.status >= 500) {
|
|
276
|
+
if (retried.has(src)) failed.add(src);
|
|
277
|
+
else {
|
|
278
|
+
retried.add(src);
|
|
279
|
+
seen.delete(src);
|
|
280
|
+
}
|
|
281
|
+
continue;
|
|
215
282
|
}
|
|
283
|
+
// Many hosts answer a missing file with the home page; that isn't a script.
|
|
284
|
+
if (r.status !== 200 || /text\/html/i.test(r.headers?.get("content-type") || "")) continue;
|
|
285
|
+
if (r.text.length >= maxBytes) cut++;
|
|
286
|
+
total += r.text.length;
|
|
287
|
+
bundles.push({ where: new URL(src).pathname, text: r.text, url: src });
|
|
288
|
+
collect(r.text, src);
|
|
216
289
|
}
|
|
217
290
|
}
|
|
291
|
+
const unread = [...srcs].filter((src) => !seen.has(src) && isOwn(src)).length + failed.size;
|
|
292
|
+
const scriptTags = [...page.text.matchAll(/<script[^>]+src=["']([^"']+)["']/gi)].map((m) => safeUrl(m[1], pageUrl)).filter((u) => u && /^https?:$/.test(u.protocol));
|
|
293
|
+
const elsewhere = scriptTags.filter((u) => !isOwn(u.href)).length;
|
|
294
|
+
// The page has scripts, but all of them live on another site, so its real code was never read.
|
|
295
|
+
const noCodeRead = bundles.length === 1 && elsewhere > 0;
|
|
218
296
|
|
|
297
|
+
let mapTries = 0;
|
|
219
298
|
let supabase = null;
|
|
220
299
|
let firebase = null;
|
|
221
300
|
const keysSeen = new Set();
|
|
@@ -256,7 +335,9 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
256
335
|
}
|
|
257
336
|
const sm = b.url && b.text.match(/sourceMappingURL=([^\s'"]+\.map)/);
|
|
258
337
|
const mapUrl = sm && safeUrl(sm[1], b.url)?.href;
|
|
259
|
-
|
|
338
|
+
// A few tries are enough: an app either publishes its maps or it doesn't.
|
|
339
|
+
if (mapUrl && isOwn(mapUrl) && mapTries < 3 && !findings.some((f) => f.id === "sourcemaps")) {
|
|
340
|
+
mapTries++;
|
|
260
341
|
// Check what comes back: hosts that answer every missing file with the home page would look "public" otherwise.
|
|
261
342
|
const r = await get(mapUrl, fetchOpts({ max: 4096 }));
|
|
262
343
|
if (r.status === 200 && /^\s*\{[\s\S]*"(version|mappings|sources)"/.test(r.text))
|
|
@@ -266,7 +347,11 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
266
347
|
|
|
267
348
|
const database = supabase?.url && supabase.anon ? "Supabase" : firebase?.project ? "Firebase" : null;
|
|
268
349
|
if (database && !mine)
|
|
269
|
-
add({ id: "db:skipped", severity: "info", where: database, title: `Your ${database} database wasn't checked`, why: `This app uses ${database}. Greenlit can check which of its data anyone on the internet can read, but only on your own computer, for an app you own.`, fix: `Run \`npx greenlitlab ${url.host} --mine\` if this is your app.`, first: null, prompt: null });
|
|
350
|
+
add({ id: "db:skipped", severity: "info", where: database, title: `Your ${database} database wasn't checked`, why: `This app uses ${database}. Greenlit can check which of its data anyone on the internet can read, but only on your own computer, for an app you own.`, fix: `Run \`npx greenlitlab ${url.host} --mine\` if this is your app.`, first: null, prompt: null, checkPrompt: P.dbCheck(database) });
|
|
351
|
+
if (unread || cut)
|
|
352
|
+
add({ id: "coverage:partial", severity: "info", where: "your app's scripts", title: unread ? `${unread} of this app's scripts weren't read` : "Some of this app's scripts were too big to read to the end", why: `Greenlit read ${bundles.length - 1} scripts, but couldn't get through the rest in one check. A problem in those wouldn't show up here.`, fix: `Run \`npx greenlitlab ${url.host}\` on your computer, which reads them all.`, first: null, prompt: null });
|
|
353
|
+
if (noCodeRead)
|
|
354
|
+
add({ id: "coverage:none", severity: "info", where: "your app's scripts", title: "This app's code wasn't read", why: `All ${elsewhere} of its scripts load from other sites, and Greenlit can't tell which of them are yours. Only the page itself and its settings were checked.`, fix: "If your app loads its code from a site of its own, check that site's address too.", first: null, prompt: null });
|
|
270
355
|
|
|
271
356
|
// Supabase: with the public anon key, which tables can anyone read?
|
|
272
357
|
let tables = null;
|
|
@@ -371,17 +456,30 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
371
456
|
|
|
372
457
|
const penalty = findings.reduce((a, f) => a + SEVERITY[f.severity], 0);
|
|
373
458
|
const score = Math.max(0, 100 - penalty);
|
|
374
|
-
|
|
459
|
+
// With none of the app's code read and nothing serious seen, there's no honest grade to give.
|
|
460
|
+
const ungraded = noCodeRead && penalty < SEVERITY.high;
|
|
461
|
+
const grade = ungraded ? "?" : score >= 90 ? "A" : score >= 75 ? "B" : score >= 60 ? "C" : score >= 40 ? "D" : "F";
|
|
462
|
+
// A good grade says only what was looked at, so it can't be read as "the database is safe too".
|
|
463
|
+
const good = grade === "A" || grade === "B";
|
|
464
|
+
const incomplete = unread > 0 || cut > 0;
|
|
465
|
+
const verdict = ungraded
|
|
466
|
+
? "Not graded: Greenlit couldn't read this app's code."
|
|
467
|
+
: good && database && !mine
|
|
468
|
+
? `Nothing serious in the ${incomplete ? "code Greenlit read" : "code"}. Your database still needs checking.`
|
|
469
|
+
: good && incomplete
|
|
470
|
+
? "Nothing serious in the code Greenlit read. Some of it wasn't read."
|
|
471
|
+
: VERDICT[grade];
|
|
375
472
|
const order = ["critical", "high", "medium", "low", "info"];
|
|
376
473
|
findings.sort((a, b) => order.indexOf(a.severity) - order.indexOf(b.severity));
|
|
377
474
|
return {
|
|
378
475
|
url: origin,
|
|
379
476
|
builder,
|
|
380
|
-
score,
|
|
477
|
+
score: ungraded ? null : score,
|
|
381
478
|
grade,
|
|
382
|
-
verdict
|
|
479
|
+
verdict,
|
|
383
480
|
mine,
|
|
384
481
|
scripts: bundles.length - 1,
|
|
482
|
+
scriptsUnread: unread,
|
|
385
483
|
supabase: supabase ? { project: supabase.ref, checked: mine, readable: tables } : null,
|
|
386
484
|
firebase: firebase ? { project: firebase.project, checked: mine, readable: firebaseOpen } : null,
|
|
387
485
|
findings,
|
|
@@ -440,10 +538,10 @@ export function renderSite(r, change, { color = true, mine = r.mine } = {}) {
|
|
|
440
538
|
const k = (code) => (s) => (color ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
441
539
|
const red = k("31"), green = k("32"), yellow = k("33"), dim = k("2"), bold = k("1"), cyan = k("36");
|
|
442
540
|
const col = { critical: red, high: red, medium: yellow, low: dim, info: dim };
|
|
443
|
-
const gcol = r.
|
|
541
|
+
const gcol = r.grade === "A" || r.grade === "B" ? green : r.grade === "C" || r.grade === "?" ? yellow : red;
|
|
444
542
|
const L = [];
|
|
445
543
|
L.push("", `${bold("Greenlit check")} · ${r.url}${r.builder ? ` · built with ${r.builder}` : ""} · ${r.scripts} scripts read${r.supabase ? " · Supabase" : ""}${r.firebase ? " · Firebase" : ""}`, "");
|
|
446
|
-
L.push(` Grade ${gcol(bold(r.grade))} ${gcol(`${r.score}/100`)} ${r.verdict}`);
|
|
544
|
+
L.push(` Grade ${gcol(bold(r.grade))} ${r.score == null ? "" : `${gcol(`${r.score}/100`)} `}${r.verdict}`);
|
|
447
545
|
if (change) {
|
|
448
546
|
const arrow = change.after.score > change.before.score ? green : change.after.score < change.before.score ? red : dim;
|
|
449
547
|
L.push(` ${arrow(`Was ${change.before.grade} (${change.before.score}) on ${change.since.slice(0, 10)}, now ${change.after.grade} (${change.after.score}).`)}`);
|
|
@@ -462,7 +560,13 @@ export function renderSite(r, change, { color = true, mine = r.mine } = {}) {
|
|
|
462
560
|
if (f.prompt) {
|
|
463
561
|
L.push(` ${cyan(`Then paste this into ${r.pasteInto}:`)}`);
|
|
464
562
|
L.push(wrap(f.prompt, 84, ` ${dim("│")} `));
|
|
465
|
-
} else
|
|
563
|
+
} else {
|
|
564
|
+
L.push(wrap(`${green("Next:")} ${f.fix}`, 88, " "));
|
|
565
|
+
if (f.checkPrompt) {
|
|
566
|
+
L.push(` ${cyan(`Or paste this into ${r.pasteInto} to have it check:`)}`);
|
|
567
|
+
L.push(wrap(f.checkPrompt, 84, ` ${dim("│")} `));
|
|
568
|
+
}
|
|
569
|
+
}
|
|
466
570
|
L.push("");
|
|
467
571
|
}
|
|
468
572
|
L.push(dim(`Read only what the site serves to every visitor${mine ? "; database checked with counts and names only, never data" : ""}.`));
|
package/src/severity.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// How much each finding takes off a 100-point score. "info" is a note, not a problem: it costs nothing.
|
|
2
|
-
export const SEVERITY = { critical:
|
|
1
|
+
// How much each finding takes off a 100-point score. One critical problem means D at best, one high means C at best. "info" is a note, not a problem: it costs nothing.
|
|
2
|
+
export const SEVERITY = { critical: 45, high: 30, medium: 5, low: 1, info: 0 };
|