greenlitlab 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 +8 -0
- package/README.md +3 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/grade.mjs +58 -13
- package/src/severity.mjs +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 (10 November 2026)
|
|
4
|
+
|
|
5
|
+
- Fixed: `--mine` was reporting nothing open when it had tested nothing. Supabase stopped listing a project's tables for the public key in 2026, and Greenlit relied on that list. It now takes table names from the app's own code, reports how many tables it tested, and says plainly when it could test none.
|
|
6
|
+
- Storage buckets named in the app's code are checked too, not only the nine common names. Database functions the app calls are listed in the JSON result and never called.
|
|
7
|
+
- An app that shows signs of Supabase without both its address and public key is reported as "database not checked" instead of nothing.
|
|
8
|
+
- Grades: one critical problem is now an F whatever else is right. Medium and low findings together take 20 points at most, so missing headers alone can never fail an app.
|
|
9
|
+
- Fairness: on a lovable.app address, missing frame protection is shown but costs no points, because the host sets those headers.
|
|
10
|
+
|
|
3
11
|
## 0.2.1 (9 November 2026)
|
|
4
12
|
|
|
5
13
|
- 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.
|
package/README.md
CHANGED
|
@@ -24,7 +24,9 @@ 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
|
|
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 is an F whatever else is right, one high problem means C at best, and small things such as missing headers take 20 points at most. What your host controls and you can't change is shown but costs nothing.
|
|
28
|
+
|
|
29
|
+
Supabase no longer lists a project's tables for the public key, so `--mine` tests the tables your app's code names, tells you how many it tested, and says so plainly when it could test none.
|
|
28
30
|
|
|
29
31
|
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.
|
|
30
32
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greenlitlab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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.
|
|
8
|
+
"version": "0.3.0",
|
|
9
9
|
"packages": [
|
|
10
10
|
{
|
|
11
11
|
"registryType": "npm",
|
|
12
12
|
"identifier": "greenlitlab",
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.3.0",
|
|
14
14
|
"transport": { "type": "stdio" },
|
|
15
15
|
"packageArguments": [{ "type": "positional", "value": "mcp" }]
|
|
16
16
|
}
|
package/src/grade.mjs
CHANGED
|
@@ -51,6 +51,11 @@ const FB_DB = /["'](https:\/\/[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:firebaseio\.com|fi
|
|
|
51
51
|
const FB_KEY = /apiKey["']?\s*:\s*["'](AIza[0-9A-Za-z_-]{35})["']/;
|
|
52
52
|
// Firestore can't list its collections without admin rights, so try the names apps use for people and money.
|
|
53
53
|
const FIRESTORE_GUESSES = ["users", "profiles", "customers", "accounts", "orders", "payments", "messages", "chats", "leads", "contacts", "posts"];
|
|
54
|
+
// Supabase stopped listing tables for the public key in 2026, so table names come from the app's own code:
|
|
55
|
+
// supabase.from("orders") calls and /rest/v1/orders addresses. Names that aren't tables answer "not found" and are dropped.
|
|
56
|
+
const TABLE_REF = /\.from\(\s*["'`]([A-Za-z_][A-Za-z0-9_]{1,62})["'`]\s*\)|\/rest\/v1\/([A-Za-z_][A-Za-z0-9_]{1,62})(?![A-Za-z0-9_])/g;
|
|
57
|
+
const RPC_REF = /\.rpc\(\s*["'`]([A-Za-z_][A-Za-z0-9_]{1,62})["'`]|\/rest\/v1\/rpc\/([A-Za-z_][A-Za-z0-9_]{1,62})/g;
|
|
58
|
+
const BUCKET_REF = /storage\s*\.from\(\s*["'`]([A-Za-z0-9_.-]{1,63})["'`]/g;
|
|
54
59
|
const PERSONAL = /user|profile|customer|account|order|payment|message|chat|contact|lead|email|subscri|invoice/i;
|
|
55
60
|
|
|
56
61
|
// Which app builder made this, so the fix prompt can say where to paste it.
|
|
@@ -355,21 +360,46 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
355
360
|
|
|
356
361
|
// Supabase: with the public anon key, which tables can anyone read?
|
|
357
362
|
let tables = null;
|
|
363
|
+
let tablesTested = 0;
|
|
364
|
+
let dbBlind = false;
|
|
365
|
+
let tablesListed = false;
|
|
366
|
+
// Database functions the app calls. Listed for the owner, never called: calling one runs it.
|
|
367
|
+
const functions = new Set();
|
|
368
|
+
const bucketsInCode = new Set();
|
|
369
|
+
if (supabase)
|
|
370
|
+
for (const b of bundles) {
|
|
371
|
+
for (const m of b.text.matchAll(RPC_REF)) functions.add(m[1] || m[2]);
|
|
372
|
+
for (const m of b.text.matchAll(BUCKET_REF)) bucketsInCode.add(m[1]);
|
|
373
|
+
}
|
|
374
|
+
// Signs of Supabase, but not both its address and its public key: nothing can be tested.
|
|
375
|
+
const supabasePartial = Boolean(supabase && !(supabase.url && supabase.anon) && !firebase?.project);
|
|
376
|
+
if (supabasePartial)
|
|
377
|
+
add({ id: "db:not-found", severity: "info", where: "Supabase", title: "This app seems to use Supabase, but its database wasn't checked", why: "Greenlit found signs of Supabase but not both its address and its public key in the code it read, so it couldn't test anything. The app may reach its database through its own server, which is the safer design, or the key may be in code that wasn't read.", fix: "Open Supabase → Advisors → Security Advisor: it lists every table and function that strangers can reach.", first: null, prompt: null, checkPrompt: P.dbCheck("Supabase") });
|
|
358
378
|
if (mine && supabase?.url && supabase.anon) {
|
|
359
379
|
// The newer sb_publishable_ keys aren't JWTs and go in the apikey header only.
|
|
360
380
|
const h = { apikey: supabase.anon, ...(supabase.anon.startsWith("eyJ") && { authorization: `Bearer ${supabase.anon}` }) };
|
|
381
|
+
const names = new Set();
|
|
382
|
+
// Older projects still answer this with the list of tables; newer ones refuse the public key.
|
|
361
383
|
const api = await get(`${supabase.url}/rest/v1/`, fetchOpts({ headers: h }));
|
|
362
|
-
let names = [];
|
|
363
384
|
try {
|
|
364
|
-
|
|
385
|
+
for (const p of Object.keys(JSON.parse(api.text).paths || {})) if (p.slice(1) && !p.startsWith("/rpc/")) names.add(p.slice(1));
|
|
365
386
|
} catch {}
|
|
387
|
+
tablesListed = names.size > 0;
|
|
388
|
+
for (const b of bundles) for (const m of b.text.matchAll(TABLE_REF)) (m[1] || m[2]) !== "rpc" && names.add(m[1] || m[2]);
|
|
366
389
|
tables = [];
|
|
367
|
-
for (const t of names.slice(0,
|
|
390
|
+
for (const t of [...names].slice(0, 80)) {
|
|
368
391
|
// A HEAD request with count=exact returns how many rows are visible, and no rows.
|
|
369
392
|
const r = await get(`${supabase.url}/rest/v1/${encodeURIComponent(t)}?select=*`, fetchOpts({ method: "HEAD", headers: { ...h, prefer: "count=exact", range: "0-0" } }));
|
|
393
|
+
// "Not found" means the name wasn't a table; no answer means it wasn't tested. Neither counts.
|
|
394
|
+
if (!r.status || r.status === 404 || r.status >= 500) continue;
|
|
395
|
+
tablesTested++;
|
|
370
396
|
const n = Number((r.headers?.get("content-range") || "").split("/")[1]);
|
|
371
397
|
if (r.status < 300 && n > 0) tables.push({ table: t, rows: n });
|
|
372
398
|
}
|
|
399
|
+
// A check that tested no tables must say so, not report "nothing open".
|
|
400
|
+
dbBlind = tablesTested === 0;
|
|
401
|
+
if (dbBlind)
|
|
402
|
+
add({ id: "db:no-tables", severity: "info", where: "Supabase", title: "Your database tables weren't checked", why: "Greenlit couldn't find any of your table names in the code it read, and Supabase no longer lists them for the public key. So it couldn't test which tables strangers can read. Storage and sign-up settings were still checked.", fix: "Open Supabase → Advisors → Security Advisor: it lists every table that strangers can reach.", first: null, prompt: null, checkPrompt: P.dbCheck("Supabase") });
|
|
373
403
|
for (const { table, rows } of tables) {
|
|
374
404
|
const personal = PERSONAL.test(table);
|
|
375
405
|
const why = personal
|
|
@@ -404,8 +434,8 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
404
434
|
add({ id: "supabase:open-signup", severity: "high", where: "Supabase Auth settings", title: "Anyone can sign up with any email, without confirming it", why: "Rules that only check \"is the user signed in?\" protect nothing: a stranger can make an account in seconds, even with someone else's email address.", fix: "Turn on email confirmation in Supabase Auth, and make every policy check who owns the row, not just that someone is signed in.", ...P.signup() });
|
|
405
435
|
} catch {}
|
|
406
436
|
// Storage: which common buckets list their files to anyone? Asks for one file name, never the file.
|
|
407
|
-
for (const bucket of ["avatars", "uploads", "files", "documents", "images", "attachments", "receipts", "invoices", "private"]) {
|
|
408
|
-
const r = await get(`${supabase.url}/storage/v1/object/list/${bucket}`, fetchOpts({ method: "POST", headers: { ...h, "content-type": "application/json" }, body: JSON.stringify({ prefix: "", limit: 1, offset: 0 }), max: 65536 }));
|
|
437
|
+
for (const bucket of [...new Set(["avatars", "uploads", "files", "documents", "images", "attachments", "receipts", "invoices", "private", ...bucketsInCode])].slice(0, 24)) {
|
|
438
|
+
const r = await get(`${supabase.url}/storage/v1/object/list/${encodeURIComponent(bucket)}`, fetchOpts({ method: "POST", headers: { ...h, "content-type": "application/json" }, body: JSON.stringify({ prefix: "", limit: 1, offset: 0 }), max: 65536 }));
|
|
409
439
|
let n = 0;
|
|
410
440
|
try {
|
|
411
441
|
n = Array.isArray(JSON.parse(r.text)) ? JSON.parse(r.text).length : 0;
|
|
@@ -451,21 +481,34 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
451
481
|
add({ id: "csp", severity: "low", where: "response headers", title: "No Content-Security-Policy", why: "If an attacker gets a script into the page (through a comment, a profile field or a dependency), nothing stops it from sending your users' data out.", fix: "Add a Content-Security-Policy header in your host's settings.", ...P.csp([...thirdParty].slice(0, 6)) });
|
|
452
482
|
|
|
453
483
|
const csp = page.headers?.get("content-security-policy") || "";
|
|
454
|
-
|
|
455
|
-
|
|
484
|
+
// Lovable's own hosting sets the response headers, and this protection can't be added from inside an app
|
|
485
|
+
// (a meta tag can't do it). What the owner can't change is shown, and costs no points.
|
|
486
|
+
const hostSetsHeaders = /\.lovable\.app$/i.test(new URL(origin).hostname);
|
|
487
|
+
if (!page.headers?.get("x-frame-options") && !/frame-ancestors/i.test(csp)) {
|
|
488
|
+
if (hostSetsHeaders)
|
|
489
|
+
add({ id: "framing", severity: "info", where: "response headers", title: "Your host decides whether other sites can frame your app", why: "Other sites can show this app inside a frame, which can be used to trick people into clicks (clickjacking). On a lovable.app address the host sets these headers and we found no way for you to change them, so this costs you no points.", fix: "Nothing to do here. If you move to your own domain on a host that lets you set headers, add Content-Security-Policy: frame-ancestors 'self'.", first: null, prompt: null });
|
|
490
|
+
else
|
|
491
|
+
add({ id: "framing", severity: "low", where: "response headers", title: "Other sites can put your app in a frame", why: "A malicious page can show your app inside an invisible frame and trick your users into clicking buttons they can't see (clickjacking).", fix: "Add the header Content-Security-Policy: frame-ancestors 'self' (or X-Frame-Options: DENY).", ...P.framing() });
|
|
492
|
+
}
|
|
456
493
|
|
|
457
|
-
|
|
458
|
-
|
|
494
|
+
// Small things add up to 20 points at most, so missing headers alone can never fail an app.
|
|
495
|
+
// One critical problem is an F whatever else is right: it can't be averaged away.
|
|
496
|
+
const sum = (kinds) => findings.reduce((a, f) => a + (kinds.includes(f.severity) ? SEVERITY[f.severity] : 0), 0);
|
|
497
|
+
const penalty = sum(["critical", "high"]) + Math.min(20, sum(["medium", "low"]));
|
|
498
|
+
const blocker = findings.some((f) => f.severity === "critical");
|
|
499
|
+
const score = Math.min(Math.max(0, 100 - penalty), blocker ? 39 : 100);
|
|
459
500
|
// With none of the app's code read and nothing serious seen, there's no honest grade to give.
|
|
460
501
|
const ungraded = noCodeRead && penalty < SEVERITY.high;
|
|
461
|
-
const grade = ungraded ? "?" : score >= 90 ? "A" : score >= 75 ? "B" : score >= 60 ? "C" : score >= 40 ? "D" : "F";
|
|
502
|
+
const grade = ungraded ? "?" : blocker ? "F" : score >= 90 ? "A" : score >= 75 ? "B" : score >= 60 ? "C" : score >= 40 ? "D" : "F";
|
|
462
503
|
// A good grade says only what was looked at, so it can't be read as "the database is safe too".
|
|
463
504
|
const good = grade === "A" || grade === "B";
|
|
464
505
|
const incomplete = unread > 0 || cut > 0;
|
|
465
506
|
const verdict = ungraded
|
|
466
507
|
? "Not graded: Greenlit couldn't read this app's code."
|
|
467
|
-
: good &&
|
|
468
|
-
? `Nothing serious in the ${incomplete ? "code Greenlit read" : "code"}. Your database
|
|
508
|
+
: good && (dbBlind || supabasePartial)
|
|
509
|
+
? `Nothing serious in the ${incomplete ? "code Greenlit read" : "code"}. Your database tables weren't checked.`
|
|
510
|
+
: good && database && !mine
|
|
511
|
+
? `Nothing serious in the ${incomplete ? "code Greenlit read" : "code"}. Your database still needs checking.`
|
|
469
512
|
: good && incomplete
|
|
470
513
|
? "Nothing serious in the code Greenlit read. Some of it wasn't read."
|
|
471
514
|
: VERDICT[grade];
|
|
@@ -480,7 +523,7 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
480
523
|
mine,
|
|
481
524
|
scripts: bundles.length - 1,
|
|
482
525
|
scriptsUnread: unread,
|
|
483
|
-
supabase: supabase ? { project: supabase.ref, checked: mine, readable: tables } : null,
|
|
526
|
+
supabase: supabase ? { project: supabase.ref, checked: Boolean(mine && tables && !dbBlind), tablesTested, tablesListed, readable: tables, functions: [...functions].slice(0, 50) } : null,
|
|
484
527
|
firebase: firebase ? { project: firebase.project, checked: mine, readable: firebaseOpen } : null,
|
|
485
528
|
findings,
|
|
486
529
|
pasteInto: builder || "your AI app builder or coding agent",
|
|
@@ -569,6 +612,8 @@ export function renderSite(r, change, { color = true, mine = r.mine } = {}) {
|
|
|
569
612
|
}
|
|
570
613
|
L.push("");
|
|
571
614
|
}
|
|
615
|
+
if (r.supabase?.checked) L.push(dim(`Supabase: ${r.supabase.tablesTested} table${r.supabase.tablesTested === 1 ? "" : "s"} tested with the public key, ${r.supabase.readable.length} readable by anyone.${r.supabase.tablesListed ? "" : " Only tables named in your app's code could be tested; Supabase's Security Advisor lists them all."}`));
|
|
616
|
+
else if (mine && r.supabase) L.push(dim("Supabase: no tables were tested. See the note above."));
|
|
572
617
|
L.push(dim(`Read only what the site serves to every visitor${mine ? "; database checked with counts and names only, never data" : ""}.`));
|
|
573
618
|
if (n) {
|
|
574
619
|
L.push(dim(`Fix the red items first, one prompt at a time. Copy one prompt: npx greenlitlab ${new URL(r.url).host}${mine ? " --mine" : ""} --prompt 1 | pbcopy (or --prompt all for every fix in one)`));
|
package/src/severity.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
// How much each finding takes off a 100-point score. One critical problem
|
|
1
|
+
// How much each finding takes off a 100-point score. One critical problem is an F whatever else is right, and
|
|
2
|
+
// one high means C at best. Medium and low together take 20 points at most. "info" is a note: it costs nothing.
|
|
2
3
|
export const SEVERITY = { critical: 45, high: 30, medium: 5, low: 1, info: 0 };
|