ship-safe 3.1.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 +200 -307
- 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 +119 -2
- package/cli/commands/agent.js +606 -0
- package/cli/commands/audit.js +565 -0
- package/cli/commands/deps.js +447 -0
- package/cli/commands/fix.js +3 -3
- package/cli/commands/init.js +86 -3
- package/cli/commands/mcp.js +2 -2
- package/cli/commands/red-team.js +315 -0
- package/cli/commands/remediate.js +4 -4
- package/cli/commands/rotate.js +6 -6
- package/cli/commands/scan.js +64 -23
- package/cli/commands/score.js +446 -0
- package/cli/commands/watch.js +160 -0
- package/cli/index.js +40 -2
- package/cli/providers/llm-provider.js +288 -0
- package/cli/utils/entropy.js +6 -0
- package/cli/utils/output.js +42 -2
- package/cli/utils/patterns.js +393 -1
- package/package.json +19 -15
package/README.md
CHANGED
|
@@ -1,434 +1,323 @@
|
|
|
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>
|
|
8
|
+
<a href="https://www.npmjs.com/package/ship-safe"><img src="https://img.shields.io/npm/dm/ship-safe.svg" alt="npm downloads" /></a>
|
|
9
|
+
<a href="https://github.com/asamassekou10/ship-safe/actions/workflows/ci.yml"><img src="https://github.com/asamassekou10/ship-safe/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
|
|
10
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/node/v/ship-safe" alt="Node.js version" /></a>
|
|
8
11
|
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
|
|
9
12
|
</p>
|
|
10
13
|
|
|
11
14
|
---
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
12 security agents. 50+ attack classes. One command.
|
|
14
17
|
|
|
15
|
-
**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.
|
|
16
19
|
|
|
17
20
|
---
|
|
18
21
|
|
|
19
22
|
## Quick Start
|
|
20
23
|
|
|
21
24
|
```bash
|
|
22
|
-
#
|
|
23
|
-
npx ship-safe
|
|
24
|
-
|
|
25
|
-
# Auto-generate .env.example from found secrets
|
|
26
|
-
npx ship-safe fix
|
|
25
|
+
# Full security audit — secrets + 12 agents + deps + remediation plan
|
|
26
|
+
npx ship-safe audit .
|
|
27
27
|
|
|
28
|
-
#
|
|
29
|
-
npx ship-safe
|
|
28
|
+
# Red team scan only (12 agents, 50+ attack classes)
|
|
29
|
+
npx ship-safe red-team .
|
|
30
30
|
|
|
31
|
-
#
|
|
32
|
-
npx ship-safe
|
|
31
|
+
# Quick secret scan
|
|
32
|
+
npx ship-safe scan .
|
|
33
33
|
|
|
34
|
-
#
|
|
35
|
-
npx ship-safe
|
|
34
|
+
# Security health score (0-100)
|
|
35
|
+
npx ship-safe score .
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
That's it. Five commands to secure your MVP.
|
|
39
|
-
|
|
40
38
|

|
|
41
39
|
|
|
42
|
-
### Let AI Do It For You
|
|
43
|
-
|
|
44
|
-
Copy this prompt to your AI coding assistant:
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
Run "npx ship-safe scan ." on my project and fix any secrets you find.
|
|
48
|
-
Then run "npx ship-safe init" to add security configs.
|
|
49
|
-
Explain what you're doing as you go.
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
[More AI prompts for specific frameworks](./AI_SECURITY_PROMPT.md)
|
|
53
|
-
|
|
54
40
|
---
|
|
55
41
|
|
|
56
|
-
##
|
|
57
|
-
|
|
58
|
-
Vibe coding is powerful. You can build a SaaS in a weekend. But speed creates blind spots:
|
|
42
|
+
## The `audit` Command
|
|
59
43
|
|
|
60
|
-
|
|
61
|
-
- Default configs ship with debug mode enabled
|
|
62
|
-
- "I'll fix it later" becomes "I got hacked"
|
|
44
|
+
One command that runs everything and generates a full report:
|
|
63
45
|
|
|
64
|
-
|
|
46
|
+
```bash
|
|
47
|
+
npx ship-safe audit .
|
|
48
|
+
```
|
|
65
49
|
|
|
66
|
-
|
|
50
|
+
```
|
|
51
|
+
════════════════════════════════════════════════════════════
|
|
52
|
+
Ship Safe v4.0 — Full Security Audit
|
|
53
|
+
════════════════════════════════════════════════════════════
|
|
67
54
|
|
|
68
|
-
|
|
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
|
|
69
59
|
|
|
70
|
-
|
|
60
|
+
Remediation Plan
|
|
61
|
+
════════════════════════════════════════════════════════
|
|
71
62
|
|
|
72
|
-
|
|
63
|
+
🔴 CRITICAL — fix immediately
|
|
64
|
+
────────────────────────────────────────────────────────
|
|
65
|
+
1. [SECRETS] Rotate Stripe Live Secret Key
|
|
66
|
+
.env:67 → Move to environment variable or secrets manager
|
|
73
67
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
npx ship-safe scan .
|
|
68
|
+
2. [INJECTION] Unsafe pickle.loads()
|
|
69
|
+
backend/ai_processor.py:64 → Use JSON for untrusted data
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
🟠 HIGH — fix before deploy
|
|
72
|
+
────────────────────────────────────────────────────────
|
|
73
|
+
3. [XSS] dangerouslySetInnerHTML without sanitization
|
|
74
|
+
frontend/src/utils/blogContentRenderer.jsx:50 → Add DOMPurify
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
npx ship-safe scan . --json
|
|
76
|
+
... 149 more items in the full report
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
npx ship-safe scan . -v
|
|
78
|
+
📊 Full report: ship-safe-report.html
|
|
86
79
|
```
|
|
87
80
|
|
|
88
|
-
**
|
|
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
|
|
89
88
|
|
|
90
89
|
**Flags:**
|
|
91
|
-
- `--json` — structured JSON output for
|
|
90
|
+
- `--json` — structured JSON output (clean for piping)
|
|
92
91
|
- `--sarif` — SARIF format for GitHub Code Scanning
|
|
93
|
-
- `--
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
**Suppress false positives:**
|
|
97
|
-
```bash
|
|
98
|
-
const apiKey = 'example-key'; // ship-safe-ignore
|
|
99
|
-
```
|
|
100
|
-
Or exclude paths with `.ship-safeignore` (gitignore syntax).
|
|
92
|
+
- `--html [file]` — custom HTML report path (default: `ship-safe-report.html`)
|
|
93
|
+
- `--no-deps` — skip dependency audit
|
|
94
|
+
- `--no-ai` — skip AI classification
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
```json
|
|
104
|
-
{
|
|
105
|
-
"patterns": [
|
|
106
|
-
{
|
|
107
|
-
"name": "My Internal API Key",
|
|
108
|
-
"pattern": "MYAPP_[A-Z0-9]{32}",
|
|
109
|
-
"severity": "high",
|
|
110
|
-
"description": "Internal key for myapp services."
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
```
|
|
96
|
+
---
|
|
115
97
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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 |
|
|
124
114
|
|
|
125
115
|
---
|
|
126
116
|
|
|
127
|
-
|
|
117
|
+
## All Commands
|
|
128
118
|
|
|
129
|
-
|
|
119
|
+
### Core Audit Commands
|
|
130
120
|
|
|
131
121
|
```bash
|
|
132
|
-
#
|
|
133
|
-
npx ship-safe
|
|
122
|
+
# Full audit with remediation plan + HTML report
|
|
123
|
+
npx ship-safe audit .
|
|
134
124
|
|
|
135
|
-
#
|
|
136
|
-
npx ship-safe
|
|
137
|
-
|
|
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
|
|
138
130
|
|
|
139
|
-
|
|
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
|
|
140
135
|
|
|
141
|
-
|
|
136
|
+
# Security health score (0-100, A-F)
|
|
137
|
+
npx ship-safe score .
|
|
142
138
|
|
|
143
|
-
|
|
139
|
+
# Dependency CVE audit
|
|
140
|
+
npx ship-safe deps .
|
|
141
|
+
npx ship-safe deps . --fix # Auto-fix vulnerabilities
|
|
142
|
+
```
|
|
144
143
|
|
|
145
|
-
|
|
144
|
+
### AI-Powered Commands
|
|
146
145
|
|
|
147
146
|
```bash
|
|
148
|
-
#
|
|
149
|
-
npx ship-safe
|
|
150
|
-
|
|
151
|
-
# Only add .gitignore patterns
|
|
152
|
-
npx ship-safe init --gitignore
|
|
147
|
+
# AI audit: scan + classify with Claude + auto-fix secrets
|
|
148
|
+
npx ship-safe agent .
|
|
153
149
|
|
|
154
|
-
#
|
|
155
|
-
npx ship-safe
|
|
150
|
+
# Auto-fix hardcoded secrets: rewrite code + write .env
|
|
151
|
+
npx ship-safe remediate .
|
|
156
152
|
|
|
157
|
-
#
|
|
158
|
-
npx ship-safe
|
|
153
|
+
# Revoke exposed keys — opens provider dashboards
|
|
154
|
+
npx ship-safe rotate .
|
|
159
155
|
```
|
|
160
156
|
|
|
161
|
-
|
|
162
|
-
- `.gitignore` - Patterns to prevent committing secrets
|
|
163
|
-
- `security-headers.config.js` - Drop-in Next.js security headers
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
### `npx ship-safe fix`
|
|
168
|
-
|
|
169
|
-
Scan for secrets and auto-generate a `.env.example` file.
|
|
157
|
+
### Infrastructure Commands
|
|
170
158
|
|
|
171
159
|
```bash
|
|
172
|
-
#
|
|
173
|
-
npx ship-safe
|
|
174
|
-
|
|
175
|
-
# Preview what would be generated without writing it
|
|
176
|
-
npx ship-safe fix --dry-run
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
---
|
|
160
|
+
# Continuous monitoring (watch files for changes)
|
|
161
|
+
npx ship-safe watch .
|
|
180
162
|
|
|
181
|
-
|
|
163
|
+
# Generate CycloneDX SBOM
|
|
164
|
+
npx ship-safe sbom .
|
|
182
165
|
|
|
183
|
-
|
|
166
|
+
# Policy-as-code (enforce minimum score, fail on severity)
|
|
167
|
+
npx ship-safe policy init
|
|
184
168
|
|
|
185
|
-
|
|
186
|
-
# Install pre-push hook (runs scan before every git push)
|
|
169
|
+
# Block git push if secrets found
|
|
187
170
|
npx ship-safe guard
|
|
188
171
|
|
|
189
|
-
#
|
|
190
|
-
npx ship-safe
|
|
172
|
+
# Initialize security configs (.gitignore, headers)
|
|
173
|
+
npx ship-safe init
|
|
191
174
|
|
|
192
|
-
#
|
|
193
|
-
npx ship-safe
|
|
194
|
-
```
|
|
175
|
+
# Launch-day security checklist
|
|
176
|
+
npx ship-safe checklist
|
|
195
177
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
178
|
+
# MCP server for AI editors (Claude Desktop, Cursor, etc.)
|
|
179
|
+
npx ship-safe mcp
|
|
180
|
+
```
|
|
199
181
|
|
|
200
182
|
---
|
|
201
183
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
Start ship-safe as an MCP server so AI editors can call it directly.
|
|
184
|
+
## Multi-LLM Support
|
|
205
185
|
|
|
206
|
-
|
|
207
|
-
```json
|
|
208
|
-
{
|
|
209
|
-
"mcpServers": {
|
|
210
|
-
"ship-safe": {
|
|
211
|
-
"command": "npx",
|
|
212
|
-
"args": ["ship-safe", "mcp"]
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
```
|
|
186
|
+
Ship Safe supports multiple AI providers for classification:
|
|
217
187
|
|
|
218
|
-
|
|
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 |
|
|
219
194
|
|
|
220
|
-
|
|
221
|
-
- `scan_secrets` — scan a directory for leaked secrets
|
|
222
|
-
- `get_checklist` — return the security checklist as structured data
|
|
223
|
-
- `analyze_file` — analyze a single file for issues
|
|
195
|
+
Auto-detected from environment variables. No API key required for scanning — AI is optional.
|
|
224
196
|
|
|
225
197
|
---
|
|
226
198
|
|
|
227
|
-
##
|
|
228
|
-
|
|
229
|
-
### [`/checklists`](./checklists)
|
|
230
|
-
**Manual security audits you can do in 5 minutes.**
|
|
231
|
-
- [Launch Day Checklist](./checklists/launch-day.md) - 10 things to check before you go live
|
|
232
|
-
|
|
233
|
-
### [`/configs`](./configs)
|
|
234
|
-
**Secure defaults for popular stacks. Drop-in ready.**
|
|
235
|
-
|
|
236
|
-
| Stack | Files |
|
|
237
|
-
|-------|-------|
|
|
238
|
-
| **Next.js** | [Security Headers](./configs/nextjs-security-headers.js) - CSP, X-Frame-Options, HSTS |
|
|
239
|
-
| **Supabase** | [RLS Templates](./configs/supabase/rls-templates.sql) \| [Security Checklist](./configs/supabase/security-checklist.md) \| [Secure Client](./configs/supabase/secure-client.ts) |
|
|
240
|
-
| **Firebase** | [Firestore Rules](./configs/firebase/firestore-rules.txt) \| [Storage Rules](./configs/firebase/storage-rules.txt) \| [Security Checklist](./configs/firebase/security-checklist.md) |
|
|
199
|
+
## Scoring System
|
|
241
200
|
|
|
242
|
-
|
|
243
|
-
**Copy-paste code blocks for common security patterns.**
|
|
201
|
+
Starts at 100. Each finding deducts points by severity and category.
|
|
244
202
|
|
|
245
|
-
|
|
246
|
-
|----------|-------|
|
|
247
|
-
| **Rate Limiting** | [Upstash Redis](./snippets/rate-limiting/upstash-ratelimit.ts) \| [Next.js Middleware](./snippets/rate-limiting/nextjs-middleware.ts) |
|
|
248
|
-
| **Authentication** | [JWT Security Checklist](./snippets/auth/jwt-checklist.md) |
|
|
249
|
-
| **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) |
|
|
203
|
+
**8 Categories** (with weight caps):
|
|
250
204
|
|
|
251
|
-
|
|
252
|
-
|
|
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 |
|
|
253
215
|
|
|
254
|
-
|
|
255
|
-
|------|-------------|
|
|
256
|
-
| [LLM Security Checklist](./ai-defense/llm-security-checklist.md) | Based on OWASP LLM Top 10 - prompt injection, data protection, scope control |
|
|
257
|
-
| [Prompt Injection Patterns](./ai-defense/prompt-injection-patterns.js) | Regex patterns to detect 25+ injection attempts |
|
|
258
|
-
| [Cost Protection Guide](./ai-defense/cost-protection.md) | Prevent $50k surprise bills - rate limits, budget caps, circuit breakers |
|
|
259
|
-
| [System Prompt Armor](./ai-defense/system-prompt-armor.md) | Template for hardened system prompts |
|
|
216
|
+
**Grades:** A (90-100), B (75-89), C (60-74), D (40-59), F (0-39)
|
|
260
217
|
|
|
261
|
-
|
|
262
|
-
**Automated scanning tools. Run them in CI or locally.**
|
|
263
|
-
- [Secret Scanner](./scripts/scan_secrets.py) - Python version of the secret scanner
|
|
218
|
+
**Exit codes:** `0` for A/B (>= 75), `1` for C/D/F — use in CI to fail builds.
|
|
264
219
|
|
|
265
220
|
---
|
|
266
221
|
|
|
267
|
-
##
|
|
268
|
-
|
|
269
|
-
Building with AI? Don't let it bankrupt you or get hijacked.
|
|
270
|
-
|
|
271
|
-
### Quick Setup
|
|
272
|
-
|
|
273
|
-
```typescript
|
|
274
|
-
import { containsInjectionAttempt } from './ai-defense/prompt-injection-patterns';
|
|
275
|
-
|
|
276
|
-
async function handleChat(userInput: string) {
|
|
277
|
-
// 1. Check for injection attempts
|
|
278
|
-
const { detected } = containsInjectionAttempt(userInput);
|
|
279
|
-
if (detected) {
|
|
280
|
-
return "I can't process that request.";
|
|
281
|
-
}
|
|
222
|
+
## Policy-as-Code
|
|
282
223
|
|
|
283
|
-
|
|
284
|
-
const { success } = await ratelimit.limit(userId);
|
|
285
|
-
if (!success) {
|
|
286
|
-
return "Too many requests. Please slow down.";
|
|
287
|
-
}
|
|
224
|
+
Create `.ship-safe.policy.json` to enforce team-wide security standards:
|
|
288
225
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
// 4. Make the API call with token limits
|
|
293
|
-
const response = await openai.chat.completions.create({
|
|
294
|
-
model: 'gpt-4',
|
|
295
|
-
messages,
|
|
296
|
-
max_tokens: 500, // Hard cap
|
|
297
|
-
});
|
|
226
|
+
```bash
|
|
227
|
+
npx ship-safe policy init
|
|
228
|
+
```
|
|
298
229
|
|
|
299
|
-
|
|
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" }
|
|
300
238
|
}
|
|
301
239
|
```
|
|
302
240
|
|
|
303
|
-
### Cost Protection Layers
|
|
304
|
-
|
|
305
|
-
1. **Token limits** - Cap input/output per request
|
|
306
|
-
2. **Rate limits** - Cap requests per user (10/min)
|
|
307
|
-
3. **Budget caps** - Daily ($1) and monthly ($10) per user
|
|
308
|
-
4. **Circuit breaker** - Disable AI when global budget hit
|
|
309
|
-
5. **Provider limits** - Set hard limits in OpenAI/Anthropic dashboard
|
|
310
|
-
|
|
311
|
-
[Full cost protection guide →](./ai-defense/cost-protection.md)
|
|
312
|
-
|
|
313
241
|
---
|
|
314
242
|
|
|
315
|
-
##
|
|
243
|
+
## CI/CD Integration
|
|
316
244
|
|
|
317
|
-
|
|
245
|
+
```yaml
|
|
246
|
+
# .github/workflows/security.yml
|
|
247
|
+
name: Security Audit
|
|
318
248
|
|
|
319
|
-
|
|
320
|
-
-- Users can only see their own data
|
|
321
|
-
CREATE POLICY "Users own their data" ON items
|
|
322
|
-
FOR ALL USING (auth.uid() = user_id);
|
|
249
|
+
on: [push, pull_request]
|
|
323
250
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
251
|
+
jobs:
|
|
252
|
+
security:
|
|
253
|
+
runs-on: ubuntu-latest
|
|
254
|
+
steps:
|
|
255
|
+
- uses: actions/checkout@v4
|
|
328
256
|
|
|
329
|
-
|
|
257
|
+
- name: Full security audit
|
|
258
|
+
run: npx ship-safe audit . --no-ai --json
|
|
330
259
|
|
|
331
|
-
|
|
260
|
+
- name: Upload SARIF to GitHub Security tab
|
|
261
|
+
run: npx ship-safe audit . --no-ai --sarif > results.sarif
|
|
332
262
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
allow read, write: if request.auth != null
|
|
337
|
-
&& request.auth.uid == userId;
|
|
338
|
-
}
|
|
263
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
264
|
+
with:
|
|
265
|
+
sarif_file: results.sarif
|
|
339
266
|
```
|
|
340
267
|
|
|
341
|
-
[Full Firestore rules template →](./configs/firebase/firestore-rules.txt)
|
|
342
|
-
|
|
343
268
|
---
|
|
344
269
|
|
|
345
|
-
##
|
|
346
|
-
|
|
347
|
-
### CORS (Don't use `*` in production)
|
|
348
|
-
|
|
349
|
-
```typescript
|
|
350
|
-
const ALLOWED_ORIGINS = [
|
|
351
|
-
'https://yourapp.com',
|
|
352
|
-
'https://www.yourapp.com',
|
|
353
|
-
];
|
|
270
|
+
## Suppress False Positives
|
|
354
271
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
272
|
+
**Inline:** Add `# ship-safe-ignore` comment on a line:
|
|
273
|
+
```python
|
|
274
|
+
password = get_password() # ship-safe-ignore
|
|
359
275
|
```
|
|
360
276
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
277
|
+
**File-level:** Create `.ship-safeignore` (gitignore syntax):
|
|
278
|
+
```gitignore
|
|
279
|
+
# Exclude test fixtures
|
|
280
|
+
tests/fixtures/
|
|
281
|
+
*.test.js
|
|
364
282
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
email: z.string().email().max(255),
|
|
368
|
-
password: z.string().min(8).max(128),
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
const result = createUserSchema.safeParse(body);
|
|
372
|
-
if (!result.success) {
|
|
373
|
-
return Response.json({ error: result.error.issues }, { status: 400 });
|
|
374
|
-
}
|
|
283
|
+
# Exclude documentation with code examples
|
|
284
|
+
docs/
|
|
375
285
|
```
|
|
376
286
|
|
|
377
|
-
[Full validation patterns →](./snippets/api-security/input-validation.ts)
|
|
378
|
-
|
|
379
287
|
---
|
|
380
288
|
|
|
381
|
-
##
|
|
382
|
-
|
|
383
|
-
Add to your GitHub Actions workflow:
|
|
384
|
-
|
|
385
|
-
```yaml
|
|
386
|
-
# .github/workflows/security.yml
|
|
387
|
-
name: Security Scan
|
|
388
|
-
|
|
389
|
-
on: [push, pull_request]
|
|
390
|
-
|
|
391
|
-
jobs:
|
|
392
|
-
scan-secrets:
|
|
393
|
-
runs-on: ubuntu-latest
|
|
394
|
-
steps:
|
|
395
|
-
- uses: actions/checkout@v4
|
|
396
|
-
- name: Scan for secrets
|
|
397
|
-
run: npx ship-safe scan . --json
|
|
398
|
-
```
|
|
289
|
+
## OWASP Coverage
|
|
399
290
|
|
|
400
|
-
|
|
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 |
|
|
401
297
|
|
|
402
298
|
---
|
|
403
299
|
|
|
404
|
-
##
|
|
300
|
+
## What's Inside
|
|
405
301
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
3. ✅ Add security headers to your Next.js config
|
|
409
|
-
4. ✅ Run `npx ship-safe checklist` before launching
|
|
410
|
-
5. ✅ If using AI features, implement [cost protection](./ai-defense/cost-protection.md)
|
|
411
|
-
6. ✅ If using Supabase, check the [RLS checklist](./configs/supabase/security-checklist.md)
|
|
412
|
-
7. ✅ If using Firebase, check the [Firebase checklist](./configs/firebase/security-checklist.md)
|
|
302
|
+
### [`/configs`](./configs)
|
|
303
|
+
Drop-in security configs for Next.js, Supabase, and Firebase.
|
|
413
304
|
|
|
414
|
-
|
|
305
|
+
### [`/snippets`](./snippets)
|
|
306
|
+
Copy-paste security patterns: rate limiting, JWT, CORS, input validation.
|
|
415
307
|
|
|
416
|
-
|
|
308
|
+
### [`/ai-defense`](./ai-defense)
|
|
309
|
+
LLM security: prompt injection detection, cost protection, system prompt hardening.
|
|
417
310
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
- **Modular** - Take what you need, ignore the rest
|
|
421
|
-
- **Copy-paste friendly** - No complex setup, just grab and go
|
|
311
|
+
### [`/checklists`](./checklists)
|
|
312
|
+
Manual security audits: launch-day checklist, framework-specific guides.
|
|
422
313
|
|
|
423
314
|
---
|
|
424
315
|
|
|
425
316
|
## Contributing
|
|
426
317
|
|
|
427
|
-
Found a security pattern that saved your app? Share it!
|
|
428
|
-
|
|
429
318
|
1. Fork the repo
|
|
430
|
-
2. Add your
|
|
431
|
-
3. Include
|
|
319
|
+
2. Add your security pattern, agent, or config
|
|
320
|
+
3. Include comments explaining *why* it matters
|
|
432
321
|
4. Open a PR
|
|
433
322
|
|
|
434
323
|
See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
@@ -437,11 +326,11 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
|
437
326
|
|
|
438
327
|
## Security Standards Reference
|
|
439
328
|
|
|
440
|
-
This toolkit is based on:
|
|
441
329
|
- [OWASP Top 10 Web 2025](https://owasp.org/Top10/)
|
|
442
330
|
- [OWASP Top 10 Mobile 2024](https://owasp.org/www-project-mobile-top-10/)
|
|
443
331
|
- [OWASP LLM Top 10 2025](https://genai.owasp.org/llm-top-10/)
|
|
444
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/)
|
|
445
334
|
|
|
446
335
|
---
|
|
447
336
|
|
|
@@ -451,6 +340,10 @@ MIT - Use it, share it, secure your stuff.
|
|
|
451
340
|
|
|
452
341
|
---
|
|
453
342
|
|
|
454
|
-
|
|
343
|
+
## Star History
|
|
344
|
+
|
|
345
|
+
[](https://star-history.com/#asamassekou10/ship-safe&Date)
|
|
346
|
+
|
|
347
|
+
---
|
|
455
348
|
|
|
456
|
-
Ship fast. Ship safe
|
|
349
|
+
**Ship fast. Ship safe.**
|