greenlitlab 0.1.0 → 0.1.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 +8 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/grade.mjs +64 -24
- package/src/severity.mjs +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1 (8 November 2026)
|
|
4
|
+
|
|
5
|
+
- Hosts that answer every missing file with the home page (Lovable, Netlify, Vercel) are no longer reported as publishing source maps.
|
|
6
|
+
- Using a database is a note, not a problem: it costs no points.
|
|
7
|
+
- A broken script address in a page, or a huge file, no longer stops or slows the check. Scripts load six at a time.
|
|
8
|
+
- The web check keeps results and visitor limits in Cloudflare's cache, so a busy day can't use up the free plan's storage writes. Errors are in plain words.
|
|
9
|
+
- Clear error for anything that isn't a web address.
|
|
10
|
+
|
|
3
11
|
## 0.1.0 (8 November 2026)
|
|
4
12
|
|
|
5
13
|
First release. Greenlit grew out of `crumple site` and is now its own product.
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ The last result for each app is kept in `~/.greenlit/sites/` (grade, finding ids
|
|
|
40
40
|
Add Greenlit as an MCP server:
|
|
41
41
|
|
|
42
42
|
```json
|
|
43
|
-
{ "mcpServers": { "greenlit": { "command": "npx", "args": ["-y", "greenlitlab@0.1.
|
|
43
|
+
{ "mcpServers": { "greenlit": { "command": "npx", "args": ["-y", "greenlitlab@0.1.1", "mcp"] } } }
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Then ask your agent to check the app it just deployed and apply the fixes. The `greenlit_check` tool returns the grade, every finding and its fix prompt.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greenlitlab",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.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.1.
|
|
8
|
+
"version": "0.1.1",
|
|
9
9
|
"packages": [
|
|
10
10
|
{
|
|
11
11
|
"registryType": "npm",
|
|
12
12
|
"identifier": "greenlitlab",
|
|
13
|
-
"version": "0.1.
|
|
13
|
+
"version": "0.1.1",
|
|
14
14
|
"transport": { "type": "stdio" },
|
|
15
15
|
"packageArguments": [{ "type": "positional", "value": "mcp" }]
|
|
16
16
|
}
|
package/src/grade.mjs
CHANGED
|
@@ -16,12 +16,12 @@ const SECRETS = [
|
|
|
16
16
|
[/rk_live_[0-9A-Za-z]{20,}/, "stripe-restricted", "A live Stripe restricted key", "Anyone can do whatever this key allows on your Stripe account.", "Stripe → Developers → API keys → delete the restricted key", "STRIPE_RESTRICTED_KEY"],
|
|
17
17
|
[/sk-(proj|svcacct|admin)-[0-9A-Za-z_-]{20,}|sk-[0-9A-Za-z]{48}\b/, "openai", "An OpenAI API key", "Anyone can run up your OpenAI bill.", "platform.openai.com → API keys → revoke", "OPENAI_API_KEY"],
|
|
18
18
|
[/sk-ant-[0-9A-Za-z_-]{20,}/, "anthropic", "An Anthropic API key", "Anyone can run up your Anthropic bill.", "console.anthropic.com → API keys → disable", "ANTHROPIC_API_KEY"],
|
|
19
|
-
[
|
|
19
|
+
[/\bAKIA[0-9A-Z]{16}\b/, "aws", "An AWS access key", "Depending on its rights: your servers, storage and bill.", "AWS console → IAM → Users → Security credentials → deactivate the key", "AWS_SECRET_ACCESS_KEY"],
|
|
20
20
|
[/gh[pousr]_[0-9A-Za-z]{30,}|github_pat_[0-9A-Za-z_]{20,}/, "github", "A GitHub token", "Access to your code, and possibly the right to change it.", "GitHub → Settings → Developer settings → tokens → delete", "GITHUB_TOKEN"],
|
|
21
21
|
[/xox[bpas]-[0-9A-Za-z-]{10,}/, "slack", "A Slack token", "Anyone can read or post in your Slack.", "api.slack.com/apps → your app → reinstall to get a new token", "SLACK_TOKEN"],
|
|
22
22
|
[/re_[0-9A-Za-z]{8}_[0-9A-Za-z]{20,}/, "resend", "A Resend API key", "Anyone can send email as you.", "resend.com → API Keys → delete", "RESEND_API_KEY"],
|
|
23
23
|
[/SG\.[0-9A-Za-z_-]{20,}\.[0-9A-Za-z_-]{20,}/, "sendgrid", "A SendGrid API key", "Anyone can send email as you.", "SendGrid → Settings → API Keys → delete", "SENDGRID_API_KEY"],
|
|
24
|
-
[
|
|
24
|
+
[/\bAC[0-9a-f]{32}\b[\s\S]{0,80}?\b[0-9a-f]{32}\b/, "twilio", "Twilio credentials", "Anyone can send texts and make calls on your account.", "Twilio console → Account → API keys & tokens → rotate the auth token", "TWILIO_AUTH_TOKEN"],
|
|
25
25
|
[/gsk_[0-9A-Za-z]{40,}/, "groq", "A Groq API key", "Anyone can run up your Groq bill.", "console.groq.com → API Keys → delete", "GROQ_API_KEY"],
|
|
26
26
|
[/AIza[0-9A-Za-z_-]{35}(?=[\s\S]{0,400}(generativelanguage|gemini))/, "gemini", "A Google AI (Gemini) API key", "Anyone can run up your Gemini bill. (Firebase keys are public by design; this one sits next to Gemini calls.)", "aistudio.google.com → API keys → delete", "GEMINI_API_KEY"],
|
|
27
27
|
];
|
|
@@ -42,7 +42,7 @@ export function detectBuilder(host, html = "") {
|
|
|
42
42
|
if (/\.replit\.app$|\.repl\.co$|\.replit\.dev$/.test(h)) return "Replit";
|
|
43
43
|
if (/\.emergent\.host$|\.emergentagent\.com$|\.preview\.emergentagent\.com$/.test(h)) return "Emergent";
|
|
44
44
|
if (/\.base44\.app$/.test(h)) return "Base44";
|
|
45
|
-
if (/v0\.dev|
|
|
45
|
+
if (/(^|\.)v0\.(dev|app)$/.test(h) || /generated by v0/i.test(html)) return "v0";
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -55,12 +55,44 @@ const decodeJwt = (t) => {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
// Reads at most `max` bytes, so a huge file can't use up the memory of the machine doing the check.
|
|
59
|
+
async function readCapped(r, max) {
|
|
60
|
+
if (!r.body?.getReader) return (await r.text()).slice(0, max);
|
|
61
|
+
const reader = r.body.getReader();
|
|
62
|
+
const parts = [];
|
|
63
|
+
let size = 0;
|
|
64
|
+
while (size < max) {
|
|
65
|
+
const { done, value } = await reader.read();
|
|
66
|
+
if (done) break;
|
|
67
|
+
parts.push(value);
|
|
68
|
+
size += value.byteLength;
|
|
69
|
+
}
|
|
70
|
+
reader.cancel().catch(() => {});
|
|
71
|
+
const all = new Uint8Array(Math.min(size, max));
|
|
72
|
+
let at = 0;
|
|
73
|
+
for (const p of parts) {
|
|
74
|
+
const take = Math.min(p.byteLength, all.length - at);
|
|
75
|
+
all.set(p.subarray(0, take), at);
|
|
76
|
+
at += take;
|
|
77
|
+
if (at >= all.length) break;
|
|
78
|
+
}
|
|
79
|
+
return new TextDecoder().decode(all);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const safeUrl = (u, base) => {
|
|
83
|
+
try {
|
|
84
|
+
return new URL(u, base);
|
|
85
|
+
} catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
58
90
|
async function get(url, { timeout = 15000, headers = {}, method = "GET", max = 8 * 1024 * 1024, fetcher = fetch } = {}) {
|
|
59
91
|
const ctl = new AbortController();
|
|
60
92
|
const t = setTimeout(() => ctl.abort(), timeout);
|
|
61
93
|
try {
|
|
62
94
|
const r = await fetcher(url, { method, headers: { "user-agent": "greenlit (+https://greenlit.priberry.com)", ...headers }, signal: ctl.signal, redirect: "follow" });
|
|
63
|
-
const text = method === "HEAD" ? "" :
|
|
95
|
+
const text = method === "HEAD" ? "" : await readCapped(r, max);
|
|
64
96
|
return { status: r.status, headers: r.headers, text, url: r.url };
|
|
65
97
|
} catch (e) {
|
|
66
98
|
return { status: 0, error: e.name === "AbortError" ? "timed out" : e.message, text: "" };
|
|
@@ -109,9 +141,10 @@ const P = {
|
|
|
109
141
|
};
|
|
110
142
|
|
|
111
143
|
// --- the check -----------------------------------------------------------------------------------
|
|
112
|
-
export async function siteScan(target, { mine = false, fetcher = fetch, maxScripts = 40 } = {}) {
|
|
113
|
-
const fetchOpts = (o = {}) => ({ ...o, fetcher });
|
|
114
|
-
const url =
|
|
144
|
+
export async function siteScan(target, { mine = false, fetcher = fetch, maxScripts = 40, maxBytes = 8 * 1024 * 1024 } = {}) {
|
|
145
|
+
const fetchOpts = (o = {}) => ({ max: maxBytes, ...o, fetcher });
|
|
146
|
+
const url = safeUrl(/^https?:\/\//i.test(String(target).trim()) ? String(target).trim() : `https://${String(target).trim()}`);
|
|
147
|
+
if (!url || !/^https?:$/.test(url.protocol) || !url.hostname.includes(".")) throw new Error(`"${target}" doesn't look like a web address`);
|
|
115
148
|
const findings = [];
|
|
116
149
|
const add = (f) => findings.push(f);
|
|
117
150
|
|
|
@@ -123,20 +156,24 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
123
156
|
// Every script the page loads from its own site, plus the scripts those import.
|
|
124
157
|
const srcs = new Set();
|
|
125
158
|
const collect = (html, base) => {
|
|
126
|
-
for (const m of html.matchAll(/<script[^>]+src=["']([^"']+)["']/gi)) srcs.add(
|
|
127
|
-
for (const m of html.matchAll(/<link[^>]+href=["']([^"']+\.m?js)["']/gi)) srcs.add(
|
|
159
|
+
for (const m of html.matchAll(/<script[^>]+src=["']([^"']+)["']/gi)) safeUrl(m[1], base) && srcs.add(safeUrl(m[1], base).href);
|
|
160
|
+
for (const m of html.matchAll(/<link[^>]+href=["']([^"']+\.m?js)["']/gi)) safeUrl(m[1], base) && srcs.add(safeUrl(m[1], base).href);
|
|
128
161
|
};
|
|
129
162
|
collect(page.text, origin);
|
|
130
163
|
const bundles = [{ where: "the page itself", text: page.text }];
|
|
131
164
|
const seen = new Set();
|
|
165
|
+
// Two rounds: the scripts the page names, then the scripts those import. Six at a time.
|
|
132
166
|
for (let pass = 0; pass < 2; pass++) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
167
|
+
const batch = [...srcs].filter((src) => !seen.has(src) && new URL(src).origin === origin).slice(0, Math.max(0, maxScripts - seen.size));
|
|
168
|
+
for (const src of batch) seen.add(src);
|
|
169
|
+
for (let i = 0; i < batch.length; i += 6) {
|
|
170
|
+
const got = await Promise.all(batch.slice(i, i + 6).map((src) => get(src, fetchOpts()).then((r) => ({ src, r }))));
|
|
171
|
+
for (const { src, r } of got) {
|
|
172
|
+
// Many hosts answer a missing file with the home page; that isn't a script.
|
|
173
|
+
if (r.status !== 200 || /text\/html/i.test(r.headers?.get("content-type") || "")) continue;
|
|
174
|
+
bundles.push({ where: new URL(src).pathname, text: r.text, url: src });
|
|
175
|
+
for (const m of r.text.matchAll(/(?:import\(|from\s*)["'](\.{0,2}\/[^"']+\.m?js)["']/g)) safeUrl(m[1], src) && srcs.add(safeUrl(m[1], src).href);
|
|
176
|
+
}
|
|
140
177
|
}
|
|
141
178
|
}
|
|
142
179
|
|
|
@@ -146,7 +183,8 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
146
183
|
const thirdParty = new Set();
|
|
147
184
|
for (const b of bundles) {
|
|
148
185
|
for (const m of b.text.matchAll(/https:\/\/([a-z0-9-]+\.)+[a-z]{2,}/gi)) {
|
|
149
|
-
const o =
|
|
186
|
+
const o = safeUrl(m[0])?.origin;
|
|
187
|
+
if (!o) continue;
|
|
150
188
|
if (o !== origin && /supabase\.co|firebase|googleapis|stripe\.com|clerk|posthog|sentry|vercel/.test(o)) thirdParty.add(o.replace(/^https:\/\/[a-z0-9]{20}\.supabase\.co$/, "https://*.supabase.co"));
|
|
151
189
|
}
|
|
152
190
|
for (const [re, id, title, why, revoke, env] of SECRETS) {
|
|
@@ -177,17 +215,19 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
177
215
|
const k = b.text.match(FB_KEY);
|
|
178
216
|
if (k) firebase.key = k[1];
|
|
179
217
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
218
|
+
const sm = b.url && b.text.match(/sourceMappingURL=([^\s'"]+\.map)/);
|
|
219
|
+
const mapUrl = sm && safeUrl(sm[1], b.url)?.href;
|
|
220
|
+
if (mapUrl && safeUrl(mapUrl).origin === origin && !findings.some((f) => f.id === "sourcemaps")) {
|
|
221
|
+
// Check what comes back: hosts that answer every missing file with the home page would look "public" otherwise.
|
|
222
|
+
const r = await get(mapUrl, fetchOpts({ max: 4096 }));
|
|
223
|
+
if (r.status === 200 && /^\s*\{[\s\S]*"(version|mappings|sources)"/.test(r.text))
|
|
184
224
|
add({ id: "sourcemaps", severity: "medium", where: new URL(mapUrl).pathname, title: "Source maps are public", why: "Anyone can read your app's original source code, including comments and any logic you assumed was hidden.", fix: "Turn off source maps in production builds (for Vite: build.sourcemap = false).", ...P.sourceMaps() });
|
|
185
225
|
}
|
|
186
226
|
}
|
|
187
227
|
|
|
188
228
|
const database = supabase?.url && supabase.anon ? "Supabase" : firebase?.project ? "Firebase" : null;
|
|
189
229
|
if (database && !mine)
|
|
190
|
-
add({ id: "db:skipped", severity: "
|
|
230
|
+
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 });
|
|
191
231
|
|
|
192
232
|
// Supabase: with the public anon key, which tables can anyone read?
|
|
193
233
|
let tables = null;
|
|
@@ -253,7 +293,7 @@ export async function siteScan(target, { mine = false, fetcher = fetch, maxScrip
|
|
|
253
293
|
const penalty = findings.reduce((a, f) => a + SEVERITY[f.severity], 0);
|
|
254
294
|
const score = Math.max(0, 100 - penalty);
|
|
255
295
|
const grade = score >= 90 ? "A" : score >= 75 ? "B" : score >= 60 ? "C" : score >= 40 ? "D" : "F";
|
|
256
|
-
const order = ["critical", "high", "medium", "low"];
|
|
296
|
+
const order = ["critical", "high", "medium", "low", "info"];
|
|
257
297
|
findings.sort((a, b) => order.indexOf(a.severity) - order.indexOf(b.severity));
|
|
258
298
|
return {
|
|
259
299
|
url: origin,
|
|
@@ -311,7 +351,7 @@ const wrap = (s, w = 92, pad = " ") => {
|
|
|
311
351
|
export function renderSite(r, change, { color = true, mine = r.mine } = {}) {
|
|
312
352
|
const k = (code) => (s) => (color ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
313
353
|
const red = k("31"), green = k("32"), yellow = k("33"), dim = k("2"), bold = k("1"), cyan = k("36");
|
|
314
|
-
const col = { critical: red, high: red, medium: yellow, low: dim };
|
|
354
|
+
const col = { critical: red, high: red, medium: yellow, low: dim, info: dim };
|
|
315
355
|
const gcol = r.score >= 75 ? green : r.score >= 55 ? yellow : red;
|
|
316
356
|
const L = [];
|
|
317
357
|
L.push("", `${bold("Greenlit check")} · ${r.url}${r.builder ? ` · built with ${r.builder}` : ""} · ${r.scripts} scripts read${r.supabase ? " · Supabase" : ""}${r.firebase ? " · Firebase" : ""}`, "");
|
package/src/severity.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// How much each finding takes off a 100-point score.
|
|
2
|
-
export const SEVERITY = { critical: 40, high: 15, medium: 5, low: 1 };
|
|
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: 40, high: 15, medium: 5, low: 1, info: 0 };
|