lilith-skill 0.1.1 → 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/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
|
|---|---|
|