lilith-skill 0.1.0 โ 0.1.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/README.md
CHANGED
|
@@ -1,12 +1,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Lilith
|
|
2
|
+
|
|
3
|
+
```text
|
|
4
|
+
owUzOoMdQwdd0XXXYJJUUzurt\(){{}}}[[[[[[[]]]]]??????--------___+~>!" '"l><~++~>!;`
|
|
5
|
+
dJnfuZakZXYYCJnt\\/tfncYCLJzn/(){}[]]????????---------___++~<iI` 'I+][[]_i;`
|
|
6
|
+
OzjtfnCpkOYcunvvj\()1{11)(/jnczcr|}[??---------_____+++~~>i;' ^i+-+!,.
|
|
7
|
+
OYvnnncQk#hobOXvczcvx/|){{}}}{)\/t\{]?-----____++++~<>i;" 'Iii;' ";:,":l>-{)+:.
|
|
8
|
+
bbkao*#W8@$$$$$%&M#*#dCuf\(11{{}{{1){]-____++++~~<>!:. .":;". `!}uQQOpoM8BB&adZCznf|{{
|
|
9
|
+
LCQmh%$$$$$BB$$$$B%%$$$%aZXx/(){{}[[]?__++++~~<>i;' ^,,"' ^i}xLd*&B$$$$$$$BMW%$$$&dz([
|
|
10
|
+
pdo8$$@MdZQQk%@8#d0QZhW@$$$WbCr|1[]?-_+++~~~>iI^ . :-fLkM88#kqboM&&M*hwzxnJp#B$Wb0
|
|
11
|
+
*MB$$Bk0Yzczp%$8&Moa#&Mohoo*MWomv)]_+~~<<>i!;^ >\Jd#WWM&&M#8$$%&MokOu{}})jQMBWb0
|
|
12
|
+
pmwb#Wo0x\((zb%&MohkkwYjxwpUjvdhwYt]<>!I,. I]fUpW&d0OdQf[upaao#&&0['."]nQLC/l'
|
|
13
|
+
pqOJC0mQv|1{\vqkmJczUJLQJUOqdkdQUc(~: '!1\/vkkqZLcUUznnnrzYqZ1 +t|-"
|
|
14
|
+
okOznjxYLz/1{{|YLnn/t/tftrjncvx1~;' "|r)|()(|\|(|\/uj> l<!
|
|
15
|
+
&Wh0n\)(\junt)1)\xc/~I!<+?{{(< '<?+:'`^;!+}}, :: '<
|
|
16
|
+
8&MhOYr\)))(|tft\||(((|(1_;. '''.. ' !_
|
|
17
|
+
%88&*wXunx/()11{11)1}?<, ":'
|
|
18
|
+
8888&Mh0nttjjj/)1}]_!'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Lilith is an agent skill that checks apps built with AI tools for the security holes those tools tend to leave: secret keys shipped to the browser, Supabase tables without row level security, API routes that never check who is calling, payment webhooks nobody verifies. It explains each finding in plain language and fixes the ones you approve. After security it can also clean up leftover AI code and UI.
|
|
2
22
|
|
|
3
|
-
|
|
23
|
+
## Install
|
|
4
24
|
|
|
5
25
|
```bash
|
|
6
26
|
npx lilith-skill
|
|
7
27
|
```
|
|
8
28
|
|
|
9
|
-
|
|
29
|
+
The installer finds the coding agents on your machine (Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf) and copies the skill to where each one looks for skills. Run it again to update. It needs Node.js 18 or later. The quick scan also uses Python 3.8+ when it is installed; without Python the agent reads the code instead.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx lilith-skill --agent claude # one agent only
|
|
33
|
+
npx lilith-skill --project # install into the current project
|
|
34
|
+
npx lilith-skill scan . # run the quick scan yourself
|
|
35
|
+
npx lilith-skill uninstall
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Other tools that support [Agent Skills](https://agentskills.io) can install it with `npx skills add Sunnik21/lilith -g`.
|
|
39
|
+
|
|
40
|
+
If you build in Lovable, Bolt or v0 and have no terminal, paste the prompt from [PROMPT.md](PROMPT.md) into the project chat instead.
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
Type `/lilith` in your agent, or ask in plain words: "check my app before launch", "is my app safe?", "clean up my landing page", "help me secure my VPS".
|
|
45
|
+
|
|
46
|
+
Lilith reports first and changes nothing until you agree. A report looks like this:
|
|
10
47
|
|
|
11
48
|
```
|
|
12
49
|
Live database: checked (Supabase query results pasted)
|
|
@@ -21,53 +58,19 @@ in the OpenAI dashboard (only you can do this).
|
|
|
21
58
|
Want me to fix the ๐ด ones now?
|
|
22
59
|
```
|
|
23
60
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
---
|
|
61
|
+
## Why
|
|
27
62
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- **CVE-2025-48757** (CVSS 9.3, critical): insufficient Row Level Security in apps generated by Lovable "allows remote unauthenticated attackers to read or write to arbitrary database tables of generated sites" ([NVD](https://nvd.nist.gov/vuln/detail/CVE-2025-48757)). Lovable disputes the CVE, saying each customer is responsible for protecting their app's data.
|
|
63
|
+
- CVE-2025-48757 (CVSS 9.3, critical): insufficient Row Level Security in apps generated by Lovable "allows remote unauthenticated attackers to read or write to arbitrary database tables of generated sites" ([NVD](https://nvd.nist.gov/vuln/detail/CVE-2025-48757)). Lovable disputes the CVE, saying each customer is responsible for protecting their app's data.
|
|
31
64
|
- The researcher's scan "identified 303 endpoints across 170 projects (approximately 10.3% of the 1645 analyzed) with inadequate RLS settings" ([Matt Palmer, May 29, 2025](https://mattpalmer.io/posts/statement-on-CVE-2025-48757/)).
|
|
32
65
|
- UpGuard "found 16,326 Supabase databases exposing readable tables" out of about 300,000 domains using Supabase, and 55.8% of them held personal information. Its explanation: "Tables created programmatically through the API, which is how coding agents interact with Supabase, do not enable RLS by default" ([UpGuard, September 23, 2026](https://www.upguard.com/blog/everything-everywhere-systemic-data-exposure-in-supabase-apps)).
|
|
33
66
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## What you get
|
|
67
|
+
Code alone can't show whether a live database is open. For Supabase, Lilith gives you a read-only query to run in the SQL Editor; it reads settings, not your data. For Firebase it asks for your deployed rules.
|
|
37
68
|
|
|
38
|
-
|
|
39
|
-
- ๐๏ธ **Live database check.** One read-only query for the Supabase SQL Editor: it reads settings, never your data.
|
|
40
|
-
- ๐ฃ๏ธ **For beginners.** Every issue: what's wrong, why it matters, how to fix. In your language.
|
|
41
|
-
- ๐งน **Then cleanup.** Leftover logs, fake data, dead buttons, AI-look UI, filler marketing copy.
|
|
42
|
-
- ๐ **Runs on your machine.** No account, no server, your code never leaves your computer.
|
|
69
|
+
Lilith has no account and no server. Your code goes only to the AI agent you already use.
|
|
43
70
|
|
|
44
|
-
##
|
|
71
|
+
## Checks
|
|
45
72
|
|
|
46
|
-
|
|
47
|
-
npx lilith-skill
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
This finds the coding agents on your computer (Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf) and puts the skill where each one looks. Run it again to update. Needs Node.js 18+; the quick scan also needs Python 3.8+ (optional: without it, the agent checks by reading).
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
npx lilith-skill --agent claude # only one agent
|
|
54
|
-
npx lilith-skill --project # into this project instead of your home folder
|
|
55
|
-
npx lilith-skill scan . # run the quick scan yourself
|
|
56
|
-
npx lilith-skill uninstall # remove it
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Other tools that support [Agent Skills](https://agentskills.io) work too: `npx skills add Sunnik21/lilith -g`.
|
|
60
|
-
|
|
61
|
-
Say `/lilith`, or in words:
|
|
62
|
-
|
|
63
|
-
- "Check my app before launch"
|
|
64
|
-
- "Is my app safe?"
|
|
65
|
-
- "Clean up the AI slop in my landing page"
|
|
66
|
-
- "Help me secure my VPS"
|
|
67
|
-
|
|
68
|
-
## What it checks
|
|
69
|
-
|
|
70
|
-
| | Check | Example |
|
|
73
|
+
| ID | Check | Example |
|
|
71
74
|
|---|---|---|
|
|
72
75
|
| S1 | Secret keys in code or git | `sk_live_...` in a file, `.env` committed |
|
|
73
76
|
| S2 | Secrets sent to the browser | `NEXT_PUBLIC_OPENAI_KEY`, OpenAI called from React |
|
|
@@ -87,21 +90,22 @@ Say `/lilith`, or in words:
|
|
|
87
90
|
| U1โU20 | UI and copy | eyebrow labels, fake badges, gradients, "seamless", "elevate" |
|
|
88
91
|
| VPS | Own server | firewall, SSH keys, closed database ports |
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
Each check, with how to spot and fix it, is in [skills/lilith/guides](skills/lilith/guides).
|
|
94
|
+
|
|
95
|
+
## Accuracy
|
|
91
96
|
|
|
92
|
-
|
|
97
|
+
The benchmark in [bench/](bench/) has three small apps written the way AI tools write them: Vite + React + Supabase, Next.js + Supabase + Stripe + OpenAI, and Express + Prisma + JWT. Between them they hold 31 planted security bugs and 17 decoys, things that look wrong but are fine, such as the Supabase anon key or `console.error` in an error handler. Each app also has a fixed version.
|
|
93
98
|
|
|
94
|
-
|
|
99
|
+
Full skill, one run per app, claude-opus-5-5 via `claude -p`, 2026-11-20 ([bench/RESULTS.md](bench/RESULTS.md)):
|
|
95
100
|
|
|
96
|
-
|
|
101
|
+
- Found all 31 planted bugs, including the ones no regex can see: users reading each other's data, prices trusted from the browser, a paid plan unlocked from `?success=true`.
|
|
102
|
+
- Flagged none of the 17 decoys.
|
|
103
|
+
- Raised 3 false alarms, all outdated-package warnings (S13), partly because the benchmark's lockfiles are empty.
|
|
104
|
+
- Matched our severity on 24 of 31; when it differed, it usually rated one level higher.
|
|
97
105
|
|
|
98
|
-
|
|
99
|
-
- Flagged **0 of 17** decoys.
|
|
100
|
-
- **3 false alarms**, all "outdated packages" (S13), partly caused by the benchmark's empty lockfiles.
|
|
101
|
-
- Severity matched ours on **24 of 31**; when it differed, it usually rated one level higher.
|
|
102
|
-
- One run per app. Results vary between runs and models, and 31 bugs in three small apps is not the real world.
|
|
106
|
+
That is one run per app on 31 bugs in three small apps. Results vary between runs and models.
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
The quick scan on its own (`lilith_scan.py`, deterministic, runs in CI):
|
|
105
109
|
|
|
106
110
|
| | Before this benchmark | Now |
|
|
107
111
|
|---|---|---|
|
|
@@ -110,24 +114,22 @@ Measured on a small benchmark in [bench/](bench/): three apps written the way AI
|
|
|
110
114
|
| Decoys flagged | 3/17 | 1/17 |
|
|
111
115
|
| Critical/high leads on the fixed apps | 3 | 0 |
|
|
112
116
|
|
|
113
|
-
The
|
|
117
|
+
The newer scanner patterns were written after looking at these apps, so the "Now" column is optimistic for other projects. The scanner still misses update policies that let users change their own `is_admin` or `plan` column, public storage buckets created in SQL, a paid plan unlocked in the browser, and secrets inside AI system prompts. It also flags credentialed CORS when the app uses no cookies. Those cases need reading, which is why the scan is only the first step.
|
|
114
118
|
|
|
115
|
-
|
|
119
|
+
To reproduce: `python3 bench/run_scanner.py` for the scanner, or `python3 bench/run_agent.py` for the full skill (needs the `claude` CLI, about $1.50 per run).
|
|
116
120
|
|
|
117
|
-
##
|
|
121
|
+
## Limits
|
|
118
122
|
|
|
119
|
-
Lilith is a
|
|
123
|
+
Lilith is a first check, not a penetration test. It reads your code and can't see settings that live only in your dashboards; it tells you what to check there. It never says an app is secure, only what it checked. If your app handles payments, health data or other sensitive data, get a human review as well.
|
|
120
124
|
|
|
121
|
-
##
|
|
125
|
+
## Contributing
|
|
122
126
|
|
|
123
|
-
Each check is a short section in a Markdown file.
|
|
127
|
+
Each check is a short section in a Markdown file. To add one:
|
|
124
128
|
|
|
125
|
-
1. Add a section to the right guide in `skills/lilith/guides/` with
|
|
129
|
+
1. Add a section to the right guide in `skills/lilith/guides/` with Spot it, Why and Fix.
|
|
126
130
|
2. If a regex can find it, add a pattern to `skills/lilith/scripts/lilith_scan.py` and a case to `tests/test_scan.py`.
|
|
127
|
-
3. Run `python3 tests/test_scan.py` and `python3 bench/run_scanner.py
|
|
131
|
+
3. Run `python3 tests/test_scan.py` and `python3 bench/run_scanner.py`. The scanner score must not drop.
|
|
128
132
|
|
|
129
133
|
## License
|
|
130
134
|
|
|
131
135
|
MIT. See [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
132
|
-
|
|
133
|
-
Made by YOUR NAME ยท [your link]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lilith-skill",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Security check for vibecoded apps: an Agent Skill for Claude Code, Codex, Cursor, Copilot, Gemini CLI and more. Finds leaked keys, open Supabase/Firebase databases and missing login checks, in plain words.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
package/skills/lilith/SKILL.md
CHANGED
|
@@ -22,11 +22,11 @@ Cleanup runs only when asked.
|
|
|
22
22
|
|
|
23
23
|
## Steps
|
|
24
24
|
|
|
25
|
-
1. **Scan.** `python3 <this-skill-folder>/scripts/lilith_scan.py <project-root>`: stack, size, leads (hints, not findings), **read plan**. No Python: check by reading. Tell the user the stack in one line.
|
|
25
|
+
1. **Scan.** `python3 <this-skill-folder>/scripts/lilith_scan.py <project-root>`: stack, size, leads (hints, not findings), **read plan**. No Python: check by reading. Tell the user the stack in one line. If the scan skipped a gitignored folder that gets deployed, scan that folder too.
|
|
26
26
|
2. **Security.** Load what the table below says, go through S1 to S14, read the plan's files. A problem counts only if you can finish "[who] can [do what] to [whose data or money]".
|
|
27
27
|
3. **Live database** (Supabase or Firebase in the stack): follow the live check in the stack file. Skipped โ the report says "Live database: NOT checked".
|
|
28
28
|
4. **Cleanup** (full or cleanup mode only): code, then UI and copy. Cleanup never changes what the app does.
|
|
29
|
-
5. **Report** with templates/report.md. Security mode ends with exactly one question: "Fix the critical ones, or continue to cleanup?"
|
|
29
|
+
5. **Report** with templates/report.md. Security mode ends with exactly one question: "Fix the critical ones, or continue to cleanup?" (nothing critical or high: "Nothing urgent. Continue to cleanup?")
|
|
30
30
|
6. **Fix** only with permission: follow guides/fixing.md.
|
|
31
31
|
|
|
32
32
|
## Load this file when...
|
|
@@ -57,5 +57,6 @@ Cleanup runs only when asked.
|
|
|
57
57
|
- Read code. Never attack live sites, call production or use real users' data; give the owner a safe self-test.
|
|
58
58
|
- Never print a full secret: `sk_live_51Hโขโขโขโข4f2a`.
|
|
59
59
|
- Don't invent problems. Unsure: "worth checking" + the exact question.
|
|
60
|
+
- Leads in tests, fixtures or sample apps are findings only if that code ships. Otherwise mention them in one line.
|
|
60
61
|
- Ask before `npm audit fix --force`, deleting files or rewriting git history.
|
|
61
62
|
- Project conventions beat Lilith's style rules.
|
|
@@ -17,6 +17,7 @@ import os
|
|
|
17
17
|
import re
|
|
18
18
|
import subprocess
|
|
19
19
|
import sys
|
|
20
|
+
from typing import Iterator, List, Set, Tuple
|
|
20
21
|
|
|
21
22
|
SKIP_DIRS = {
|
|
22
23
|
"node_modules", ".git", "dist", "build", ".next", ".nuxt", ".svelte-kit", ".astro",
|
|
@@ -32,6 +33,7 @@ MAX_BYTES = 1_000_000
|
|
|
32
33
|
BIG_FILE_LINES = 400
|
|
33
34
|
LONG_FILE_LINES = 300 # read plan gives line ranges for files longer than this
|
|
34
35
|
PLAN_LIMIT = 25
|
|
36
|
+
SKIPPED_SHOWN = 6 # gitignored folders named in the text output
|
|
35
37
|
SIZE_CLASSES = [("small", 60, 8_000), ("medium", 400, 60_000)] # (name, max files, max lines); else large
|
|
36
38
|
RULE_FILES = ("firestore.rules", "storage.rules", "database.rules.json")
|
|
37
39
|
LEAD_WEIGHT = {"critical": 8, "high": 4, "medium": 2, "info": 0.5, "cleanup": 0}
|
|
@@ -191,6 +193,28 @@ def git_tracked(root):
|
|
|
191
193
|
return None
|
|
192
194
|
|
|
193
195
|
|
|
196
|
+
def git_ignored(root: str) -> Tuple[Set[str], Set[str]]:
|
|
197
|
+
"""Gitignored (folders, files) under root, relative to it. Empty without git or inside an ignored folder."""
|
|
198
|
+
try:
|
|
199
|
+
out = subprocess.run(
|
|
200
|
+
["git", "-C", root, "ls-files", "-z", "--others", "--ignored", "--exclude-standard", "--directory"],
|
|
201
|
+
capture_output=True, text=True, timeout=20,
|
|
202
|
+
)
|
|
203
|
+
except Exception:
|
|
204
|
+
return set(), set()
|
|
205
|
+
if out.returncode != 0:
|
|
206
|
+
return set(), set()
|
|
207
|
+
paths = [p for p in out.stdout.split("\0") if p]
|
|
208
|
+
return {p.rstrip("/") for p in paths if p.endswith("/")}, {p for p in paths if not p.endswith("/")}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def reportable_ignored(ignored_dirs: Set[str]) -> List[str]:
|
|
212
|
+
"""Skipped gitignored folders worth telling the agent about (not node_modules and the like)."""
|
|
213
|
+
def is_noise(path: str) -> bool:
|
|
214
|
+
return any(part in SKIP_DIRS or part.startswith(".git") for part in path.split("/"))
|
|
215
|
+
return sorted(d + "/" for d in ignored_dirs if not is_noise(d))
|
|
216
|
+
|
|
217
|
+
|
|
194
218
|
def git_history_env(root):
|
|
195
219
|
try:
|
|
196
220
|
out = subprocess.run(
|
|
@@ -211,13 +235,20 @@ def is_env_file(name):
|
|
|
211
235
|
return not any(x in n for x in ("example", "sample", "template", "defaults"))
|
|
212
236
|
|
|
213
237
|
|
|
214
|
-
def iter_files(root):
|
|
238
|
+
def iter_files(root: str, ignored_dirs: Set[str] = frozenset(), ignored_files: Set[str] = frozenset()) -> Iterator[str]:
|
|
239
|
+
"""Text files to scan. Gitignored folders are skipped; gitignored files too, except env files."""
|
|
240
|
+
def rel_of(dirpath: str, name: str) -> str:
|
|
241
|
+
return os.path.relpath(os.path.join(dirpath, name), root).replace(os.sep, "/")
|
|
242
|
+
|
|
215
243
|
for dirpath, dirnames, filenames in os.walk(root):
|
|
216
244
|
dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS and not d.startswith(".git")
|
|
217
|
-
and os.path.abspath(os.path.join(dirpath, d)) != SELF_DIR
|
|
245
|
+
and os.path.abspath(os.path.join(dirpath, d)) != SELF_DIR
|
|
246
|
+
and rel_of(dirpath, d) not in ignored_dirs]
|
|
218
247
|
for f in filenames:
|
|
219
248
|
if f in SKIP_FILES:
|
|
220
249
|
continue
|
|
250
|
+
if not is_env_file(f) and rel_of(dirpath, f) in ignored_files:
|
|
251
|
+
continue
|
|
221
252
|
path = os.path.join(dirpath, f)
|
|
222
253
|
ext = os.path.splitext(f)[1].lower()
|
|
223
254
|
if ext not in TEXT_EXT and not is_env_file(f) and f not in ("Dockerfile", ".gitignore"):
|
|
@@ -269,10 +300,12 @@ def detect_project(root):
|
|
|
269
300
|
info = {"stack": [], "spa": False}
|
|
270
301
|
pkg = read(os.path.join(root, "package.json"))
|
|
271
302
|
deps = {}
|
|
303
|
+
has_bin = False
|
|
272
304
|
if pkg:
|
|
273
305
|
try:
|
|
274
306
|
data = json.loads(pkg)
|
|
275
307
|
deps = {**data.get("dependencies", {}), **data.get("devDependencies", {})}
|
|
308
|
+
has_bin = bool(data.get("bin"))
|
|
276
309
|
except Exception:
|
|
277
310
|
pass
|
|
278
311
|
names = set(deps)
|
|
@@ -303,8 +336,10 @@ def detect_project(root):
|
|
|
303
336
|
if os.path.exists(os.path.join(root, "vercel.json")): info["stack"].append("Vercel")
|
|
304
337
|
if os.path.exists(os.path.join(root, "netlify.toml")): info["stack"].append("Netlify")
|
|
305
338
|
if os.path.exists(os.path.join(root, "Dockerfile")) or os.path.exists(os.path.join(root, "docker-compose.yml")): info["stack"].append("Docker")
|
|
306
|
-
|
|
307
|
-
|
|
339
|
+
if has_bin: info["stack"].insert(0, "Node CLI")
|
|
340
|
+
elif pkg and not info["stack"]: info["stack"].append("Node.js")
|
|
341
|
+
if any(os.path.exists(os.path.join(root, py)) for py in ("requirements.txt", "pyproject.toml", "setup.py", "Pipfile")):
|
|
342
|
+
info["stack"].append("Python")
|
|
308
343
|
info["has_lockfile"] = any(os.path.exists(os.path.join(root, f)) for f in ("package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"))
|
|
309
344
|
info["has_package_json"] = bool(pkg)
|
|
310
345
|
return info
|
|
@@ -414,6 +449,7 @@ def scan(root, max_examples):
|
|
|
414
449
|
root = os.path.abspath(root)
|
|
415
450
|
project = detect_project(root)
|
|
416
451
|
tracked = git_tracked(root)
|
|
452
|
+
ignored_dirs, ignored_files = git_ignored(root)
|
|
417
453
|
findings = []
|
|
418
454
|
|
|
419
455
|
def add(check, severity, rel, line, note):
|
|
@@ -439,8 +475,9 @@ def scan(root, max_examples):
|
|
|
439
475
|
totals = {"C1": 0, "C3": 0}
|
|
440
476
|
hints, file_lines = {}, {}
|
|
441
477
|
n_files = n_lines_total = 0
|
|
478
|
+
has_python = False
|
|
442
479
|
|
|
443
|
-
for path in iter_files(root):
|
|
480
|
+
for path in iter_files(root, ignored_dirs, ignored_files):
|
|
444
481
|
rel = os.path.relpath(path, root)
|
|
445
482
|
name = os.path.basename(path)
|
|
446
483
|
ext = os.path.splitext(name)[1].lower()
|
|
@@ -451,6 +488,8 @@ def scan(root, max_examples):
|
|
|
451
488
|
is_example_env = name.lower().startswith(".env") and not is_env
|
|
452
489
|
is_code = ext in CODE_EXT
|
|
453
490
|
is_doc = ext in (".md", ".txt")
|
|
491
|
+
is_data = ext == ".json" # manifests and fixtures name env vars without bundling them
|
|
492
|
+
has_python = has_python or ext == ".py"
|
|
454
493
|
client = is_code and is_client_file(rel, text, project)
|
|
455
494
|
file_lines[rel.replace(os.sep, "/")] = text.count("\n") + 1
|
|
456
495
|
if is_code or ext in (".sql", ".rules") or name in RULE_FILES:
|
|
@@ -493,7 +532,7 @@ def scan(root, max_examples):
|
|
|
493
532
|
var = m.group(0)
|
|
494
533
|
if "PUBLISHABLE" in var or "ANON" in var:
|
|
495
534
|
continue
|
|
496
|
-
add("S2", "info" if is_doc else "critical", rel, line_of(text, m.start()), f"{var} is bundled into browser code (public prefix on a secret)")
|
|
535
|
+
add("S2", "info" if is_doc or is_data else "critical", rel, line_of(text, m.start()), f"{var} is bundled into browser code (public prefix on a secret)")
|
|
497
536
|
|
|
498
537
|
# S2 secret clients in browser code
|
|
499
538
|
if client:
|
|
@@ -606,6 +645,9 @@ def scan(root, max_examples):
|
|
|
606
645
|
for f in findings:
|
|
607
646
|
f["file"] = f["file"].replace(os.sep, "/")
|
|
608
647
|
project["size"] = {"files": n_files, "lines": n_lines_total, "class": size_class(n_files, n_lines_total)}
|
|
648
|
+
if has_python and "Python" not in project["stack"]:
|
|
649
|
+
project["stack"] = project["stack"] + ["Python"]
|
|
650
|
+
project["skipped_ignored"] = reportable_ignored(ignored_dirs)
|
|
609
651
|
project["hints"] = hints
|
|
610
652
|
project["file_lines"] = file_lines
|
|
611
653
|
return project, findings, totals
|
|
@@ -625,7 +667,14 @@ def header_lines(project, findings):
|
|
|
625
667
|
head = (f"Lilith quick scan ยท {', '.join(project['stack']) or 'unknown stack'} ยท "
|
|
626
668
|
f"{size['files']} files, {size['lines']:,} lines ({size['class']})")
|
|
627
669
|
leads = "Leads (hints, confirm by reading): " + " ".join(f"{ICONS[k]}{v}" for k, v in counts.items() if v)
|
|
628
|
-
return [head, leads]
|
|
670
|
+
return [head, leads] + skipped_lines(project.get("skipped_ignored", []))
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
def skipped_lines(skipped: List[str]) -> List[str]:
|
|
674
|
+
if not skipped:
|
|
675
|
+
return []
|
|
676
|
+
more = f" +{len(skipped) - SKIPPED_SHOWN} more" if len(skipped) > SKIPPED_SHOWN else ""
|
|
677
|
+
return [f"Skipped (gitignored): {' '.join(skipped[:SKIPPED_SHOWN])}{more}. Scan one separately if it gets deployed."]
|
|
629
678
|
|
|
630
679
|
|
|
631
680
|
def plan_lines(entries, left_out):
|
|
@@ -687,6 +736,7 @@ def summarize(project, findings, max_examples):
|
|
|
687
736
|
out.append("Stack: " + (", ".join(project["stack"]) or "unknown"))
|
|
688
737
|
size = project["size"]
|
|
689
738
|
out.append(f"Size: {size['files']} files, {size['lines']:,} lines ({size['class']})")
|
|
739
|
+
out += skipped_lines(project.get("skipped_ignored", []))
|
|
690
740
|
out.append("Every item below is a LEAD. Confirm by reading the code before reporting it.\n")
|
|
691
741
|
by_check = {}
|
|
692
742
|
for f in findings:
|
|
@@ -732,7 +782,8 @@ def main():
|
|
|
732
782
|
plan, left_out = read_plan(findings, project["hints"], project["file_lines"], args.plan_limit)
|
|
733
783
|
if args.json:
|
|
734
784
|
print(json.dumps({"stack": project["stack"], "size": project["size"], "findings": findings, "totals": totals,
|
|
735
|
-
"read_plan": plan, "read_plan_left_out": left_out
|
|
785
|
+
"read_plan": plan, "read_plan_left_out": left_out,
|
|
786
|
+
"skipped_ignored": project["skipped_ignored"]}, indent=2, ensure_ascii=False))
|
|
736
787
|
return
|
|
737
788
|
try:
|
|
738
789
|
sys.stdout.reconfigure(encoding="utf-8")
|
|
@@ -6,6 +6,7 @@ Fill this in. Skip any section that's empty. Write in the user's language.
|
|
|
6
6
|
- ๐ก: one line each.
|
|
7
7
|
- โช Cleanup: grouped counts only ("34 leftover logs in 12 files"). Details only if the user asks.
|
|
8
8
|
- ๐ก: one line each, or skip.
|
|
9
|
+
- Last line when nothing is ๐ด or ๐ : "Nothing urgent. Continue to cleanup?"
|
|
9
10
|
|
|
10
11
|
| Level | Meaning |
|
|
11
12
|
|---|---|
|