@shipmate-agency/shipready 0.2.0 → 0.2.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/README.md +22 -4
- package/check.py +30 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://shipmate.agency/rules/">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Shipmate-agency/.github/main/assets/shipmate-check-banner.png" alt="ShipReady by Shipmate — Pre-launch security CLI & GitHub Action for Next.js, Supabase, Stripe & AI apps" width="840" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
1
7
|
# ShipReady by Shipmate
|
|
2
8
|
|
|
9
|
+
[](https://shipmate.agency)
|
|
10
|
+
[](https://shipmate.agency/rules/)
|
|
11
|
+
[](./LICENSE)
|
|
12
|
+
[](https://github.com/Shipmate-agency)
|
|
13
|
+
|
|
3
14
|
A pre-launch security checklist and a zero-dependency checker for web apps built fast with **Cursor, Lovable, Bolt, v0, Next.js, Supabase, and Stripe**.
|
|
4
15
|
|
|
5
16
|
ShipReady scans a repo for leaked keys, missing Row Level Security, open write policies and unverified Stripe webhooks. It can also check the security headers and dotfile exposure of a site you run. Every finding has a stable rule ID and a page that explains the fix.
|
|
@@ -21,10 +32,14 @@ uvx --from vibe-code-security-checklist shipready check .
|
|
|
21
32
|
python3 check.py check .
|
|
22
33
|
```
|
|
23
34
|
|
|
35
|
+
The PyPI package is `vibe-code-security-checklist`. The PyPI package named `shipready` is an unrelated project, so do not `pip install shipready`.
|
|
36
|
+
|
|
37
|
+
`check` reads files on disk and makes no network calls. Only `url` and `--supabase-url` send requests: read-only GETs to the host you name (following its redirects). Findings name the file, line and key type, never the secret value.
|
|
38
|
+
|
|
24
39
|
### Commands
|
|
25
40
|
|
|
26
41
|
```bash
|
|
27
|
-
# Scan a local repo for client-exposed secrets, hardcoded AI/Stripe/Supabase keys,
|
|
42
|
+
# Scan a local repo for client-exposed secrets, hardcoded AI/Stripe/Supabase/AWS/GitHub keys,
|
|
28
43
|
# missing RLS, USING (true) write policies, and unverified Stripe webhooks
|
|
29
44
|
shipready check /path/to/your-app
|
|
30
45
|
|
|
@@ -42,7 +57,7 @@ The older flags still work: `vibe-code-check --repo .`, `--url`, `--supabase-url
|
|
|
42
57
|
|
|
43
58
|
### Exit codes
|
|
44
59
|
|
|
45
|
-
Exit code is `1` if any high-severity finding is detected, `0` otherwise. Change the threshold with `--fail-on high|medium|low|none`.
|
|
60
|
+
Exit code is `1` if any high-severity finding is detected or a check could not run (for example a path that does not exist), `0` otherwise, and `2` for a usage error. Change the threshold with `--fail-on high|medium|low|none`.
|
|
46
61
|
|
|
47
62
|
## GitHub Action
|
|
48
63
|
|
|
@@ -59,6 +74,7 @@ on:
|
|
|
59
74
|
permissions:
|
|
60
75
|
contents: read
|
|
61
76
|
security-events: write # upload results to the Security tab
|
|
77
|
+
actions: read # only needed in private repositories
|
|
62
78
|
pull-requests: write # only needed with comment: true
|
|
63
79
|
|
|
64
80
|
jobs:
|
|
@@ -66,7 +82,7 @@ jobs:
|
|
|
66
82
|
runs-on: ubuntu-latest
|
|
67
83
|
steps:
|
|
68
84
|
- uses: actions/checkout@v7
|
|
69
|
-
- uses:
|
|
85
|
+
- uses: Shipmate-agency/shipready@v0.2.1
|
|
70
86
|
with:
|
|
71
87
|
path: .
|
|
72
88
|
fail-on: high
|
|
@@ -81,7 +97,9 @@ Inputs:
|
|
|
81
97
|
| `fail-on` | `high` | Fail the job on findings at or above this severity: `high`, `medium`, `low` or `none` |
|
|
82
98
|
| `comment` | `false` | Post or update one comment on the pull request with the findings |
|
|
83
99
|
|
|
84
|
-
|
|
100
|
+
Output: `sarif-file`, the path of the SARIF file that was uploaded.
|
|
101
|
+
|
|
102
|
+
Results are uploaded even when the check fails the job. Uploading to the Security tab is free for public repositories; a private repository needs GitHub Code Security (Advanced Security) enabled, or the upload step fails the job.
|
|
85
103
|
|
|
86
104
|
## Rules
|
|
87
105
|
|
package/check.py
CHANGED
|
@@ -14,6 +14,7 @@ from __future__ import annotations
|
|
|
14
14
|
|
|
15
15
|
import argparse
|
|
16
16
|
import base64
|
|
17
|
+
import fnmatch
|
|
17
18
|
import ipaddress
|
|
18
19
|
import json
|
|
19
20
|
import os
|
|
@@ -27,7 +28,7 @@ from dataclasses import asdict, dataclass
|
|
|
27
28
|
from pathlib import Path
|
|
28
29
|
from typing import Iterable
|
|
29
30
|
|
|
30
|
-
__version__ = "0.2.
|
|
31
|
+
__version__ = "0.2.1"
|
|
31
32
|
RULES_BASE_URL = "https://shipmate.agency/rules/"
|
|
32
33
|
LOCKDOWN_LINE = "Want a person to fix these in one PR? https://shipmate.agency/lockdown"
|
|
33
34
|
|
|
@@ -116,28 +117,34 @@ TEXT_EXTS = {
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
CLIENT_SECRET_ENV_RE = re.compile(
|
|
119
|
-
r"\b(?:NEXT_PUBLIC_|VITE_|PUBLIC_)[A-Z0-9_]*(?:SECRET|SERVICE_ROLE|PRIVATE_KEY|PASSWORD|DATABASE_URL|API_SECRET)[A-Z0-9_]*\b"
|
|
120
|
+
r"\b(?:NEXT_PUBLIC_|VITE_|PUBLIC_)[A-Z0-9_]*(?:SECRET|SERVICE_ROLE|PRIVATE_KEY|PASSWORD|DATABASE_URL|API_SECRET|(?:OPENAI|ANTHROPIC|OPENROUTER)_API_KEY|REPLICATE_API_TOKEN|FAL_KEY)[A-Z0-9_]*\b"
|
|
120
121
|
)
|
|
121
122
|
|
|
122
123
|
HARDCODED_SECRET_PATTERNS = [
|
|
123
|
-
("Stripe live secret key", re.compile(r"\
|
|
124
|
+
("Stripe live secret key", re.compile(r"\b[rs]k_live_[A-Za-z0-9]{16,}\b")),
|
|
124
125
|
("Stripe webhook secret", re.compile(r"\bwhsec_[A-Za-z0-9]{16,}\b")),
|
|
125
126
|
("OpenAI API key", re.compile(r"\bsk-(?:proj|svcacct)-[A-Za-z0-9_-]{20,}\b")),
|
|
126
127
|
("Anthropic API key", re.compile(r"\bsk-ant-api\d{2}-[A-Za-z0-9_-]{20,}\b")),
|
|
127
128
|
("Supabase secret key", re.compile(r"\bsb_secret_[A-Za-z0-9_-]{20,}\b")),
|
|
128
129
|
("AWS access key ID", re.compile(r"\bAKIA[0-9A-Z]{16}\b")),
|
|
129
|
-
("GitHub personal access token", re.compile(r"\
|
|
130
|
+
("GitHub personal access token", re.compile(r"\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{40,})\b")),
|
|
130
131
|
("Private key block", re.compile(r"-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----")),
|
|
131
132
|
]
|
|
132
133
|
|
|
133
134
|
JWT_RE = re.compile(r"\beyJ[A-Za-z0-9_-]{10,}\.(eyJ[A-Za-z0-9_-]{16,})\.[A-Za-z0-9_-]{10,}\b")
|
|
134
135
|
|
|
135
136
|
CREATE_TABLE_RE = re.compile(r"create\s+table\s+(?:if\s+not\s+exists\s+)?([a-zA-Z0-9_.\"`]+)", re.I)
|
|
136
|
-
ENABLE_RLS_RE = re.compile(r"alter\s+table\s+(?:only\s+)?([a-zA-Z0-9_.\"`]+)\s+enable\s+row\s+level\s+security", re.I)
|
|
137
|
+
ENABLE_RLS_RE = re.compile(r"alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?([a-zA-Z0-9_.\"`]+)\s+enable\s+row\s+level\s+security", re.I)
|
|
137
138
|
CREATE_POLICY_RE = re.compile(r"create\s+policy\s+([^;]+);", re.I | re.S)
|
|
138
139
|
POLICY_READONLY_RE = re.compile(r"\bfor\s+select\b", re.I)
|
|
140
|
+
# service_role bypasses RLS anyway, so a policy granted only TO service_role opens nothing
|
|
141
|
+
POLICY_SERVICE_ROLE_RE = re.compile(r"\bto\s+service_role\b(?!\s*,)", re.I)
|
|
139
142
|
POLICY_OPEN_TRUE_RE = re.compile(r"\b(?:using|with\s+check)\s*\(\s*true\s*\)", re.I)
|
|
140
|
-
STRIPE_WEBHOOK_HINT_RE = re.compile(
|
|
143
|
+
STRIPE_WEBHOOK_HINT_RE = re.compile(
|
|
144
|
+
r"stripe.*webhook|webhook.*stripe|['\"](?:checkout\.session|customer\.subscription|invoice|payment_intent)\.[a-z_.]+['\"]", re.I
|
|
145
|
+
)
|
|
146
|
+
# foo.test.ts, foo.spec.js, test_foo.py, foo_test.py; not latest.ts or inspector.ts
|
|
147
|
+
TEST_FILE_RE = re.compile(r"(?:^|[._-])(?:test|spec)s?(?:[._-]|$)")
|
|
141
148
|
STRIPE_SIG_CHECK_RE = re.compile(r"constructEvent|stripe-signature", re.I)
|
|
142
149
|
|
|
143
150
|
|
|
@@ -182,13 +189,19 @@ def check_repo(repo_path: Path) -> list[Finding]:
|
|
|
182
189
|
|
|
183
190
|
# 1. Check for .env files in public/ or committed without .gitignore entry
|
|
184
191
|
gitignore = (repo_path / ".gitignore").read_text(errors="ignore") if (repo_path / ".gitignore").exists() else ""
|
|
192
|
+
# shortcut: root .gitignore only, negations ignored; nested .gitignore files are not read
|
|
193
|
+
ignore_pats = [
|
|
194
|
+
ln.strip().removeprefix("**/").strip("/")
|
|
195
|
+
for ln in gitignore.splitlines()
|
|
196
|
+
if ln.strip() and not ln.lstrip().startswith(("#", "!"))
|
|
197
|
+
]
|
|
185
198
|
env_files = [p for p in iter_repo_files(repo_path) if p.name == ".env" or p.name.startswith(".env.")]
|
|
186
199
|
real_envs = [p for p in env_files if not p.name.endswith((".example", ".sample", ".template"))]
|
|
187
200
|
for p in real_envs:
|
|
188
201
|
rel = str(p.relative_to(repo_path))
|
|
189
202
|
if rel.startswith("public/"):
|
|
190
203
|
findings.append(Finding("secrets", "FAIL", "Env file inside public/ directory", "Files in public/ are served over HTTP.", rel, rule="SR-WEB-007"))
|
|
191
|
-
elif
|
|
204
|
+
elif not any(fnmatch.fnmatchcase(p.name, pat) or fnmatch.fnmatchcase(rel, pat) for pat in ignore_pats):
|
|
192
205
|
findings.append(Finding("secrets", "WARN", "Env file present and .env not in .gitignore", "Add .env* to .gitignore and verify it is not tracked by git.", rel, rule="SR-SEC-003"))
|
|
193
206
|
|
|
194
207
|
# 2. Scan source files
|
|
@@ -199,13 +212,16 @@ def check_repo(repo_path: Path) -> list[Finding]:
|
|
|
199
212
|
tables_with_rls: set[str] = set()
|
|
200
213
|
|
|
201
214
|
for path in iter_repo_files(repo_path):
|
|
202
|
-
|
|
215
|
+
try:
|
|
216
|
+
if path.stat().st_size > 1_000_000:
|
|
217
|
+
continue
|
|
218
|
+
text = path.read_text(errors="ignore")
|
|
219
|
+
except OSError: # broken symlink, unreadable file
|
|
203
220
|
continue
|
|
204
221
|
rel = str(path.relative_to(repo_path))
|
|
205
|
-
text = path.read_text(errors="ignore")
|
|
206
222
|
|
|
207
223
|
# Skip test files for secret pattern noise unless explicitly .env
|
|
208
|
-
is_test =
|
|
224
|
+
is_test = bool(TEST_FILE_RE.search(path.name.lower()))
|
|
209
225
|
|
|
210
226
|
if not is_test:
|
|
211
227
|
for match in CLIENT_SECRET_ENV_RE.finditer(text):
|
|
@@ -270,15 +286,15 @@ def check_repo(repo_path: Path) -> list[Finding]:
|
|
|
270
286
|
# Supabase / Postgres SQL RLS check
|
|
271
287
|
if path.suffix.lower() == ".sql":
|
|
272
288
|
for m in CREATE_TABLE_RE.finditer(text):
|
|
273
|
-
tbl =
|
|
289
|
+
tbl = re.sub(r'["`]', "", m.group(1)).lower().split(".")[-1]
|
|
274
290
|
tables_created[tbl] = (rel, _line(text, m.start()))
|
|
275
291
|
for m in ENABLE_RLS_RE.finditer(text):
|
|
276
|
-
tbl =
|
|
292
|
+
tbl = re.sub(r'["`]', "", m.group(1)).lower().split(".")[-1]
|
|
277
293
|
tables_with_rls.add(tbl)
|
|
278
294
|
for m in CREATE_POLICY_RE.finditer(text):
|
|
279
295
|
stmt = m.group(1)
|
|
280
|
-
if POLICY_OPEN_TRUE_RE.search(stmt) and not POLICY_READONLY_RE.search(stmt):
|
|
281
|
-
policy_name =
|
|
296
|
+
if POLICY_OPEN_TRUE_RE.search(stmt) and not POLICY_READONLY_RE.search(stmt) and not POLICY_SERVICE_ROLE_RE.search(stmt):
|
|
297
|
+
policy_name = re.match(r'\s*("[^"]+"|\S+)', stmt).group(1).strip('"`')
|
|
282
298
|
findings.append(
|
|
283
299
|
Finding(
|
|
284
300
|
"database",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipmate-agency/shipready",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "ShipReady by Shipmate: zero-dependency pre-launch security check for Next.js, Supabase and Stripe apps.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"shipready": "npm/shipready.js"
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"homepage": "https://shipmate.agency",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/
|
|
20
|
+
"url": "git+https://github.com/Shipmate-agency/shipready.git"
|
|
21
21
|
},
|
|
22
|
-
"bugs": "https://github.com/
|
|
22
|
+
"bugs": "https://github.com/Shipmate-agency/shipready/issues",
|
|
23
23
|
"author": "Dmitry (Dee) Kargaev <hi@deeflect.com>",
|
|
24
24
|
"license": "MIT"
|
|
25
25
|
}
|