greenlitlab 0.4.3 → 0.4.4
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/package.json +1 -1
- package/server.json +2 -2
- package/src/scan.mjs +55 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.4 (unreleased)
|
|
4
|
+
|
|
5
|
+
- `greenlit scan` no longer raises an alarm for `verify_jwt = false` on a webhook whose code verifies the sender's signature (Stripe, Svix, GitHub and others): it's reported as low, to confirm the check runs first.
|
|
6
|
+
- `greenlit scan` reads Firebase rules: `firestore.rules`, `storage.rules` and `database.rules.json`. A rule of `if true`, or Firebase's test-mode date rule, is reported with a fix prompt (critical for database data and anything writable, high for a public read of files, which may be intended). Open Firebase rules are a common cause of leaks from mobile and AI apps.
|
|
7
|
+
|
|
8
|
+
## Unreleased (website only)
|
|
9
|
+
|
|
10
|
+
- "Tell me when it opens" takes an optional email, kept with the app's address only to write once on the day weekly re-checks open.
|
|
11
|
+
- The site counts, with no address and nothing about the visitor, how often the same browser checks an app again (the same day, after a fix, or a later day) and how many apps get each grade. Visits from our own test browsers are left out.
|
|
12
|
+
- Badge and report pages limit how often one visitor can ask, so a flood of made-up addresses can't use up the store's daily reads.
|
|
13
|
+
|
|
3
14
|
## 0.4.3 (19 November 2026)
|
|
4
15
|
|
|
5
16
|
- A passing grade now ends with what to check next: `--mine` (when the app has a database), `scan` and `questions`, the parts no outside check can see.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greenlitlab",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
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": {
|
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.4.
|
|
8
|
+
"version": "0.4.4",
|
|
9
9
|
"packages": [
|
|
10
10
|
{
|
|
11
11
|
"registryType": "npm",
|
|
12
12
|
"identifier": "greenlitlab",
|
|
13
|
-
"version": "0.4.
|
|
13
|
+
"version": "0.4.4",
|
|
14
14
|
"transport": { "type": "stdio" },
|
|
15
15
|
"packageArguments": [{ "type": "positional", "value": "mcp" }]
|
|
16
16
|
}
|
package/src/scan.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { execFileSync } from "node:child_process";
|
|
|
7
7
|
|
|
8
8
|
// Build output, dependencies, agents' working copies, and tests (whose made-up secrets and tables aren't the app's).
|
|
9
9
|
const SKIP = new Set(["node_modules", ".claude", "worktrees", "__tests__", "__mocks__", "__fixtures__", "fixtures", "test", "tests", "e2e", "cypress", ".git", "dist", "build", ".next", ".vercel", ".netlify", ".wrangler", "coverage", ".turbo", ".cache", "vendor", "__pycache__", ".venv"]);
|
|
10
|
-
const TEXT = /\.(sql|toml|json|js|jsx|ts|tsx|mjs|cjs|py|vue|svelte)$|(^|\/)\.env[^/]*$/;
|
|
10
|
+
const TEXT = /\.(sql|toml|json|js|jsx|ts|tsx|mjs|cjs|py|vue|svelte|rules)$|(^|\/)\.env[^/]*$/;
|
|
11
11
|
const PUBLIC_PREFIX = "(?:VITE_|NEXT_PUBLIC_|REACT_APP_|EXPO_PUBLIC_|PUBLIC_|NUXT_PUBLIC_)";
|
|
12
12
|
// The name must END in the secret word (or _KEY/_TOKEN after it): VITE_STRIPE_SECRET_KEY is a secret,
|
|
13
13
|
// VITE_PASSWORD_MIN_LENGTH and VITE_WEBHOOK_URL are settings.
|
|
@@ -41,6 +41,30 @@ function walk(root, max = 5000) {
|
|
|
41
41
|
|
|
42
42
|
const lineOf = (text, index) => text.slice(0, index).split("\n").length;
|
|
43
43
|
|
|
44
|
+
// Whether a function's own code checks a webhook signature (Stripe, Svix/Resend/Clerk, GitHub, Lemon Squeezy, Paddle).
|
|
45
|
+
const SIGNATURE = /constructEvent(?:Async)?\s*\(|webhooks?\.verify\s*\(|new\s+Webhook\s*\([\s\S]*?\.verify\s*\(|x-hub-signature|x-signature|paddle-signature|timingSafeEqual/i;
|
|
46
|
+
function signsItself(dir) {
|
|
47
|
+
let found = false;
|
|
48
|
+
const stack = [dir];
|
|
49
|
+
while (stack.length && !found) {
|
|
50
|
+
const d = stack.pop();
|
|
51
|
+
let entries = [];
|
|
52
|
+
try {
|
|
53
|
+
entries = fs.readdirSync(d, { withFileTypes: true });
|
|
54
|
+
} catch {}
|
|
55
|
+
for (const e of entries) {
|
|
56
|
+
const full = path.join(d, e.name);
|
|
57
|
+
if (e.isDirectory()) e.name !== "node_modules" && stack.push(full);
|
|
58
|
+
else if (/\.(ts|js|mjs)$/.test(e.name)) {
|
|
59
|
+
try {
|
|
60
|
+
if (SIGNATURE.test(fs.readFileSync(full, "utf8"))) found = true;
|
|
61
|
+
} catch {}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return found;
|
|
66
|
+
}
|
|
67
|
+
|
|
44
68
|
export function codeScan(dir = ".") {
|
|
45
69
|
const root = path.resolve(dir);
|
|
46
70
|
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) throw new Error(`"${dir}" isn't a folder`);
|
|
@@ -75,6 +99,30 @@ export function codeScan(dir = ".") {
|
|
|
75
99
|
}
|
|
76
100
|
if (isEnv) continue;
|
|
77
101
|
|
|
102
|
+
// Firebase rules: "if true", or the test-mode date check, lets anyone on the internet in.
|
|
103
|
+
// Open rules are a common cause of leaks from mobile and AI apps.
|
|
104
|
+
const fb = name.match(/(?:^|\/)(firestore|storage)\.rules$/);
|
|
105
|
+
if (fb) {
|
|
106
|
+
const rules = text.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, " "));
|
|
107
|
+
const kind = fb[1] === "storage" ? "Storage" : "Firestore";
|
|
108
|
+
for (const m of rules.matchAll(/allow\s+([a-z,\s]+?)\s*:\s*if\s+(true|request\.time\s*<\s*timestamp\.date\s*\([^)]*\))\s*;/g)) {
|
|
109
|
+
const actions = m[1].replace(/\s+/g, "").split(",").filter(Boolean);
|
|
110
|
+
const writes = actions.some((a) => ["write", "create", "update", "delete"].includes(a));
|
|
111
|
+
const testMode = m[2] !== "true";
|
|
112
|
+
const line = lineOf(rules, m.index);
|
|
113
|
+
const what = writes ? (actions.some((a) => ["read", "get", "list"].includes(a)) ? "read and change" : "change") : "read";
|
|
114
|
+
add({ id: `scan:firebase-open:${fb[1]}:${line}`, severity: writes || kind === "Firestore" ? "critical" : "high", where: `${name}:${line}`, title: `Your ${kind} rules let anyone ${what} this data${testMode ? " until a date" : ""}`, why: testMode ? `"${m[2].replace(/\s+/g, " ")}" is Firebase's test-mode rule: until that date, anyone on the internet passes it, signed in or not. Data is often left in test mode by accident.` : `"if true" lets anyone on the internet ${what} it, signed in or not, with nothing but the project's public config.`, fix: "Allow access only when request.auth != null and the document belongs to request.auth.uid.", first: writes ? "Look for data you didn't put there: with write open, anyone could have changed or deleted it." : null, prompt: `My ${kind === "Storage" ? "Firebase Storage" : "Firestore"} security rules in ${name} use "allow ${actions.join(", ")}: if ${testMode ? "request.time < timestamp.date(...)" : "true"}" at line ${line}, so anyone on the internet can ${what} the data. Rewrite the rules so a signed-in user reaches only their own documents (request.auth != null && request.auth.uid == the owner field or path segment), keep anything truly public read-only and say which it is, and show me the new rules file. Then tell me how to test them with the Firebase emulator before deploying.` });
|
|
115
|
+
}
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (/(^|\/)database\.rules\.json$/.test(name)) {
|
|
119
|
+
for (const m of text.matchAll(/"\.(read|write)"\s*:\s*(?:true|"true")/g)) {
|
|
120
|
+
const line = lineOf(text, m.index);
|
|
121
|
+
add({ id: `scan:firebase-open:database:${line}`, severity: "critical", where: `${name}:${line}`, title: `Your Realtime Database rules let anyone ${m[1]} this data`, why: `"${m[0]}" lets anyone on the internet ${m[1]} it, signed in or not.`, fix: 'Use "auth != null && auth.uid === $uid" under a per-user path instead of true.', first: m[1] === "write" ? "Look for data you didn't put there: anyone could have changed or deleted it." : null, prompt: `My Firebase Realtime Database rules in ${name} set ".${m[1]}": true at line ${line}, so anyone can ${m[1]} the data. Rewrite them so each user reaches only their own data (for example under users/$uid with auth != null && auth.uid === $uid), keep anything truly public read-only and say which it is, and show me the new rules.` });
|
|
122
|
+
}
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
78
126
|
if (name.endsWith(".sql")) {
|
|
79
127
|
const sql = noComments(text);
|
|
80
128
|
// What this file does, in the order it does it.
|
|
@@ -141,8 +189,12 @@ export function codeScan(dir = ".") {
|
|
|
141
189
|
}
|
|
142
190
|
|
|
143
191
|
if (/(^|\/)supabase\/config\.toml$/.test(name)) {
|
|
144
|
-
for (const m of text.matchAll(/\[functions\.([\w-]+)\][^\[]*?verify_jwt\s*=\s*false/g))
|
|
145
|
-
|
|
192
|
+
for (const m of text.matchAll(/\[functions\.([\w-]+)\][^\[]*?verify_jwt\s*=\s*false/g)) {
|
|
193
|
+
// A webhook that verifies its sender's signature itself is the one right use of verify_jwt = false.
|
|
194
|
+
if (signsItself(path.join(path.dirname(file), "functions", m[1])))
|
|
195
|
+
add({ id: `scan:verify-jwt:${m[1]}`, severity: "low", where: `${name}:${lineOf(text, m.index)}`, title: `The function "${m[1]}" skips the sign-in check and verifies a signature instead`, why: "That is the right setup for a webhook. Greenlit saw a signature check in its code but can't confirm it runs before anything else.", fix: "Make sure the signature check is the first thing the function does.", first: null, prompt: `My Supabase edge function "${m[1]}" has verify_jwt = false and verifies a webhook signature. Confirm the signature check runs before the function reads or changes anything, and that a request with a missing or wrong signature gets a 400. Change nothing unless it doesn't.` });
|
|
196
|
+
else add({ id: `scan:verify-jwt:${m[1]}`, severity: "high", where: `${name}:${lineOf(text, m.index)}`, title: `The function "${m[1]}" skips the sign-in check`, why: "verify_jwt = false means anyone on the internet can call this function. That is right only for webhooks that check a signature themselves.", fix: "Remove verify_jwt = false, or verify a signature inside the function.", first: null, prompt: `My Supabase edge function "${m[1]}" has verify_jwt = false, so anyone can call it. If it is a webhook, make it verify the sender's signature before doing anything. Otherwise remove that setting and make the function check the signed-in user and what they are allowed to do. Show me what you changed.` });
|
|
197
|
+
}
|
|
146
198
|
}
|
|
147
199
|
|
|
148
200
|
if (/webhook/i.test(name) && /\.(js|ts|mjs|tsx|py)$/.test(name) && /stripe/i.test(text) && !/constructEvent|construct_event|stripe-signature/i.test(text))
|