@continum/cli 0.1.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 +481 -0
- package/SETUP.md +517 -0
- package/dist/api/client.d.ts +17 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +70 -0
- package/dist/api/client.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +104 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +217 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/patterns.d.ts +3 -0
- package/dist/commands/patterns.d.ts.map +1 -0
- package/dist/commands/patterns.js +67 -0
- package/dist/commands/patterns.js.map +1 -0
- package/dist/commands/scan.d.ts +11 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +219 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +61 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +87 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/config/default-config.d.ts +3 -0
- package/dist/config/default-config.d.ts.map +1 -0
- package/dist/config/default-config.js +25 -0
- package/dist/config/default-config.js.map +1 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +96 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/git/git-utils.d.ts +8 -0
- package/dist/git/git-utils.d.ts.map +1 -0
- package/dist/git/git-utils.js +130 -0
- package/dist/git/git-utils.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/scanner/local-scan.d.ts +15 -0
- package/dist/scanner/local-scan.d.ts.map +1 -0
- package/dist/scanner/local-scan.js +227 -0
- package/dist/scanner/local-scan.js.map +1 -0
- package/dist/scanner/pattern-updater.d.ts +12 -0
- package/dist/scanner/pattern-updater.d.ts.map +1 -0
- package/dist/scanner/pattern-updater.js +110 -0
- package/dist/scanner/pattern-updater.js.map +1 -0
- package/dist/scanner/patterns.d.ts +5 -0
- package/dist/scanner/patterns.d.ts.map +1 -0
- package/dist/scanner/patterns.js +145 -0
- package/dist/scanner/patterns.js.map +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -0
- package/src/api/client.ts +77 -0
- package/src/commands/init.ts +113 -0
- package/src/commands/login.ts +205 -0
- package/src/commands/patterns.ts +68 -0
- package/src/commands/scan.ts +257 -0
- package/src/commands/status.ts +57 -0
- package/src/commands/uninstall.ts +55 -0
- package/src/config/default-config.ts +23 -0
- package/src/config/loader.ts +67 -0
- package/src/git/git-utils.ts +95 -0
- package/src/index.ts +72 -0
- package/src/scanner/local-scan.ts +222 -0
- package/src/scanner/pattern-updater.ts +94 -0
- package/src/scanner/patterns.ts +156 -0
- package/src/types.ts +64 -0
- package/tsconfig.json +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
# @continum/cli
|
|
2
|
+
|
|
3
|
+
Continum CLI - Pre-commit credential scanner with AI-powered pattern learning
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Install globally
|
|
9
|
+
npm install -g @continum/cli
|
|
10
|
+
|
|
11
|
+
# 2. Login to Continum (opens browser)
|
|
12
|
+
continum login
|
|
13
|
+
|
|
14
|
+
# 3. Initialize in your project
|
|
15
|
+
cd your-project
|
|
16
|
+
continum init
|
|
17
|
+
|
|
18
|
+
# That's it! Every commit is now scanned
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What It Does
|
|
22
|
+
|
|
23
|
+
The Continum CLI provides two-layer protection against credential leaks:
|
|
24
|
+
|
|
25
|
+
**Layer 1: Local Scanner (Instant)**
|
|
26
|
+
- Regex-based pattern matching
|
|
27
|
+
- Runs in milliseconds before commit
|
|
28
|
+
- Works offline
|
|
29
|
+
- Blocks commit immediately if violations found
|
|
30
|
+
|
|
31
|
+
**Layer 2: Sandbox Audit (Background)**
|
|
32
|
+
- AI-powered context analysis
|
|
33
|
+
- Catches generic credentials with no known pattern
|
|
34
|
+
- Fire-and-forget (doesn't block workflow)
|
|
35
|
+
- Creates signals for team review
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### For End Users
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g @continum/cli
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### For Development
|
|
46
|
+
|
|
47
|
+
See [SETUP.md](./SETUP.md) for development setup instructions.
|
|
48
|
+
|
|
49
|
+
## Authentication
|
|
50
|
+
|
|
51
|
+
### Login (Required First Step)
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
continum login
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**What happens:**
|
|
58
|
+
1. Opens browser to console.continum.dev
|
|
59
|
+
2. You sign in with your Continum account
|
|
60
|
+
3. Browser shows "Authentication Successful"
|
|
61
|
+
4. CLI automatically receives credentials
|
|
62
|
+
5. Credentials saved to `~/.continum/credentials.json`
|
|
63
|
+
|
|
64
|
+
**You only need to login once per machine.**
|
|
65
|
+
|
|
66
|
+
## Project Setup
|
|
67
|
+
|
|
68
|
+
### Initialize in Your Project
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
cd your-project
|
|
72
|
+
continum init
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Requirements:**
|
|
76
|
+
- Must be in a git repository
|
|
77
|
+
- Must be logged in (run `continum login` first)
|
|
78
|
+
|
|
79
|
+
**What it does:**
|
|
80
|
+
1. Creates `.continum.json` configuration file
|
|
81
|
+
2. Installs pre-commit hook at `.git/hooks/pre-commit`
|
|
82
|
+
3. Verifies connection to Continum API
|
|
83
|
+
|
|
84
|
+
## Daily Usage
|
|
85
|
+
|
|
86
|
+
### Making Commits
|
|
87
|
+
|
|
88
|
+
Just commit normally:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
git add .
|
|
92
|
+
git commit -m "your changes"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The pre-commit hook runs automatically.
|
|
96
|
+
|
|
97
|
+
### Scenario 1: Clean Commit
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
$ git commit -m "add user feature"
|
|
101
|
+
|
|
102
|
+
Continum — scanning 3 files...
|
|
103
|
+
✓ Clean
|
|
104
|
+
|
|
105
|
+
[main abc1234] add user feature
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
✅ Commit goes through.
|
|
109
|
+
|
|
110
|
+
### Scenario 2: Known Pattern Blocked
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
$ git commit -m "add config"
|
|
114
|
+
|
|
115
|
+
Continum — scanning 1 file...
|
|
116
|
+
|
|
117
|
+
❌ BLOCKED
|
|
118
|
+
|
|
119
|
+
config.ts (line 14)
|
|
120
|
+
──────────────────────────────────────────────────────
|
|
121
|
+
Type: AWS_ACCESS_KEY
|
|
122
|
+
Found: AKIA••••••••7EXAMPLE
|
|
123
|
+
Severity: CRITICAL
|
|
124
|
+
|
|
125
|
+
Fix these before committing.
|
|
126
|
+
Override (not recommended): git commit --no-verify
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
❌ Commit blocked. Remove the credential and try again.
|
|
130
|
+
|
|
131
|
+
### Scenario 3: Unknown Pattern Detected
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
$ git commit -m "add acme integration"
|
|
135
|
+
|
|
136
|
+
Continum — scanning 1 file...
|
|
137
|
+
|
|
138
|
+
⚠️ POSSIBLE CREDENTIAL DETECTED
|
|
139
|
+
|
|
140
|
+
config.ts (line 14)
|
|
141
|
+
──────────────────────────────────────────────────────
|
|
142
|
+
Type: UNKNOWN_PATTERN (HIGH confidence)
|
|
143
|
+
Found: acme_prod_x7k9••••••••
|
|
144
|
+
Pattern: acme_prod_[a-z0-9]{16}
|
|
145
|
+
|
|
146
|
+
This looks like a credential, but it's not in our pattern library.
|
|
147
|
+
|
|
148
|
+
Options:
|
|
149
|
+
[b] Block this commit
|
|
150
|
+
[a] Approve pattern and block (will catch in future)
|
|
151
|
+
[i] Ignore this pattern
|
|
152
|
+
[c] Continue anyway (not recommended)
|
|
153
|
+
|
|
154
|
+
Choice: a
|
|
155
|
+
|
|
156
|
+
Pattern description: ACME Production API Key
|
|
157
|
+
Severity level: HIGH
|
|
158
|
+
|
|
159
|
+
✓ Pattern saved to your library
|
|
160
|
+
✓ This pattern will now be caught locally on future commits
|
|
161
|
+
|
|
162
|
+
Commit blocked. Remove the credential and try again.
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**What happened:**
|
|
166
|
+
- CLI detected a potential credential
|
|
167
|
+
- You approved it as a real pattern
|
|
168
|
+
- Pattern saved to Continum platform
|
|
169
|
+
- All team members will now catch this pattern
|
|
170
|
+
- Commit still blocked (remove the credential first)
|
|
171
|
+
|
|
172
|
+
## Commands
|
|
173
|
+
|
|
174
|
+
### `continum login`
|
|
175
|
+
|
|
176
|
+
Authenticate with your Continum account. Opens browser for secure OAuth-style authentication.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
continum login
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**You only need to run this once per machine.**
|
|
183
|
+
|
|
184
|
+
### `continum init`
|
|
185
|
+
|
|
186
|
+
Initialize Continum in a project.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
continum init
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Requirements:**
|
|
193
|
+
- Must be in a git repository
|
|
194
|
+
- Must be logged in first
|
|
195
|
+
|
|
196
|
+
**Options:**
|
|
197
|
+
- `--silent` - Non-interactive mode (for postinstall scripts)
|
|
198
|
+
|
|
199
|
+
### `continum scan`
|
|
200
|
+
|
|
201
|
+
Scan files for credentials and sensitive data.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Scan specific files
|
|
205
|
+
continum scan src/config.ts src/utils.ts
|
|
206
|
+
|
|
207
|
+
# Scan staged files
|
|
208
|
+
continum scan --staged
|
|
209
|
+
|
|
210
|
+
# Scan with strict mode (block on unknown patterns)
|
|
211
|
+
continum scan --staged --strict
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Options:**
|
|
215
|
+
- `--staged` - Scan staged files (used by pre-commit hook)
|
|
216
|
+
- `--hook` - Minimal output mode (for git hooks)
|
|
217
|
+
- `--strict` - Block on unknown patterns without prompting
|
|
218
|
+
- `--warn-only` - Show warnings but don't block commits
|
|
219
|
+
|
|
220
|
+
### `continum patterns`
|
|
221
|
+
|
|
222
|
+
Manage credential patterns.
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Update patterns from Continum API
|
|
226
|
+
continum patterns update
|
|
227
|
+
|
|
228
|
+
# List all available patterns
|
|
229
|
+
continum patterns list
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### `continum status`
|
|
233
|
+
|
|
234
|
+
Check Continum configuration and API connection.
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
continum status
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Shows:
|
|
241
|
+
- Git repository status
|
|
242
|
+
- Configuration file
|
|
243
|
+
- Pre-commit hook status
|
|
244
|
+
- API connection
|
|
245
|
+
- Your account info
|
|
246
|
+
|
|
247
|
+
### `continum uninstall`
|
|
248
|
+
|
|
249
|
+
Remove Continum pre-commit hook from the repository.
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
continum uninstall
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Configuration
|
|
256
|
+
|
|
257
|
+
The `.continum.json` file controls scanner behavior:
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"scanOnCommit": true,
|
|
262
|
+
"sandbox": "employee_confidential",
|
|
263
|
+
"block": ["CRITICAL", "HIGH"],
|
|
264
|
+
"warn": ["MEDIUM"],
|
|
265
|
+
"ignore": [
|
|
266
|
+
".env.example",
|
|
267
|
+
"**/*.test.ts",
|
|
268
|
+
"**/fixtures/**",
|
|
269
|
+
"**/mocks/**"
|
|
270
|
+
],
|
|
271
|
+
"patterns": {
|
|
272
|
+
"custom": [
|
|
273
|
+
"ACME-[0-9]{6}",
|
|
274
|
+
"internal-project-[a-z]+"
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Configuration Options
|
|
281
|
+
|
|
282
|
+
- `scanOnCommit` - Enable/disable pre-commit scanning (default: true)
|
|
283
|
+
- `sandbox` - Continum sandbox to use for auditing
|
|
284
|
+
- `block` - Risk levels that block commits (CRITICAL, HIGH, MEDIUM, LOW)
|
|
285
|
+
- `warn` - Risk levels that show warnings but allow commits
|
|
286
|
+
- `ignore` - Glob patterns for files to skip
|
|
287
|
+
- `patterns.custom` - Custom regex patterns to detect
|
|
288
|
+
|
|
289
|
+
## Built-in Patterns
|
|
290
|
+
|
|
291
|
+
The CLI ships with patterns for:
|
|
292
|
+
|
|
293
|
+
**Cloud Credentials:**
|
|
294
|
+
- AWS access keys (AKIA...)
|
|
295
|
+
- GCP service account JSON
|
|
296
|
+
- Azure connection strings
|
|
297
|
+
|
|
298
|
+
**API Tokens:**
|
|
299
|
+
- Stripe (sk_live_...)
|
|
300
|
+
- GitHub PATs (ghp_...)
|
|
301
|
+
- Anthropic (sk-ant-...)
|
|
302
|
+
- OpenAI (sk-...)
|
|
303
|
+
|
|
304
|
+
**Database:**
|
|
305
|
+
- PostgreSQL connection strings
|
|
306
|
+
- MySQL connection strings
|
|
307
|
+
- MongoDB connection strings
|
|
308
|
+
|
|
309
|
+
**Private Keys:**
|
|
310
|
+
- PEM format RSA/EC keys
|
|
311
|
+
- SSH private keys
|
|
312
|
+
|
|
313
|
+
**UK PII:**
|
|
314
|
+
- NHS numbers
|
|
315
|
+
- National Insurance numbers
|
|
316
|
+
|
|
317
|
+
**Generic:**
|
|
318
|
+
- JWT tokens
|
|
319
|
+
- High-entropy API keys
|
|
320
|
+
|
|
321
|
+
## Team Deployment
|
|
322
|
+
|
|
323
|
+
### Option 1: Manual Setup
|
|
324
|
+
|
|
325
|
+
Each team member runs:
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
npm install -g @continum/cli
|
|
329
|
+
continum login
|
|
330
|
+
cd project
|
|
331
|
+
continum init
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Option 2: Auto-Install (Recommended)
|
|
335
|
+
|
|
336
|
+
Add to your project's `package.json`:
|
|
337
|
+
|
|
338
|
+
```json
|
|
339
|
+
{
|
|
340
|
+
"scripts": {
|
|
341
|
+
"postinstall": "continum init --silent"
|
|
342
|
+
},
|
|
343
|
+
"devDependencies": {
|
|
344
|
+
"@continum/cli": "^0.1.0"
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
**Team member workflow:**
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
# 1. Install CLI globally (one time)
|
|
353
|
+
npm install -g @continum/cli
|
|
354
|
+
|
|
355
|
+
# 2. Login (one time per machine)
|
|
356
|
+
continum login
|
|
357
|
+
|
|
358
|
+
# 3. Clone and install project
|
|
359
|
+
git clone <your-repo>
|
|
360
|
+
cd <your-repo>
|
|
361
|
+
npm install
|
|
362
|
+
# ↑ Automatically runs continum init --silent
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Troubleshooting
|
|
366
|
+
|
|
367
|
+
### "Command not found: continum"
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
npm install -g @continum/cli
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### "Not logged in to Continum"
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
continum login
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### "Not in a git repository"
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
git init
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### "Port 8765 already in use"
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# Kill process on port 8765
|
|
389
|
+
lsof -ti:8765 | xargs kill -9
|
|
390
|
+
|
|
391
|
+
# Then try again
|
|
392
|
+
continum login
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### "Authentication timeout"
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Just try again
|
|
399
|
+
continum login
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### "Failed to connect to Continum API"
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
# Check credentials
|
|
406
|
+
cat ~/.continum/credentials.json
|
|
407
|
+
|
|
408
|
+
# Re-login
|
|
409
|
+
continum login
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Commits still going through despite violations
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# Verify hook is installed
|
|
416
|
+
ls -la .git/hooks/pre-commit
|
|
417
|
+
|
|
418
|
+
# Verify hook is executable
|
|
419
|
+
chmod +x .git/hooks/pre-commit
|
|
420
|
+
|
|
421
|
+
# Test manually
|
|
422
|
+
continum scan --staged
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
## File Locations
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
# Credentials (per machine)
|
|
429
|
+
~/.continum/credentials.json
|
|
430
|
+
|
|
431
|
+
# Pattern cache (per machine)
|
|
432
|
+
~/.continum/patterns.json
|
|
433
|
+
|
|
434
|
+
# Project config (committed to repo)
|
|
435
|
+
.continum.json
|
|
436
|
+
|
|
437
|
+
# Git hook (per project)
|
|
438
|
+
.git/hooks/pre-commit
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## CI/CD Integration
|
|
442
|
+
|
|
443
|
+
```yaml
|
|
444
|
+
# .github/workflows/security.yml
|
|
445
|
+
name: Security Scan
|
|
446
|
+
|
|
447
|
+
on: [push, pull_request]
|
|
448
|
+
|
|
449
|
+
jobs:
|
|
450
|
+
scan:
|
|
451
|
+
runs-on: ubuntu-latest
|
|
452
|
+
steps:
|
|
453
|
+
- uses: actions/checkout@v2
|
|
454
|
+
|
|
455
|
+
- name: Install Continum CLI
|
|
456
|
+
run: npm install -g @continum/cli
|
|
457
|
+
|
|
458
|
+
- name: Setup credentials
|
|
459
|
+
env:
|
|
460
|
+
CONTINUM_API_KEY: ${{ secrets.CONTINUM_API_KEY }}
|
|
461
|
+
run: |
|
|
462
|
+
mkdir -p ~/.continum
|
|
463
|
+
echo '{"apiUrl":"https://api.continum.dev","apiKey":"'$CONTINUM_API_KEY'"}' > ~/.continum/credentials.json
|
|
464
|
+
|
|
465
|
+
- name: Initialize Continum
|
|
466
|
+
run: continum init --silent
|
|
467
|
+
|
|
468
|
+
- name: Scan all files
|
|
469
|
+
run: continum scan $(git ls-files)
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
## Support
|
|
473
|
+
|
|
474
|
+
- Documentation: https://docs.continum.dev/cli
|
|
475
|
+
- Issues: GitHub Issues
|
|
476
|
+
- Discord: https://discord.gg/continum
|
|
477
|
+
- Email: support@continum.dev
|
|
478
|
+
|
|
479
|
+
## License
|
|
480
|
+
|
|
481
|
+
MIT
|