greenlitlab 0.5.1 → 0.5.2
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 +9 -1
- package/README.md +4 -2
- package/package.json +2 -2
- package/server.json +2 -2
- package/src/scan.mjs +54 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.5.
|
|
3
|
+
## 0.5.2
|
|
4
|
+
|
|
5
|
+
- **Keys baked into the built app are found.**
|
|
6
|
+
- `greenlitlab scan` now also reads `dist/`, `build/`, `out/` and `.next/static` for key shapes and Supabase service_role tokens. These are the files that ship to visitors.
|
|
7
|
+
- A `VITE_` or `NEXT_PUBLIC_` variable is swapped for its value when the app is built, so a key can be missing from the source and still be public. Priberry's study found AI keys shipped this way in about 1 in 30 public Lovable apps.
|
|
8
|
+
- Values are never shown. A build folder that is a symlink out of the project is not read.
|
|
9
|
+
- Every key finding in a built app says to rotate the key first.
|
|
10
|
+
|
|
11
|
+
## 0.5.1
|
|
4
12
|
|
|
5
13
|
Hand-checked against real public Lovable projects (25 November 2026). Each wrong answer became a test case.
|
|
6
14
|
|
package/README.md
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
npx greenlitlab myapp.lovable.app
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
Runs on Mac, Windows and Linux (Node 20+).
|
|
16
|
+
|
|
15
17
|
## What it checks
|
|
16
18
|
|
|
17
19
|
| Check | Where it runs |
|
|
@@ -69,13 +71,13 @@ The last result for each app is kept in `~/.greenlit/sites/` (grade, finding ids
|
|
|
69
71
|
Add Greenlit as an MCP server:
|
|
70
72
|
|
|
71
73
|
```json
|
|
72
|
-
{ "mcpServers": { "greenlit": { "command": "npx", "args": ["-y", "greenlitlab@0.
|
|
74
|
+
{ "mcpServers": { "greenlit": { "command": "npx", "args": ["-y", "greenlitlab@0.5.1", "mcp"] } } }
|
|
73
75
|
```
|
|
74
76
|
|
|
75
77
|
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.
|
|
76
78
|
|
|
77
79
|
## Made by Priberry
|
|
78
80
|
|
|
79
|
-
Greenlit comes from [Priberry](https://priberry.com), the crash-test lab for AI agents. Its sister tools: [Crumple](https://crumple.priberry.com) crash-tests coding agents,
|
|
81
|
+
Greenlit comes from [Priberry](https://priberry.com), the crash-test lab for AI agents. Its sister tools: [Launch Blockers](https://greenlit.priberry.com/blockers/) stops a deploy that would leak your users' data, [Crumple](https://crumple.priberry.com) crash-tests coding agents, [Tare](https://tare.priberry.com) shows what they cost, and [MarkOS](https://markos.priberry.com) is an AI exec team on your own computer.
|
|
80
82
|
|
|
81
83
|
Apache-2.0. Found a problem? [Open an issue](https://github.com/priberry-data/greenlitlab/issues), or see [SECURITY.md](SECURITY.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greenlitlab",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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. Checks leaks, open data and launch basics.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"test": "node --test
|
|
23
|
+
"test": "node --test"
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"keywords": [
|
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.5.
|
|
8
|
+
"version": "0.5.2",
|
|
9
9
|
"packages": [
|
|
10
10
|
{
|
|
11
11
|
"registryType": "npm",
|
|
12
12
|
"identifier": "greenlitlab",
|
|
13
|
-
"version": "0.5.
|
|
13
|
+
"version": "0.5.2",
|
|
14
14
|
"transport": { "type": "stdio" },
|
|
15
15
|
"packageArguments": [{ "type": "positional", "value": "mcp" }]
|
|
16
16
|
}
|
package/src/scan.mjs
CHANGED
|
@@ -723,6 +723,60 @@ export function codeScan(dir = ".") {
|
|
|
723
723
|
if (hasDeps && !["package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((f) => fs.existsSync(path.join(root, f))))
|
|
724
724
|
add({ id: "scan:no-lockfile", severity: "low", where: "package.json", title: "No lockfile", why: "Without a lockfile every build may install different versions of your dependencies, so the app you tested isn't the app you ship.", fix: "Commit the lockfile your package manager creates.", first: null, prompt: "My project has no lockfile. Run the install for the package manager this project uses, commit the lockfile it creates, and make the build use it." });
|
|
725
725
|
|
|
726
|
+
// The built app (dist/, build/, out/, .next/static) is skipped above because it repeats the source. But it is what
|
|
727
|
+
// ships to every visitor, and it holds values the source only names: a VITE_ or NEXT_PUBLIC_ variable is replaced by
|
|
728
|
+
// its value at build time. Priberry's study found AI keys shipped this way in about 1 in 30 public Lovable apps.
|
|
729
|
+
// Only key shapes and service_role tokens are looked for here, never code patterns, and values are never shown.
|
|
730
|
+
for (const out of ["dist", "build", "out", ".next/static"]) {
|
|
731
|
+
const top = path.join(root, out);
|
|
732
|
+
let st;
|
|
733
|
+
try {
|
|
734
|
+
st = fs.lstatSync(top);
|
|
735
|
+
} catch {
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
if (!st.isDirectory()) continue; // not a symlink out of the project
|
|
739
|
+
const stack = [top];
|
|
740
|
+
let read = 0;
|
|
741
|
+
while (stack.length && read < 2000) {
|
|
742
|
+
const d = stack.pop();
|
|
743
|
+
let entries = [];
|
|
744
|
+
try {
|
|
745
|
+
entries = fs.readdirSync(d, { withFileTypes: true });
|
|
746
|
+
} catch {}
|
|
747
|
+
for (const e of entries) {
|
|
748
|
+
const full = path.join(d, e.name);
|
|
749
|
+
if (e.isDirectory()) stack.push(full);
|
|
750
|
+
if (!e.isFile() || !/\.(m?js|cjs|html|json)$/.test(e.name)) continue;
|
|
751
|
+
let text;
|
|
752
|
+
try {
|
|
753
|
+
if (fs.statSync(full).size > 8e6) continue;
|
|
754
|
+
text = fs.readFileSync(full, "utf8");
|
|
755
|
+
} catch {
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
read++;
|
|
759
|
+
const name = rel(full);
|
|
760
|
+
for (const [kind, re] of KEY_SHAPES) {
|
|
761
|
+
for (const m of text.matchAll(re)) {
|
|
762
|
+
if (PLACEHOLDER.test(m[0].slice(6)) || /^(.)\1+$/.test(m[0].slice(-12))) continue;
|
|
763
|
+
add({ id: `scan:key-in-bundle:${out}:${shortHash(kind)}`, severity: "critical", where: `${name}:${lineOf(text, m.index)}`, title: `${kind[0].toUpperCase()}${kind.slice(1)} is in the built app that ships to visitors`, why: `The ${out}/ folder is what gets deployed, and anyone who opens the app can read this key from its JavaScript. The source may only name it (a VITE_ or NEXT_PUBLIC_ variable is swapped for its value when the app is built), so the key can be missing from the code and still be public.`, fix: "Move the call that needs this key into a server function, read the key there from a secret, and rebuild.", first: "Rotate this key now: if the app was ever deployed with it, it is already public.", prompt: `My built app in ${out}/ contains ${kind}. Don't show me the value. First tell me where to rotate it. Then find which environment variable puts it into the browser build (a VITE_ or NEXT_PUBLIC_ prefix, or a define in the build config), move the code that uses it into a server function or Supabase edge function that reads it from a secret, rebuild, and confirm the key no longer appears anywhere in ${out}/.` });
|
|
764
|
+
break;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
for (const m of text.matchAll(/\beyJ[A-Za-z0-9_-]{10,}\.(eyJ[A-Za-z0-9_-]{10,})\.[A-Za-z0-9_-]{8,}/g)) {
|
|
768
|
+
let role = "";
|
|
769
|
+
try {
|
|
770
|
+
role = JSON.parse(Buffer.from(m[1], "base64url").toString("utf8")).role;
|
|
771
|
+
} catch {}
|
|
772
|
+
if (role !== "service_role") continue;
|
|
773
|
+
add({ id: `scan:service-role-in-bundle:${out}`, severity: "critical", where: `${name}:${lineOf(text, m.index)}`, title: "The Supabase service_role key is in the built app that ships to visitors", why: "The service_role key skips every Row Level Security rule. It's in the deployed JavaScript, so anyone can read, change or delete everything in the database.", fix: "Use the publishable (anon) key in the browser and move admin work into an edge function that checks who's calling.", first: "Rotate the service_role key in the Supabase dashboard now, before anything else.", prompt: `My built app in ${out}/ contains my Supabase service_role key. Don't show me the value. First tell me how to rotate it in the Supabase dashboard. Then find what puts it into the browser build, replace it with the publishable key, move anything that needs admin rights into an edge function that checks the signed-in user, rebuild, and confirm the key no longer appears in ${out}/.` });
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
726
780
|
const order = ["critical", "high", "medium", "low", "info"];
|
|
727
781
|
findings.sort((a, b) => order.indexOf(a.severity) - order.indexOf(b.severity));
|
|
728
782
|
return { source: "your project's files", dir: root, files: files.length, findings, truncated: walked.truncated, unread, gitUnavailable, nested: walked.nested };
|