greenlitlab 0.5.3 → 0.6.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 +24 -0
- package/README.md +13 -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 +1097 -0
- package/src/scan.mjs +97 -748
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
- **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.
|
|
6
|
+
- 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.
|
|
7
|
+
- `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.
|
|
8
|
+
- `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.
|
|
9
|
+
- **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):
|
|
10
|
+
- 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`).
|
|
11
|
+
- Views: `scan:view-definer:<view>`, `scan:view-auth-users:<view>`, `scan:matview-exposed:<view>` keep the view's case.
|
|
12
|
+
- Functions: `scan:definer-function:<function>` keeps the function's case.
|
|
13
|
+
- 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).
|
|
14
|
+
- `"Orders"` and `orders` are two tables, as in Postgres: switching RLS on for one doesn't count for the other.
|
|
15
|
+
- 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.
|
|
16
|
+
- 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).
|
|
17
|
+
- `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).
|
|
18
|
+
- 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).
|
|
19
|
+
- 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.
|
|
20
|
+
- 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.
|
|
21
|
+
- `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.
|
|
22
|
+
|
|
23
|
+
## 0.5.4
|
|
24
|
+
|
|
25
|
+
- **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.
|
|
26
|
+
|
|
3
27
|
## 0.5.3
|
|
4
28
|
|
|
5
29
|
- **"Copy all fixes" ends with a re-check.** The combined prompt (`--prompt all`, the web page's Copy all fixes button, and the MCP tool's `allFixes`) now closes with: "When every fix is live, check again at https://greenlit.priberry.com/?url=<your app> and tell me the new grade." The web and the CLI give the same words, and a test keeps them identical.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Is your AI-built app safe to launch?** Greenlit grades a deployed app from A to F for what a stranger can use against it. It explains each problem in plain words and gives you a prompt to paste back into Lovable, Bolt, v0, Replit or Emergent that fixes it. Run it again after the fix, and it shows what got fixed.
|
|
4
4
|
|
|
5
|
-
<p><img src="https://raw.githubusercontent.com/priberry-data/greenlitlab/main/docs/demo.gif" alt="Greenlit checks a Lovable app: grade F with a leaked Stripe key
|
|
5
|
+
<p><img src="https://raw.githubusercontent.com/priberry-data/greenlitlab/main/docs/demo.gif" alt="Greenlit checks a Lovable app: grade F with a leaked Stripe key and a Supabase service_role key in the page, a fix prompt to paste back, then grade A" width="720"></p>
|
|
6
6
|
|
|
7
7
|
**In the browser:** [greenlit.priberry.com](https://greenlit.priberry.com). Paste your app's address. Nothing to install.
|
|
8
8
|
|
|
@@ -61,9 +61,12 @@ 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
|
+
|
|
67
70
|
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
71
|
|
|
69
72
|
## In Claude, Cursor, VS Code and other agents
|
|
@@ -71,13 +74,20 @@ The last result for each app is kept in `~/.greenlit/sites/` (grade, finding ids
|
|
|
71
74
|
Add Greenlit as an MCP server:
|
|
72
75
|
|
|
73
76
|
```json
|
|
74
|
-
{ "mcpServers": { "greenlit": { "command": "npx", "args": ["-y", "greenlitlab@0.
|
|
77
|
+
{ "mcpServers": { "greenlit": { "command": "npx", "args": ["-y", "greenlitlab@0.6.0", "mcp"] } } }
|
|
75
78
|
```
|
|
76
79
|
|
|
77
80
|
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.
|
|
78
81
|
|
|
79
82
|
## Made by Priberry
|
|
80
83
|
|
|
81
|
-
Greenlit comes from [Priberry](https://priberry.com), the crash-test lab for AI agents.
|
|
84
|
+
Greenlit comes from [Priberry](https://priberry.com), the crash-test lab for AI agents. Priberry makes six free, open-source tools:
|
|
85
|
+
|
|
86
|
+
- **[Launch Blockers](https://github.com/priberry-data/launch-blockers)**: the leaks AI-built apps ship, checked in your code. `npx launch-blockers check`
|
|
87
|
+
- **[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.0 ./my-app`
|
|
88
|
+
- **Greenlit**: what a stranger can see in your live app. `npx greenlitlab yourapp.com`
|
|
89
|
+
- **[Crumple](https://github.com/priberry-data/crumplelab)**: a crash-test lab for AI coding agents. `npx crumplelab attack`
|
|
90
|
+
- **[Tare](https://github.com/priberry-data/tarelab)**: where your coding agent's tokens go. `npx tarelab`
|
|
91
|
+
- **[MarkOS](https://markos.priberry.com)**: an AI exec team on your own computer. `git clone https://github.com/priberry-data/markos && cd markos && ./install.sh`
|
|
82
92
|
|
|
83
93
|
Apache-2.0. Found a problem? [Open an issue](https://github.com/priberry-data/greenlitlab/issues), or see [SECURITY.md](SECURITY.md).
|
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.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. 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.0",
|
|
9
9
|
"packages": [
|
|
10
10
|
{
|
|
11
11
|
"registryType": "npm",
|
|
12
12
|
"identifier": "greenlitlab",
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.6.0",
|
|
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})`)}` : ""}`);
|