codeprobe-scanner 1.0.3 → 1.0.5
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/package.json +2 -2
- package/.claude/settings.local.json +0 -19
- package/.dockerignore +0 -17
- package/.env.development +0 -8
- package/.env.setup +0 -214
- package/.github/workflows/codeprobe-scan.yml +0 -137
- package/.github/workflows/codeprobe.yml +0 -84
- package/.github/workflows/scan-schedule.yml +0 -28
- package/ANALYSIS_SUMMARY.md +0 -365
- package/API_INTEGRATIONS.md +0 -469
- package/BUILD_PLAYBOOK.md +0 -349
- package/CLAUDE.md +0 -106
- package/DEPLOY.md +0 -452
- package/DEPLOYMENT_STATUS.md +0 -240
- package/DEPLOY_CHECKLIST.md +0 -316
- package/Dockerfile +0 -24
- package/EXECUTION_PLAN.html +0 -1086
- package/IMPLEMENTATION_COMPLETE.md +0 -288
- package/IMPLEMENTATION_SUMMARY.md +0 -443
- package/INTERACTIVE_FIX_FLOW.md +0 -308
- package/MIGRATION_COMPLETE.md +0 -327
- package/ORCHESTRATOR_SYNTHESIS.json +0 -80
- package/PENDING_WORK.md +0 -308
- package/PREFLIGHT_PLAN.md +0 -182
- package/QUICKSTART.md +0 -305
- package/STAGE_1_SETUP_ENGINE.md +0 -245
- package/STAGE_2_ARCHITECTURE.md +0 -714
- package/STAGE_2_CLI_VERIFICATION.md +0 -269
- package/STAGE_2_COMPLETE.md +0 -332
- package/STAGE_2_IMPLEMENTATION_PLAN.md +0 -679
- package/STAGE_3_COMPLETE.md +0 -246
- package/STAGE_3_DASHBOARD_POLISH.md +0 -371
- package/STAGE_3_SETUP.md +0 -155
- package/VIDEODB_INTEGRATION.md +0 -237
- package/archived/DASHBOARD_UI_WALKTHROUGH.md +0 -392
- package/archived/FRONTEND_SETUP.md +0 -236
- package/archived/auth.ts +0 -40
- package/archived/dashboard/components/BusinessImpactCard.tsx +0 -48
- package/archived/dashboard/components/CVETable.tsx +0 -104
- package/archived/dashboard/components/ErrorBoundary.tsx +0 -48
- package/archived/dashboard/components/PatchDiffViewer.tsx +0 -43
- package/archived/dashboard/components/RiskGauge.tsx +0 -64
- package/archived/dashboard/frontend.tsx +0 -104
- package/archived/dashboard/hooks/useAuth.ts +0 -32
- package/archived/dashboard/hooks/useScan.ts +0 -65
- package/archived/dashboard/index.html +0 -15
- package/archived/dashboard/pages/LoginPage.tsx +0 -28
- package/archived/dashboard/pages/ScanDetailPage.tsx +0 -143
- package/archived/dashboard/pages/ScansListPage.tsx +0 -160
- package/bun.lock +0 -603
- package/codeprobe-prd.md +0 -674
- package/cve-cache.json +0 -25
- package/demo-vulnerable-app/.github/workflows/codeprobe.yml +0 -32
- package/demo-vulnerable-app/README.md +0 -70
- package/demo-vulnerable-app/package-lock.json +0 -27
- package/demo-vulnerable-app/package.json +0 -15
- package/demo-vulnerable-app/server.js +0 -34
- package/demo.sh +0 -45
- package/index.ts +0 -19
- package/patches.json +0 -12
- package/serve-dashboard.ts +0 -23
- package/src/cli/index.ts +0 -137
- package/src/engine/index.ts +0 -90
- package/src/test/cli.test.ts +0 -211
- package/src/test/dashboard.test.ts +0 -38
- package/src/test/demo-scan.json +0 -32
- package/src/test/engine.test.ts +0 -157
- package/tailwind.config.js +0 -11
- package/tsconfig.json +0 -30
- package/verify-dashboard.ts +0 -87
- package/verify-env.sh +0 -98
- /package/bin/{codeprobe.js → codeprobe.cjs} +0 -0
package/STAGE_2_ARCHITECTURE.md
DELETED
|
@@ -1,714 +0,0 @@
|
|
|
1
|
-
# CodeProbe Stage 2: Architecture & Dependency Graph
|
|
2
|
-
|
|
3
|
-
**Visual Overview of CLI + Verification System**
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## System Architecture Diagram
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
┌─────────────────────────────────────────────────────────────────────┐
|
|
11
|
-
│ USER INVOCATION │
|
|
12
|
-
│ $ codeprobe scan <repo> [--fix] │
|
|
13
|
-
└────────────────────────────────┬────────────────────────────────────┘
|
|
14
|
-
│
|
|
15
|
-
┌────────────┴────────────┐
|
|
16
|
-
│ │
|
|
17
|
-
┌───────▼────────┐ ┌────────▼──────────┐
|
|
18
|
-
│ CLI Entry │ │ Config System │
|
|
19
|
-
│ index.ts │ │ config.ts │
|
|
20
|
-
│ │ │ │
|
|
21
|
-
│ • Route args │ │ • Load/save │
|
|
22
|
-
│ • Dispatch cmd │ │ • Encrypt token │
|
|
23
|
-
│ • Exit codes │ │ • Get API keys │
|
|
24
|
-
└────────┬────────┘ └──────────────────┘
|
|
25
|
-
│ ▲
|
|
26
|
-
│ │
|
|
27
|
-
┌────────────▼──────────────────────┘
|
|
28
|
-
│
|
|
29
|
-
│ ┌──────────────────────────────────────┐
|
|
30
|
-
└─▶│ Commands Router │
|
|
31
|
-
│ │
|
|
32
|
-
├─ scan.ts ──────────────────────────┐
|
|
33
|
-
│ • Parse repo path │
|
|
34
|
-
│ • Call runFullScan() │
|
|
35
|
-
│ • Format output │
|
|
36
|
-
│ • Save report │
|
|
37
|
-
│ │
|
|
38
|
-
├─ scan-with-fix.ts ────────────────┐
|
|
39
|
-
│ • Run scan first │
|
|
40
|
-
│ • Extract CVEs │
|
|
41
|
-
│ • Apply patches │
|
|
42
|
-
│ • Create git branch │
|
|
43
|
-
│ • Commit + push │
|
|
44
|
-
│ │
|
|
45
|
-
└─ report.ts ──────────────────────┐
|
|
46
|
-
• Read latest.json │
|
|
47
|
-
• Format as table │
|
|
48
|
-
• Export JSON/HTML │
|
|
49
|
-
│
|
|
50
|
-
├────────────────────────────────┤
|
|
51
|
-
│ │
|
|
52
|
-
┌──────▼───────┐ ┌─────────▼──────┐
|
|
53
|
-
│ Progress │ │ Errors │
|
|
54
|
-
│ progress.ts │ │ errors.ts │
|
|
55
|
-
│ │ │ │
|
|
56
|
-
│ • Event │ │ • Catch │
|
|
57
|
-
│ listener │ │ exceptions │
|
|
58
|
-
│ • Format │ │ • Map to │
|
|
59
|
-
│ output │ │ messages │
|
|
60
|
-
│ • Colors │ │ • Fallback │
|
|
61
|
-
│ • Timestamps │ │ triggers │
|
|
62
|
-
└───────┬───────┘ └────────┬──────┘
|
|
63
|
-
│ │
|
|
64
|
-
└────────────┬───────────────┘
|
|
65
|
-
│
|
|
66
|
-
┌────────▼────────────────┐
|
|
67
|
-
│ STAGE 1 ENGINE │
|
|
68
|
-
│ (External Dependency) │
|
|
69
|
-
│ │
|
|
70
|
-
│ • runFullScan() │
|
|
71
|
-
│ • Event Emitter │
|
|
72
|
-
│ • Report Builder │
|
|
73
|
-
│ • CVE Matcher │
|
|
74
|
-
│ • Sandbox Orchestrator │
|
|
75
|
-
└────────┬────────────────┘
|
|
76
|
-
│
|
|
77
|
-
┌────────────────────┼───────────────────────┐
|
|
78
|
-
│ │ │
|
|
79
|
-
│ ┌─────────▼────────┐ ┌─────────▼────────┐
|
|
80
|
-
│ │ Bright Data │ │ Daytona Sandbox │
|
|
81
|
-
│ │ (External API) │ │ (External API) │
|
|
82
|
-
│ │ │ │ │
|
|
83
|
-
│ │ • CVE scraping │ │ • PoC execution │
|
|
84
|
-
│ │ • Fallback cache │ │ • Verify exploit │
|
|
85
|
-
│ └───────────────────┘ └──────────────────┘
|
|
86
|
-
│
|
|
87
|
-
└─────────────────────────────────────────┐
|
|
88
|
-
│
|
|
89
|
-
┌─────────────▼───────────┐
|
|
90
|
-
│ Report Output │
|
|
91
|
-
│ │
|
|
92
|
-
├─ ~/.codeprobe/scans/ │
|
|
93
|
-
│ • {id}.json │
|
|
94
|
-
│ • latest.json (link) │
|
|
95
|
-
│ • File perms: 0600 │
|
|
96
|
-
│ │
|
|
97
|
-
├─ Git Changes (--fix) │
|
|
98
|
-
│ • New branch created │
|
|
99
|
-
│ • Patches applied │
|
|
100
|
-
│ • Commits signed │
|
|
101
|
-
│ │
|
|
102
|
-
└─ Terminal Output │
|
|
103
|
-
• Colored text │
|
|
104
|
-
• Progress events │
|
|
105
|
-
• Risk score display │
|
|
106
|
-
• Exit code: 0/1/2 │
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Data Flow Diagram (End-to-End)
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
START: codeprobe scan ./demo-vulnerable-app
|
|
115
|
-
│
|
|
116
|
-
├─ index.ts parses arguments
|
|
117
|
-
│ └─ repo_path = "./demo-vulnerable-app"
|
|
118
|
-
│ flags = { fix: false, json: false, verbose: false }
|
|
119
|
-
│
|
|
120
|
-
├─ config.ts loads API keys
|
|
121
|
-
│ ├─ Check env: BRIGHT_DATA_API_KEY, DAYTONA_API_KEY
|
|
122
|
-
│ └─ Fallback: ~/.codeprobe/config.json (decrypt token)
|
|
123
|
-
│
|
|
124
|
-
├─ scan.ts calls runFullScan(repo_path, { onEvent })
|
|
125
|
-
│ │
|
|
126
|
-
│ └─ STAGE 1 ENGINE TAKES OVER
|
|
127
|
-
│ │
|
|
128
|
-
│ ├─ parser.ts extracts dependencies
|
|
129
|
-
│ │ └─ emit: { phase: 'parsing', message: 'Found 8 deps' }
|
|
130
|
-
│ │
|
|
131
|
-
│ ├─ scraper.ts fetches CVE data
|
|
132
|
-
│ │ └─ emit: { phase: 'scraping', message: 'Found 3 CVEs' }
|
|
133
|
-
│ │
|
|
134
|
-
│ ├─ matcher.ts matches versions
|
|
135
|
-
│ │ └─ emit: { phase: 'matching', message: '2 matches' }
|
|
136
|
-
│ │
|
|
137
|
-
│ ├─ sandbox.ts spawns Daytona containers
|
|
138
|
-
│ │ └─ emit: { phase: 'sandboxing', message: 'Running PoC' }
|
|
139
|
-
│ │
|
|
140
|
-
│ ├─ sandbox.ts runs exploit
|
|
141
|
-
│ │ └─ exploit succeeds → exploitable: true
|
|
142
|
-
│ │ emit: { phase: 'verification', message: 'CONFIRMED' }
|
|
143
|
-
│ │
|
|
144
|
-
│ ├─ patcher.ts generates patches
|
|
145
|
-
│ │ └─ emit: { phase: 'patching', message: 'Patch ready' }
|
|
146
|
-
│ │
|
|
147
|
-
│ └─ report.ts builds report
|
|
148
|
-
│ └─ emit: { phase: 'report', message: 'Report complete' }
|
|
149
|
-
│
|
|
150
|
-
├─ progress.ts consumes events
|
|
151
|
-
│ │
|
|
152
|
-
│ ├─ on 'parsing': log "[12:34:56] Parsing dependencies..."
|
|
153
|
-
│ ├─ on 'scraping': log "[12:34:59] Found 3 CVEs"
|
|
154
|
-
│ ├─ on 'verification': log "[12:35:17] ✓ CONFIRMED EXPLOITABLE"
|
|
155
|
-
│ └─ on 'report': log "[12:35:20] Scan complete"
|
|
156
|
-
│
|
|
157
|
-
├─ errors.ts wraps try/catch
|
|
158
|
-
│ │
|
|
159
|
-
│ ├─ If Bright Data timeout:
|
|
160
|
-
│ │ ├─ Log warning: "❌ Bright Data failed"
|
|
161
|
-
│ │ └─ fallback: use cve-cache.json
|
|
162
|
-
│ │
|
|
163
|
-
│ ├─ If Daytona crash:
|
|
164
|
-
│ │ ├─ Log warning: "⚠️ Sandbox failed"
|
|
165
|
-
│ │ └─ Mark CVE: exploitable = false
|
|
166
|
-
│ │
|
|
167
|
-
│ └─ If network error:
|
|
168
|
-
│ ├─ Log error: "❌ Network error"
|
|
169
|
-
│ └─ Save partial results + exit 2
|
|
170
|
-
│
|
|
171
|
-
├─ scan.ts formats report
|
|
172
|
-
│ │
|
|
173
|
-
│ ├─ Table output:
|
|
174
|
-
│ │ │ CVE ID | Severity | Exploitable | Patch
|
|
175
|
-
│ │ │ CVE-2023-44487 | CRITICAL | ✓ | 1.0.1
|
|
176
|
-
│ │ │
|
|
177
|
-
│ ├─ Risk gauge:
|
|
178
|
-
│ │ │ Risk Score: 8.5/10 (HIGH)
|
|
179
|
-
│ │ │
|
|
180
|
-
│ └─ Summary:
|
|
181
|
-
│ │ Confirmed: 1 | Theoretical: 2
|
|
182
|
-
│
|
|
183
|
-
├─ report.ts saves JSON
|
|
184
|
-
│ │
|
|
185
|
-
│ ├─ File: ~/.codeprobe/scans/UUID.json
|
|
186
|
-
│ │ {
|
|
187
|
-
│ │ "scan": {
|
|
188
|
-
│ │ "id": "scan_abc123",
|
|
189
|
-
│ │ "timestamp": "2026-06-13T12:35:20Z",
|
|
190
|
-
│ │ "cves": [
|
|
191
|
-
│ │ {
|
|
192
|
-
│ │ "id": "CVE-2023-44487",
|
|
193
|
-
│ │ "exploitable": true,
|
|
194
|
-
│ │ "patch_diff": "...",
|
|
195
|
-
│ │ "patch_version": "1.0.1"
|
|
196
|
-
│ │ }
|
|
197
|
-
│ │ ],
|
|
198
|
-
│ │ "risk_score": 8.5
|
|
199
|
-
│ │ }
|
|
200
|
-
│ │ }
|
|
201
|
-
│ │
|
|
202
|
-
│ └─ Symlink: ~/.codeprobe/scans/latest.json → UUID.json
|
|
203
|
-
│ File perms: 0600 (owner read/write only)
|
|
204
|
-
│
|
|
205
|
-
└─ Exit code: 1 (vulnerabilities found)
|
|
206
|
-
|
|
207
|
-
IF --fix flag:
|
|
208
|
-
│
|
|
209
|
-
├─ scan-with-fix.ts extracts exploitable CVEs
|
|
210
|
-
│ └─ Found 1 confirmed exploit
|
|
211
|
-
│
|
|
212
|
-
├─ Git flow:
|
|
213
|
-
│ ├─ Check: git status (fail if dirty)
|
|
214
|
-
│ ├─ Create: git branch codeprobe-fix-20260613-001
|
|
215
|
-
│ ├─ Apply: patch to package.json
|
|
216
|
-
│ ├─ Validate: git apply --check
|
|
217
|
-
│ ├─ Commit: "[CodeProbe] Fix CVE-2023-44487"
|
|
218
|
-
│ └─ Push: git push -u origin codeprobe-fix-20260613-001
|
|
219
|
-
│
|
|
220
|
-
└─ Exit code: 0 (patches applied) or 1 (failed)
|
|
221
|
-
|
|
222
|
-
END: Return exit code + show next steps
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## Module Dependency Graph
|
|
228
|
-
|
|
229
|
-
```
|
|
230
|
-
Execution Dependency Graph
|
|
231
|
-
═════════════════════════════════════════
|
|
232
|
-
|
|
233
|
-
index.ts
|
|
234
|
-
├─ commands/scan.ts (no dependency on others)
|
|
235
|
-
├─ commands/scan-with-fix.ts (depends on scan.ts logic)
|
|
236
|
-
├─ commands/report.ts (no dependency on others)
|
|
237
|
-
├─ config.ts (no dependency on others)
|
|
238
|
-
└─ shared/types.ts (import from Stage 1 engine)
|
|
239
|
-
|
|
240
|
-
scan.ts
|
|
241
|
-
├─ config.ts (get API keys)
|
|
242
|
-
├─ progress.ts (log events)
|
|
243
|
-
├─ errors.ts (catch + handle errors)
|
|
244
|
-
├─ Stage 1 engine: runFullScan()
|
|
245
|
-
└─ shared/types.ts (Report type)
|
|
246
|
-
|
|
247
|
-
scan-with-fix.ts
|
|
248
|
-
├─ scan.ts (run scan first)
|
|
249
|
-
├─ config.ts (get GitHub token)
|
|
250
|
-
├─ errors.ts (handle git errors)
|
|
251
|
-
├─ Stage 1 patcher: patch generation
|
|
252
|
-
└─ Node.js: git commands
|
|
253
|
-
|
|
254
|
-
progress.ts
|
|
255
|
-
├─ shared/types.ts (ScanEvent interface)
|
|
256
|
-
└─ chalk (colors), dayjs (timestamps)
|
|
257
|
-
|
|
258
|
-
errors.ts
|
|
259
|
-
├─ chalk (colors)
|
|
260
|
-
└─ No other dependencies (reusable utilities)
|
|
261
|
-
|
|
262
|
-
config.ts
|
|
263
|
-
├─ fs (file system)
|
|
264
|
-
├─ path (file paths)
|
|
265
|
-
├─ crypto (AES-256-GCM encryption, chosen method)
|
|
266
|
-
└─ No other dependencies
|
|
267
|
-
|
|
268
|
-
report.ts
|
|
269
|
-
├─ config.ts (not needed if using latest.json)
|
|
270
|
-
├─ chalk (colors)
|
|
271
|
-
├─ table-cli (table formatting)
|
|
272
|
-
└─ shared/types.ts (Report type)
|
|
273
|
-
|
|
274
|
-
shared/types.ts
|
|
275
|
-
└─ Stage 1 engine: import { Scan, CVE, Report, ScanEvent } from '../engine'
|
|
276
|
-
|
|
277
|
-
shared/utils.ts
|
|
278
|
-
└─ chalk (colors)
|
|
279
|
-
|
|
280
|
-
shared/constants.ts
|
|
281
|
-
└─ No dependencies
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
## File Structure After Implementation
|
|
287
|
-
|
|
288
|
-
```
|
|
289
|
-
codeprobe/
|
|
290
|
-
├── src/
|
|
291
|
-
│ ├── cli/
|
|
292
|
-
│ │ ├── index.ts ← Entry point
|
|
293
|
-
│ │ ├── commands/
|
|
294
|
-
│ │ │ ├── scan.ts ← Main scan command
|
|
295
|
-
│ │ │ ├── scan-with-fix.ts ← Git integration
|
|
296
|
-
│ │ │ └── report.ts ← Display results
|
|
297
|
-
│ │ ├── config.ts ← Token + API key storage
|
|
298
|
-
│ │ ├── progress.ts ← Event → CLI formatting
|
|
299
|
-
│ │ ├── errors.ts ← Error handling + fallbacks
|
|
300
|
-
│ │ └── types.ts ← CLI-specific types
|
|
301
|
-
│ │
|
|
302
|
-
│ ├── engine/ ← Stage 1 (external)
|
|
303
|
-
│ │ ├── index.ts (runFullScan export)
|
|
304
|
-
│ │ ├── parser.ts
|
|
305
|
-
│ │ ├── scraper.ts
|
|
306
|
-
│ │ ├── sandbox.ts
|
|
307
|
-
│ │ ├── matcher.ts
|
|
308
|
-
│ │ ├── patcher.ts
|
|
309
|
-
│ │ └── report.ts
|
|
310
|
-
│ │
|
|
311
|
-
│ ├── shared/
|
|
312
|
-
│ │ ├── types.ts (Scan, CVE, Report, ScanEvent)
|
|
313
|
-
│ │ ├── constants.ts (timeouts, paths)
|
|
314
|
-
│ │ └── utils.ts (format score, colorize, etc.)
|
|
315
|
-
│ │
|
|
316
|
-
│ └── test/
|
|
317
|
-
│ ├── cli.test.ts (mocked engine tests)
|
|
318
|
-
│ └── e2e.cli.test.ts (real engine tests)
|
|
319
|
-
│
|
|
320
|
-
├── demo-vulnerable-app/ (Stage 1 creates this)
|
|
321
|
-
│ ├── package.json
|
|
322
|
-
│ └── server.js
|
|
323
|
-
│
|
|
324
|
-
├── package.json
|
|
325
|
-
├── tsconfig.json
|
|
326
|
-
├── .env.example
|
|
327
|
-
├── demo.sh
|
|
328
|
-
├── STAGE_2_IMPLEMENTATION_PLAN.md (this file's companion)
|
|
329
|
-
└── STAGE_2_ARCHITECTURE.md (this file)
|
|
330
|
-
|
|
331
|
-
Runtime State:
|
|
332
|
-
├── ~/.codeprobe/
|
|
333
|
-
│ ├── config.json (encrypted tokens)
|
|
334
|
-
│ └── scans/
|
|
335
|
-
│ ├── scan_abc123.json (report JSON)
|
|
336
|
-
│ ├── scan_def456.json
|
|
337
|
-
│ └── latest.json (symlink to most recent)
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
---
|
|
341
|
-
|
|
342
|
-
## Event Flow Sequence (Phase by Phase)
|
|
343
|
-
|
|
344
|
-
```
|
|
345
|
-
Timeline of Events During codeprobe scan ./demo-vulnerable-app
|
|
346
|
-
═══════════════════════════════════════════════════════════════════
|
|
347
|
-
|
|
348
|
-
T=0:00 index.ts dispatches 'scan' command
|
|
349
|
-
└─ scan.ts::runFullScan()
|
|
350
|
-
│
|
|
351
|
-
T=0:02 EVENT: { phase: 'parsing', status: 'start', message: 'Parsing dependencies...' }
|
|
352
|
-
progress.ts: "[00:00:02] Parsing dependencies..."
|
|
353
|
-
│
|
|
354
|
-
T=0:04 EVENT: { phase: 'parsing', status: 'complete', message: 'Found 8 dependencies' }
|
|
355
|
-
progress.ts: "[00:00:04] ✓ Found 8 dependencies"
|
|
356
|
-
│
|
|
357
|
-
T=0:05 EVENT: { phase: 'scraping', status: 'start', message: 'Fetching CVE data...' }
|
|
358
|
-
progress.ts: "[00:00:05] Fetching CVE data (Bright Data)..."
|
|
359
|
-
│
|
|
360
|
-
[Bright Data API call — 5s typical]
|
|
361
|
-
│
|
|
362
|
-
T=0:20 EVENT: { phase: 'scraping', status: 'complete', message: 'Found 3 CVEs' }
|
|
363
|
-
progress.ts: "[00:00:20] ✓ Found 3 CVEs"
|
|
364
|
-
│
|
|
365
|
-
T=0:21 EVENT: { phase: 'matching', status: 'complete', message: '2 matches' }
|
|
366
|
-
progress.ts: "[00:00:21] Matched 2 CVEs"
|
|
367
|
-
│
|
|
368
|
-
T=0:22 EVENT: { phase: 'sandboxing', status: 'start', message: 'Spinning up sandbox...' }
|
|
369
|
-
progress.ts: "[00:00:22] Spinning up sandboxes for CRITICAL CVEs..."
|
|
370
|
-
│
|
|
371
|
-
[Daytona provisioning — 15s typical]
|
|
372
|
-
│
|
|
373
|
-
T=0:37 EVENT: { phase: 'sandboxing', status: 'complete', message: 'Sandbox ready' }
|
|
374
|
-
progress.ts: "[00:00:37] Sandbox 1: CVE-2023-44487 ready"
|
|
375
|
-
│
|
|
376
|
-
T=0:38 EVENT: { phase: 'verification', status: 'start', message: 'Running exploit...' }
|
|
377
|
-
progress.ts: "[00:00:38] Running exploit..."
|
|
378
|
-
│
|
|
379
|
-
[PoC execution — 60s typical]
|
|
380
|
-
│
|
|
381
|
-
T=1:38 EVENT: { phase: 'verification', status: 'complete', message: 'CONFIRMED EXPLOITABLE' }
|
|
382
|
-
progress.ts: "[00:01:38] ✓ CONFIRMED EXPLOITABLE (0.8s DoS achieved)"
|
|
383
|
-
│
|
|
384
|
-
T=1:39 EVENT: { phase: 'patching', status: 'complete', message: 'Patch ready' }
|
|
385
|
-
progress.ts: "[00:01:39] Patch available: http2-server 1.0.0 → 1.0.1"
|
|
386
|
-
│
|
|
387
|
-
T=1:40 EVENT: { phase: 'report', status: 'complete', message: 'Report generated' }
|
|
388
|
-
progress.ts: "[00:01:40] Report complete"
|
|
389
|
-
│
|
|
390
|
-
T=1:41 scan.ts displays summary:
|
|
391
|
-
┌────────────────────────────────┐
|
|
392
|
-
│ SCAN COMPLETE │
|
|
393
|
-
│ Risk Score: 8.5/10 (HIGH) │
|
|
394
|
-
│ Confirmed: 1 | Theoretical: 2 │
|
|
395
|
-
│ Patches: 1 available │
|
|
396
|
-
└────────────────────────────────┘
|
|
397
|
-
│
|
|
398
|
-
T=1:42 report.ts saves to ~/.codeprobe/scans/scan_abc.json
|
|
399
|
-
└─ sets permissions 0600
|
|
400
|
-
updates latest.json symlink
|
|
401
|
-
│
|
|
402
|
-
T=1:43 exit code: 1 (vulnerabilities found)
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
---
|
|
406
|
-
|
|
407
|
-
## Fallback Cascade Diagram
|
|
408
|
-
|
|
409
|
-
```
|
|
410
|
-
Fallback Strategy: What Happens When APIs Fail
|
|
411
|
-
═════════════════════════════════════════════════
|
|
412
|
-
|
|
413
|
-
Scenario 1: Bright Data API timeout (>5s)
|
|
414
|
-
─────────────────────────────────────────
|
|
415
|
-
errors.ts catches timeout
|
|
416
|
-
│
|
|
417
|
-
├─ Log warning: "❌ Bright Data API failed (timeout)"
|
|
418
|
-
├─ Check for cache file: cve-cache.json exists?
|
|
419
|
-
│ │
|
|
420
|
-
│ ├─ If yes:
|
|
421
|
-
│ │ └─ Load cached CVE data (may be stale)
|
|
422
|
-
│ │ Log: "→ Using cached CVE data (updated 6h ago)"
|
|
423
|
-
│ │
|
|
424
|
-
│ └─ If no:
|
|
425
|
-
│ └─ Fail scan with error
|
|
426
|
-
│ Log: "❌ No cache available. Configure BRIGHT_DATA_API_KEY"
|
|
427
|
-
│
|
|
428
|
-
└─ Scan continues with cached data
|
|
429
|
-
Risk: CVEs may be outdated
|
|
430
|
-
Mitigation: Show "Cache timestamp" in output
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
Scenario 2: Daytona sandbox crash (provisioning fails)
|
|
434
|
-
─────────────────────────────────────────────────────
|
|
435
|
-
sandbox.ts catches error
|
|
436
|
-
│
|
|
437
|
-
├─ Retry once (total 2 attempts)
|
|
438
|
-
├─ If retry succeeds:
|
|
439
|
-
│ └─ Continue normally
|
|
440
|
-
│
|
|
441
|
-
└─ If retry fails:
|
|
442
|
-
├─ Log error: "⚠️ Sandbox verification failed (Daytona unavailable)"
|
|
443
|
-
├─ Mark CVE: exploitable = false
|
|
444
|
-
├─ Status: "Verification failed" (shown in output)
|
|
445
|
-
└─ Scan continues with theoretical results only
|
|
446
|
-
Risk: Exploit status unknown
|
|
447
|
-
Mitigation: Clearly mark as "unverified"
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
Scenario 3: LLM patch generation fails (Nosana timeout)
|
|
451
|
-
──────────────────────────────────────────────────────
|
|
452
|
-
patcher.ts catches error
|
|
453
|
-
│
|
|
454
|
-
├─ Retry once (total 2 attempts)
|
|
455
|
-
├─ If retry succeeds:
|
|
456
|
-
│ └─ Use generated patch
|
|
457
|
-
│
|
|
458
|
-
└─ If retry fails:
|
|
459
|
-
├─ Check for pre-baked patch
|
|
460
|
-
├─ If pre-baked exists:
|
|
461
|
-
│ └─ Use pre-baked patch
|
|
462
|
-
│ Log: "→ Using pre-baked patch for CVE-2023-44487"
|
|
463
|
-
│
|
|
464
|
-
└─ If no pre-baked:
|
|
465
|
-
└─ Show "Patch generation failed"
|
|
466
|
-
Log: "⚠️ Manual patch needed for CVE-2023-44487"
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
Scenario 4: Network interruption mid-scan
|
|
470
|
-
──────────────────────────────────────────
|
|
471
|
-
errors.ts catches network error
|
|
472
|
-
│
|
|
473
|
-
├─ Determine: where in pipeline did it fail?
|
|
474
|
-
├─ Save: partial results to ~/.codeprobe/scans/{id}-partial.json
|
|
475
|
-
├─ Log: "❌ Network interrupted at {phase}"
|
|
476
|
-
├─ Log: "Partial results saved to {path}"
|
|
477
|
-
└─ Exit code: 2 (scan failed)
|
|
478
|
-
User guidance: "Try again when online. Resume data cached."
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
Scenario 5: Git dirty repo on --fix
|
|
482
|
-
───────────────────────────────────
|
|
483
|
-
scan-with-fix.ts checks git status
|
|
484
|
-
│
|
|
485
|
-
├─ git status shows uncommitted changes
|
|
486
|
-
├─ Log warning: "⚠️ Git repository is dirty"
|
|
487
|
-
├─ Log guidance: "Commit or stash changes first:"
|
|
488
|
-
├─ Log: "git add . && git commit -m 'WIP'"
|
|
489
|
-
└─ Exit code: 2 (operation failed)
|
|
490
|
-
User action: commit locally, then retry
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
---
|
|
494
|
-
|
|
495
|
-
## Security Boundaries Diagram
|
|
496
|
-
|
|
497
|
-
```
|
|
498
|
-
Security Model: What's Protected & What's Exposed
|
|
499
|
-
════════════════════════════════════════════════════
|
|
500
|
-
|
|
501
|
-
┌─────────────────────────────────────────────────────────┐
|
|
502
|
-
│ User's Local Machine │
|
|
503
|
-
│ │
|
|
504
|
-
│ ┌────────────────────────────────────────────────┐ │
|
|
505
|
-
│ │ ~/.codeprobe/ (Owner Read/Write Only, 0700) │ │
|
|
506
|
-
│ │ │ │
|
|
507
|
-
│ │ ├─ config.json (Encrypted Tokens, 0600) │ │
|
|
508
|
-
│ │ │ └─ BRIGHT_DATA_API_KEY (AES-256-GCM) │ │
|
|
509
|
-
│ │ │ DAYTONA_API_KEY (AES-256-GCM) │ │
|
|
510
|
-
│ │ │ GITHUB_TOKEN (AES-256-GCM) │ │
|
|
511
|
-
│ │ │ │ │
|
|
512
|
-
│ │ └─ scans/ (Directory, 0700) │ │
|
|
513
|
-
│ │ ├─ scan_abc123.json (Report, 0600) │ │
|
|
514
|
-
│ │ ├─ scan_def456.json (Report, 0600) │ │
|
|
515
|
-
│ │ └─ latest.json (Symlink) │ │
|
|
516
|
-
│ │ └─ Contains: │ │
|
|
517
|
-
│ │ • CVE IDs + severities │ │
|
|
518
|
-
│ │ • Exploitable status │ │
|
|
519
|
-
│ │ • Patch diffs │ │
|
|
520
|
-
│ │ • PoC evidence │ │
|
|
521
|
-
│ │ │ │
|
|
522
|
-
│ └────────────────────────────────────────────────┘ │
|
|
523
|
-
│ │
|
|
524
|
-
│ Threat Model: │
|
|
525
|
-
│ ✓ Local user (owner): Can read config + reports │
|
|
526
|
-
│ ✓ Owner runs `git push`: GitHub token retrieved │
|
|
527
|
-
│ ✗ Other user on machine: Cannot read config/reports │
|
|
528
|
-
│ ✗ SSH session: Cannot access ~/.codeprobe without │
|
|
529
|
-
│ escalation │
|
|
530
|
-
│ ✗ Malware/injection: Would need user-level access │
|
|
531
|
-
│ (out of scope for MVP) │
|
|
532
|
-
│ │
|
|
533
|
-
└─────────────────────────────────────────────────────────┘
|
|
534
|
-
|
|
535
|
-
Network Boundaries:
|
|
536
|
-
═══════════════════
|
|
537
|
-
|
|
538
|
-
CLI ←→ Bright Data (encrypted HTTPS)
|
|
539
|
-
└─ Sends: dependency names + versions
|
|
540
|
-
Returns: CVE metadata (public info)
|
|
541
|
-
|
|
542
|
-
CLI ←→ Daytona (authenticated API key)
|
|
543
|
-
└─ Sends: PoC exploit script
|
|
544
|
-
Returns: sandbox stdout/stderr
|
|
545
|
-
Note: Code execution in isolated container
|
|
546
|
-
|
|
547
|
-
CLI ←→ Nosana/Claude (authenticated API key, optional)
|
|
548
|
-
└─ Sends: CVE details + code
|
|
549
|
-
Returns: patch diffs
|
|
550
|
-
Encryption: TLS only (no end-to-end crypto)
|
|
551
|
-
Note: User code sent to third-party if LLM needed
|
|
552
|
-
|
|
553
|
-
GitHub ←→ CLI (git + HTTPS with token)
|
|
554
|
-
└─ Sends: branch + commits via authenticated push
|
|
555
|
-
Uses: GitHub token from config.json
|
|
556
|
-
Security: Token must be kept secret
|
|
557
|
-
|
|
558
|
-
User (Manual) ←→ Git Repo (ssh/https)
|
|
559
|
-
└─ Reviews: auto-generated branch + patch
|
|
560
|
-
Accepts: pulls to main (user decision)
|
|
561
|
-
Safety: Pull request review gate recommended
|
|
562
|
-
```
|
|
563
|
-
|
|
564
|
-
---
|
|
565
|
-
|
|
566
|
-
## Test Coverage Map
|
|
567
|
-
|
|
568
|
-
```
|
|
569
|
-
Test Layers & Coverage
|
|
570
|
-
════════════════════════════════════════════════════════════════════
|
|
571
|
-
|
|
572
|
-
Layer 1: Unit Tests (Mocked Engine)
|
|
573
|
-
───────────────────────────────────────
|
|
574
|
-
File: src/test/cli.test.ts
|
|
575
|
-
Run: bun test src/test/cli.test.ts
|
|
576
|
-
Environment: Offline, mocked engine, no API calls
|
|
577
|
-
Runnable Now: ✓ Yes (before Stage 1 ready)
|
|
578
|
-
|
|
579
|
-
Tests:
|
|
580
|
-
✓ CLI entry point parses args
|
|
581
|
-
✓ Config loads/saves correctly
|
|
582
|
-
✓ Config encryption roundtrip
|
|
583
|
-
✓ Error handling: Bright Data timeout
|
|
584
|
-
✓ Error handling: Daytona crash
|
|
585
|
-
✓ Error handling: Network error
|
|
586
|
-
✓ Progress formatting (colors, timestamps)
|
|
587
|
-
✓ Scan command exit codes (0, 1, 2)
|
|
588
|
-
✓ --json flag outputs valid JSON
|
|
589
|
-
✓ --fix flag creates git branch
|
|
590
|
-
✓ --fix flag applies patch
|
|
591
|
-
✓ Report formatting (table)
|
|
592
|
-
✓ Fallback logic: cache used on timeout
|
|
593
|
-
✓ Fallback logic: patch applied despite sandbox fail
|
|
594
|
-
✓ Permission checks: 0600 on report files
|
|
595
|
-
|
|
596
|
-
Coverage: ~85% (mocked dependencies)
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
Layer 2: Integration Tests (Real Engine, Same Machine)
|
|
600
|
-
──────────────────────────────────────────────────────────
|
|
601
|
-
File: src/test/e2e.cli.test.ts
|
|
602
|
-
Run: bun test src/test/e2e.cli.test.ts
|
|
603
|
-
Environment: Real Stage 1 engine, demo repo, real Bright Data
|
|
604
|
-
Runnable After: Stage 1 ready (Hour 3)
|
|
605
|
-
|
|
606
|
-
Tests:
|
|
607
|
-
✓ Full scan pipeline: parse → scrape → verify → report
|
|
608
|
-
✓ Report saved to correct path (~/.codeprobe/scans/{id}.json)
|
|
609
|
-
✓ Exit code 1 when CVEs found
|
|
610
|
-
✓ Exit code 0 when no CVEs
|
|
611
|
-
✓ Output contains "CONFIRMED EXPLOITABLE" for demo CVE
|
|
612
|
-
✓ latest.json symlink updated
|
|
613
|
-
✓ --fix creates real git branch
|
|
614
|
-
✓ --fix commits patches
|
|
615
|
-
✓ Timing: scan completes in <3 minutes
|
|
616
|
-
✓ Timing breakdown per phase
|
|
617
|
-
|
|
618
|
-
Coverage: ~95% (real endpoints)
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
Layer 3: Manual/Demo Tests
|
|
622
|
-
──────────────────────────────
|
|
623
|
-
File: demo.sh
|
|
624
|
-
Run: bash demo.sh && time bash demo.sh
|
|
625
|
-
Environment: Real system, real repo, real APIs
|
|
626
|
-
Runnable After: Stage 2 + Stage 1 complete (Hour 3.5)
|
|
627
|
-
|
|
628
|
-
Scenarios:
|
|
629
|
-
✓ Full demo from scratch (clean cache)
|
|
630
|
-
✓ Timing <3 minutes
|
|
631
|
-
✓ Git branch created + visible
|
|
632
|
-
✓ Report readable by human
|
|
633
|
-
✓ Fallback video recorded (Bright Data timeout)
|
|
634
|
-
|
|
635
|
-
Coverage: ~100% (complete flow)
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
---
|
|
639
|
-
|
|
640
|
-
## Deployment / Runtime Checklist
|
|
641
|
-
|
|
642
|
-
```
|
|
643
|
-
Before Hackathon Demo:
|
|
644
|
-
════════════════════════════════════════════════════════════════════
|
|
645
|
-
|
|
646
|
-
Pre-Flight (30 minutes before demo):
|
|
647
|
-
─────────────────────────────────────
|
|
648
|
-
□ Start fresh: rm -rf ~/.codeprobe/scans/*
|
|
649
|
-
□ Run dry-run scan: bun run src/cli/index.ts scan ./demo-vulnerable-app
|
|
650
|
-
└─ Verify: "CONFIRMED EXPLOITABLE" appears
|
|
651
|
-
└─ Verify: Risk score displays
|
|
652
|
-
└─ Verify: Timing <3 min
|
|
653
|
-
□ Verify git: git branch (no codeprobe-fix branches)
|
|
654
|
-
□ Start API server: bun run src/api/server.ts (if dashboard included)
|
|
655
|
-
□ Test OAuth: Can you log in?
|
|
656
|
-
□ Check network: ping to Bright Data / Daytona working
|
|
657
|
-
□ Backup: Have fallback video ready (demo-fallback-video.mp4)
|
|
658
|
-
□ Power: Plug in laptop, have cable ready
|
|
659
|
-
|
|
660
|
-
During Demo (Judges Watching):
|
|
661
|
-
───────────────────────────────
|
|
662
|
-
1. CLI Demo (0–1 min):
|
|
663
|
-
$ codeprobe scan ./demo-vulnerable-app
|
|
664
|
-
└─ Show real-time progress
|
|
665
|
-
└─ Highlight "CONFIRMED EXPLOITABLE"
|
|
666
|
-
|
|
667
|
-
2. Dashboard Demo (1–1.5 min):
|
|
668
|
-
$ open http://localhost:3000
|
|
669
|
-
└─ Login with GitHub OAuth
|
|
670
|
-
└─ Show scan results
|
|
671
|
-
└─ Highlight risk score + business impact
|
|
672
|
-
|
|
673
|
-
3. Patch Application (1.5–2 min):
|
|
674
|
-
$ codeprobe scan ./demo-vulnerable-app --fix
|
|
675
|
-
$ git branch | grep codeprobe-fix
|
|
676
|
-
└─ Show auto-created branch
|
|
677
|
-
└─ Explain: judges could merge PR to fix
|
|
678
|
-
|
|
679
|
-
If Live Demo Fails (After 30s of issues):
|
|
680
|
-
──────────────────────────────────────────
|
|
681
|
-
▶ Switch to fallback video
|
|
682
|
-
▶ Walk judges through code
|
|
683
|
-
▶ Show GitHub bot PR commenting (if built)
|
|
684
|
-
▶ Explain: "Architecture is sound, API latency unexpected today"
|
|
685
|
-
```
|
|
686
|
-
|
|
687
|
-
---
|
|
688
|
-
|
|
689
|
-
## Summary
|
|
690
|
-
|
|
691
|
-
**Stage 2 is the bridge between:**
|
|
692
|
-
- **Input**: Stage 1 engine exports + user CLI args
|
|
693
|
-
- **Processing**: Event streams, error handling, fallbacks
|
|
694
|
-
- **Output**: Terminal UI + JSON reports + git branches
|
|
695
|
-
|
|
696
|
-
**Key Design Decisions:**
|
|
697
|
-
1. **Event-driven** (not polling) — Stage 1 emits, Stage 2 listens
|
|
698
|
-
2. **Graceful fallbacks** — Demo works even if APIs fail
|
|
699
|
-
3. **Local-first** — Reports saved to `~/.codeprobe/`, no database needed
|
|
700
|
-
4. **Git-native** — Uses git commands directly, no wrapper library
|
|
701
|
-
5. **Security-conscious** — Encrypted token storage, file permissions, no silent failures
|
|
702
|
-
|
|
703
|
-
**Critical Dependencies:**
|
|
704
|
-
- Stage 1 contract (interface specification locked)
|
|
705
|
-
- Token encryption decision (blocks config.ts)
|
|
706
|
-
- Demo vulnerable app (provided by Stage 1)
|
|
707
|
-
- Pre-baked patches (provided by Stage 1)
|
|
708
|
-
|
|
709
|
-
**Success Metrics:**
|
|
710
|
-
- `bun test` passes (all tests)
|
|
711
|
-
- `demo.sh` completes <3 minutes
|
|
712
|
-
- `codeprobe scan --fix` creates real git branch
|
|
713
|
-
- Output is colorized, timestamped, readable
|
|
714
|
-
- Fallbacks work (cache on Bright Data fail, continue on Daytona fail)
|