ship-safe 3.2.0 → 4.0.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/README.md +182 -459
- package/cli/agents/api-fuzzer.js +224 -0
- package/cli/agents/auth-bypass-agent.js +326 -0
- package/cli/agents/base-agent.js +240 -0
- package/cli/agents/cicd-scanner.js +200 -0
- package/cli/agents/config-auditor.js +413 -0
- package/cli/agents/git-history-scanner.js +167 -0
- package/cli/agents/html-reporter.js +363 -0
- package/cli/agents/index.js +56 -0
- package/cli/agents/injection-tester.js +401 -0
- package/cli/agents/llm-redteam.js +251 -0
- package/cli/agents/mobile-scanner.js +225 -0
- package/cli/agents/orchestrator.js +152 -0
- package/cli/agents/policy-engine.js +149 -0
- package/cli/agents/recon-agent.js +196 -0
- package/cli/agents/sbom-generator.js +176 -0
- package/cli/agents/scoring-engine.js +207 -0
- package/cli/agents/ssrf-prober.js +130 -0
- package/cli/agents/supply-chain-agent.js +274 -0
- package/cli/bin/ship-safe.js +83 -3
- package/cli/commands/audit.js +565 -0
- package/cli/commands/red-team.js +315 -0
- package/cli/commands/watch.js +160 -0
- package/cli/index.js +36 -1
- package/cli/providers/llm-provider.js +288 -0
- package/package.json +18 -14
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<img src=".github/assets/logo%20ship%20safe.png" alt="Ship Safe Logo" width="180" />
|
|
3
3
|
</p>
|
|
4
|
-
<p align="center"><strong>
|
|
4
|
+
<p align="center"><strong>AI-powered application security platform for developers.</strong></p>
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
7
|
<a href="https://www.npmjs.com/package/ship-safe"><img src="https://badge.fury.io/js/ship-safe.svg" alt="npm version" /></a>
|
|
@@ -13,523 +13,238 @@
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
12 security agents. 50+ attack classes. One command.
|
|
17
17
|
|
|
18
|
-
**Ship Safe** is
|
|
18
|
+
**Ship Safe v4.0** is an AI-powered security platform that runs 12 specialized agents against your codebase — scanning for secrets, injection vulnerabilities, auth bypass, SSRF, supply chain attacks, Docker/Terraform misconfigs, CI/CD pipeline poisoning, LLM security issues, and more. It produces a prioritized remediation plan so you know exactly what to fix first.
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
## Quick Start
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
#
|
|
26
|
-
npx ship-safe
|
|
25
|
+
# Full security audit — secrets + 12 agents + deps + remediation plan
|
|
26
|
+
npx ship-safe audit .
|
|
27
|
+
|
|
28
|
+
# Red team scan only (12 agents, 50+ attack classes)
|
|
29
|
+
npx ship-safe red-team .
|
|
27
30
|
|
|
28
|
-
#
|
|
31
|
+
# Quick secret scan
|
|
29
32
|
npx ship-safe scan .
|
|
30
33
|
|
|
31
|
-
# Security health score (0-100
|
|
34
|
+
# Security health score (0-100)
|
|
32
35
|
npx ship-safe score .
|
|
33
|
-
|
|
34
|
-
# Audit dependencies for known CVEs
|
|
35
|
-
npx ship-safe deps .
|
|
36
|
-
|
|
37
|
-
# Auto-fix hardcoded secrets: rewrite code + write .env
|
|
38
|
-
npx ship-safe remediate .
|
|
39
|
-
|
|
40
|
-
# Revoke exposed keys — opens provider dashboards with step-by-step guide
|
|
41
|
-
npx ship-safe rotate .
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Or if you prefer the manual toolkit:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npx ship-safe fix # Generate .env.example from secrets
|
|
48
|
-
npx ship-safe guard # Block git push if secrets found
|
|
49
|
-
npx ship-safe checklist # Run launch-day security checklist
|
|
50
|
-
npx ship-safe init # Add security configs to your project
|
|
51
36
|
```
|
|
52
37
|
|
|
53
38
|

|
|
54
39
|
|
|
55
|
-
### Let AI Do It For You
|
|
56
|
-
|
|
57
|
-
Copy this prompt to your AI coding assistant:
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
Run "npx ship-safe scan ." on my project and fix any secrets you find.
|
|
61
|
-
Then run "npx ship-safe init" to add security configs.
|
|
62
|
-
Explain what you're doing as you go.
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
[More AI prompts for specific frameworks](./AI_SECURITY_PROMPT.md)
|
|
66
|
-
|
|
67
40
|
---
|
|
68
41
|
|
|
69
|
-
##
|
|
70
|
-
|
|
71
|
-
Vibe coding is powerful. You can build a SaaS in a weekend. But speed creates blind spots:
|
|
72
|
-
|
|
73
|
-
- AI-generated code often hardcodes secrets
|
|
74
|
-
- Default configs ship with debug mode enabled
|
|
75
|
-
- "I'll fix it later" becomes "I got hacked"
|
|
42
|
+
## The `audit` Command
|
|
76
43
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## CLI Commands
|
|
82
|
-
|
|
83
|
-
### `npx ship-safe agent [path]`
|
|
84
|
-
|
|
85
|
-
AI-powered security audit. Scans for both secrets and code vulnerabilities, sends findings to Claude for classification, auto-fixes confirmed secrets, and provides specific fix suggestions for code issues.
|
|
44
|
+
One command that runs everything and generates a full report:
|
|
86
45
|
|
|
87
46
|
```bash
|
|
88
|
-
|
|
89
|
-
npx ship-safe agent .
|
|
90
|
-
|
|
91
|
-
# Preview classification without writing any files
|
|
92
|
-
npx ship-safe agent . --dry-run
|
|
93
|
-
|
|
94
|
-
# Use a specific Claude model
|
|
95
|
-
npx ship-safe agent . --model claude-opus-4-6
|
|
47
|
+
npx ship-safe audit .
|
|
96
48
|
```
|
|
97
49
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
4. For code vulns: print Claude's verdict + specific 1-line fix suggestion
|
|
103
|
-
5. Re-scan to verify secrets are gone
|
|
104
|
-
|
|
105
|
-
No `ANTHROPIC_API_KEY`? Falls back to `remediate` for secrets automatically.
|
|
106
|
-
|
|
107
|
-
---
|
|
50
|
+
```
|
|
51
|
+
════════════════════════════════════════════════════════════
|
|
52
|
+
Ship Safe v4.0 — Full Security Audit
|
|
53
|
+
════════════════════════════════════════════════════════════
|
|
108
54
|
|
|
109
|
-
|
|
55
|
+
[Phase 1/4] Scanning for secrets... ✔ 49 found
|
|
56
|
+
[Phase 2/4] Running 12 security agents... ✔ 103 findings
|
|
57
|
+
[Phase 3/4] Auditing dependencies... ✔ 44 CVEs
|
|
58
|
+
[Phase 4/4] Computing security score... ✔ 25/100 F
|
|
110
59
|
|
|
111
|
-
|
|
60
|
+
Remediation Plan
|
|
61
|
+
════════════════════════════════════════════════════════
|
|
112
62
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
63
|
+
🔴 CRITICAL — fix immediately
|
|
64
|
+
────────────────────────────────────────────────────────
|
|
65
|
+
1. [SECRETS] Rotate Stripe Live Secret Key
|
|
66
|
+
.env:67 → Move to environment variable or secrets manager
|
|
116
67
|
|
|
117
|
-
|
|
118
|
-
|
|
68
|
+
2. [INJECTION] Unsafe pickle.loads()
|
|
69
|
+
backend/ai_processor.py:64 → Use JSON for untrusted data
|
|
119
70
|
|
|
120
|
-
|
|
121
|
-
|
|
71
|
+
🟠 HIGH — fix before deploy
|
|
72
|
+
────────────────────────────────────────────────────────
|
|
73
|
+
3. [XSS] dangerouslySetInnerHTML without sanitization
|
|
74
|
+
frontend/src/utils/blogContentRenderer.jsx:50 → Add DOMPurify
|
|
122
75
|
|
|
123
|
-
|
|
124
|
-
npx ship-safe scan . --sarif
|
|
76
|
+
... 149 more items in the full report
|
|
125
77
|
|
|
126
|
-
|
|
127
|
-
npx ship-safe scan . -v
|
|
78
|
+
📊 Full report: ship-safe-report.html
|
|
128
79
|
```
|
|
129
80
|
|
|
130
|
-
**
|
|
81
|
+
**What it runs:**
|
|
82
|
+
1. **Secret scan** — 50+ patterns with entropy scoring (API keys, passwords, tokens)
|
|
83
|
+
2. **12 security agents** — injection, auth, SSRF, supply chain, config, LLM, mobile, git history, CI/CD, API
|
|
84
|
+
3. **Dependency audit** — npm/pip/bundler CVE scanning
|
|
85
|
+
4. **Score computation** — 8-category weighted scoring (0-100, A-F)
|
|
86
|
+
5. **Remediation plan** — prioritized fix list grouped by severity
|
|
87
|
+
6. **HTML report** — standalone dark-themed report with table of contents
|
|
131
88
|
|
|
132
89
|
**Flags:**
|
|
133
|
-
- `--json` — structured JSON output for
|
|
90
|
+
- `--json` — structured JSON output (clean for piping)
|
|
134
91
|
- `--sarif` — SARIF format for GitHub Code Scanning
|
|
135
|
-
- `--
|
|
136
|
-
-
|
|
137
|
-
|
|
138
|
-
**Suppress false positives:**
|
|
139
|
-
```bash
|
|
140
|
-
const apiKey = 'example-key'; // ship-safe-ignore
|
|
141
|
-
```
|
|
142
|
-
Or exclude paths with `.ship-safeignore` (gitignore syntax).
|
|
143
|
-
|
|
144
|
-
**Custom patterns** — create `.ship-safe.json` in your project root:
|
|
145
|
-
```json
|
|
146
|
-
{
|
|
147
|
-
"patterns": [
|
|
148
|
-
{
|
|
149
|
-
"name": "My Internal API Key",
|
|
150
|
-
"pattern": "MYAPP_[A-Z0-9]{32}",
|
|
151
|
-
"severity": "high",
|
|
152
|
-
"description": "Internal key for myapp services."
|
|
153
|
-
}
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**Detects 50+ secret patterns:**
|
|
159
|
-
- **AI/ML:** OpenAI, Anthropic, Google AI, Cohere, Replicate, Hugging Face
|
|
160
|
-
- **Auth:** Clerk, Auth0, Supabase Auth
|
|
161
|
-
- **Cloud:** AWS, Google Cloud, Azure
|
|
162
|
-
- **Database:** Supabase, PlanetScale, Neon, MongoDB, PostgreSQL, MySQL
|
|
163
|
-
- **Payment:** Stripe, PayPal
|
|
164
|
-
- **Messaging:** Twilio, SendGrid, Resend
|
|
165
|
-
- **And more:** GitHub tokens, private keys, JWTs, generic secrets
|
|
166
|
-
|
|
167
|
-
**Detects 18 code vulnerability patterns (OWASP Top 10):**
|
|
168
|
-
- **Injection:** SQL injection (template literals), command injection, code injection (`eval`)
|
|
169
|
-
- **XSS:** `dangerouslySetInnerHTML`, `innerHTML` assignment, `document.write`
|
|
170
|
-
- **Crypto:** MD5 / SHA-1 for passwords, weak random number generation
|
|
171
|
-
- **TLS:** `NODE_TLS_REJECT_UNAUTHORIZED=0`, `rejectUnauthorized: false`, Python `verify=False`
|
|
172
|
-
- **Deserialization:** `pickle.loads`, `yaml.load` without `Loader`
|
|
173
|
-
- **Misconfiguration:** CORS wildcard (`*`), deprecated `new Buffer()`
|
|
92
|
+
- `--html [file]` — custom HTML report path (default: `ship-safe-report.html`)
|
|
93
|
+
- `--no-deps` — skip dependency audit
|
|
94
|
+
- `--no-ai` — skip AI classification
|
|
174
95
|
|
|
175
96
|
---
|
|
176
97
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
### `npx ship-safe rotate [path]`
|
|
198
|
-
|
|
199
|
-
Revoke and rotate exposed secrets. Detects which providers your secrets belong to and opens the right dashboard with step-by-step revocation instructions.
|
|
200
|
-
|
|
201
|
-
```bash
|
|
202
|
-
# Open dashboards for all detected secrets
|
|
203
|
-
npx ship-safe rotate .
|
|
204
|
-
|
|
205
|
-
# Rotate only a specific provider
|
|
206
|
-
npx ship-safe rotate . --provider github
|
|
207
|
-
npx ship-safe rotate . --provider stripe
|
|
208
|
-
npx ship-safe rotate . --provider openai
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
**Supports:** OpenAI, Anthropic, GitHub, Stripe, AWS, Google Cloud, Supabase, and more.
|
|
98
|
+
## 12 Security Agents
|
|
99
|
+
|
|
100
|
+
| Agent | Category | What It Detects |
|
|
101
|
+
|-------|----------|-----------------|
|
|
102
|
+
| **InjectionTester** | Code Vulns | SQL/NoSQL injection, command injection, code injection (eval), XSS, path traversal, XXE, ReDoS, prototype pollution |
|
|
103
|
+
| **AuthBypassAgent** | Auth | JWT vulnerabilities (alg:none, weak secrets), cookie security, CSRF, OAuth misconfig, BOLA/IDOR, weak crypto, timing attacks, TLS bypass |
|
|
104
|
+
| **SSRFProber** | SSRF | User input in fetch/axios, cloud metadata endpoints, internal IPs, redirect following |
|
|
105
|
+
| **SupplyChainAudit** | Supply Chain | Typosquatting (Levenshtein distance), git/URL dependencies, wildcard versions, suspicious install scripts |
|
|
106
|
+
| **ConfigAuditor** | Config | Dockerfile (running as root, :latest tags), Terraform (public S3, open SG), Kubernetes (privileged containers), CORS, CSP, Firebase, Nginx |
|
|
107
|
+
| **LLMRedTeam** | AI/LLM | OWASP LLM Top 10 — prompt injection, excessive agency, system prompt leakage, unbounded consumption, RAG poisoning |
|
|
108
|
+
| **MobileScanner** | Mobile | OWASP Mobile Top 10 2024 — insecure storage, WebView JS injection, HTTP endpoints, excessive permissions, debug mode |
|
|
109
|
+
| **GitHistoryScanner** | Secrets | Leaked secrets in git commit history (checks if still active in working tree) |
|
|
110
|
+
| **CICDScanner** | CI/CD | OWASP CI/CD Top 10 — pipeline poisoning, unpinned actions, secret logging, self-hosted runners, script injection |
|
|
111
|
+
| **APIFuzzer** | API | Routes without auth, missing input validation, mass assignment, unrestricted file upload, GraphQL introspection, debug endpoints |
|
|
112
|
+
| **ReconAgent** | Recon | Attack surface discovery — frameworks, languages, auth patterns, databases, cloud providers, IaC, CI/CD pipelines |
|
|
113
|
+
| **ScoringEngine** | Scoring | 8-category weighted scoring with trend tracking |
|
|
212
114
|
|
|
213
115
|
---
|
|
214
116
|
|
|
215
|
-
|
|
117
|
+
## All Commands
|
|
216
118
|
|
|
217
|
-
|
|
119
|
+
### Core Audit Commands
|
|
218
120
|
|
|
219
121
|
```bash
|
|
220
|
-
#
|
|
221
|
-
npx ship-safe
|
|
222
|
-
|
|
223
|
-
# Also run the package manager's auto-fix command
|
|
224
|
-
npx ship-safe deps . --fix
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
**Supported package managers:**
|
|
228
|
-
- `npm` → `npm audit`
|
|
229
|
-
- `yarn` → `yarn audit`
|
|
230
|
-
- `pnpm` → `pnpm audit`
|
|
231
|
-
- `pip` → `pip-audit` (install with `pip install pip-audit`)
|
|
232
|
-
- `bundler` → `bundle-audit` (install with `gem install bundler-audit`)
|
|
233
|
-
|
|
234
|
-
Auto-detected from your lock file. Gracefully skips if the tool isn't installed.
|
|
122
|
+
# Full audit with remediation plan + HTML report
|
|
123
|
+
npx ship-safe audit .
|
|
235
124
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
125
|
+
# Red team: 12 agents, 50+ attack classes
|
|
126
|
+
npx ship-safe red-team .
|
|
127
|
+
npx ship-safe red-team . --agents injection,auth # Run specific agents
|
|
128
|
+
npx ship-safe red-team . --html report.html # HTML report
|
|
129
|
+
npx ship-safe red-team . --json # JSON output
|
|
239
130
|
|
|
240
|
-
|
|
131
|
+
# Secret scanner (pattern matching + entropy)
|
|
132
|
+
npx ship-safe scan .
|
|
133
|
+
npx ship-safe scan . --json # JSON for CI
|
|
134
|
+
npx ship-safe scan . --sarif # SARIF for GitHub
|
|
241
135
|
|
|
242
|
-
|
|
243
|
-
# Score the project
|
|
136
|
+
# Security health score (0-100, A-F)
|
|
244
137
|
npx ship-safe score .
|
|
245
138
|
|
|
246
|
-
#
|
|
247
|
-
npx ship-safe
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
**Scoring (starts at 100):**
|
|
251
|
-
|
|
252
|
-
| Category | Critical | High | Medium | Cap |
|
|
253
|
-
|----------|----------|------|--------|-----|
|
|
254
|
-
| Secrets | −25 | −15 | −5 | −40 |
|
|
255
|
-
| Code Vulns | −20 | −10 | −3 | −30 |
|
|
256
|
-
| Dependencies | −20 | −10 | −5 | −30 |
|
|
257
|
-
|
|
258
|
-
**Grades:**
|
|
259
|
-
|
|
260
|
-
| Score | Grade | Verdict |
|
|
261
|
-
|-------|-------|---------|
|
|
262
|
-
| 90–100 | A | Ship it! |
|
|
263
|
-
| 75–89 | B | Minor issues to review |
|
|
264
|
-
| 60–74 | C | Fix before shipping |
|
|
265
|
-
| 40–59 | D | Significant security risks |
|
|
266
|
-
| 0–39 | F | Not safe to ship |
|
|
267
|
-
|
|
268
|
-
**Exit codes:** Returns `0` for A/B (≥ 75), `1` for C/D/F.
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
### `npx ship-safe checklist`
|
|
273
|
-
|
|
274
|
-
Interactive 10-point security checklist for launch day.
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
# Interactive mode (prompts for each item)
|
|
278
|
-
npx ship-safe checklist
|
|
279
|
-
|
|
280
|
-
# Print checklist without prompts
|
|
281
|
-
npx ship-safe checklist --no-interactive
|
|
139
|
+
# Dependency CVE audit
|
|
140
|
+
npx ship-safe deps .
|
|
141
|
+
npx ship-safe deps . --fix # Auto-fix vulnerabilities
|
|
282
142
|
```
|
|
283
143
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
---
|
|
287
|
-
|
|
288
|
-
### `npx ship-safe init`
|
|
289
|
-
|
|
290
|
-
Initialize security configs in your project.
|
|
144
|
+
### AI-Powered Commands
|
|
291
145
|
|
|
292
146
|
```bash
|
|
293
|
-
#
|
|
294
|
-
npx ship-safe
|
|
295
|
-
|
|
296
|
-
# Only add .gitignore patterns
|
|
297
|
-
npx ship-safe init --gitignore
|
|
147
|
+
# AI audit: scan + classify with Claude + auto-fix secrets
|
|
148
|
+
npx ship-safe agent .
|
|
298
149
|
|
|
299
|
-
#
|
|
300
|
-
npx ship-safe
|
|
150
|
+
# Auto-fix hardcoded secrets: rewrite code + write .env
|
|
151
|
+
npx ship-safe remediate .
|
|
301
152
|
|
|
302
|
-
#
|
|
303
|
-
npx ship-safe
|
|
153
|
+
# Revoke exposed keys — opens provider dashboards
|
|
154
|
+
npx ship-safe rotate .
|
|
304
155
|
```
|
|
305
156
|
|
|
306
|
-
|
|
307
|
-
- `.gitignore` - Patterns to prevent committing secrets
|
|
308
|
-
- `security-headers.config.js` - Drop-in Next.js security headers
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
### `npx ship-safe fix`
|
|
313
|
-
|
|
314
|
-
Scan for secrets and auto-generate a `.env.example` file.
|
|
157
|
+
### Infrastructure Commands
|
|
315
158
|
|
|
316
159
|
```bash
|
|
317
|
-
#
|
|
318
|
-
npx ship-safe
|
|
160
|
+
# Continuous monitoring (watch files for changes)
|
|
161
|
+
npx ship-safe watch .
|
|
319
162
|
|
|
320
|
-
#
|
|
321
|
-
npx ship-safe
|
|
322
|
-
```
|
|
163
|
+
# Generate CycloneDX SBOM
|
|
164
|
+
npx ship-safe sbom .
|
|
323
165
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
### `npx ship-safe guard`
|
|
327
|
-
|
|
328
|
-
Install a git hook that blocks pushes if secrets are found. Works with or without Husky.
|
|
166
|
+
# Policy-as-code (enforce minimum score, fail on severity)
|
|
167
|
+
npx ship-safe policy init
|
|
329
168
|
|
|
330
|
-
|
|
331
|
-
# Install pre-push hook (runs scan before every git push)
|
|
169
|
+
# Block git push if secrets found
|
|
332
170
|
npx ship-safe guard
|
|
333
171
|
|
|
334
|
-
#
|
|
335
|
-
npx ship-safe
|
|
336
|
-
|
|
337
|
-
# Remove installed hooks
|
|
338
|
-
npx ship-safe guard remove
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
**Suppress false positives:**
|
|
342
|
-
- Add `# ship-safe-ignore` as a comment on a line to skip it
|
|
343
|
-
- Create `.ship-safeignore` (gitignore syntax) to exclude paths
|
|
344
|
-
|
|
345
|
-
---
|
|
346
|
-
|
|
347
|
-
### `npx ship-safe mcp`
|
|
172
|
+
# Initialize security configs (.gitignore, headers)
|
|
173
|
+
npx ship-safe init
|
|
348
174
|
|
|
349
|
-
|
|
175
|
+
# Launch-day security checklist
|
|
176
|
+
npx ship-safe checklist
|
|
350
177
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
{
|
|
354
|
-
"mcpServers": {
|
|
355
|
-
"ship-safe": {
|
|
356
|
-
"command": "npx",
|
|
357
|
-
"args": ["ship-safe", "mcp"]
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
178
|
+
# MCP server for AI editors (Claude Desktop, Cursor, etc.)
|
|
179
|
+
npx ship-safe mcp
|
|
361
180
|
```
|
|
362
181
|
|
|
363
|
-
Works with Claude Desktop, Cursor, Windsurf, Zed, and any MCP-compatible editor.
|
|
364
|
-
|
|
365
|
-
**Available tools:**
|
|
366
|
-
- `scan_secrets` — scan a directory for leaked secrets
|
|
367
|
-
- `get_checklist` — return the security checklist as structured data
|
|
368
|
-
- `analyze_file` — analyze a single file for issues
|
|
369
|
-
|
|
370
182
|
---
|
|
371
183
|
|
|
372
|
-
##
|
|
373
|
-
|
|
374
|
-
### [`/checklists`](./checklists)
|
|
375
|
-
**Manual security audits you can do in 5 minutes.**
|
|
376
|
-
- [Launch Day Checklist](./checklists/launch-day.md) - 10 things to check before you go live
|
|
377
|
-
|
|
378
|
-
### [`/configs`](./configs)
|
|
379
|
-
**Secure defaults for popular stacks. Drop-in ready.**
|
|
380
|
-
|
|
381
|
-
| Stack | Files |
|
|
382
|
-
|-------|-------|
|
|
383
|
-
| **Next.js** | [Security Headers](./configs/nextjs-security-headers.js) - CSP, X-Frame-Options, HSTS |
|
|
384
|
-
| **Supabase** | [RLS Templates](./configs/supabase/rls-templates.sql) \| [Security Checklist](./configs/supabase/security-checklist.md) \| [Secure Client](./configs/supabase/secure-client.ts) |
|
|
385
|
-
| **Firebase** | [Firestore Rules](./configs/firebase/firestore-rules.txt) \| [Storage Rules](./configs/firebase/storage-rules.txt) \| [Security Checklist](./configs/firebase/security-checklist.md) |
|
|
386
|
-
|
|
387
|
-
### [`/snippets`](./snippets)
|
|
388
|
-
**Copy-paste code blocks for common security patterns.**
|
|
389
|
-
|
|
390
|
-
| Category | Files |
|
|
391
|
-
|----------|-------|
|
|
392
|
-
| **Rate Limiting** | [Upstash Redis](./snippets/rate-limiting/upstash-ratelimit.ts) \| [Next.js Middleware](./snippets/rate-limiting/nextjs-middleware.ts) |
|
|
393
|
-
| **Authentication** | [JWT Security Checklist](./snippets/auth/jwt-checklist.md) |
|
|
394
|
-
| **API Security** | [CORS Config](./snippets/api-security/cors-config.ts) \| [Input Validation](./snippets/api-security/input-validation.ts) \| [API Checklist](./snippets/api-security/api-security-checklist.md) |
|
|
184
|
+
## Multi-LLM Support
|
|
395
185
|
|
|
396
|
-
|
|
397
|
-
**Protect your AI features from abuse and cost explosions.**
|
|
186
|
+
Ship Safe supports multiple AI providers for classification:
|
|
398
187
|
|
|
399
|
-
|
|
|
400
|
-
|
|
401
|
-
|
|
|
402
|
-
|
|
|
403
|
-
|
|
|
404
|
-
|
|
|
188
|
+
| Provider | Env Variable | Model |
|
|
189
|
+
|----------|-------------|-------|
|
|
190
|
+
| **Anthropic** | `ANTHROPIC_API_KEY` | claude-haiku-4-5 |
|
|
191
|
+
| **OpenAI** | `OPENAI_API_KEY` | gpt-4o-mini |
|
|
192
|
+
| **Google** | `GOOGLE_AI_API_KEY` | gemini-2.0-flash |
|
|
193
|
+
| **Ollama** | `OLLAMA_HOST` | Local models |
|
|
405
194
|
|
|
406
|
-
|
|
407
|
-
**Automated scanning tools. Run them in CI or locally.**
|
|
408
|
-
- [Secret Scanner](./scripts/scan_secrets.py) - Python version of the secret scanner
|
|
195
|
+
Auto-detected from environment variables. No API key required for scanning — AI is optional.
|
|
409
196
|
|
|
410
197
|
---
|
|
411
198
|
|
|
412
|
-
##
|
|
413
|
-
|
|
414
|
-
Building with AI? Don't let it bankrupt you or get hijacked.
|
|
199
|
+
## Scoring System
|
|
415
200
|
|
|
416
|
-
|
|
201
|
+
Starts at 100. Each finding deducts points by severity and category.
|
|
417
202
|
|
|
418
|
-
|
|
419
|
-
import { containsInjectionAttempt } from './ai-defense/prompt-injection-patterns';
|
|
203
|
+
**8 Categories** (with weight caps):
|
|
420
204
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
205
|
+
| Category | Weight | Critical | High | Medium | Cap |
|
|
206
|
+
|----------|--------|----------|------|--------|-----|
|
|
207
|
+
| Secrets | 15% | -25 | -15 | -5 | -15 |
|
|
208
|
+
| Code Vulnerabilities | 15% | -20 | -10 | -3 | -15 |
|
|
209
|
+
| Dependencies | 15% | -20 | -10 | -5 | -15 |
|
|
210
|
+
| Auth & Access Control | 15% | -20 | -10 | -3 | -15 |
|
|
211
|
+
| Configuration | 10% | -15 | -8 | -3 | -10 |
|
|
212
|
+
| Supply Chain | 10% | -15 | -8 | -3 | -10 |
|
|
213
|
+
| API Security | 10% | -15 | -8 | -3 | -10 |
|
|
214
|
+
| AI/LLM Security | 10% | -15 | -8 | -3 | -10 |
|
|
427
215
|
|
|
428
|
-
|
|
429
|
-
const { success } = await ratelimit.limit(userId);
|
|
430
|
-
if (!success) {
|
|
431
|
-
return "Too many requests. Please slow down.";
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// 3. Check budget before calling
|
|
435
|
-
await checkUserBudget(userId, estimatedCost);
|
|
436
|
-
|
|
437
|
-
// 4. Make the API call with token limits
|
|
438
|
-
const response = await openai.chat.completions.create({
|
|
439
|
-
model: 'gpt-4',
|
|
440
|
-
messages,
|
|
441
|
-
max_tokens: 500, // Hard cap
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
return response;
|
|
445
|
-
}
|
|
446
|
-
```
|
|
216
|
+
**Grades:** A (90-100), B (75-89), C (60-74), D (40-59), F (0-39)
|
|
447
217
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
1. **Token limits** - Cap input/output per request
|
|
451
|
-
2. **Rate limits** - Cap requests per user (10/min)
|
|
452
|
-
3. **Budget caps** - Daily ($1) and monthly ($10) per user
|
|
453
|
-
4. **Circuit breaker** - Disable AI when global budget hit
|
|
454
|
-
5. **Provider limits** - Set hard limits in OpenAI/Anthropic dashboard
|
|
455
|
-
|
|
456
|
-
[Full cost protection guide →](./ai-defense/cost-protection.md)
|
|
457
|
-
|
|
458
|
-
---
|
|
459
|
-
|
|
460
|
-
## Database Security
|
|
461
|
-
|
|
462
|
-
### Supabase RLS Templates
|
|
463
|
-
|
|
464
|
-
```sql
|
|
465
|
-
-- Users can only see their own data
|
|
466
|
-
CREATE POLICY "Users own their data" ON items
|
|
467
|
-
FOR ALL USING (auth.uid() = user_id);
|
|
468
|
-
|
|
469
|
-
-- Read-only public data
|
|
470
|
-
CREATE POLICY "Public read access" ON public_items
|
|
471
|
-
FOR SELECT USING (true);
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
[6 more RLS patterns →](./configs/supabase/rls-templates.sql)
|
|
475
|
-
|
|
476
|
-
### Firebase Security Rules
|
|
477
|
-
|
|
478
|
-
```javascript
|
|
479
|
-
// Users can only access their own documents
|
|
480
|
-
match /users/{userId} {
|
|
481
|
-
allow read, write: if request.auth != null
|
|
482
|
-
&& request.auth.uid == userId;
|
|
483
|
-
}
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
[Full Firestore rules template →](./configs/firebase/firestore-rules.txt)
|
|
218
|
+
**Exit codes:** `0` for A/B (>= 75), `1` for C/D/F — use in CI to fail builds.
|
|
487
219
|
|
|
488
220
|
---
|
|
489
221
|
|
|
490
|
-
##
|
|
491
|
-
|
|
492
|
-
### CORS (Don't use `*` in production)
|
|
222
|
+
## Policy-as-Code
|
|
493
223
|
|
|
494
|
-
|
|
495
|
-
const ALLOWED_ORIGINS = [
|
|
496
|
-
'https://yourapp.com',
|
|
497
|
-
'https://www.yourapp.com',
|
|
498
|
-
];
|
|
224
|
+
Create `.ship-safe.policy.json` to enforce team-wide security standards:
|
|
499
225
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
headers['Access-Control-Allow-Origin'] = origin;
|
|
503
|
-
}
|
|
226
|
+
```bash
|
|
227
|
+
npx ship-safe policy init
|
|
504
228
|
```
|
|
505
229
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
const result = createUserSchema.safeParse(body);
|
|
517
|
-
if (!result.success) {
|
|
518
|
-
return Response.json({ error: result.error.issues }, { status: 400 });
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"minimumScore": 70,
|
|
233
|
+
"failOn": "critical",
|
|
234
|
+
"requiredScans": ["secrets", "injection", "deps", "auth"],
|
|
235
|
+
"ignoreRules": [],
|
|
236
|
+
"customSeverityOverrides": {},
|
|
237
|
+
"maxAge": { "criticalCVE": "7d", "highCVE": "30d", "mediumCVE": "90d" }
|
|
519
238
|
}
|
|
520
239
|
```
|
|
521
240
|
|
|
522
|
-
[Full validation patterns →](./snippets/api-security/input-validation.ts)
|
|
523
|
-
|
|
524
241
|
---
|
|
525
242
|
|
|
526
243
|
## CI/CD Integration
|
|
527
244
|
|
|
528
|
-
Add to your GitHub Actions workflow:
|
|
529
|
-
|
|
530
245
|
```yaml
|
|
531
246
|
# .github/workflows/security.yml
|
|
532
|
-
name: Security
|
|
247
|
+
name: Security Audit
|
|
533
248
|
|
|
534
249
|
on: [push, pull_request]
|
|
535
250
|
|
|
@@ -539,60 +254,70 @@ jobs:
|
|
|
539
254
|
steps:
|
|
540
255
|
- uses: actions/checkout@v4
|
|
541
256
|
|
|
542
|
-
- name:
|
|
543
|
-
run: npx ship-safe
|
|
257
|
+
- name: Full security audit
|
|
258
|
+
run: npx ship-safe audit . --no-ai --json
|
|
544
259
|
|
|
545
|
-
- name:
|
|
546
|
-
run: npx ship-safe
|
|
260
|
+
- name: Upload SARIF to GitHub Security tab
|
|
261
|
+
run: npx ship-safe audit . --no-ai --sarif > results.sarif
|
|
547
262
|
|
|
548
|
-
-
|
|
549
|
-
|
|
263
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
264
|
+
with:
|
|
265
|
+
sarif_file: results.sarif
|
|
550
266
|
```
|
|
551
267
|
|
|
552
|
-
|
|
268
|
+
---
|
|
553
269
|
|
|
554
|
-
|
|
555
|
-
- name: Scan (SARIF for GitHub Security tab)
|
|
556
|
-
run: npx ship-safe scan . --sarif > results.sarif
|
|
270
|
+
## Suppress False Positives
|
|
557
271
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
272
|
+
**Inline:** Add `# ship-safe-ignore` comment on a line:
|
|
273
|
+
```python
|
|
274
|
+
password = get_password() # ship-safe-ignore
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**File-level:** Create `.ship-safeignore` (gitignore syntax):
|
|
278
|
+
```gitignore
|
|
279
|
+
# Exclude test fixtures
|
|
280
|
+
tests/fixtures/
|
|
281
|
+
*.test.js
|
|
282
|
+
|
|
283
|
+
# Exclude documentation with code examples
|
|
284
|
+
docs/
|
|
562
285
|
```
|
|
563
286
|
|
|
564
287
|
---
|
|
565
288
|
|
|
566
|
-
##
|
|
289
|
+
## OWASP Coverage
|
|
567
290
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
7. ✅ If using AI features, implement [cost protection](./ai-defense/cost-protection.md)
|
|
575
|
-
8. ✅ If using Supabase, check the [RLS checklist](./configs/supabase/security-checklist.md)
|
|
576
|
-
9. ✅ If using Firebase, check the [Firebase checklist](./configs/firebase/security-checklist.md)
|
|
291
|
+
| Standard | Coverage |
|
|
292
|
+
|----------|----------|
|
|
293
|
+
| **OWASP Top 10 Web 2025** | A01-A10: Broken Access Control, Cryptographic Failures, Injection, Insecure Design, Security Misconfiguration, Vulnerable Components, Auth Failures, Data Integrity, Logging Failures, SSRF |
|
|
294
|
+
| **OWASP Top 10 Mobile 2024** | M1-M10: Improper Credential Usage, Inadequate Supply Chain, Insecure Auth, Insufficient Validation, Insecure Communication, Inadequate Privacy, Binary Protections, Security Misconfiguration, Insecure Data Storage, Insufficient Cryptography |
|
|
295
|
+
| **OWASP LLM Top 10 2025** | LLM01-LLM10: Prompt Injection, Sensitive Info Disclosure, Supply Chain, Data Poisoning, Improper Output Handling, Excessive Agency, System Prompt Leakage, Vector/Embedding Weaknesses, Misinformation, Unbounded Consumption |
|
|
296
|
+
| **OWASP CI/CD Top 10** | CICD-SEC-1 to 10: Insufficient Flow Control, Identity Management, Dependency Chain Abuse, Poisoned Pipeline Execution, Insufficient PBAC, Credential Hygiene, Insecure System Config, Ungoverned Usage, Improper Artifact Integrity, Insufficient Logging |
|
|
577
297
|
|
|
578
298
|
---
|
|
579
299
|
|
|
580
|
-
##
|
|
300
|
+
## What's Inside
|
|
301
|
+
|
|
302
|
+
### [`/configs`](./configs)
|
|
303
|
+
Drop-in security configs for Next.js, Supabase, and Firebase.
|
|
581
304
|
|
|
582
|
-
|
|
583
|
-
-
|
|
584
|
-
|
|
585
|
-
|
|
305
|
+
### [`/snippets`](./snippets)
|
|
306
|
+
Copy-paste security patterns: rate limiting, JWT, CORS, input validation.
|
|
307
|
+
|
|
308
|
+
### [`/ai-defense`](./ai-defense)
|
|
309
|
+
LLM security: prompt injection detection, cost protection, system prompt hardening.
|
|
310
|
+
|
|
311
|
+
### [`/checklists`](./checklists)
|
|
312
|
+
Manual security audits: launch-day checklist, framework-specific guides.
|
|
586
313
|
|
|
587
314
|
---
|
|
588
315
|
|
|
589
316
|
## Contributing
|
|
590
317
|
|
|
591
|
-
Found a security pattern that saved your app? Share it!
|
|
592
|
-
|
|
593
318
|
1. Fork the repo
|
|
594
|
-
2. Add your
|
|
595
|
-
3. Include
|
|
319
|
+
2. Add your security pattern, agent, or config
|
|
320
|
+
3. Include comments explaining *why* it matters
|
|
596
321
|
4. Open a PR
|
|
597
322
|
|
|
598
323
|
See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
@@ -601,11 +326,11 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
|
601
326
|
|
|
602
327
|
## Security Standards Reference
|
|
603
328
|
|
|
604
|
-
This toolkit is based on:
|
|
605
329
|
- [OWASP Top 10 Web 2025](https://owasp.org/Top10/)
|
|
606
330
|
- [OWASP Top 10 Mobile 2024](https://owasp.org/www-project-mobile-top-10/)
|
|
607
331
|
- [OWASP LLM Top 10 2025](https://genai.owasp.org/llm-top-10/)
|
|
608
332
|
- [OWASP API Security Top 10 2023](https://owasp.org/API-Security/)
|
|
333
|
+
- [OWASP CI/CD Top 10](https://owasp.org/www-project-top-10-ci-cd-security-risks/)
|
|
609
334
|
|
|
610
335
|
---
|
|
611
336
|
|
|
@@ -621,6 +346,4 @@ MIT - Use it, share it, secure your stuff.
|
|
|
621
346
|
|
|
622
347
|
---
|
|
623
348
|
|
|
624
|
-
**
|
|
625
|
-
|
|
626
|
-
Ship fast. Ship safe.
|
|
349
|
+
**Ship fast. Ship safe.**
|