preship 2.0.8 → 2.0.10
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 +470 -79
- package/dist/cli.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,144 +1,535 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">PreShip</h1>
|
|
3
|
+
<p align="center"><strong>Pre-ship verification for modern dev teams.</strong></p>
|
|
4
|
+
<p align="center">License compliance + Security vulnerabilities + Secret detection — all in one command.</p>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/preship"><img src="https://img.shields.io/npm/v/preship.svg" alt="npm version"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/preship"><img src="https://img.shields.io/npm/dm/preship.svg" alt="npm downloads"></a>
|
|
10
|
+
<a href="https://github.com/dipen-code/preship/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License"></a>
|
|
11
|
+
<a href="https://badge.socket.dev/npm/package/preship"><img src="https://badge.socket.dev/npm/package/preship" alt="Socket Badge"></a>
|
|
12
|
+
<a href="https://github.com/dipen-code/preship"><img src="https://img.shields.io/github/stars/dipen-code/preship?style=social" alt="GitHub Stars"></a>
|
|
13
|
+
</p>
|
|
5
14
|
|
|
6
|
-
|
|
15
|
+
---
|
|
7
16
|
|
|
8
|
-
|
|
17
|
+
## What is PreShip?
|
|
9
18
|
|
|
10
|
-
|
|
19
|
+
PreShip is a **free, open-source CLI tool** that runs three critical checks on your project before you ship:
|
|
20
|
+
|
|
21
|
+
| Check | What it catches | How |
|
|
22
|
+
|-------|----------------|-----|
|
|
23
|
+
| **License Compliance** | GPL, AGPL, EUPL, SSPL and other problematic licenses in your dependency tree | Parses lockfile, resolves licenses via npm registry / GitHub / local |
|
|
24
|
+
| **Security Vulnerabilities** | Known CVEs + deprecated, outdated, and unmaintained packages | Queries [OSV.dev](https://osv.dev) + npm registry health data |
|
|
25
|
+
| **Secret Detection** | Leaked API keys, tokens, private keys, database URLs in source code | 38 regex rules + Shannon entropy analysis |
|
|
26
|
+
|
|
27
|
+
**Zero config. No signup. No API keys. Works offline.**
|
|
28
|
+
|
|
29
|
+
---
|
|
11
30
|
|
|
12
31
|
## Quick Start
|
|
13
32
|
|
|
14
|
-
|
|
33
|
+
### Run instantly (no install needed)
|
|
34
|
+
|
|
15
35
|
```bash
|
|
16
36
|
npx preship scan
|
|
17
37
|
```
|
|
18
38
|
|
|
19
|
-
|
|
39
|
+
That's it. PreShip detects your package manager, parses your lockfile, and runs all three checks.
|
|
40
|
+
|
|
41
|
+
### Install in your project
|
|
42
|
+
|
|
20
43
|
```bash
|
|
21
44
|
npm install --save-dev preship
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then add it to your `package.json` scripts:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"scripts": {
|
|
52
|
+
"preshipcheck": "preship scan",
|
|
53
|
+
"prebuild": "preship scan"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Now every `npm run build` automatically verifies your project before building.
|
|
59
|
+
|
|
60
|
+
### Set up config and build hooks
|
|
61
|
+
|
|
62
|
+
```bash
|
|
22
63
|
npx preship init
|
|
23
64
|
```
|
|
24
65
|
|
|
25
|
-
|
|
66
|
+
This creates a `preship-config.yml` and optionally adds pre-build hooks to your project.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## How It Works
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
npx preship scan
|
|
74
|
+
|
|
|
75
|
+
v
|
|
76
|
+
[1] Detect project
|
|
77
|
+
- Reads package.json
|
|
78
|
+
- Finds lockfile (npm / yarn / pnpm)
|
|
79
|
+
- Detects framework (React, Next.js, Vue, Nuxt, Angular, Svelte, Express...)
|
|
80
|
+
|
|
|
81
|
+
v
|
|
82
|
+
[2] Parse dependencies
|
|
83
|
+
- Extracts all packages + versions from lockfile
|
|
84
|
+
- Separates direct vs transitive, dev vs production
|
|
85
|
+
|
|
|
86
|
+
v
|
|
87
|
+
[3] Run scan modules (in parallel)
|
|
88
|
+
|
|
|
89
|
+
├── License: Resolve license for each package → Apply policy
|
|
90
|
+
├── Security: Query OSV.dev for CVEs → Check npm for deprecated/outdated
|
|
91
|
+
└── Secrets: Walk source files → Match 38 rules + entropy check
|
|
92
|
+
|
|
|
93
|
+
v
|
|
94
|
+
[4] Output results
|
|
95
|
+
- Summary table with pass/fail per module
|
|
96
|
+
- Grouped failures (critical + high)
|
|
97
|
+
- Grouped warnings (medium + low)
|
|
98
|
+
- Exit code 1 if any module fails
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Sample Output
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
🔍 PreShip: Pre-ship verification
|
|
107
|
+
Project: my-app (nextjs)
|
|
108
|
+
Lock file: package-lock.json (npm)
|
|
109
|
+
Policy: commercial-safe | Mode: auto
|
|
110
|
+
Modules: license, security, secrets
|
|
111
|
+
|
|
112
|
+
📊 Scan Summary Total time: 6.9s
|
|
113
|
+
┌────────────┬────────────┬─────────┬─────────┬──────────┬─────────┬────────┐
|
|
114
|
+
│ Module │ Scanned │ Passed │ Issues │ Warnings │ Status │ Time │
|
|
115
|
+
├────────────┼────────────┼─────────┼─────────┼──────────┼─────────┼────────┤
|
|
116
|
+
│ License │ 534 pkgs │ 533 │ 0 │ 1 │ PASS │ 0.1s │
|
|
117
|
+
│ Security │ 534 pkgs │ -- │ 6 │ 4 │ FAIL │ 6.9s │
|
|
118
|
+
│ Secrets │ 166 files │ -- │ 0 │ 0 │ PASS │ 0.0s │
|
|
119
|
+
└────────────┴────────────┴─────────┴─────────┴──────────┴─────────┴────────┘
|
|
120
|
+
|
|
121
|
+
📜 License Compliance — ✅ 533 passed, 1 warning
|
|
122
|
+
🔑 Secret Detection — ✅ No issues found
|
|
123
|
+
|
|
124
|
+
❌ Failures
|
|
125
|
+
🛡️ Security Vulnerabilities — 6 high
|
|
126
|
+
Health Issues:
|
|
127
|
+
├── [HIGH] glob@10.3.10 — package is deprecated
|
|
128
|
+
└── ... and 4 more
|
|
129
|
+
|
|
130
|
+
⚠️ Warnings
|
|
131
|
+
📜 License Compliance — 1 weak copyleft
|
|
132
|
+
└── axe-core@4.11.1 — MPL-2.0
|
|
133
|
+
|
|
134
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
135
|
+
❌ RESULT: 1 of 3 checks failed
|
|
136
|
+
💡 To fix:
|
|
137
|
+
• Update packages with known vulnerabilities
|
|
138
|
+
• Replace deprecated or unmaintained packages
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Supported Frameworks & Package Managers
|
|
144
|
+
|
|
145
|
+
### Package Managers
|
|
146
|
+
|
|
147
|
+
| Manager | Lockfile | Versions |
|
|
148
|
+
|---------|----------|----------|
|
|
149
|
+
| **npm** | `package-lock.json` | v1, v2, v3 |
|
|
150
|
+
| **Yarn** | `yarn.lock` | v1, v2+ |
|
|
151
|
+
| **pnpm** | `pnpm-lock.yaml` | v5, v6, v9+ |
|
|
26
152
|
|
|
27
|
-
|
|
153
|
+
### Frameworks (auto-detected)
|
|
28
154
|
|
|
29
|
-
|
|
30
|
-
and AGPL) require you to open-source your entire codebase if you distribute
|
|
31
|
-
your software. PreShip catches these before they become a legal problem.
|
|
155
|
+
React, Next.js, Vue.js, Nuxt.js, Angular, Svelte, SvelteKit, Express, Fastify, NestJS
|
|
32
156
|
|
|
33
|
-
|
|
157
|
+
Framework detection is automatic — PreShip reads your `package.json` and identifies the framework for display. **All frameworks scan identically** — detection is informational only.
|
|
34
158
|
|
|
35
|
-
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## All CLI Commands
|
|
162
|
+
|
|
163
|
+
### `preship scan` — Run all checks
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npx preship scan # Full scan (all 3 modules)
|
|
167
|
+
npx preship scan --no-security # Skip security scanning
|
|
168
|
+
npx preship scan --no-secrets # Skip secret detection
|
|
169
|
+
npx preship scan --no-license # Skip license checking
|
|
170
|
+
npx preship scan --license-only # Legacy: license scan only
|
|
171
|
+
npx preship scan --strict # Fail on any warnings
|
|
172
|
+
npx preship scan --dev # Include devDependencies
|
|
173
|
+
npx preship scan --format json # JSON output (for CI/CD)
|
|
174
|
+
npx preship scan --format csv # CSV output
|
|
175
|
+
npx preship scan --mode local # Offline mode (zero network calls)
|
|
176
|
+
npx preship scan --silent # No output, exit code only
|
|
177
|
+
npx preship scan --scan-timeout 120000 # Custom timeout (ms)
|
|
178
|
+
npx preship scan --no-cache # Skip encrypted cache
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Security-specific flags:**
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npx preship scan --security-severity strict # strict | default | lenient
|
|
185
|
+
npx preship scan --security-fail-on critical # critical | high | medium | low
|
|
186
|
+
npx preship scan --no-deprecated # Ignore deprecated packages
|
|
187
|
+
npx preship scan --no-outdated # Ignore outdated packages
|
|
188
|
+
npx preship scan --no-unmaintained # Ignore unmaintained packages
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### `preship init` — Set up config
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
npx preship init # Interactive setup
|
|
195
|
+
npx preship init --policy strict # Use strict policy
|
|
196
|
+
npx preship init --skip-hooks # Don't add build hooks
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### `preship list` — Show findings
|
|
36
200
|
|
|
37
201
|
```bash
|
|
38
|
-
preship
|
|
39
|
-
preship
|
|
40
|
-
preship
|
|
41
|
-
preship
|
|
42
|
-
|
|
202
|
+
npx preship list # All module findings
|
|
203
|
+
npx preship list --license-only # License info only
|
|
204
|
+
npx preship list --filter GPL-3.0 # Filter by license
|
|
205
|
+
npx preship list --format csv # CSV output
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### `preship report` — Generate reports
|
|
43
209
|
|
|
44
|
-
|
|
45
|
-
preship
|
|
46
|
-
preship report
|
|
47
|
-
preship
|
|
210
|
+
```bash
|
|
211
|
+
npx preship report # Full compliance report
|
|
212
|
+
npx preship report --license-only # License NOTICE file
|
|
213
|
+
npx preship report --out compliance.json --format json # JSON export
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### `preship allow <package>` — Add exceptions
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npx preship allow readline-sync --reason "Internal CLI only, not distributed"
|
|
48
220
|
```
|
|
49
221
|
|
|
50
|
-
|
|
222
|
+
---
|
|
51
223
|
|
|
52
|
-
|
|
53
|
-
- **Build gate** -- blocks builds when violations are found (exit code 1)
|
|
54
|
-
- **Fast** -- scans 200+ packages in under 3 seconds
|
|
55
|
-
- **Fully offline** -- `--mode local` requires zero network access
|
|
56
|
-
- **Air-gap safe** -- your code and dependency data never leave your machine
|
|
57
|
-
- **Encrypted cache** -- AES-256-CBC encrypted, project-level
|
|
58
|
-
- **Multiple formats** -- terminal, JSON, CSV output
|
|
59
|
-
- **3 resolution modes** -- auto (default), online, local
|
|
60
|
-
- **Configurable** -- custom policies, exceptions, overrides
|
|
224
|
+
## Features in Detail
|
|
61
225
|
|
|
62
|
-
|
|
226
|
+
### License Compliance
|
|
227
|
+
|
|
228
|
+
PreShip resolves the license for every package in your dependency tree using a multi-source resolution chain:
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
1. Encrypted cache (instant, no network)
|
|
232
|
+
2. npm registry API (most reliable)
|
|
233
|
+
3. GitHub API (fallback for uncommon packages)
|
|
234
|
+
4. Local node_modules/ (air-gap environments)
|
|
235
|
+
5. UNKNOWN (if all sources fail)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Each resolved license is then evaluated against your chosen policy. Results are categorized as **allowed**, **warned**, **rejected**, or **unknown**.
|
|
239
|
+
|
|
240
|
+
**5 built-in policy templates:**
|
|
63
241
|
|
|
64
242
|
| Policy | Rejects | Warns | Best For |
|
|
65
243
|
|--------|---------|-------|----------|
|
|
66
244
|
| **commercial-safe** (default) | GPL, AGPL, EUPL, SSPL | LGPL, MPL | SaaS, commercial apps |
|
|
67
|
-
| **
|
|
68
|
-
| **
|
|
245
|
+
| **saas-safe** | AGPL, SSPL | LGPL, MPL | SaaS applications |
|
|
246
|
+
| **distribution-safe** | All copyleft risky for distribution | MPL-2.0 | Desktop apps, binaries |
|
|
247
|
+
| **strict** | All copyleft (GPL + LGPL + MPL) | — | Embedded/distributed software |
|
|
248
|
+
| **permissive-only** | Everything not explicitly allowed | — | Maximum legal safety |
|
|
249
|
+
|
|
250
|
+
### Security Vulnerability Scanning
|
|
251
|
+
|
|
252
|
+
PreShip checks your dependencies against two sources:
|
|
253
|
+
|
|
254
|
+
**Vulnerability database ([OSV.dev](https://osv.dev)):**
|
|
255
|
+
- Covers CVEs, GHSAs, and ecosystem-specific advisories
|
|
256
|
+
- Batch queries for performance (one API call for all packages)
|
|
257
|
+
- No API key required, completely free
|
|
258
|
+
|
|
259
|
+
**Package health checks (npm registry):**
|
|
260
|
+
- **Deprecated** — Package author marked it as deprecated (HIGH severity)
|
|
261
|
+
- **Outdated** — Major version behind latest (MEDIUM severity)
|
|
262
|
+
- **Unmaintained** — No updates in 2+ years (MEDIUM severity)
|
|
263
|
+
|
|
264
|
+
**Severity → Action mapping:**
|
|
265
|
+
|
|
266
|
+
| Severity | Classification | Default Behavior |
|
|
267
|
+
|----------|---------------|-----------------|
|
|
268
|
+
| Critical | Issue | Fails scan |
|
|
269
|
+
| High | Issue | Fails scan |
|
|
270
|
+
| Medium | Warning | Reported, doesn't fail |
|
|
271
|
+
| Low | Warning | Reported, doesn't fail |
|
|
272
|
+
|
|
273
|
+
### Secret Detection
|
|
274
|
+
|
|
275
|
+
PreShip scans your source code for accidentally committed credentials:
|
|
276
|
+
|
|
277
|
+
**38 detection rules covering:**
|
|
278
|
+
- Cloud providers: AWS, GCP, Azure access keys and secrets
|
|
279
|
+
- API services: GitHub, GitLab, Stripe, Slack, Twilio, SendGrid, Mailgun
|
|
280
|
+
- Databases: MongoDB, PostgreSQL, MySQL, Redis connection strings
|
|
281
|
+
- Auth: JWTs, OAuth tokens, bearer tokens, private keys (RSA/EC/PGP)
|
|
282
|
+
- Generic: passwords, API keys, high-entropy hex/base64 strings
|
|
283
|
+
|
|
284
|
+
**Smart exclusions (never scanned):**
|
|
285
|
+
- `node_modules/`, `.git/`, `dist/`, build output
|
|
286
|
+
- `.env` and `.env.*` files (expected to contain secrets)
|
|
287
|
+
- Binary files (images, fonts, etc.)
|
|
288
|
+
- Lockfiles (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`)
|
|
289
|
+
- Minified files and files larger than 1MB
|
|
290
|
+
|
|
291
|
+
**Shannon entropy analysis** catches secrets that don't match any rule pattern but have suspiciously high randomness (hex strings > 3.5 bits/char, base64 > 4.0 bits/char).
|
|
292
|
+
|
|
293
|
+
---
|
|
69
294
|
|
|
70
295
|
## Configuration
|
|
71
296
|
|
|
72
|
-
Create `preship-config.yml` in your project root (or run `preship init`):
|
|
297
|
+
Create `preship-config.yml` in your project root (or run `npx preship init`):
|
|
73
298
|
|
|
74
299
|
```yaml
|
|
75
|
-
# Policy template
|
|
76
|
-
policy: commercial-safe
|
|
300
|
+
# Policy template
|
|
301
|
+
policy: commercial-safe # commercial-safe | saas-safe | distribution-safe | strict | permissive-only
|
|
77
302
|
|
|
78
|
-
#
|
|
79
|
-
|
|
303
|
+
# Module toggles (all enabled by default)
|
|
304
|
+
modules:
|
|
305
|
+
license: true
|
|
306
|
+
security: true
|
|
307
|
+
secrets: true
|
|
80
308
|
|
|
81
|
-
#
|
|
309
|
+
# Resolution mode
|
|
310
|
+
mode: auto # auto | online | local
|
|
311
|
+
|
|
312
|
+
# License settings
|
|
313
|
+
scanDevDependencies: false
|
|
82
314
|
flagUnknown: true
|
|
83
315
|
|
|
84
|
-
#
|
|
316
|
+
# Custom license overrides
|
|
317
|
+
# reject:
|
|
318
|
+
# - CUSTOM-LICENSE
|
|
319
|
+
# allow:
|
|
320
|
+
# - BSD-3-Clause-No-Nuclear-License
|
|
85
321
|
# exceptions:
|
|
86
|
-
# - package: some-package
|
|
87
|
-
# reason: "Used internally only"
|
|
322
|
+
# - package: some-internal-package
|
|
323
|
+
# reason: "Used internally only, not distributed"
|
|
88
324
|
# approvedBy: your-name
|
|
89
|
-
# date:
|
|
325
|
+
# date: 2025-01-15
|
|
326
|
+
|
|
327
|
+
# Security settings
|
|
328
|
+
# security:
|
|
329
|
+
# severity: default # default | strict | lenient
|
|
330
|
+
# failOn: high # critical | high | medium | low
|
|
331
|
+
# checkOutdated: true
|
|
332
|
+
# checkDeprecated: true
|
|
333
|
+
# checkUnmaintained: true
|
|
334
|
+
|
|
335
|
+
# Secrets settings
|
|
336
|
+
# secrets:
|
|
337
|
+
# allowPaths: [] # Glob paths to skip
|
|
338
|
+
# allowRules: [] # Rule IDs to disable (e.g., generic-password)
|
|
90
339
|
```
|
|
91
340
|
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Resolution Modes
|
|
344
|
+
|
|
345
|
+
| Mode | What it does | Network | Cache | Best for |
|
|
346
|
+
|------|-------------|---------|-------|----------|
|
|
347
|
+
| **auto** (default) | Cache → npm registry → GitHub API → local node_modules | Yes | Yes | Daily development |
|
|
348
|
+
| **online** | Cache → npm registry → GitHub API (no local fallback) | Yes | Yes | CI/CD without node_modules |
|
|
349
|
+
| **local** | Local node_modules only | None | No | Air-gapped / offline environments |
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
npx preship scan --mode auto # Default
|
|
353
|
+
npx preship scan --mode online # Registry only
|
|
354
|
+
npx preship scan --mode local # Zero network calls
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
92
359
|
## CI/CD Integration
|
|
93
360
|
|
|
361
|
+
### GitHub Actions
|
|
362
|
+
|
|
94
363
|
```yaml
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
364
|
+
name: PreShip Check
|
|
365
|
+
on: [push, pull_request]
|
|
366
|
+
|
|
367
|
+
jobs:
|
|
368
|
+
preship:
|
|
369
|
+
runs-on: ubuntu-latest
|
|
370
|
+
steps:
|
|
371
|
+
- uses: actions/checkout@v4
|
|
372
|
+
- uses: actions/setup-node@v4
|
|
373
|
+
with:
|
|
374
|
+
node-version: '20'
|
|
375
|
+
- run: npm ci
|
|
376
|
+
- run: npx preship scan
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### As a pre-commit hook
|
|
98
380
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
script:
|
|
102
|
-
- npx preship scan --strict
|
|
381
|
+
```bash
|
|
382
|
+
npx preship init # Adds hooks automatically
|
|
103
383
|
```
|
|
104
384
|
|
|
105
|
-
|
|
385
|
+
Or manually in `package.json`:
|
|
386
|
+
|
|
387
|
+
```json
|
|
388
|
+
{
|
|
389
|
+
"scripts": {
|
|
390
|
+
"precommit": "preship scan --silent",
|
|
391
|
+
"prebuild": "preship scan"
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### JSON output for pipelines
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
npx preship scan --format json > preship-report.json
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
---
|
|
106
403
|
|
|
107
404
|
## Programmatic API
|
|
108
405
|
|
|
406
|
+
PreShip can be used as a library in your own tools:
|
|
407
|
+
|
|
109
408
|
```typescript
|
|
110
|
-
import { scan } from 'preship';
|
|
409
|
+
import { scan, unifiedScan } from 'preship';
|
|
410
|
+
import type { ScanResult, UnifiedScanResult } from 'preship';
|
|
411
|
+
|
|
412
|
+
// Full unified scan (all modules)
|
|
413
|
+
const result: UnifiedScanResult = await unifiedScan({
|
|
414
|
+
projectPath: './my-project',
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
console.log(result.passed); // true if ALL modules pass
|
|
418
|
+
console.log(result.modules.license?.rejected); // License violations
|
|
419
|
+
console.log(result.modules.security?.findings); // Security findings
|
|
420
|
+
console.log(result.modules.secrets?.findings); // Secret findings
|
|
421
|
+
|
|
422
|
+
// Configure specific modules
|
|
423
|
+
const secOnly = await unifiedScan({
|
|
424
|
+
config: {
|
|
425
|
+
modules: { license: false, security: true, secrets: false },
|
|
426
|
+
security: { failOn: 'critical' },
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// Offline scan
|
|
431
|
+
const offline = await unifiedScan({
|
|
432
|
+
config: { mode: 'local' },
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// Legacy: license-only scan
|
|
436
|
+
const licenseResult: ScanResult = await scan({
|
|
437
|
+
projectPath: './my-project',
|
|
438
|
+
});
|
|
439
|
+
```
|
|
111
440
|
|
|
112
|
-
|
|
441
|
+
Individual packages are also available:
|
|
113
442
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
443
|
+
```bash
|
|
444
|
+
npm install @preship/license # License scanning API
|
|
445
|
+
npm install @preship/security # Vulnerability checking API
|
|
446
|
+
npm install @preship/secrets # Secret detection API
|
|
117
447
|
```
|
|
118
448
|
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
## Performance
|
|
452
|
+
|
|
453
|
+
| Feature | Detail |
|
|
454
|
+
|---------|--------|
|
|
455
|
+
| **Parallel scanning** | All 3 modules run concurrently via `Promise.all()` |
|
|
456
|
+
| **Encrypted cache** | AES-256-CBC encrypted, 7-day TTL, instant license lookups on repeat scans |
|
|
457
|
+
| **Adaptive rate limiting** | Reads `X-RateLimit-*` headers, backs off proportionally |
|
|
458
|
+
| **Scan timeout** | 60s default (configurable, 0 = disabled), AbortController-based |
|
|
459
|
+
| **Batch vulnerability queries** | One API call to OSV.dev for all packages |
|
|
460
|
+
| **Keyword prefiltering** | Secrets scanner skips files with no keyword matches |
|
|
461
|
+
|
|
462
|
+
Typical scan: **500+ packages in under 10 seconds** (with cache).
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
119
466
|
## License Cheat Sheet
|
|
120
467
|
|
|
121
|
-
| License |
|
|
122
|
-
|
|
123
|
-
| MIT, BSD, ISC |
|
|
124
|
-
| Apache-2.0 |
|
|
125
|
-
| LGPL-2.1/3.0 |
|
|
126
|
-
| MPL-2.0 |
|
|
127
|
-
| GPL-2.0/3.0 |
|
|
128
|
-
| AGPL-3.0 |
|
|
129
|
-
|
|
|
130
|
-
|
|
|
468
|
+
| License | What it means | Default verdict |
|
|
469
|
+
|---------|---------------|-----------------|
|
|
470
|
+
| MIT, BSD, ISC | Do whatever you want, keep the copyright | Allowed |
|
|
471
|
+
| Apache-2.0 | Same + patent grant | Allowed |
|
|
472
|
+
| LGPL-2.1/3.0 | OK if dynamically linked, risky if static | Warning |
|
|
473
|
+
| MPL-2.0 | Must share modifications to MPL files only | Warning |
|
|
474
|
+
| GPL-2.0/3.0 | Must open-source your entire codebase | Rejected |
|
|
475
|
+
| AGPL-3.0 | GPL + network use triggers it (SaaS killer) | Rejected |
|
|
476
|
+
| EUPL-1.2 | European GPL equivalent | Rejected |
|
|
477
|
+
| SSPL-1.0 | AGPL on steroids (MongoDB license) | Rejected |
|
|
478
|
+
| UNKNOWN | No license detected | Flagged |
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Use Cases
|
|
483
|
+
|
|
484
|
+
- **Startups** — Clean up before investor due diligence
|
|
485
|
+
- **Agencies** — Scan client projects before delivery
|
|
486
|
+
- **Enterprise** — Gate CI/CD pipelines without paying $20K+/year for Snyk/FOSSA
|
|
487
|
+
- **Open source maintainers** — Keep your dependency tree clean
|
|
488
|
+
- **Regulated industries** — Finance, healthcare, defense — air-gapped scanning with `--mode local`
|
|
489
|
+
- **Security teams** — Catch leaked secrets before they hit production
|
|
131
490
|
|
|
132
|
-
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
## Architecture
|
|
494
|
+
|
|
495
|
+
PreShip is a monorepo with feature-based packages:
|
|
496
|
+
|
|
497
|
+
```
|
|
498
|
+
preship/
|
|
499
|
+
packages/
|
|
500
|
+
core/ @preship/core Config, parsers, cache, rate limiter, types
|
|
501
|
+
license/ @preship/license License compliance scanning
|
|
502
|
+
security/ @preship/security Vulnerability + health scanning
|
|
503
|
+
secrets/ @preship/secrets Secret/credential detection
|
|
504
|
+
apps/
|
|
505
|
+
cli/ preship Unified CLI
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## Requirements
|
|
511
|
+
|
|
512
|
+
- **Node.js 18+** (uses native `fetch` — no HTTP library dependency)
|
|
513
|
+
- A lockfile (`package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`)
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## Contributing
|
|
518
|
+
|
|
519
|
+
Contributions are welcome! PreShip is Apache-2.0 licensed.
|
|
520
|
+
|
|
521
|
+
```bash
|
|
522
|
+
git clone https://github.com/dipen-code/preship.git
|
|
523
|
+
cd preship
|
|
524
|
+
npm install
|
|
525
|
+
npm run build
|
|
526
|
+
npm test # 613 tests across 21 test files
|
|
527
|
+
```
|
|
133
528
|
|
|
134
|
-
|
|
135
|
-
- **Secret detection** -- catch leaked API keys, tokens, credentials
|
|
136
|
-
- **PreShip Enterprise** -- dashboard, team policies, audit trail, SBOM export
|
|
529
|
+
---
|
|
137
530
|
|
|
138
|
-
##
|
|
531
|
+
## License
|
|
139
532
|
|
|
140
|
-
-
|
|
141
|
-
- **Issues**: [github.com/dipen-code/preship/issues](https://github.com/dipen-code/preship/issues)
|
|
142
|
-
- **License**: Apache 2.0
|
|
533
|
+
**Apache-2.0** — fully open source, free for commercial use.
|
|
143
534
|
|
|
144
|
-
|
|
535
|
+
Created by [Cyfox Inc.](https://www.cyfox.tech) (Chicago, IL)
|
package/dist/cli.js
CHANGED
|
@@ -4018,7 +4018,7 @@ function registerAllowCommand(program2) {
|
|
|
4018
4018
|
|
|
4019
4019
|
// src/cli.ts
|
|
4020
4020
|
var program = new import_commander.Command();
|
|
4021
|
-
program.name("preship").description("Pre-ship verification: license compliance, security scanning, and secret detection \u2014 all before you ship.").version("2.0.
|
|
4021
|
+
program.name("preship").description("Pre-ship verification: license compliance, security scanning, and secret detection \u2014 all before you ship.").version("2.0.10");
|
|
4022
4022
|
registerScanCommand(program);
|
|
4023
4023
|
registerInitCommand(program);
|
|
4024
4024
|
registerListCommand(program);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "preship",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "Pre-ship verification for modern dev teams. License compliance, security vulnerability scanning, and secret detection — all in one CLI. Zero config. Fully offline. Free forever.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"license",
|