greenlitlab 0.5.4 → 0.6.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 +33 -0
- package/README.md +8 -3
- package/bin/greenlit.mjs +8 -1
- package/package.json +2 -1
- package/server.json +2 -2
- package/src/plain.mjs +15 -2
- package/src/scan-files.mjs +1290 -0
- package/src/scan.mjs +97 -748
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
- **New check: a read rule that hands out contact details** (`scan:open-profile:<table>`). A Row Level Security policy `for select` (or `for all`) whose condition is `true` (or `1=1`, `(select true)`, `true or …`) on a table whose columns include an email, phone, birth date, home address or ID number is now its own finding: **high** when anyone can read people's details (no role, `public` or `anon`), **medium** when only signed-in users pass (`to authenticated`, or a condition that only asks `auth.uid() is not null`), since anyone can sign up. A read rule covers every column, so a profiles table meant to show a name and an avatar hands out the email next to it. From Priberry's study of public Lovable apps: in 25 of the 32 apps that exposed contact details, the open table was a profiles or users table with a rule like this.
|
|
6
|
+
- **Places, listings and organisations are asked about, not blocked (medium).** When the table's last word is a place, listing or organisation (`stores`, `restaurants`, `venues`, `locations`, `events`, `listings`, `properties`, `jobs`, `vendors`, `clinics`, `hotels`, `offices`, `schools`, `organizations` and the like, singular too), or every contact column is a business's own (`support_`, `business_`, `venue_`, `store_`, `office_`, `company_`, `agent_`, `shop_`, `public_` or `…_public`), the prompt asks whether it is meant to be public: keep it and mark it reviewed if these are a business's details, lock it to the owner if they are people's. `event_attendees`, `company_employees`, `waitlist`, `leads`, `bookings` and `posts.author_email` stay high.
|
|
7
|
+
- **Who can really read is worked out.** A restrictive select (or all) policy with a real condition keeps out the roles it covers (one that only asks whether someone is signed in keeps out anon). `revoke select` (or `all`) on the table from `anon` or `authenticated` removes that role, and a column grant after it (`grant select (id, username) on t to anon`) opens only those columns: the finding names only the contact columns that can be read, and none means no finding. A revoke from `PUBLIC` alone doesn't count, since Supabase grants to `anon` and `authenticated` by name.
|
|
8
|
+
- Columns are read from `create table` and from later `alter table … add column`, `drop column` and `rename column` (and follow the table through `alter table … rename to`, policies included), by the column's own name split into words (`contact_email`, `phoneNumber`, `DateOfBirth`, `contact_number`, `emergency_contact`, `pan_number`, `upi_id`, `license_number`, `mail`). Flags about a detail (`email_verified boolean`, `phone_confirmed_at`, `email_hash`) and links such as `address_id uuid` don't count (`notification_…` and `provider_…` names do when they end in email, phone or address: `notification_email`); nor do a name, username, avatar or city alone.
|
|
9
|
+
- One finding per table, the widest rule winning. Such a table is no longer also listed in the `scan:public-read:*` question. A `for all` rule still gets its `scan:policy-true:<table>:all` finding too, for the writes.
|
|
10
|
+
- Not flagged: a table with Row Level Security off (that is `scan:no-rls`), a restrictive policy on its own, one for `service_role` or a custom role only, a dropped policy or table, and a select policy with no `using` (Postgres lets no row through one on its own). Not seen: SQL inside a `DO` block or built for `EXECUTE` (as for the always-true policy checks; the README says so).
|
|
11
|
+
- The finding lists the columns (`columns`) and its fix prompt says: limit reads to the row's owner (`auth.uid() = id`), or keep the public fields in their own table or a `security_invoker` view and lock the base table.
|
|
12
|
+
- Always-true policy checks also read `(select true)` as true.
|
|
13
|
+
- A table renamed with `alter table … rename to` keeps its policies under the new name.
|
|
14
|
+
- `contactColumn(name, type)` is exported from `src/scan-files.mjs`.
|
|
15
|
+
|
|
16
|
+
## 0.6.0
|
|
17
|
+
|
|
18
|
+
- **The project scan also runs over files held in memory.** `scanFiles(files, opts)` takes a `Map` of path to content and returns the same result as `codeScan(folder)`, with no disk, git or network, so it can run where there is no filesystem. It lives in `src/scan-files.mjs`, the package's main entry, which imports nothing but `node:path` and `node:crypto`. `codeScan` (in `src/scan.mjs`) now reads the folder into that map (`readFolder`) and calls it, so both give the same answer; a parity test runs every scan fixture both ways.
|
|
19
|
+
- A tracked `.env` file sent to `scanFiles` without its values is reported as a medium finding to review (`scan:env-review`: check it holds no secret key), never as a blocker. `greenlit scan` on a folder is unchanged: it reads the values and still flags a tracked `.env` only when it holds a filled-in secret.
|
|
20
|
+
- `scanFiles` takes a `Map` or a plain object. Content may be a string, a `Uint8Array`, an `ArrayBuffer` or `null`; anything else is a `TypeError` naming the file, raised before the scan starts. Paths read `\` as `/` (before the folders to skip), drop a leading `./` and lose control characters. A path that is absolute, climbs out with `..` or holds a NUL character is not scanned and is listed in the result's `skippedPaths` with the reason.
|
|
21
|
+
- `scanFiles` stops at limits when it is called directly: `maxFindings`, `maxBytes` and `deadlineMs` (defaults in `HOSTED_LIMITS`). A scan that stops says so (`truncated: true` and `stopped` with the limit reached) and adds nothing more, so a half-read project never reads as clean. `codeScan` and `greenlit scan` set no limits, as before.
|
|
22
|
+
- **Quoted names are read correctly.** A name in double quotes may hold any character and keeps its case (`"my-table"`, `public."my-table"`, `"Orders"`); an unquoted name is folded to lower case, as Postgres does. Before, every name was lower-cased and a hyphenated quoted name was cut short, so a table with Row Level Security switched on was reported without it. What changes for a quoted name with capitals (unquoted names and quoted lower-case names are unchanged):
|
|
23
|
+
- Tables: `scan:no-rls:<table>`, `scan:policy-true:<table>:<action>`, `scan:policy-user-metadata:<table>` and the `tables` list of `scan:public-read:*` use the name as written (`scan:no-rls:Orders`, was `orders`).
|
|
24
|
+
- Views: `scan:view-definer:<view>`, `scan:view-auth-users:<view>`, `scan:matview-exposed:<view>` keep the view's case.
|
|
25
|
+
- Functions: `scan:definer-function:<function>` keeps the function's case.
|
|
26
|
+
- Policies: a policy's name is case-sensitive when quoted, so `drop policy "Read"` no longer removes a policy created as `"read"` (Postgres wouldn't either).
|
|
27
|
+
- `"Orders"` and `orders` are two tables, as in Postgres: switching RLS on for one doesn't count for the other.
|
|
28
|
+
- Names are matched exactly as written, so `"orders "`, `"my table"` and a name with a zero-width character are not `orders` or `"my table"`. Only what is shown is cleaned: in ids, titles and fixes a control, bidi or zero-width character shows as `?` (in names, storage bucket ids and function names from `config.toml`), and a name over 63 characters is shortened with a hash so two names never share an id. No finding text carries a control or bidi character.
|
|
29
|
+
- A path `scanFiles` drops (absolute, `..`, NUL, or a duplicate) that would have been SQL, rules or config is listed in `unread`, judged by the path with control characters taken out (`002.sql` followed by NUL counts as SQL).
|
|
30
|
+
- `greenlit scan` never prints a green "Nothing found" for a partial scan: it prints "Not fully checked" with the reason (files that couldn't be read, a file cap, a limit), and `--fail-on` exits with 3 instead of passing (documented in the README).
|
|
31
|
+
- A long `revoke … on function …` statement is read in linear time (1.4 MB took 30 s; now 13 ms, and 16 MB 79 ms).
|
|
32
|
+
- A file that can't be read (no permission, gone mid-scan) now counts as a file and, if it is SQL or a rules file, is listed in `unread` (so the result is partial, never clean). Before, it was left out without a word.
|
|
33
|
+
- Large inputs no longer slow the scan down out of proportion: 4 MB of `create table` lines takes about a tenth of a second (it took 85 seconds), and a `.ts` file full of public-prefixed secret names is linear too. `greenlit scan` reads each file when it reaches it rather than loading the project and its build output up front, so memory stays near the 0.5.4 level.
|
|
34
|
+
- `src/scan.mjs` now needs `src/scan-files.mjs` next to it. Anything that copies the scan file on its own must copy both; launch-blockers 0.2.6 does.
|
|
35
|
+
|
|
3
36
|
## 0.5.4
|
|
4
37
|
|
|
5
38
|
- **Six Priberry tools.** The README, llms.txt, the site and guide footers and public report pages now name Rolelock too (`npx rolelock@0.1.0 ./my-app`), and the README and llms.txt give each tool its one command.
|
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ The owner-only checks ask for a row count (Supabase), one file or document name
|
|
|
45
45
|
| No DMARC record or a broken SPF record on your own domain | everywhere, custom domains only |
|
|
46
46
|
| Personal columns (email, phone, password…) in tables strangers can read; backend functions listed for review | your own app: `--mine` |
|
|
47
47
|
| Rules that are too loose, tables strangers can change: Supabase's Security Advisor in plain words | `advisor`, with your advisor results |
|
|
48
|
-
| Always-true policies, tables without Row Level Security, unverified payment webhooks, secrets behind a public prefix | `scan`, on your project's files |
|
|
48
|
+
| Always-true policies (and read rules that hand out emails, phones or addresses), tables without Row Level Security, unverified payment webhooks, secrets behind a public prefix | `scan`, on your project's files |
|
|
49
49
|
| Backups, spending limits, a separate test database, outage alerts | `questions`: only you know, never graded |
|
|
50
50
|
|
|
51
51
|
Only what Greenlit confirmed moves the grade. What it couldn't see is said out loud, and what only you know is asked. Greenlit never signs in, never reads your users' data and never writes to your database.
|
|
@@ -61,9 +61,14 @@ npx greenlitlab <url> --json # the full result
|
|
|
61
61
|
npx greenlitlab <url> --fail-on high # exit 1 if anything this serious is found, for CI
|
|
62
62
|
npx greenlitlab questions # seven things only you know, with a fix for each gap
|
|
63
63
|
npx greenlitlab scan [folder] # read your project's files before you deploy
|
|
64
|
+
npx greenlitlab scan . --fail-on high # for CI: see the exit codes below
|
|
64
65
|
npx greenlitlab advisor results.json # Supabase's Security Advisor, in plain words
|
|
65
66
|
```
|
|
66
67
|
|
|
68
|
+
With `--fail-on <level>`, `scan` exits with 1 when it finds anything at that level or above, and with 3 when it couldn't check everything (a file that matters couldn't be read, or too many files). A 3 is never a pass. Otherwise it exits with 0.
|
|
69
|
+
|
|
70
|
+
`scan` reads migrations statement by statement, in order. SQL run inside a `DO $$ … $$` block or built for `EXECUTE` isn't read, so a policy created, dropped or changed that way doesn't count (for the always-true policy checks and the read rules that hand out contact columns alike). Rules changed in the Supabase dashboard never show up in files: check the live app with `--mine`.
|
|
71
|
+
|
|
67
72
|
The last result for each app is kept in `~/.greenlit/sites/` (grade, finding ids and titles only, never keys) so the next run can show what changed.
|
|
68
73
|
|
|
69
74
|
## In Claude, Cursor, VS Code and other agents
|
|
@@ -71,7 +76,7 @@ The last result for each app is kept in `~/.greenlit/sites/` (grade, finding ids
|
|
|
71
76
|
Add Greenlit as an MCP server:
|
|
72
77
|
|
|
73
78
|
```json
|
|
74
|
-
{ "mcpServers": { "greenlit": { "command": "npx", "args": ["-y", "greenlitlab@0.
|
|
79
|
+
{ "mcpServers": { "greenlit": { "command": "npx", "args": ["-y", "greenlitlab@0.6.0", "mcp"] } } }
|
|
75
80
|
```
|
|
76
81
|
|
|
77
82
|
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.
|
|
@@ -81,7 +86,7 @@ Then ask your agent to check the app it just deployed and apply the fixes. The `
|
|
|
81
86
|
Greenlit comes from [Priberry](https://priberry.com), the crash-test lab for AI agents. Priberry makes six free, open-source tools:
|
|
82
87
|
|
|
83
88
|
- **[Launch Blockers](https://github.com/priberry-data/launch-blockers)**: the leaks AI-built apps ship, checked in your code. `npx launch-blockers check`
|
|
84
|
-
- **[Rolelock](https://github.com/priberry-data/rolelock)**: can your users raise their own role? Finds two holes in Supabase apps: signed-in users who can raise their own role, and edge functions that use the secret key with an id from the request. `npx rolelock@0.1.
|
|
89
|
+
- **[Rolelock](https://github.com/priberry-data/rolelock)**: can your users raise their own role? Finds two holes in Supabase apps: signed-in users who can raise their own role, and edge functions that use the secret key with an id from the request. `npx rolelock@0.1.1 ./my-app`
|
|
85
90
|
- **Greenlit**: what a stranger can see in your live app. `npx greenlitlab yourapp.com`
|
|
86
91
|
- **[Crumple](https://github.com/priberry-data/crumplelab)**: a crash-test lab for AI coding agents. `npx crumplelab attack`
|
|
87
92
|
- **[Tare](https://github.com/priberry-data/tarelab)**: where your coding agent's tokens go. `npx tarelab`
|
package/bin/greenlit.mjs
CHANGED
|
@@ -75,12 +75,19 @@ if (opt.version) {
|
|
|
75
75
|
if (opt.json) console.log(JSON.stringify(r, null, 2));
|
|
76
76
|
else console.log(renderList(heading, r.findings, { color, ...extra }));
|
|
77
77
|
if (failOn && r.findings.some((f) => SEVERITY[f.severity] >= SEVERITY[failOn])) process.exitCode = 1;
|
|
78
|
+
// Nothing found in files that couldn't all be read is not a pass.
|
|
79
|
+
else if (failOn && extra?.partial) {
|
|
80
|
+
console.error(`greenlit: ${extra.partial} Exiting with 3.`);
|
|
81
|
+
process.exitCode = 3;
|
|
82
|
+
}
|
|
78
83
|
};
|
|
79
84
|
try {
|
|
80
85
|
if (positionals[0] === "scan") {
|
|
81
86
|
const { codeScan } = await import("../src/scan.mjs");
|
|
82
87
|
const r = codeScan(positionals[1] || ".");
|
|
83
|
-
|
|
88
|
+
const { notFullyChecked } = await import("../src/plain.mjs");
|
|
89
|
+
const partial = notFullyChecked(r);
|
|
90
|
+
finish(r, `Greenlit scan · ${r.dir} · ${r.files} files read`, { partial, empty: "Nothing found in the patterns Greenlit knows. This is not a full code review.", footer: "Read on your computer; nothing was sent anywhere. Names in .env files were read, never values.\nThis finds known mistakes by pattern. It can't see the live database: for that, run npx greenlitlab <your app> --mine" });
|
|
84
91
|
} else if (positionals[0] === "advisor") {
|
|
85
92
|
const { fromAdvisor, ADVISOR_HOW } = await import("../src/advisor.mjs");
|
|
86
93
|
const file = positionals[1];
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greenlitlab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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. Checks leaks, open data and launch basics.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "src/scan-files.mjs",
|
|
6
7
|
"bin": {
|
|
7
8
|
"greenlit": "bin/greenlit.mjs",
|
|
8
9
|
"greenlitlab": "bin/greenlit.mjs"
|
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.6.1",
|
|
9
9
|
"packages": [
|
|
10
10
|
{
|
|
11
11
|
"registryType": "npm",
|
|
12
12
|
"identifier": "greenlitlab",
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.6.1",
|
|
14
14
|
"transport": { "type": "stdio" },
|
|
15
15
|
"packageArguments": [{ "type": "positional", "value": "mcp" }]
|
|
16
16
|
}
|
package/src/plain.mjs
CHANGED
|
@@ -12,12 +12,25 @@ const wrap = (s, w, pad) => {
|
|
|
12
12
|
return out.join("\n");
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
// Why a scan result is not the whole answer, or null when it is: files that matter left unread, a file cap, or a
|
|
16
|
+
// limit reached. A partial scan is never shown as "Nothing found".
|
|
17
|
+
export function notFullyChecked(r) {
|
|
18
|
+
if (!r) return null;
|
|
19
|
+
const why = [];
|
|
20
|
+
const n = r.unread?.length ?? 0;
|
|
21
|
+
if (n) why.push(`${n} file${n > 1 ? "s" : ""} that matter${n > 1 ? "" : "s"} couldn't be read (${r.unread.slice(0, 3).join(", ")}${n > 3 ? ` and ${n - 3} more` : ""})`);
|
|
22
|
+
if (r.stopped) why.push(`the scan stopped at its ${r.stopped.reason} limit (${r.stopped.limit})`);
|
|
23
|
+
else if (r.truncated) why.push(`only the first ${r.files} files were read`);
|
|
24
|
+
return why.length ? `Not fully checked: ${why.join("; ")}.` : null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function renderList(heading, findings, { color = true, pasteInto = "your AI app builder or coding agent", empty = "Nothing found.", footer = "", partial = null } = {}) {
|
|
16
28
|
const k = (code) => (s) => (color ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
17
29
|
const red = k("31"), green = k("32"), yellow = k("33"), dim = k("2"), bold = k("1"), cyan = k("36");
|
|
18
30
|
const col = { critical: red, high: red, medium: yellow, low: dim, info: dim };
|
|
19
31
|
const L = ["", bold(heading), ""];
|
|
20
|
-
if (
|
|
32
|
+
if (partial) L.push(yellow(` ${partial}`), "");
|
|
33
|
+
else if (!findings.length) L.push(green(` ${empty}`), "");
|
|
21
34
|
let n = 0;
|
|
22
35
|
for (const f of findings) {
|
|
23
36
|
L.push(`${String(++n).padStart(2)}. ${col[f.severity](f.severity.toUpperCase().padEnd(8))} ${bold(f.title)}${f.where ? ` ${dim(`(${f.where})`)}` : ""}`);
|