ship-safe 6.1.1 → 6.2.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.
Files changed (47) hide show
  1. package/README.md +735 -641
  2. package/cli/agents/api-fuzzer.js +345 -345
  3. package/cli/agents/auth-bypass-agent.js +348 -348
  4. package/cli/agents/base-agent.js +272 -272
  5. package/cli/agents/cicd-scanner.js +236 -201
  6. package/cli/agents/config-auditor.js +521 -521
  7. package/cli/agents/deep-analyzer.js +6 -2
  8. package/cli/agents/git-history-scanner.js +170 -170
  9. package/cli/agents/html-reporter.js +568 -568
  10. package/cli/agents/index.js +84 -84
  11. package/cli/agents/injection-tester.js +500 -500
  12. package/cli/agents/llm-redteam.js +251 -251
  13. package/cli/agents/mobile-scanner.js +231 -231
  14. package/cli/agents/orchestrator.js +322 -322
  15. package/cli/agents/pii-compliance-agent.js +301 -301
  16. package/cli/agents/scoring-engine.js +248 -248
  17. package/cli/agents/supabase-rls-agent.js +154 -154
  18. package/cli/agents/supply-chain-agent.js +650 -507
  19. package/cli/bin/ship-safe.js +452 -426
  20. package/cli/commands/agent.js +608 -608
  21. package/cli/commands/audit.js +986 -980
  22. package/cli/commands/baseline.js +193 -193
  23. package/cli/commands/ci.js +342 -342
  24. package/cli/commands/deps.js +516 -516
  25. package/cli/commands/doctor.js +159 -159
  26. package/cli/commands/fix.js +218 -218
  27. package/cli/commands/hooks.js +268 -0
  28. package/cli/commands/init.js +407 -407
  29. package/cli/commands/mcp.js +304 -304
  30. package/cli/commands/red-team.js +7 -1
  31. package/cli/commands/remediate.js +798 -798
  32. package/cli/commands/rotate.js +571 -571
  33. package/cli/commands/scan.js +569 -569
  34. package/cli/commands/score.js +449 -449
  35. package/cli/commands/watch.js +281 -281
  36. package/cli/hooks/patterns.js +313 -0
  37. package/cli/hooks/post-tool-use.js +140 -0
  38. package/cli/hooks/pre-tool-use.js +186 -0
  39. package/cli/index.js +73 -69
  40. package/cli/providers/llm-provider.js +397 -287
  41. package/cli/utils/autofix-rules.js +74 -74
  42. package/cli/utils/cache-manager.js +311 -311
  43. package/cli/utils/output.js +230 -230
  44. package/cli/utils/patterns.js +1121 -1121
  45. package/cli/utils/pdf-generator.js +94 -94
  46. package/package.json +69 -69
  47. package/configs/supabase/rls-templates.sql +0 -242
package/README.md CHANGED
@@ -1,641 +1,735 @@
1
- <p align="center">
2
- <img src=".github/assets/logo%20ship%20safe.png" alt="Ship Safe Logo" width="180" />
3
- </p>
4
- <p align="center"><strong>AI-powered application security platform for developers.</strong></p>
5
- <p align="center"><a href="https://shipsafecli.com">shipsafecli.com</a></p>
6
-
7
- <p align="center">
8
- <a href="https://www.npmjs.com/package/ship-safe"><img src="https://badge.fury.io/js/ship-safe.svg" alt="npm version" /></a>
9
- <a href="https://www.npmjs.com/package/ship-safe"><img src="https://img.shields.io/npm/dm/ship-safe.svg" alt="npm downloads" /></a>
10
- <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>
11
- <a href="https://nodejs.org"><img src="https://img.shields.io/node/v/ship-safe" alt="Node.js version" /></a>
12
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
13
- <a href="https://github.com/asamassekou10/ship-safe/stargazers"><img src="https://img.shields.io/github/stars/asamassekou10/ship-safe?style=social" alt="GitHub stars" /></a>
14
- </p>
15
-
16
- ---
17
-
18
- 18 security agents. 80+ attack classes. One command.
19
-
20
- **Ship Safe v6.1.1** is an AI-powered security platform that runs 18 specialized agents in parallel against your codebase, scanning for secrets, injection vulnerabilities, auth bypass, SSRF, supply chain attacks, Supabase RLS misconfigs, Docker/Terraform/Kubernetes misconfigs, CI/CD pipeline poisoning, LLM/agentic AI security, MCP server misuse, RAG poisoning, PII compliance, vibe coding patterns, exception handling, AI agent config security, and more. OWASP 2025 scoring with EPSS exploit probability. LLM-powered deep analysis verifies exploitability of critical findings. Secrets verification probes provider APIs to check if leaked keys are still active. Compliance mapping to SOC 2, ISO 27001, and NIST AI RMF. Built-in threat intelligence feed with offline-first IOC matching. CI integration with GitHub PR comments, threshold gating, and SARIF output.
21
-
22
- **v6.1.1 highlights:** Supply chain hardening against the [March 2026 Trivy/CanisterWorm attack chain](https://shipsafecli.com/blog/supply-chain-attacks-2026-how-we-hardened-ship-safe). All GitHub Actions SHA-pinned, `postinstall` scripts disabled in CI, OIDC trusted publishing with provenance, CODEOWNERS on critical paths.
23
-
24
- [Documentation](https://shipsafecli.com/docs) | [Blog](https://shipsafecli.com/blog) | [Pricing](https://shipsafecli.com/pricing)
25
-
26
- ---
27
-
28
- ## Quick Start
29
-
30
- ```bash
31
- # Full security audit — secrets + 18 agents + deps + remediation plan
32
- npx ship-safe audit .
33
-
34
- # LLM-powered deep analysis (Anthropic, OpenAI, Google, Ollama)
35
- npx ship-safe audit . --deep
36
-
37
- # Red team scan only (18 agents, 80+ attack classes)
38
- npx ship-safe red-team .
39
-
40
- # Scan only changed files (fast pre-commit & PR scanning)
41
- npx ship-safe diff
42
- npx ship-safe diff --staged
43
-
44
- # Fun emoji security grade with shareable badge
45
- npx ship-safe vibe-check .
46
-
47
- # Compare your score against industry averages
48
- npx ship-safe benchmark .
49
-
50
- # Quick secret scan
51
- npx ship-safe scan .
52
-
53
- # Security health score (0-100)
54
- npx ship-safe score .
55
-
56
- # CI/CD pipeline mode — compact output, exit codes, PR comments
57
- npx ship-safe ci .
58
- npx ship-safe ci . --github-pr
59
-
60
- # Accept current findings, only report regressions
61
- npx ship-safe baseline .
62
- npx ship-safe audit . --baseline
63
-
64
- # Check if leaked secrets are still active
65
- npx ship-safe audit . --verify
66
-
67
- # Environment diagnostics
68
- npx ship-safe doctor
69
- ```
70
-
71
- ![ship-safe terminal demo](.github/assets/ship%20safe%20terminal.jpg)
72
-
73
- ---
74
-
75
- ## The `audit` Command
76
-
77
- One command that runs everything and generates a full report:
78
-
79
- ```bash
80
- npx ship-safe audit .
81
- ```
82
-
83
- ```
84
- ════════════════════════════════════════════════════════════
85
- Ship Safe v6.0 — Full Security Audit
86
- ════════════════════════════════════════════════════════════
87
-
88
- [Phase 1/4] Scanning for secrets... ✔ 49 found
89
- [Phase 2/4] Running 18 security agents... ✔ 103 findings
90
- [Phase 3/4] Auditing dependencies... ✔ 44 CVEs
91
- [Phase 4/4] Computing security score... ✔ 25/100 F
92
-
93
- Remediation Plan
94
- ════════════════════════════════════════════════════════
95
-
96
- 🔴 CRITICAL fix immediately
97
- ────────────────────────────────────────────────────────
98
- 1. [SECRETS] Rotate Stripe Live Secret Key
99
- .env:67 → Move to environment variable or secrets manager
100
-
101
- 2. [INJECTION] Unsafe pickle.loads()
102
- backend/ai_processor.py:64 → Use JSON for untrusted data
103
-
104
- 🟠 HIGH fix before deploy
105
- ────────────────────────────────────────────────────────
106
- 3. [XSS] dangerouslySetInnerHTML without sanitization
107
- frontend/src/utils/blogContentRenderer.jsx:50Add DOMPurify
108
-
109
- ... 149 more items in the full report
110
-
111
- 📊 Full report: ship-safe-report.html
112
- ```
113
-
114
- **What it runs:**
115
- 1. **Secret scan** — 50+ patterns with entropy scoring (API keys, passwords, tokens)
116
- 2. **18 security agents** — run in parallel with per-agent timeouts and framework-aware filtering (injection, auth, SSRF, supply chain, config, Supabase RLS, LLM, MCP, agentic AI, RAG, PII, vibe coding, exception handling, agent config, mobile, git history, CI/CD, API)
117
- 3. **Dependency audit** — npm/pip/bundler CVE scanning with EPSS exploit probability scores
118
- 4. **Secrets verification** — probes provider APIs (GitHub, Stripe, OpenAI, etc.) to check if leaked keys are still active
119
- 5. **Deep analysis** — LLM-powered taint analysis verifies exploitability of critical/high findings (optional)
120
- 6. **Score computation** — OWASP 2025 weighted scoring across 8 categories (0-100, A-F)
121
- 7. **Context-aware confidence tuning** — downgrades findings in test files, docs, and comments
122
- 8. **Compliance mapping** — maps findings to SOC 2 Type II, ISO 27001:2022, and NIST AI Risk Management Framework controls
123
- 9. **Remediation plan** — prioritized fix list grouped by severity
124
- 10. **Interactive HTML report** — standalone dark-themed report with severity filtering, search, collapsible findings, compliance summary, and click-to-copy ignore annotations
125
-
126
- **Flags:**
127
- - `--json`structured JSON output (clean for piping)
128
- - `--sarif`SARIF format for GitHub Code Scanning
129
- - `--csv`CSV export for spreadsheets
130
- - `--md` — Markdown report
131
- - `--html [file]` — custom HTML report path (default: `ship-safe-report.html`)
132
- - `--compare` — show per-category score delta vs. last scan
133
- - `--timeout <ms>` per-agent timeout (default: 30s)
134
- - `--no-deps` — skip dependency audit
135
- - `--no-ai` — skip AI classification
136
- - `--no-cache` — force full rescan (ignore cached results)
137
- - `--baseline` — only show findings not in the baseline
138
- - `--pdf [file]`generate PDF report (requires Chrome/Chromium)
139
- - `--deep` — LLM-powered taint analysis for critical/high findings
140
- - `--local` — use local Ollama model for deep analysis
141
- - `--model <model>` LLM model to use for deep/AI analysis
142
- - `--budget <cents>` max spend in cents for deep analysis (default: 50)
143
- - `--verify` — check if leaked secrets are still active (probes provider APIs)
144
-
145
- ---
146
-
147
- ## 18 Security Agents
148
-
149
- | Agent | Category | What It Detects |
150
- |-------|----------|-----------------|
151
- | **InjectionTester** | Code Vulns | SQL/NoSQL injection, command injection, code injection (eval), XSS, path traversal, XXE, ReDoS, prototype pollution, Python f-string SQL injection, Python subprocess shell injection |
152
- | **AuthBypassAgent** | Auth | JWT vulnerabilities (alg:none, weak secrets), cookie security, CSRF, OAuth misconfig, BOLA/IDOR, weak crypto, timing attacks, TLS bypass, Django `DEBUG = True`, Flask hardcoded secret keys |
153
- | **SSRFProber** | SSRF | User input in fetch/axios, cloud metadata endpoints, internal IPs, redirect following |
154
- | **SupplyChainAudit** | Supply Chain | Typosquatting (Levenshtein distance), git/URL dependencies, wildcard versions, suspicious install scripts, dependency confusion, lockfile integrity |
155
- | **ConfigAuditor** | Config | Dockerfile (running as root, :latest tags), Terraform (public S3/RDS, open SG, CloudFront HTTP, Lambda admin, S3 no versioning), Kubernetes (privileged containers, `:latest` tags, missing NetworkPolicy), CORS, CSP, Firebase, Nginx |
156
- | **SupabaseRLSAgent** | Auth | Supabase Row Level Security — `service_role` key in client code, `CREATE TABLE` without RLS, anon key inserts, unprotected storage operations |
157
- | **LLMRedTeam** | AI/LLM | OWASP LLM Top 10 — prompt injection, excessive agency, system prompt leakage, unbounded consumption, RAG poisoning |
158
- | **MCPSecurityAgent** | AI/LLM | MCP server security unvalidated tool inputs, missing auth, excessive permissions, tool poisoning, typosquatting detection, over-permissioned tools, shadow config discovery |
159
- | **AgenticSecurityAgent** | AI/LLM | OWASP Agentic AI Top 10 agent hijacking, privilege escalation, unsafe code execution, memory poisoning |
160
- | **RAGSecurityAgent** | AI/LLM | RAG pipeline security unvalidated embeddings, context injection, document poisoning, vector DB access control |
161
- | **PIIComplianceAgent** | Compliance | PII detection — SSNs, credit cards, emails, phone numbers in source code, logs, and configs |
162
- | **VibeCodingAgent** | Code Vulns | AI-generated code patterns no input validation, empty catch blocks, hardcoded secrets, disabled security features, TODO-auth patterns |
163
- | **ExceptionHandlerAgent** | Code Vulns | OWASP A10:2025empty catch blocks, unhandled promise rejections, missing React error boundaries, leaked stack traces, generic catch-all without rethrow |
164
- | **AgentConfigScanner** | AI/LLM | AI agent config security — prompt injection in .cursorrules/CLAUDE.md/AGENTS.md/.windsurfrules, malicious Claude Code hooks (CVE-2026), OpenClaw public binding & malicious skills, encoded/obfuscated payloads, data exfiltration instructions, agent memory poisoning |
165
- | **MobileScanner** | Mobile | OWASP Mobile Top 10 2024 insecure storage, WebView JS injection, HTTP endpoints, excessive permissions, debug mode |
166
- | **GitHistoryScanner** | Secrets | Leaked secrets in git commit history (checks if still active in working tree) |
167
- | **CICDScanner** | CI/CD | OWASP CI/CD Top 10 pipeline poisoning, unpinned actions, secret logging, self-hosted runners, script injection |
168
- | **APIFuzzer** | API | Routes without auth, missing input validation, mass assignment, unrestricted file upload, GraphQL introspection, debug endpoints, missing rate limiting, OpenAPI spec security issues |
169
- | **ReconAgent** | Recon | Attack surface discoveryframeworks, languages, auth patterns, databases, cloud providers, IaC, CI/CD pipelines |
170
-
171
- **Post-processors:** ScoringEngine (8-category weighted scoring), VerifierAgent (secrets liveness verification), DeepAnalyzer (LLM-powered taint analysis)
172
-
173
- ---
174
-
175
- ## All Commands
176
-
177
- ### Core Audit Commands
178
-
179
- ```bash
180
- # Full audit with remediation plan + HTML report
181
- npx ship-safe audit .
182
-
183
- # Red team: 18 agents, 80+ attack classes
184
- npx ship-safe red-team .
185
- npx ship-safe red-team . --agents injection,auth # Run specific agents
186
- npx ship-safe red-team . --html report.html # HTML report
187
- npx ship-safe red-team . --json # JSON output
188
-
189
- # Secret scanner (pattern matching + entropy)
190
- npx ship-safe scan .
191
- npx ship-safe scan . --json # JSON for CI
192
- npx ship-safe scan . --sarif # SARIF for GitHub
193
-
194
- # Security health score (0-100, A-F)
195
- npx ship-safe score .
196
-
197
- # Dependency CVE audit
198
- npx ship-safe deps .
199
- npx ship-safe deps . --fix # Auto-fix vulnerabilities
200
- ```
201
-
202
- ### AI-Powered Commands
203
-
204
- ```bash
205
- # AI audit: scan + classify with Claude + auto-fix secrets
206
- npx ship-safe agent .
207
-
208
- # Auto-fix hardcoded secrets: rewrite code + write .env
209
- npx ship-safe remediate .
210
- npx ship-safe remediate . --all # Also fix agent findings (TLS, debug, XSS, etc.)
211
-
212
- # Revoke exposed keys opens provider dashboards
213
- npx ship-safe rotate .
214
- ```
215
-
216
- ### Baseline Management
217
-
218
- ```bash
219
- # Accept current findings as baseline
220
- npx ship-safe baseline .
221
-
222
- # Audit showing only new findings since baseline
223
- npx ship-safe audit . --baseline
224
-
225
- # Show what changed since baseline
226
- npx ship-safe baseline --diff
227
-
228
- # Remove baseline
229
- npx ship-safe baseline --clear
230
- ```
231
-
232
- ### Diff Scanning
233
-
234
- ```bash
235
- # Scan only changed files (fast pre-commit & PR scanning)
236
- npx ship-safe diff # All uncommitted changes
237
- npx ship-safe diff --staged # Only staged changes
238
- npx ship-safe diff HEAD~3 # Changes in last 3 commits
239
- npx ship-safe diff --json # JSON output
240
- ```
241
-
242
- ### Vibe Check & Benchmark
243
-
244
- ```bash
245
- # Fun emoji security grade
246
- npx ship-safe vibe-check .
247
- npx ship-safe vibe-check . --badge # Generate shields.io README badge
248
-
249
- # Compare your score against industry averages (OWASP, Synopsys, Snyk)
250
- npx ship-safe benchmark .
251
- npx ship-safe benchmark . --json # JSON output
252
- ```
253
-
254
- ### CI/CD Pipeline
255
-
256
- ```bash
257
- # CI mode — compact output, exit codes, threshold gating
258
- npx ship-safe ci .
259
- npx ship-safe ci . --threshold 80 # Custom passing score
260
- npx ship-safe ci . --fail-on critical # Fail on severity
261
- npx ship-safe ci . --sarif out.sarif # SARIF for GitHub
262
- npx ship-safe ci . --github-pr # Post results as PR comment
263
- ```
264
-
265
- ### Deep Analysis & Verification
266
-
267
- ```bash
268
- # LLM-powered deep analysis (Anthropic/OpenAI/Google/Ollama)
269
- npx ship-safe audit . --deep
270
- npx ship-safe audit . --deep --local # Use local Ollama
271
- npx ship-safe audit . --deep --budget 50 # Cap spend at 50 cents
272
-
273
- # Check if leaked secrets are still active
274
- npx ship-safe audit . --verify
275
- ```
276
-
277
- ### Diagnostics
278
-
279
- ```bash
280
- # Environment check Node.js, git, npm, API keys, cache, version
281
- npx ship-safe doctor
282
- ```
283
-
284
- ### OpenClaw Security
285
-
286
- ```bash
287
- # Focused OpenClaw security scan
288
- npx ship-safe openclaw .
289
-
290
- # Auto-harden OpenClaw configs (0.0.0.0→127.0.0.1, add auth, ws→wss)
291
- npx ship-safe openclaw . --fix
292
-
293
- # Red team: simulate ClawJacked, prompt injection, data exfil attacks
294
- npx ship-safe openclaw . --red-team
295
-
296
- # CI preflight — exit non-zero on critical findings
297
- npx ship-safe openclaw . --preflight
298
-
299
- # Scan a skill before installing it
300
- npx ship-safe scan-skill https://clawhub.io/skills/some-skill
301
- npx ship-safe scan-skill ./local-skill.json
302
- npx ship-safe scan-skill --all # Scan all skills from openclaw.json
303
-
304
- # Generate hardened OpenClaw config
305
- npx ship-safe init --openclaw
306
-
307
- # Generate Agent Bill of Materials (CycloneDX 1.5)
308
- npx ship-safe abom .
309
- ```
310
-
311
- ### Threat Intelligence
312
-
313
- ```bash
314
- # Update threat intel feed (ClawHavoc IOCs, malicious skills, config signatures)
315
- npx ship-safe update-intel
316
-
317
- # Ships with offline-first seed data — no internet required for scanning
318
- ```
319
-
320
- ### Defensive Hooks
321
-
322
- ```bash
323
- # Install Claude Code defensive hooks (blocks curl|bash, exfil domains, rm -rf /)
324
- npx ship-safe guard --generate-hooks
325
-
326
- # Watch agent config files for drift (.cursorrules, CLAUDE.md, openclaw.json)
327
- npx ship-safe watch . --configs
328
- ```
329
-
330
- ### Infrastructure Commands
331
-
332
- ```bash
333
- # Continuous monitoring (watch files for changes)
334
- npx ship-safe watch .
335
-
336
- # Generate CycloneDX SBOM
337
- npx ship-safe sbom .
338
-
339
- # Policy-as-code (enforce minimum score, fail on severity)
340
- npx ship-safe policy init
341
-
342
- # Block git push if secrets found
343
- npx ship-safe guard
344
-
345
- # Initialize security configs (.gitignore, headers)
346
- npx ship-safe init
347
-
348
- # Launch-day security checklist
349
- npx ship-safe checklist
350
-
351
- # MCP server for AI editors (Claude Desktop, Cursor, etc.)
352
- npx ship-safe mcp
353
- ```
354
-
355
- ---
356
-
357
- ## Claude Code Plugin
358
-
359
- Use Ship Safe directly inside Claude Code — no CLI needed:
360
-
361
- ```bash
362
- claude plugin add github:asamassekou10/ship-safe
363
- ```
364
-
365
- | Command | Description |
366
- |---------|-------------|
367
- | `/ship-safe` | Full security audit 18 agents, remediation plan, auto-fix |
368
- | `/ship-safe-scan` | Quick scan for leaked secrets |
369
- | `/ship-safe-score` | Security health score (0-100) |
370
- | `/ship-safe-deep` | LLM-powered deep taint analysis |
371
- | `/ship-safe-ci` | CI/CD pipeline setup guide |
372
-
373
- Claude interprets the results, explains findings in plain language, and can fix issues directly in your codebase.
374
-
375
- ---
376
-
377
- ## Incremental Scanning
378
-
379
- Ship Safe caches file hashes and findings in `.ship-safe/context.json`. On subsequent runs, only changed files are re-scanned — unchanged files reuse cached results.
380
-
381
- ```
382
- [Phase 1/4] Secrets: 41 found (0 changed, 313 cached)
383
- ```
384
-
385
- - **~40% faster** on repeated scans
386
- - **Auto-invalidation** — cache expires after 24 hours or when ship-safe updates
387
- - **`--no-cache`** — force a full rescan anytime
388
-
389
- The cache is stored in `.ship-safe/` which is automatically excluded from scans.
390
-
391
- ### LLM Response Caching
392
-
393
- When using AI classification (`--no-ai` to disable), results are cached in `.ship-safe/llm-cache.json` with a 7-day TTL. Repeated scans reuse cached classifications — reducing API costs significantly.
394
-
395
- ---
396
-
397
- ## Smart `.gitignore` Handling
398
-
399
- Ship Safe respects your `.gitignore` for build output, caches, and vendor directories — but **always scans security-sensitive files** even if gitignored:
400
-
401
- | Skipped (gitignore respected) | Always scanned (gitignore overridden) |
402
- |-------------------------------|---------------------------------------|
403
- | `node_modules/`, `dist/`, `build/` | `.env`, `.env.local`, `.env.production` |
404
- | `*.log`, `*.pkl`, vendor dirs | `*.pem`, `*.key`, `*.p12` |
405
- | Cache directories, IDE files | `credentials.json`, `*.secret` |
406
-
407
- Why? Files like `.env` are gitignored *because* they contain secrets — which is exactly what a security scanner should catch.
408
-
409
- ---
410
-
411
- ## Multi-LLM Support
412
-
413
- Ship Safe supports multiple AI providers for classification:
414
-
415
- | Provider | Env Variable | Model |
416
- |----------|-------------|-------|
417
- | **Anthropic** | `ANTHROPIC_API_KEY` | claude-haiku-4-5 |
418
- | **OpenAI** | `OPENAI_API_KEY` | gpt-4o-mini |
419
- | **Google** | `GOOGLE_AI_API_KEY` | gemini-2.0-flash |
420
- | **Ollama** | `OLLAMA_HOST` | Local models |
421
-
422
- Auto-detected from environment variables. No API key required for scanning — AI is optional.
423
-
424
- ---
425
-
426
- ## Scoring System
427
-
428
- Starts at 100. Each finding deducts points by severity and category, weighted by confidence level (high: 100%, medium: 60%, low: 30%) to reduce noise from heuristic patterns.
429
-
430
- **8 Categories** (with weight caps):
431
-
432
- | Category | Weight | Critical | High | Medium | Cap |
433
- |----------|--------|----------|------|--------|-----|
434
- | Secrets | 15% | -25 | -15 | -5 | -15 |
435
- | Code Vulnerabilities | 15% | -20 | -10 | -3 | -15 |
436
- | Dependencies | 13% | -20 | -10 | -5 | -13 |
437
- | Auth & Access Control | 15% | -20 | -10 | -3 | -15 |
438
- | Configuration | 8% | -15 | -8 | -3 | -8 |
439
- | Supply Chain | 12% | -15 | -8 | -3 | -12 |
440
- | API Security | 10% | -15 | -8 | -3 | -10 |
441
- | AI/LLM Security | 12% | -15 | -8 | -3 | -12 |
442
-
443
- *Weights aligned with OWASP Top 10 2025 risk rankings.*
444
-
445
- **Grades:** A (90-100), B (75-89), C (60-74), D (40-59), F (0-39)
446
-
447
- **Exit codes:** `0` for A/B (>= 75), `1` for C/D/F — use in CI to fail builds.
448
-
449
- ---
450
-
451
- ## Policy-as-Code
452
-
453
- Create `.ship-safe.policy.json` to enforce team-wide security standards:
454
-
455
- ```bash
456
- npx ship-safe policy init
457
- ```
458
-
459
- ```json
460
- {
461
- "minimumScore": 70,
462
- "failOn": "critical",
463
- "requiredScans": ["secrets", "injection", "deps", "auth"],
464
- "ignoreRules": [],
465
- "customSeverityOverrides": {},
466
- "maxAge": { "criticalCVE": "7d", "highCVE": "30d", "mediumCVE": "90d" }
467
- }
468
- ```
469
-
470
- ---
471
-
472
- ## CI/CD Integration
473
-
474
- The dedicated `ci` command is optimized for pipelines — compact output, exit codes, threshold-based gating:
475
-
476
- ```bash
477
- # Basic CI — fail if score < 75
478
- npx ship-safe ci .
479
-
480
- # Strict — fail on any critical finding
481
- npx ship-safe ci . --fail-on critical
482
-
483
- # Custom threshold + SARIF for GitHub Security tab
484
- npx ship-safe ci . --threshold 80 --sarif results.sarif
485
-
486
- # Only check new findings (not in baseline)
487
- npx ship-safe ci . --baseline
488
- ```
489
-
490
- **GitHub Actions example:**
491
-
492
- ```yaml
493
- # .github/workflows/security.yml
494
- name: Security Audit
495
-
496
- on: [push, pull_request]
497
-
498
- jobs:
499
- security:
500
- runs-on: ubuntu-latest
501
- steps:
502
- - uses: actions/checkout@v4
503
-
504
- - name: Security gate
505
- run: npx ship-safe ci . --threshold 75 --sarif results.sarif --github-pr
506
-
507
- - uses: github/codeql-action/upload-sarif@v3
508
- if: always()
509
- with:
510
- sarif_file: results.sarif
511
- ```
512
-
513
- **Export formats:** `--json`, `--sarif`, `--csv`, `--md`, `--html`, `--pdf`
514
-
515
- ---
516
-
517
- ## Suppress False Positives
518
-
519
- **Inline:** Add `# ship-safe-ignore` comment on a line:
520
- ```python
521
- password = get_password() # ship-safe-ignore
522
- ```
523
-
524
- **File-level:** Create `.ship-safeignore` (gitignore syntax):
525
- ```gitignore
526
- # Exclude test fixtures
527
- tests/fixtures/
528
- *.test.js
529
-
530
- # Exclude documentation with code examples
531
- docs/
532
- ```
533
-
534
- ---
535
-
536
- ## OWASP Coverage
537
-
538
- | Standard | Coverage |
539
- |----------|----------|
540
- | **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 |
541
- | **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 |
542
- | **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 |
543
- | **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 |
544
- | **OWASP Agentic AI Top 10** | ASI01-ASI10: Agent Hijacking, Tool Misuse, Privilege Escalation, Unsafe Code Execution, Memory Poisoning, Identity Spoofing, Excessive Autonomy, Logging Gaps, Supply Chain Attacks, Cascading Hallucination |
545
-
546
- ---
547
-
548
- ## What's Inside
549
-
550
- ### [`/configs`](./configs)
551
- Drop-in security configs for Next.js, Supabase, and Firebase.
552
-
553
- ### [`/snippets`](./snippets)
554
- Copy-paste security patterns: rate limiting, JWT, CORS, input validation.
555
-
556
- ### [`/ai-defense`](./ai-defense)
557
- LLM security: prompt injection detection, cost protection, system prompt hardening.
558
-
559
- ### [`/checklists`](./checklists)
560
- Manual security audits: launch-day checklist, framework-specific guides.
561
-
562
- ---
563
-
564
- ## Add a Security Badge to Your README
565
-
566
- Show the world your project is secure. After running `npx ship-safe audit .` or `npx ship-safe vibe-check . --badge`, add one of these to your README:
567
-
568
- ```markdown
569
- <!-- Replace GRADE and COLOR with your results -->
570
- [![Ship Safe](https://img.shields.io/badge/Ship_Safe-A+-22c55e)](https://shipsafecli.com)
571
- ```
572
-
573
- | Grade | Badge |
574
- |-------|-------|
575
- | A+ | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-A+-22c55e)](https://shipsafecli.com)` |
576
- | A | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-A-22c55e)](https://shipsafecli.com)` |
577
- | B | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-B-06b6d4)](https://shipsafecli.com)` |
578
- | C | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-C-eab308)](https://shipsafecli.com)` |
579
- | D | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-D-ef4444)](https://shipsafecli.com)` |
580
- | F | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-F-dc2626)](https://shipsafecli.com)` |
581
-
582
- ---
583
-
584
- ## Supply Chain Hardening
585
-
586
- Ship Safe practices what it preaches. Our own supply chain is hardened against the [2026 Trivy/CanisterWorm attack chain](https://shipsafecli.com/blog/supply-chain-attacks-2026-how-we-hardened-ship-safe):
587
-
588
- | Defense | What It Blocks |
589
- |---------|---------------|
590
- | All GitHub Actions pinned to full commit SHAs | Tag repointing (Trivy-style) |
591
- | `permissions: contents: read` in CI | Excessive token scope |
592
- | `npm ci --ignore-scripts` in all pipelines | CanisterWorm postinstall propagation |
593
- | OIDC trusted publishing with provenance | Stolen npm token publishing |
594
- | CODEOWNERS on `action.yml`, `.github/`, `package.json` | Unauthorized changes to critical paths |
595
- | Strict `files` allowlist in package.json | Accidental inclusion of secrets/configs |
596
- | Self-scanning with ship-safe in CI | Malicious code injection |
597
- | 5 direct dependencies | Minimal transitive attack surface |
598
-
599
- Verify provenance on any Ship Safe release:
600
-
601
- ```bash
602
- npm audit signatures
603
- ```
604
-
605
- ---
606
-
607
- ## Contributing
608
-
609
- 1. Fork the repo
610
- 2. Add your security pattern, agent, or config
611
- 3. Include comments explaining *why* it matters
612
- 4. Open a PR
613
-
614
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
615
-
616
- ---
617
-
618
- ## Security Standards Reference
619
-
620
- - [OWASP Top 10 Web 2025](https://owasp.org/Top10/)
621
- - [OWASP Top 10 Mobile 2024](https://owasp.org/www-project-mobile-top-10/)
622
- - [OWASP LLM Top 10 2025](https://genai.owasp.org/llm-top-10/)
623
- - [OWASP API Security Top 10 2023](https://owasp.org/API-Security/)
624
- - [OWASP CI/CD Top 10](https://owasp.org/www-project-top-10-ci-cd-security-risks/)
625
- - [OWASP Agentic AI Top 10](https://owasp.org/www-project-agentic-ai-top-10/)
626
-
627
- ---
628
-
629
- ## License
630
-
631
- MIT - Use it, share it, secure your stuff.
632
-
633
- ---
634
-
635
- ## Star History
636
-
637
- [![Star History Chart](https://api.star-history.com/svg?repos=asamassekou10/ship-safe&type=Date)](https://star-history.com/#asamassekou10/ship-safe&Date)
638
-
639
- ---
640
-
641
- **Ship fast. Ship safe.** — [shipsafecli.com](https://shipsafecli.com)
1
+ <p align="center">
2
+ <img src=".github/assets/logo%20ship%20safe.png" alt="Ship Safe Logo" width="180" />
3
+ </p>
4
+ <p align="center"><strong>AI-powered application security platform for developers.</strong></p>
5
+ <p align="center"><a href="https://shipsafecli.com">shipsafecli.com</a></p>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/ship-safe"><img src="https://badge.fury.io/js/ship-safe.svg" alt="npm version" /></a>
9
+ <a href="https://www.npmjs.com/package/ship-safe"><img src="https://img.shields.io/npm/dm/ship-safe.svg" alt="npm downloads" /></a>
10
+ <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>
11
+ <a href="https://nodejs.org"><img src="https://img.shields.io/node/v/ship-safe" alt="Node.js version" /></a>
12
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
13
+ <a href="https://github.com/asamassekou10/ship-safe/stargazers"><img src="https://img.shields.io/github/stars/asamassekou10/ship-safe?style=social" alt="GitHub stars" /></a>
14
+ </p>
15
+
16
+ ---
17
+
18
+ 18 security agents. 80+ attack classes. One command.
19
+
20
+ **Ship Safe v6.2.0** is an AI-powered security platform that runs 18 specialized agents in parallel against your codebase, scanning for secrets, injection vulnerabilities, auth bypass, SSRF, supply chain attacks, Supabase RLS misconfigs, Docker/Terraform/Kubernetes misconfigs, CI/CD pipeline poisoning, LLM/agentic AI security, MCP server misuse, RAG poisoning, PII compliance, vibe coding patterns, exception handling, AI agent config security, and more. OWASP 2025 scoring with EPSS exploit probability. LLM-powered deep analysis verifies exploitability of critical findings. Secrets verification probes provider APIs to check if leaked keys are still active. Compliance mapping to SOC 2, ISO 27001, and NIST AI RMF. Built-in threat intelligence feed with offline-first IOC matching. CI integration with GitHub PR comments, threshold gating, and SARIF output.
21
+
22
+ **v6.2.0 highlights:** Real-time Claude Code hooks (`npx ship-safe hooks install`) block secrets before they land on disk. Universal LLM support use Groq, Together AI, Mistral, DeepSeek, xAI, Perplexity, LM Studio, or any OpenAI-compatible endpoint for deep analysis. Supply chain IOC matching for known-compromised packages and CanisterWorm-style ICP blockchain C2 indicators.
23
+
24
+ [Documentation](https://shipsafecli.com/docs) | [Blog](https://shipsafecli.com/blog) | [Pricing](https://shipsafecli.com/pricing)
25
+
26
+ ---
27
+
28
+ ## Quick Start
29
+
30
+ ```bash
31
+ # Full security audit — secrets + 18 agents + deps + remediation plan
32
+ npx ship-safe audit .
33
+
34
+ # LLM-powered deep analysis (Anthropic, OpenAI, Google, Ollama)
35
+ npx ship-safe audit . --deep
36
+
37
+ # Red team scan only (18 agents, 80+ attack classes)
38
+ npx ship-safe red-team .
39
+
40
+ # Scan only changed files (fast pre-commit & PR scanning)
41
+ npx ship-safe diff
42
+ npx ship-safe diff --staged
43
+
44
+ # Fun emoji security grade with shareable badge
45
+ npx ship-safe vibe-check .
46
+
47
+ # Compare your score against industry averages
48
+ npx ship-safe benchmark .
49
+
50
+ # Quick secret scan
51
+ npx ship-safe scan .
52
+
53
+ # Security health score (0-100)
54
+ npx ship-safe score .
55
+
56
+ # CI/CD pipeline mode — compact output, exit codes, PR comments
57
+ npx ship-safe ci .
58
+ npx ship-safe ci . --github-pr
59
+
60
+ # Accept current findings, only report regressions
61
+ npx ship-safe baseline .
62
+ npx ship-safe audit . --baseline
63
+
64
+ # Check if leaked secrets are still active
65
+ npx ship-safe audit . --verify
66
+
67
+ # Environment diagnostics
68
+ npx ship-safe doctor
69
+
70
+ # Install Claude Code hooks — real-time secret blocking + advisory scan
71
+ npx ship-safe hooks install
72
+ npx ship-safe hooks status
73
+ npx ship-safe hooks remove
74
+ ```
75
+
76
+ ![ship-safe terminal demo](.github/assets/ship%20safe%20terminal.jpg)
77
+
78
+ ---
79
+
80
+ ## The `audit` Command
81
+
82
+ One command that runs everything and generates a full report:
83
+
84
+ ```bash
85
+ npx ship-safe audit .
86
+ ```
87
+
88
+ ```
89
+ ════════════════════════════════════════════════════════════
90
+ Ship Safe v6.0 Full Security Audit
91
+ ════════════════════════════════════════════════════════════
92
+
93
+ [Phase 1/4] Scanning for secrets... ✔ 49 found
94
+ [Phase 2/4] Running 18 security agents... ✔ 103 findings
95
+ [Phase 3/4] Auditing dependencies... ✔ 44 CVEs
96
+ [Phase 4/4] Computing security score... ✔ 25/100 F
97
+
98
+ Remediation Plan
99
+ ════════════════════════════════════════════════════════
100
+
101
+ 🔴 CRITICAL fix immediately
102
+ ────────────────────────────────────────────────────────
103
+ 1. [SECRETS] Rotate Stripe Live Secret Key
104
+ .env:67 Move to environment variable or secrets manager
105
+
106
+ 2. [INJECTION] Unsafe pickle.loads()
107
+ backend/ai_processor.py:64Use JSON for untrusted data
108
+
109
+ 🟠 HIGH fix before deploy
110
+ ────────────────────────────────────────────────────────
111
+ 3. [XSS] dangerouslySetInnerHTML without sanitization
112
+ frontend/src/utils/blogContentRenderer.jsx:50 → Add DOMPurify
113
+
114
+ ... 149 more items in the full report
115
+
116
+ 📊 Full report: ship-safe-report.html
117
+ ```
118
+
119
+ **What it runs:**
120
+ 1. **Secret scan** — 50+ patterns with entropy scoring (API keys, passwords, tokens)
121
+ 2. **18 security agents** — run in parallel with per-agent timeouts and framework-aware filtering (injection, auth, SSRF, supply chain, config, Supabase RLS, LLM, MCP, agentic AI, RAG, PII, vibe coding, exception handling, agent config, mobile, git history, CI/CD, API)
122
+ 3. **Dependency audit** — npm/pip/bundler CVE scanning with EPSS exploit probability scores
123
+ 4. **Secrets verification** — probes provider APIs (GitHub, Stripe, OpenAI, etc.) to check if leaked keys are still active
124
+ 5. **Deep analysis** — LLM-powered taint analysis verifies exploitability of critical/high findings (optional)
125
+ 6. **Score computation** — OWASP 2025 weighted scoring across 8 categories (0-100, A-F)
126
+ 7. **Context-aware confidence tuning** — downgrades findings in test files, docs, and comments
127
+ 8. **Compliance mapping** maps findings to SOC 2 Type II, ISO 27001:2022, and NIST AI Risk Management Framework controls
128
+ 9. **Remediation plan** prioritized fix list grouped by severity
129
+ 10. **Interactive HTML report** standalone dark-themed report with severity filtering, search, collapsible findings, compliance summary, and click-to-copy ignore annotations
130
+
131
+ **Flags:**
132
+ - `--json` — structured JSON output (clean for piping)
133
+ - `--sarif`SARIF format for GitHub Code Scanning
134
+ - `--csv` — CSV export for spreadsheets
135
+ - `--md` — Markdown report
136
+ - `--html [file]` — custom HTML report path (default: `ship-safe-report.html`)
137
+ - `--compare` — show per-category score delta vs. last scan
138
+ - `--timeout <ms>`per-agent timeout (default: 30s)
139
+ - `--no-deps` — skip dependency audit
140
+ - `--no-ai` — skip AI classification
141
+ - `--no-cache`force full rescan (ignore cached results)
142
+ - `--baseline`only show findings not in the baseline
143
+ - `--pdf [file]` — generate PDF report (requires Chrome/Chromium)
144
+ - `--deep` — LLM-powered taint analysis for critical/high findings
145
+ - `--local` — use local Ollama model for deep analysis
146
+ - `--model <model>` — LLM model to use for deep/AI analysis
147
+ - `--provider <name>` — LLM provider: groq, together, mistral, deepseek, xai, perplexity, lmstudio
148
+ - `--base-url <url>` — custom OpenAI-compatible base URL (e.g. LM Studio, vLLM)
149
+ - `--budget <cents>` max spend in cents for deep analysis (default: 50)
150
+ - `--verify` — check if leaked secrets are still active (probes provider APIs)
151
+
152
+ ---
153
+
154
+ ## 18 Security Agents
155
+
156
+ | Agent | Category | What It Detects |
157
+ |-------|----------|-----------------|
158
+ | **InjectionTester** | Code Vulns | SQL/NoSQL injection, command injection, code injection (eval), XSS, path traversal, XXE, ReDoS, prototype pollution, Python f-string SQL injection, Python subprocess shell injection |
159
+ | **AuthBypassAgent** | Auth | JWT vulnerabilities (alg:none, weak secrets), cookie security, CSRF, OAuth misconfig, BOLA/IDOR, weak crypto, timing attacks, TLS bypass, Django `DEBUG = True`, Flask hardcoded secret keys |
160
+ | **SSRFProber** | SSRF | User input in fetch/axios, cloud metadata endpoints, internal IPs, redirect following |
161
+ | **SupplyChainAudit** | Supply Chain | Typosquatting (Levenshtein distance), git/URL dependencies, wildcard versions, suspicious install scripts, dependency confusion, lockfile integrity |
162
+ | **ConfigAuditor** | Config | Dockerfile (running as root, :latest tags), Terraform (public S3/RDS, open SG, CloudFront HTTP, Lambda admin, S3 no versioning), Kubernetes (privileged containers, `:latest` tags, missing NetworkPolicy), CORS, CSP, Firebase, Nginx |
163
+ | **SupabaseRLSAgent** | Auth | Supabase Row Level Security `service_role` key in client code, `CREATE TABLE` without RLS, anon key inserts, unprotected storage operations |
164
+ | **LLMRedTeam** | AI/LLM | OWASP LLM Top 10 — prompt injection, excessive agency, system prompt leakage, unbounded consumption, RAG poisoning |
165
+ | **MCPSecurityAgent** | AI/LLM | MCP server security unvalidated tool inputs, missing auth, excessive permissions, tool poisoning, typosquatting detection, over-permissioned tools, shadow config discovery |
166
+ | **AgenticSecurityAgent** | AI/LLM | OWASP Agentic AI Top 10 agent hijacking, privilege escalation, unsafe code execution, memory poisoning |
167
+ | **RAGSecurityAgent** | AI/LLM | RAG pipeline securityunvalidated embeddings, context injection, document poisoning, vector DB access control |
168
+ | **PIIComplianceAgent** | Compliance | PII detection — SSNs, credit cards, emails, phone numbers in source code, logs, and configs |
169
+ | **VibeCodingAgent** | Code Vulns | AI-generated code patternsno input validation, empty catch blocks, hardcoded secrets, disabled security features, TODO-auth patterns |
170
+ | **ExceptionHandlerAgent** | Code Vulns | OWASP A10:2025 — empty catch blocks, unhandled promise rejections, missing React error boundaries, leaked stack traces, generic catch-all without rethrow |
171
+ | **AgentConfigScanner** | AI/LLM | AI agent config security — prompt injection in .cursorrules/CLAUDE.md/AGENTS.md/.windsurfrules, malicious Claude Code hooks (CVE-2026), OpenClaw public binding & malicious skills, encoded/obfuscated payloads, data exfiltration instructions, agent memory poisoning |
172
+ | **MobileScanner** | Mobile | OWASP Mobile Top 10 2024 — insecure storage, WebView JS injection, HTTP endpoints, excessive permissions, debug mode |
173
+ | **GitHistoryScanner** | Secrets | Leaked secrets in git commit history (checks if still active in working tree) |
174
+ | **CICDScanner** | CI/CD | OWASP CI/CD Top 10 — pipeline poisoning, unpinned actions, secret logging, self-hosted runners, script injection |
175
+ | **APIFuzzer** | API | Routes without auth, missing input validation, mass assignment, unrestricted file upload, GraphQL introspection, debug endpoints, missing rate limiting, OpenAPI spec security issues |
176
+ | **ReconAgent** | Recon | Attack surface discovery — frameworks, languages, auth patterns, databases, cloud providers, IaC, CI/CD pipelines |
177
+
178
+ **Post-processors:** ScoringEngine (8-category weighted scoring), VerifierAgent (secrets liveness verification), DeepAnalyzer (LLM-powered taint analysis)
179
+
180
+ ---
181
+
182
+ ## All Commands
183
+
184
+ ### Core Audit Commands
185
+
186
+ ```bash
187
+ # Full audit with remediation plan + HTML report
188
+ npx ship-safe audit .
189
+
190
+ # Red team: 18 agents, 80+ attack classes
191
+ npx ship-safe red-team .
192
+ npx ship-safe red-team . --agents injection,auth # Run specific agents
193
+ npx ship-safe red-team . --html report.html # HTML report
194
+ npx ship-safe red-team . --json # JSON output
195
+
196
+ # Secret scanner (pattern matching + entropy)
197
+ npx ship-safe scan .
198
+ npx ship-safe scan . --json # JSON for CI
199
+ npx ship-safe scan . --sarif # SARIF for GitHub
200
+
201
+ # Security health score (0-100, A-F)
202
+ npx ship-safe score .
203
+
204
+ # Dependency CVE audit
205
+ npx ship-safe deps .
206
+ npx ship-safe deps . --fix # Auto-fix vulnerabilities
207
+ ```
208
+
209
+ ### AI-Powered Commands
210
+
211
+ ```bash
212
+ # AI audit: scan + classify with Claude + auto-fix secrets
213
+ npx ship-safe agent .
214
+
215
+ # Auto-fix hardcoded secrets: rewrite code + write .env
216
+ npx ship-safe remediate .
217
+ npx ship-safe remediate . --all # Also fix agent findings (TLS, debug, XSS, etc.)
218
+
219
+ # Revoke exposed keys opens provider dashboards
220
+ npx ship-safe rotate .
221
+ ```
222
+
223
+ ### Baseline Management
224
+
225
+ ```bash
226
+ # Accept current findings as baseline
227
+ npx ship-safe baseline .
228
+
229
+ # Audit showing only new findings since baseline
230
+ npx ship-safe audit . --baseline
231
+
232
+ # Show what changed since baseline
233
+ npx ship-safe baseline --diff
234
+
235
+ # Remove baseline
236
+ npx ship-safe baseline --clear
237
+ ```
238
+
239
+ ### Diff Scanning
240
+
241
+ ```bash
242
+ # Scan only changed files (fast pre-commit & PR scanning)
243
+ npx ship-safe diff # All uncommitted changes
244
+ npx ship-safe diff --staged # Only staged changes
245
+ npx ship-safe diff HEAD~3 # Changes in last 3 commits
246
+ npx ship-safe diff --json # JSON output
247
+ ```
248
+
249
+ ### Vibe Check & Benchmark
250
+
251
+ ```bash
252
+ # Fun emoji security grade
253
+ npx ship-safe vibe-check .
254
+ npx ship-safe vibe-check . --badge # Generate shields.io README badge
255
+
256
+ # Compare your score against industry averages (OWASP, Synopsys, Snyk)
257
+ npx ship-safe benchmark .
258
+ npx ship-safe benchmark . --json # JSON output
259
+ ```
260
+
261
+ ### CI/CD Pipeline
262
+
263
+ ```bash
264
+ # CI mode — compact output, exit codes, threshold gating
265
+ npx ship-safe ci .
266
+ npx ship-safe ci . --threshold 80 # Custom passing score
267
+ npx ship-safe ci . --fail-on critical # Fail on severity
268
+ npx ship-safe ci . --sarif out.sarif # SARIF for GitHub
269
+ npx ship-safe ci . --github-pr # Post results as PR comment
270
+ ```
271
+
272
+ ### Deep Analysis & Verification
273
+
274
+ ```bash
275
+ # LLM-powered deep analysis (Anthropic/OpenAI/Google/Ollama)
276
+ npx ship-safe audit . --deep
277
+ npx ship-safe audit . --deep --local # Use local Ollama
278
+ npx ship-safe audit . --deep --budget 50 # Cap spend at 50 cents
279
+
280
+ # Use any OpenAI-compatible provider for deep analysis
281
+ npx ship-safe audit . --deep --provider groq
282
+ npx ship-safe audit . --deep --provider together
283
+ npx ship-safe audit . --deep --provider mistral
284
+ npx ship-safe audit . --deep --provider deepseek
285
+ npx ship-safe audit . --deep --provider lmstudio # Local LM Studio
286
+ npx ship-safe audit . --deep --provider xai
287
+ npx ship-safe audit . --deep --provider perplexity
288
+ npx ship-safe audit . --deep --base-url http://localhost:1234/v1 --model my-model # Custom
289
+
290
+ # Check if leaked secrets are still active
291
+ npx ship-safe audit . --verify
292
+ ```
293
+
294
+ ### Diagnostics
295
+
296
+ ```bash
297
+ # Environment check — Node.js, git, npm, API keys, cache, version
298
+ npx ship-safe doctor
299
+ ```
300
+
301
+ ### OpenClaw Security
302
+
303
+ ```bash
304
+ # Focused OpenClaw security scan
305
+ npx ship-safe openclaw .
306
+
307
+ # Auto-harden OpenClaw configs (0.0.0.0→127.0.0.1, add auth, ws→wss)
308
+ npx ship-safe openclaw . --fix
309
+
310
+ # Red team: simulate ClawJacked, prompt injection, data exfil attacks
311
+ npx ship-safe openclaw . --red-team
312
+
313
+ # CI preflight — exit non-zero on critical findings
314
+ npx ship-safe openclaw . --preflight
315
+
316
+ # Scan a skill before installing it
317
+ npx ship-safe scan-skill https://clawhub.io/skills/some-skill
318
+ npx ship-safe scan-skill ./local-skill.json
319
+ npx ship-safe scan-skill --all # Scan all skills from openclaw.json
320
+
321
+ # Generate hardened OpenClaw config
322
+ npx ship-safe init --openclaw
323
+
324
+ # Generate Agent Bill of Materials (CycloneDX 1.5)
325
+ npx ship-safe abom .
326
+ ```
327
+
328
+ ### Threat Intelligence
329
+
330
+ ```bash
331
+ # Update threat intel feed (ClawHavoc IOCs, malicious skills, config signatures)
332
+ npx ship-safe update-intel
333
+
334
+ # Ships with offline-first seed data — no internet required for scanning
335
+ ```
336
+
337
+ ### OpenClaw GitHub Action
338
+
339
+ Drop-in CI action that blocks PRs introducing agent config vulnerabilities:
340
+
341
+ ```yaml
342
+ # .github/workflows/openclaw-security.yml
343
+ name: OpenClaw Security Check
344
+
345
+ on: [pull_request]
346
+
347
+ permissions:
348
+ contents: read
349
+
350
+ jobs:
351
+ openclaw:
352
+ runs-on: ubuntu-latest
353
+ steps:
354
+ - uses: actions/checkout@v4
355
+
356
+ - uses: asamassekou10/ship-safe/.github/actions/openclaw-check@main
357
+ with:
358
+ fail-on-critical: 'true'
359
+ ```
360
+
361
+ **Inputs:**
362
+
363
+ | Input | Default | Description |
364
+ |-------|---------|-------------|
365
+ | `path` | `.` | Path to scan |
366
+ | `fail-on-critical` | `true` | Fail the check if critical findings are found |
367
+ | `node-version` | `20` | Node.js version to use |
368
+
369
+ **Outputs:**
370
+
371
+ | Output | Description |
372
+ |--------|-------------|
373
+ | `findings` | Total number of findings detected |
374
+ | `critical` | Number of critical findings |
375
+
376
+ Scans `openclaw.json`, `.cursorrules`, `CLAUDE.md`, Claude Code hooks, and MCP configs. Checks against the bundled threat intelligence database for known ClawHavoc IOCs.
377
+
378
+ ### Defensive Hooks
379
+
380
+ ```bash
381
+ # Install Claude Code defensive hooks (blocks curl|bash, exfil domains, rm -rf /)
382
+ npx ship-safe guard --generate-hooks
383
+
384
+ # Watch agent config files for drift (.cursorrules, CLAUDE.md, openclaw.json)
385
+ npx ship-safe watch . --configs
386
+ ```
387
+
388
+ ### Infrastructure Commands
389
+
390
+ ```bash
391
+ # Continuous monitoring (watch files for changes)
392
+ npx ship-safe watch .
393
+
394
+ # Generate CycloneDX SBOM
395
+ npx ship-safe sbom .
396
+
397
+ # Policy-as-code (enforce minimum score, fail on severity)
398
+ npx ship-safe policy init
399
+
400
+ # Block git push if secrets found
401
+ npx ship-safe guard
402
+
403
+ # Initialize security configs (.gitignore, headers)
404
+ npx ship-safe init
405
+
406
+ # Launch-day security checklist
407
+ npx ship-safe checklist
408
+
409
+ # MCP server for AI editors (Claude Desktop, Cursor, etc.)
410
+ npx ship-safe mcp
411
+ ```
412
+
413
+ ---
414
+
415
+ ## Claude Code Hooks
416
+
417
+ Install ship-safe as real-time Claude Code hooks — secrets are blocked **before** they ever touch disk:
418
+
419
+ ```bash
420
+ npx ship-safe hooks install
421
+ ```
422
+
423
+ Once installed, two hooks activate automatically on every Claude Code session:
424
+
425
+ | Hook | Trigger | Behaviour |
426
+ |------|---------|-----------|
427
+ | **PreToolUse** | Write / Edit / MultiEdit / Bash | Blocks the write if critical secrets are detected; blocks dangerous Bash patterns (curl\|bash, credential exfiltration, `rm -rf /`) |
428
+ | **PostToolUse** | Write / Edit / MultiEdit | Scans the saved file and injects advisory findings (high-severity patterns, DB URLs with credentials) directly into Claude's context never blocks |
429
+
430
+ Hook scripts are copied to `~/.ship-safe/hooks/` at install time — a stable, user-owned location that survives `npx` cache rotations.
431
+
432
+ ```bash
433
+ npx ship-safe hooks status # Check installation
434
+ npx ship-safe hooks remove # Uninstall
435
+ ```
436
+
437
+ ---
438
+
439
+ ## Claude Code Plugin
440
+
441
+ Use Ship Safe directly inside Claude Code no CLI needed:
442
+
443
+ ```bash
444
+ claude plugin add github:asamassekou10/ship-safe
445
+ ```
446
+
447
+ | Command | Description |
448
+ |---------|-------------|
449
+ | `/ship-safe` | Full security audit — 18 agents, remediation plan, auto-fix |
450
+ | `/ship-safe-scan` | Quick scan for leaked secrets |
451
+ | `/ship-safe-score` | Security health score (0-100) |
452
+ | `/ship-safe-deep` | LLM-powered deep taint analysis |
453
+ | `/ship-safe-ci` | CI/CD pipeline setup guide |
454
+ | `/ship-safe-hooks` | Install real-time Claude Code hooks (blocks secrets on write) |
455
+ | `/ship-safe-baseline` | Accept current findings as baseline; report only regressions |
456
+ | `/ship-safe-fix` | Auto-fix secrets and common vulnerabilities |
457
+ | `/ship-safe-red-team` | Run full red-team audit and open HTML report |
458
+
459
+ Claude interprets the results, explains findings in plain language, and can fix issues directly in your codebase.
460
+
461
+ ---
462
+
463
+ ## Incremental Scanning
464
+
465
+ Ship Safe caches file hashes and findings in `.ship-safe/context.json`. On subsequent runs, only changed files are re-scanned — unchanged files reuse cached results.
466
+
467
+ ```
468
+ ✔ [Phase 1/4] Secrets: 41 found (0 changed, 313 cached)
469
+ ```
470
+
471
+ - **~40% faster** on repeated scans
472
+ - **Auto-invalidation** — cache expires after 24 hours or when ship-safe updates
473
+ - **`--no-cache`** — force a full rescan anytime
474
+
475
+ The cache is stored in `.ship-safe/` which is automatically excluded from scans.
476
+
477
+ ### LLM Response Caching
478
+
479
+ When using AI classification (`--no-ai` to disable), results are cached in `.ship-safe/llm-cache.json` with a 7-day TTL. Repeated scans reuse cached classifications — reducing API costs significantly.
480
+
481
+ ---
482
+
483
+ ## Smart `.gitignore` Handling
484
+
485
+ Ship Safe respects your `.gitignore` for build output, caches, and vendor directories — but **always scans security-sensitive files** even if gitignored:
486
+
487
+ | Skipped (gitignore respected) | Always scanned (gitignore overridden) |
488
+ |-------------------------------|---------------------------------------|
489
+ | `node_modules/`, `dist/`, `build/` | `.env`, `.env.local`, `.env.production` |
490
+ | `*.log`, `*.pkl`, vendor dirs | `*.pem`, `*.key`, `*.p12` |
491
+ | Cache directories, IDE files | `credentials.json`, `*.secret` |
492
+
493
+ Why? Files like `.env` are gitignored *because* they contain secrets — which is exactly what a security scanner should catch.
494
+
495
+ ---
496
+
497
+ ## Multi-LLM Support
498
+
499
+ Ship Safe supports any AI provider for deep analysis and classification:
500
+
501
+ | Provider | Env Variable | Flag | Default Model |
502
+ |----------|-------------|------|---------------|
503
+ | **Anthropic** | `ANTHROPIC_API_KEY` | *(auto-detected)* | claude-haiku-4-5 |
504
+ | **OpenAI** | `OPENAI_API_KEY` | *(auto-detected)* | gpt-4o-mini |
505
+ | **Google** | `GOOGLE_AI_API_KEY` | *(auto-detected)* | gemini-2.0-flash |
506
+ | **Ollama** | `OLLAMA_HOST` | `--local` | Local models |
507
+ | **Groq** | `GROQ_API_KEY` | `--provider groq` | llama-3.3-70b-versatile |
508
+ | **Together AI** | `TOGETHER_API_KEY` | `--provider together` | meta-llama/Llama-3-70b-chat-hf |
509
+ | **Mistral** | `MISTRAL_API_KEY` | `--provider mistral` | mistral-small-latest |
510
+ | **DeepSeek** | `DEEPSEEK_API_KEY` | `--provider deepseek` | deepseek-chat |
511
+ | **xAI (Grok)** | `XAI_API_KEY` | `--provider xai` | grok-beta |
512
+ | **Perplexity** | `PERPLEXITY_API_KEY` | `--provider perplexity` | llama-3.1-sonar-small-128k-online |
513
+ | **LM Studio** | *(none)* | `--provider lmstudio` | Local server |
514
+ | **Custom** | *(any)* | `--base-url <url> --model <model>` | Any OpenAI-compatible |
515
+
516
+ Auto-detected from environment variables. Use `--provider <name>` to override. No API key required for scanning — AI is optional.
517
+
518
+ ---
519
+
520
+ ## Scoring System
521
+
522
+ Starts at 100. Each finding deducts points by severity and category, weighted by confidence level (high: 100%, medium: 60%, low: 30%) to reduce noise from heuristic patterns.
523
+
524
+ **8 Categories** (with weight caps):
525
+
526
+ | Category | Weight | Critical | High | Medium | Cap |
527
+ |----------|--------|----------|------|--------|-----|
528
+ | Secrets | 15% | -25 | -15 | -5 | -15 |
529
+ | Code Vulnerabilities | 15% | -20 | -10 | -3 | -15 |
530
+ | Dependencies | 13% | -20 | -10 | -5 | -13 |
531
+ | Auth & Access Control | 15% | -20 | -10 | -3 | -15 |
532
+ | Configuration | 8% | -15 | -8 | -3 | -8 |
533
+ | Supply Chain | 12% | -15 | -8 | -3 | -12 |
534
+ | API Security | 10% | -15 | -8 | -3 | -10 |
535
+ | AI/LLM Security | 12% | -15 | -8 | -3 | -12 |
536
+
537
+ *Weights aligned with OWASP Top 10 2025 risk rankings.*
538
+
539
+ **Grades:** A (90-100), B (75-89), C (60-74), D (40-59), F (0-39)
540
+
541
+ **Exit codes:** `0` for A/B (>= 75), `1` for C/D/F use in CI to fail builds.
542
+
543
+ ---
544
+
545
+ ## Policy-as-Code
546
+
547
+ Create `.ship-safe.policy.json` to enforce team-wide security standards:
548
+
549
+ ```bash
550
+ npx ship-safe policy init
551
+ ```
552
+
553
+ ```json
554
+ {
555
+ "minimumScore": 70,
556
+ "failOn": "critical",
557
+ "requiredScans": ["secrets", "injection", "deps", "auth"],
558
+ "ignoreRules": [],
559
+ "customSeverityOverrides": {},
560
+ "maxAge": { "criticalCVE": "7d", "highCVE": "30d", "mediumCVE": "90d" }
561
+ }
562
+ ```
563
+
564
+ ---
565
+
566
+ ## CI/CD Integration
567
+
568
+ The dedicated `ci` command is optimized for pipelines — compact output, exit codes, threshold-based gating:
569
+
570
+ ```bash
571
+ # Basic CI — fail if score < 75
572
+ npx ship-safe ci .
573
+
574
+ # Strict — fail on any critical finding
575
+ npx ship-safe ci . --fail-on critical
576
+
577
+ # Custom threshold + SARIF for GitHub Security tab
578
+ npx ship-safe ci . --threshold 80 --sarif results.sarif
579
+
580
+ # Only check new findings (not in baseline)
581
+ npx ship-safe ci . --baseline
582
+ ```
583
+
584
+ **GitHub Actions example:**
585
+
586
+ ```yaml
587
+ # .github/workflows/security.yml
588
+ name: Security Audit
589
+
590
+ on: [push, pull_request]
591
+
592
+ jobs:
593
+ security:
594
+ runs-on: ubuntu-latest
595
+ steps:
596
+ - uses: actions/checkout@v4
597
+
598
+ - name: Security gate
599
+ run: npx ship-safe ci . --threshold 75 --sarif results.sarif --github-pr
600
+
601
+ - uses: github/codeql-action/upload-sarif@v3
602
+ if: always()
603
+ with:
604
+ sarif_file: results.sarif
605
+ ```
606
+
607
+ **Export formats:** `--json`, `--sarif`, `--csv`, `--md`, `--html`, `--pdf`
608
+
609
+ ---
610
+
611
+ ## Suppress False Positives
612
+
613
+ **Inline:** Add `# ship-safe-ignore` comment on a line:
614
+ ```python
615
+ password = get_password() # ship-safe-ignore
616
+ ```
617
+
618
+ **File-level:** Create `.ship-safeignore` (gitignore syntax):
619
+ ```gitignore
620
+ # Exclude test fixtures
621
+ tests/fixtures/
622
+ *.test.js
623
+
624
+ # Exclude documentation with code examples
625
+ docs/
626
+ ```
627
+
628
+ ---
629
+
630
+ ## OWASP Coverage
631
+
632
+ | Standard | Coverage |
633
+ |----------|----------|
634
+ | **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 |
635
+ | **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 |
636
+ | **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 |
637
+ | **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 |
638
+ | **OWASP Agentic AI Top 10** | ASI01-ASI10: Agent Hijacking, Tool Misuse, Privilege Escalation, Unsafe Code Execution, Memory Poisoning, Identity Spoofing, Excessive Autonomy, Logging Gaps, Supply Chain Attacks, Cascading Hallucination |
639
+
640
+ ---
641
+
642
+ ## What's Inside
643
+
644
+ ### [`/configs`](./configs)
645
+ Drop-in security configs for Next.js, Supabase, and Firebase.
646
+
647
+ ### [`/snippets`](./snippets)
648
+ Copy-paste security patterns: rate limiting, JWT, CORS, input validation.
649
+
650
+ ### [`/ai-defense`](./ai-defense)
651
+ LLM security: prompt injection detection, cost protection, system prompt hardening.
652
+
653
+ ### [`/checklists`](./checklists)
654
+ Manual security audits: launch-day checklist, framework-specific guides.
655
+
656
+ ---
657
+
658
+ ## Add a Security Badge to Your README
659
+
660
+ Show the world your project is secure. After running `npx ship-safe audit .` or `npx ship-safe vibe-check . --badge`, add one of these to your README:
661
+
662
+ ```markdown
663
+ <!-- Replace GRADE and COLOR with your results -->
664
+ [![Ship Safe](https://img.shields.io/badge/Ship_Safe-A+-22c55e)](https://shipsafecli.com)
665
+ ```
666
+
667
+ | Grade | Badge |
668
+ |-------|-------|
669
+ | A+ | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-A+-22c55e)](https://shipsafecli.com)` |
670
+ | A | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-A-22c55e)](https://shipsafecli.com)` |
671
+ | B | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-B-06b6d4)](https://shipsafecli.com)` |
672
+ | C | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-C-eab308)](https://shipsafecli.com)` |
673
+ | D | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-D-ef4444)](https://shipsafecli.com)` |
674
+ | F | `[![Ship Safe](https://img.shields.io/badge/Ship_Safe-F-dc2626)](https://shipsafecli.com)` |
675
+
676
+ ---
677
+
678
+ ## Supply Chain Hardening
679
+
680
+ Ship Safe practices what it preaches. Our own supply chain is hardened against the [2026 Trivy/CanisterWorm attack chain](https://shipsafecli.com/blog/supply-chain-attacks-2026-how-we-hardened-ship-safe):
681
+
682
+ | Defense | What It Blocks |
683
+ |---------|---------------|
684
+ | All GitHub Actions pinned to full commit SHAs | Tag repointing (Trivy-style) |
685
+ | `permissions: contents: read` in CI | Excessive token scope |
686
+ | `npm ci --ignore-scripts` in all pipelines | CanisterWorm postinstall propagation |
687
+ | OIDC trusted publishing with provenance | Stolen npm token publishing |
688
+ | CODEOWNERS on `action.yml`, `.github/`, `package.json` | Unauthorized changes to critical paths |
689
+ | Strict `files` allowlist in package.json | Accidental inclusion of secrets/configs |
690
+ | Self-scanning with ship-safe in CI | Malicious code injection |
691
+ | 5 direct dependencies | Minimal transitive attack surface |
692
+
693
+ Verify provenance on any Ship Safe release:
694
+
695
+ ```bash
696
+ npm audit signatures
697
+ ```
698
+
699
+ ---
700
+
701
+ ## Contributing
702
+
703
+ 1. Fork the repo
704
+ 2. Add your security pattern, agent, or config
705
+ 3. Include comments explaining *why* it matters
706
+ 4. Open a PR
707
+
708
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
709
+
710
+ ---
711
+
712
+ ## Security Standards Reference
713
+
714
+ - [OWASP Top 10 Web 2025](https://owasp.org/Top10/)
715
+ - [OWASP Top 10 Mobile 2024](https://owasp.org/www-project-mobile-top-10/)
716
+ - [OWASP LLM Top 10 2025](https://genai.owasp.org/llm-top-10/)
717
+ - [OWASP API Security Top 10 2023](https://owasp.org/API-Security/)
718
+ - [OWASP CI/CD Top 10](https://owasp.org/www-project-top-10-ci-cd-security-risks/)
719
+ - [OWASP Agentic AI Top 10](https://owasp.org/www-project-agentic-ai-top-10/)
720
+
721
+ ---
722
+
723
+ ## License
724
+
725
+ MIT - Use it, share it, secure your stuff.
726
+
727
+ ---
728
+
729
+ ## Star History
730
+
731
+ [![Star History Chart](https://api.star-history.com/svg?repos=asamassekou10/ship-safe&type=Date)](https://star-history.com/#asamassekou10/ship-safe&Date)
732
+
733
+ ---
734
+
735
+ **Ship fast. Ship safe.** — [shipsafecli.com](https://shipsafecli.com)