codeprobe-scanner 1.0.4 → 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 +1 -1
- 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/INTERACTIVE_FIX_FLOW.md
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
# CodeProbe Interactive Fix Flow
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The `--fix` mode enables an **interactive vulnerability patching workflow** that:
|
|
6
|
-
1. **Scans** the repository for vulnerabilities
|
|
7
|
-
2. **Reviews** patches with the user before applying
|
|
8
|
-
3. **Applies** patches to local files
|
|
9
|
-
4. **Commits** changes with meaningful messages
|
|
10
|
-
5. **Pushes** to a new branch
|
|
11
|
-
6. **Creates** a pull request automatically
|
|
12
|
-
|
|
13
|
-
## Complete Flow
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
User: codeprobe scan . --fix
|
|
17
|
-
↓
|
|
18
|
-
[1] SCAN PHASE
|
|
19
|
-
- Parse package.json locally
|
|
20
|
-
- POST dependencies to server
|
|
21
|
-
- Server runs full scan:
|
|
22
|
-
* Scrapes CVEs (Bright Data)
|
|
23
|
-
* Tests exploits (Daytona sandbox)
|
|
24
|
-
* Generates patches (Kimi/Nosana LLM)
|
|
25
|
-
- Returns scan results with patch_diff
|
|
26
|
-
↓
|
|
27
|
-
[2] INTERACTIVE REVIEW
|
|
28
|
-
For each CVE with a patch available:
|
|
29
|
-
- Show CVE details (CVSS, description)
|
|
30
|
-
- Show the unified diff
|
|
31
|
-
- Prompt: "Apply this patch? (yes/no/skip/view-details)"
|
|
32
|
-
|
|
33
|
-
User can:
|
|
34
|
-
- "yes/y" → Mark for patching
|
|
35
|
-
- "no/n" → Skip this CVE
|
|
36
|
-
- "skip/s" → Skip this CVE
|
|
37
|
-
- Other → Show more details
|
|
38
|
-
↓
|
|
39
|
-
[3] FINAL APPROVAL
|
|
40
|
-
Show summary:
|
|
41
|
-
- "Will apply X patches"
|
|
42
|
-
- Prompt: "Proceed with patches? (yes/no)"
|
|
43
|
-
↓
|
|
44
|
-
[4] APPLY PATCHES
|
|
45
|
-
If user approves:
|
|
46
|
-
- Create new branch: codeprobe-security-fixes-{timestamp}
|
|
47
|
-
- Modify package.json with fixed versions
|
|
48
|
-
- Run: npm install / bun install (optional)
|
|
49
|
-
↓
|
|
50
|
-
[5] COMMIT
|
|
51
|
-
- git add package.json
|
|
52
|
-
- git commit -m "security: patch N vulnerabilities via codeprobe"
|
|
53
|
-
- Show: "✓ Committed with message..."
|
|
54
|
-
↓
|
|
55
|
-
[6] PUSH
|
|
56
|
-
- git push -u origin codeprobe-security-fixes-{timestamp}
|
|
57
|
-
- Show: "✓ Pushed to origin/codeprobe-security-fixes-{timestamp}"
|
|
58
|
-
↓
|
|
59
|
-
[7] CREATE PR
|
|
60
|
-
- gh pr create --title "Security: Patch N vulnerabilities"
|
|
61
|
-
- Includes CVE list, risk score, exploitable count
|
|
62
|
-
- Show: "✓ PR created! Opening in browser..."
|
|
63
|
-
- Show PR URL
|
|
64
|
-
↓
|
|
65
|
-
Done! User reviews PR, tests, and merges if approved
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## API Flow (Server-Side)
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
POST /api/scan
|
|
72
|
-
├─ Parse dependencies from package.json
|
|
73
|
-
├─ [Bright Data] Scrape CVE databases
|
|
74
|
-
│ └─ Bearer token: c9cbd1ab-937a-4ee1-b6b5-13e90f957438
|
|
75
|
-
├─ [Daytona] Run exploits in sandbox
|
|
76
|
-
│ └─ API key: dtn_e4e5fd8c6c30f5b9da9453078f6b4e396202e56c0aaa1260e704e34d1380d2dc
|
|
77
|
-
├─ [Kimi LLM] Generate patches
|
|
78
|
-
│ ├─ Prompt engineer the CVE → patch
|
|
79
|
-
│ ├─ API: https://api.aimlapi.com/v1/chat/completions
|
|
80
|
-
│ ├─ Model: moonshot/kimi-k2-5
|
|
81
|
-
│ └─ API key: sk-lYLn5p8nepNgraaEC63XoOt1ZlHQGkudLJ12QwO4N6teJHVJ
|
|
82
|
-
├─ [Nosana] Fallback patch generation
|
|
83
|
-
│ ├─ GPU inference job for patch generation
|
|
84
|
-
│ ├─ API: https://api.nosana.com/v1/jobs
|
|
85
|
-
│ └─ API key: nos_jNqyjmvmboO-tU5nuuLH9T7oIx6p6Xw7mKHG36yQAI4
|
|
86
|
-
└─ Return Report with patch_diff populated
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## CLI Flow (Client-Side)
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
codeprobe scan . --fix
|
|
93
|
-
├─ Parse scan args (path, --fix, --json, etc.)
|
|
94
|
-
├─ Parse dependencies locally (package.json)
|
|
95
|
-
├─ POST to SERVER_URL/api/scan
|
|
96
|
-
├─ [INTERACTIVE] reviewAndApplyPatches()
|
|
97
|
-
│ ├─ For each CVE with patch_diff:
|
|
98
|
-
│ │ ├─ Show details (CVSS, description)
|
|
99
|
-
│ │ ├─ Show unified diff
|
|
100
|
-
│ │ ├─ promptUser("Apply this patch?")
|
|
101
|
-
│ │ └─ Mark if approved
|
|
102
|
-
│ ├─ Show summary
|
|
103
|
-
│ ├─ promptUser("Proceed with patches?")
|
|
104
|
-
│ └─ Return approved = true/false
|
|
105
|
-
├─ [GIT] applyPatchesAndCreatePR()
|
|
106
|
-
│ ├─ git checkout -b codeprobe-security-fixes-{timestamp}
|
|
107
|
-
│ ├─ Modify package.json (update versions)
|
|
108
|
-
│ ├─ git add package.json
|
|
109
|
-
│ ├─ git commit -m "security: patch N vulnerabilities via codeprobe"
|
|
110
|
-
│ ├─ git push -u origin {branchName}
|
|
111
|
-
│ ├─ gh pr create --title "..." --body "..."
|
|
112
|
-
│ └─ Show PR URL
|
|
113
|
-
└─ Exit with code 0 (success)
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Example Session
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
$ codeprobe scan /path/to/app --fix
|
|
120
|
-
|
|
121
|
-
⚡ CodeProbe Scanner v1.0.0
|
|
122
|
-
Scanning: /path/to/app
|
|
123
|
-
Parsing dependencies...
|
|
124
|
-
Sending to server...
|
|
125
|
-
|
|
126
|
-
📋 Review Patches
|
|
127
|
-
|
|
128
|
-
1. CVE-2022-29078 (ejs@3.1.6 → 3.1.7)
|
|
129
|
-
Severity: CRITICAL | CVSS: 9.8
|
|
130
|
-
EJS before 3.1.7 allows template injection attacks with arbitrary code execution
|
|
131
|
-
|
|
132
|
-
Proposed changes:
|
|
133
|
-
--- a/package.json
|
|
134
|
-
+++ b/package.json
|
|
135
|
-
@@ -5,1 +5,1 @@
|
|
136
|
-
- "ejs": "3.1.6"
|
|
137
|
-
+ "ejs": "3.1.7"
|
|
138
|
-
|
|
139
|
-
Apply this patch? (yes/no/skip/view-details): yes
|
|
140
|
-
✓ Marked for patching: CVE-2022-29078
|
|
141
|
-
|
|
142
|
-
📦 Summary
|
|
143
|
-
Will apply 1 patch(es)
|
|
144
|
-
|
|
145
|
-
Proceed with patches? (yes/no): yes
|
|
146
|
-
|
|
147
|
-
🔧 Applying Patches
|
|
148
|
-
|
|
149
|
-
Creating branch: codeprobe-security-fixes-1718365539291
|
|
150
|
-
Updating package.json...
|
|
151
|
-
✓ Updated ejs to ^3.1.7
|
|
152
|
-
Committing changes...
|
|
153
|
-
✓ Committed with message: "security: patch 1 vulnerability via codeprobe"
|
|
154
|
-
Pushing to remote...
|
|
155
|
-
✓ Pushed to origin/codeprobe-security-fixes-1718365539291
|
|
156
|
-
Creating pull request...
|
|
157
|
-
✓ PR created! Opening in browser...
|
|
158
|
-
https://github.com/user/repo/pull/42
|
|
159
|
-
|
|
160
|
-
✨ Done! Your security patches are ready for review.
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Normal Scan Mode (Without --fix)
|
|
164
|
-
|
|
165
|
-
For CI/CD and non-interactive use:
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
$ codeprobe scan /path/to/app
|
|
169
|
-
|
|
170
|
-
⚡ CodeProbe Scanner v1.0.0
|
|
171
|
-
Scanning: /path/to/app
|
|
172
|
-
|
|
173
|
-
CodeProbe Vulnerability Report
|
|
174
|
-
════════════════════════════════════
|
|
175
|
-
|
|
176
|
-
Summary:
|
|
177
|
-
Total CVEs: 2
|
|
178
|
-
Exploitable: 1
|
|
179
|
-
Theoretical: 1
|
|
180
|
-
Risk Score: 9.5/10
|
|
181
|
-
|
|
182
|
-
Vulnerabilities:
|
|
183
|
-
─────────────────
|
|
184
|
-
|
|
185
|
-
CVE-2022-29078 CRITICAL
|
|
186
|
-
Package: ejs@3.1.6
|
|
187
|
-
CVSS: 9.8/10
|
|
188
|
-
Status: EXPLOITABLE
|
|
189
|
-
Fixed in: 3.1.7
|
|
190
|
-
|
|
191
|
-
✓ Powered by Bright Data | Daytona | Nosana
|
|
192
|
-
|
|
193
|
-
$ echo $?
|
|
194
|
-
1 # Exit code 1 = vulnerabilities found
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## Environment Variables Required
|
|
198
|
-
|
|
199
|
-
### On Local Machine
|
|
200
|
-
```bash
|
|
201
|
-
# Server configuration
|
|
202
|
-
SERVER_URL=http://localhost:8080 # or your cloud URL
|
|
203
|
-
CODEPROBE_SECRET=random-secret # Shared secret with server
|
|
204
|
-
|
|
205
|
-
# Optional: for GitHub PR creation
|
|
206
|
-
export GH_TOKEN=github_token_here # Set via `gh auth login` instead
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### On Server
|
|
210
|
-
```bash
|
|
211
|
-
# Sponsor APIs (in .env)
|
|
212
|
-
BRIGHT_DATA_API_KEY=c9cbd1ab-937a-4ee1-b6b5-13e90f957438
|
|
213
|
-
DAYTONA_API_KEY=dtn_e4e5fd8c6c30f5b9da9453078f6b4e396202e56c0aaa1260e704e34d1380d2dc
|
|
214
|
-
NOSANA_API_KEY=nos_jNqyjmvmboO-tU5nuuLH9T7oIx6p6Xw7mKHG36yQAI4
|
|
215
|
-
KIMI_API_KEY=sk-lYLn5p8nepNgraaEC63XoOt1ZlHQGkudLJ12QwO4N6teJHVJ
|
|
216
|
-
|
|
217
|
-
# Server configuration
|
|
218
|
-
PORT=8080
|
|
219
|
-
NODE_ENV=development
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Key Features
|
|
223
|
-
|
|
224
|
-
✅ **Real Patch Generation**
|
|
225
|
-
- Kimi K2.5 LLM with long context windows
|
|
226
|
-
- Nosana GPU inference as fallback
|
|
227
|
-
- Pre-baked patches for known CVEs
|
|
228
|
-
|
|
229
|
-
✅ **Real Exploit Verification**
|
|
230
|
-
- Daytona sandboxes for RCE testing
|
|
231
|
-
- Automatic fallback to simulation
|
|
232
|
-
|
|
233
|
-
✅ **Real CVE Data**
|
|
234
|
-
- Bright Data scraping with authentication
|
|
235
|
-
- NVD fallback if scraper fails
|
|
236
|
-
- Caching to ~/.codeprobe/cache.json
|
|
237
|
-
|
|
238
|
-
✅ **Interactive User Experience**
|
|
239
|
-
- Review each patch before applying
|
|
240
|
-
- Skip patches you don't want
|
|
241
|
-
- Get detailed information on demand
|
|
242
|
-
|
|
243
|
-
✅ **Git & GitHub Integration**
|
|
244
|
-
- Automatic branch creation
|
|
245
|
-
- Meaningful commit messages
|
|
246
|
-
- GitHub CLI support for PR creation
|
|
247
|
-
|
|
248
|
-
✅ **CI/CD Compatible**
|
|
249
|
-
- Use `--json` flag for structured output
|
|
250
|
-
- Use without `--fix` for read-only scanning
|
|
251
|
-
- Exit codes for automation
|
|
252
|
-
|
|
253
|
-
## Testing Locally
|
|
254
|
-
|
|
255
|
-
```bash
|
|
256
|
-
# Terminal 1: Start the server
|
|
257
|
-
export NODE_ENV=development
|
|
258
|
-
bun src/api/server-cli.ts
|
|
259
|
-
|
|
260
|
-
# Terminal 2: Test scan (no fix)
|
|
261
|
-
export SERVER_URL=http://localhost:8080
|
|
262
|
-
export CODEPROBE_SECRET=dev-token
|
|
263
|
-
bun src/cli-server.ts scan ./demo-vulnerable-app
|
|
264
|
-
|
|
265
|
-
# Terminal 3: Test --fix mode (interactive)
|
|
266
|
-
export SERVER_URL=http://localhost:8080
|
|
267
|
-
export CODEPROBE_SECRET=dev-token
|
|
268
|
-
cd /tmp/test-app
|
|
269
|
-
bun /Users/nr/Developer/codeprobe/src/cli-server.ts scan . --fix
|
|
270
|
-
# Answer prompts:
|
|
271
|
-
# - "yes" to apply ejs patch
|
|
272
|
-
# - "yes" to proceed
|
|
273
|
-
# - Observe branch creation, commit, push, and PR
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
## Troubleshooting
|
|
277
|
-
|
|
278
|
-
### "Connection refused"
|
|
279
|
-
- Make sure server is running: `bun src/api/server-cli.ts`
|
|
280
|
-
- Check SERVER_URL env var is correct
|
|
281
|
-
- Try: `curl http://localhost:8080/health`
|
|
282
|
-
|
|
283
|
-
### "Unauthorized" error
|
|
284
|
-
- Check CODEPROBE_SECRET matches between CLI and server
|
|
285
|
-
- In development mode, any token works
|
|
286
|
-
|
|
287
|
-
### "Kimi API error"
|
|
288
|
-
- Check KIMI_API_KEY is set correctly in .env
|
|
289
|
-
- Verify internet connection
|
|
290
|
-
- Check API key has sufficient credits
|
|
291
|
-
|
|
292
|
-
### "git push failed"
|
|
293
|
-
- Ensure you have Git configured: `git config user.name` and `git config user.email`
|
|
294
|
-
- Ensure you have push access to the repository
|
|
295
|
-
- Check remote is configured: `git remote -v`
|
|
296
|
-
|
|
297
|
-
### "gh pr create failed"
|
|
298
|
-
- Run `gh auth login` to authenticate
|
|
299
|
-
- Verify you have repo permissions
|
|
300
|
-
- Check GH_TOKEN is set if using token auth
|
|
301
|
-
|
|
302
|
-
## Next Steps
|
|
303
|
-
|
|
304
|
-
1. **Deploy Server to Google Cloud Run** (see DEPLOY.md)
|
|
305
|
-
2. **Publish to NPM** (see DEPLOY_CHECKLIST.md)
|
|
306
|
-
3. **Add to GitHub Actions** (automatic PR scanning)
|
|
307
|
-
4. **Configure Scheduled Scans** (hourly package change detection)
|
|
308
|
-
|
package/MIGRATION_COMPLETE.md
DELETED
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
# CodeProbe: Stage Migration Complete
|
|
2
|
-
|
|
3
|
-
**Date**: 2026-06-13
|
|
4
|
-
**Status**: ✅ All stages integrated, types reconciled, tests passing (25/25)
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## What Was Done
|
|
9
|
-
|
|
10
|
-
### 1. **Completed Stalled Git Rebase**
|
|
11
|
-
- The handoff document was stale — all PRs (#1, #2, #3) were already merged to origin/main
|
|
12
|
-
- Restarted the Stage 3 rebase with proper editor configuration
|
|
13
|
-
- Clean merge with no conflicts remaining
|
|
14
|
-
|
|
15
|
-
### 2. **Diagnosed Corruption from Botched Merge**
|
|
16
|
-
The PR merge process had concatenated three stages' overlapping files instead of reconciling them:
|
|
17
|
-
- **package.json** had duplicate `"module"`, `"type"`, `"scripts"`, `"dependencies"` fields
|
|
18
|
-
- **src/shared/types.ts** had two incompatible type systems side-by-side
|
|
19
|
-
- **src/shared/constants.ts** declared `PATHS` twice with conflicting values
|
|
20
|
-
|
|
21
|
-
**Root Cause**: When merging Stage 2 (CLI) onto Stage 3 (Dashboard), then both onto main (Stage 1), the merger concatenated files instead of intelligently merging them.
|
|
22
|
-
|
|
23
|
-
### 3. **Reconciled Type Systems**
|
|
24
|
-
|
|
25
|
-
#### Before (Broken)
|
|
26
|
-
```typescript
|
|
27
|
-
// Stage 1 types (lines 1-57)
|
|
28
|
-
type CVE { affected_versions, fixed_version, ... }
|
|
29
|
-
type ScanCVE { version_vulnerable, exploitable, patch_diff, ... }
|
|
30
|
-
type Scan { cves: ScanCVE[] }
|
|
31
|
-
type Report { scan: Scan, summary }
|
|
32
|
-
|
|
33
|
-
// Stage 2 types (lines 97-137) — DUPLICATE/CONFLICTING
|
|
34
|
-
type CVE { version_vulnerable, exploitable, patch_diff, ... }
|
|
35
|
-
type Scan { cves: CVE[], patches_available }
|
|
36
|
-
type Report { scan: Scan, summary }
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**Problem**: Stages 1 and 2 expected different `CVE` shapes.
|
|
40
|
-
|
|
41
|
-
#### After (Fixed)
|
|
42
|
-
```typescript
|
|
43
|
-
// Stage 1: CVE from vulnerability sources
|
|
44
|
-
type CVE {
|
|
45
|
-
id, package, affected_versions[], fixed_version,
|
|
46
|
-
severity, cvss, description, cwe?, exploit_url?
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Stage 2+3: CVE result in a scan report
|
|
50
|
-
type ScanCVE {
|
|
51
|
-
id, package, version_vulnerable, version_fixed?,
|
|
52
|
-
severity, cvss, description, exploitable, exploit_evidence?,
|
|
53
|
-
patch_diff?, patch_version?, verification_time_ms?
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Unified types used across all stages
|
|
57
|
-
type Scan {
|
|
58
|
-
id, timestamp, repo_url, cves: ScanCVE[],
|
|
59
|
-
risk_score, exploitable_count, theoretical_count,
|
|
60
|
-
total_dependencies, patches_available
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type Report { scan: Scan, summary: {...} }
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**Result**: Stages 1, 2, 3 now share coherent types that map properly.
|
|
67
|
-
|
|
68
|
-
### 4. **Unified Configuration Constants**
|
|
69
|
-
|
|
70
|
-
**Before**:
|
|
71
|
-
- `PATHS` declared twice (lines 24 and 52) with conflicting values
|
|
72
|
-
- Stray `import` statement mid-file (line 49)
|
|
73
|
-
- Duplicate retry config fields
|
|
74
|
-
- `API_TIMEOUTS` vs `TIMEOUTS` naming inconsistency
|
|
75
|
-
|
|
76
|
-
**After**:
|
|
77
|
-
- Single `PATHS` object with all necessary paths for CLI + Engine + Dashboard
|
|
78
|
-
- Organized constants: API_ENDPOINTS, TIMEOUTS, SANDBOX_CONFIG, FILE_PERMISSIONS, RISK_SCORE_WEIGHTS, EXIT_CODES
|
|
79
|
-
- Cleaned up imports; all constants properly exported and typed
|
|
80
|
-
|
|
81
|
-
### 5. **Fixed package.json**
|
|
82
|
-
|
|
83
|
-
**Before**:
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"module": "index.ts",
|
|
87
|
-
"type": "module",
|
|
88
|
-
"private": true,
|
|
89
|
-
"bin": {...},
|
|
90
|
-
"scripts": {...},
|
|
91
|
-
"dependencies": {...},
|
|
92
|
-
// DUPLICATE FIELDS
|
|
93
|
-
"module": "index.ts",
|
|
94
|
-
"type": "module",
|
|
95
|
-
"private": true,
|
|
96
|
-
"scripts": {...},
|
|
97
|
-
"dependencies": {...},
|
|
98
|
-
// ANOTHER DUPLICATE SET
|
|
99
|
-
"bin": {...},
|
|
100
|
-
"scripts": {...},
|
|
101
|
-
...
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**After**:
|
|
106
|
-
```json
|
|
107
|
-
{
|
|
108
|
-
"name": "codeprobe",
|
|
109
|
-
"type": "module",
|
|
110
|
-
"bin": { "codeprobe": "src/cli/index.ts" },
|
|
111
|
-
"scripts": {
|
|
112
|
-
"test": "bun test",
|
|
113
|
-
"dev": "bun run src/api/server.ts",
|
|
114
|
-
"build": "bun build src/dashboard/frontend.tsx --outdir dist"
|
|
115
|
-
},
|
|
116
|
-
"dependencies": {
|
|
117
|
-
"zod", "axios", "chalk", "dayjs", "cli-table3", "ora",
|
|
118
|
-
"react", "react-dom", "tailwindcss"
|
|
119
|
-
},
|
|
120
|
-
"devDependencies": { "@types/bun", "@types/node", "@types/react", "@types/react-dom", "typescript" }
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## Current Status: All Green ✅
|
|
127
|
-
|
|
128
|
-
### Tests
|
|
129
|
-
```
|
|
130
|
-
bun test
|
|
131
|
-
✅ 25 tests passing (0 failures)
|
|
132
|
-
- Stage 1 Engine: ✅ (8 tests)
|
|
133
|
-
- Stage 2 CLI: ✅ (14 tests)
|
|
134
|
-
- Stage 3 Dashboard: ✅ (3 tests)
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Builds
|
|
138
|
-
```
|
|
139
|
-
✅ CLI: bun run src/cli/index.ts --help
|
|
140
|
-
→ Functional, parses args, dispatches commands
|
|
141
|
-
|
|
142
|
-
✅ Dashboard: bun build src/dashboard/frontend.tsx --outdir dist
|
|
143
|
-
→ 1.0 MB bundle, React+Tailwind compiles cleanly
|
|
144
|
-
|
|
145
|
-
✅ API: bun build src/api/server.ts --target bun
|
|
146
|
-
→ 5.23 KB, REST endpoints ready
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Runtime Verification
|
|
150
|
-
```
|
|
151
|
-
$ bun run src/cli/index.ts scan . --json
|
|
152
|
-
✅ Parses codeprobe repo
|
|
153
|
-
✅ Finds 1 CVE (mocked engine)
|
|
154
|
-
✅ Verifies exploitable (mocked sandbox)
|
|
155
|
-
✅ Saves report to ~/.codeprobe/scans/
|
|
156
|
-
✅ Outputs valid JSON with all required fields
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## Data Flow: Stage Integration
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
┌─────────────────────────────────────────────────────────┐
|
|
165
|
-
│ Stage 1: Core Engine (src/engine/) │
|
|
166
|
-
│ • Parser: extract deps from package.json │
|
|
167
|
-
│ • Scraper: fetch CVEs (Bright Data API, with fallback) │
|
|
168
|
-
│ • Matcher: semver match deps → CVEs │
|
|
169
|
-
│ • Sandbox: run PoC exploits (Daytona) │
|
|
170
|
-
│ • Patcher: generate diffs │
|
|
171
|
-
│ • Report: build JSON report │
|
|
172
|
-
│ │
|
|
173
|
-
│ Output: Report { scan: Scan { cves: ScanCVE[] } } │
|
|
174
|
-
└──────────────────┬──────────────────────────────────────┘
|
|
175
|
-
│ (exports types via shared/types.ts)
|
|
176
|
-
↓
|
|
177
|
-
┌─────────────────────────────────────────────────────────┐
|
|
178
|
-
│ Stage 2: CLI (src/cli/) │
|
|
179
|
-
│ • Import: runFullScan() from Stage 1 │
|
|
180
|
-
│ • Display: Format Report as colored table │
|
|
181
|
-
│ • Git: Apply patches (--fix flag) │
|
|
182
|
-
│ • Store: Save reports to ~/.codeprobe/scans/ │
|
|
183
|
-
│ • Config: Manage API keys (AES-256-GCM encrypted) │
|
|
184
|
-
│ │
|
|
185
|
-
│ Input: Report (from Stage 1) │
|
|
186
|
-
│ Output: JSON file + terminal display │
|
|
187
|
-
└──────────────────┬──────────────────────────────────────┘
|
|
188
|
-
│ (scans saved to disk)
|
|
189
|
-
↓
|
|
190
|
-
┌─────────────────────────────────────────────────────────┐
|
|
191
|
-
│ Stage 3: Dashboard (src/dashboard/ + src/api/) │
|
|
192
|
-
│ • API: REST endpoints for /api/scans, /api/scans/{id} │
|
|
193
|
-
│ • Auth: GitHub OAuth + Bearer tokens │
|
|
194
|
-
│ • UI: React dashboard (ScansListPage, ScanDetailPage) │
|
|
195
|
-
│ • Visual: Business impact card ($4.9M breach risk) │
|
|
196
|
-
│ • Export: Download patch diffs, JSON reports │
|
|
197
|
-
│ │
|
|
198
|
-
│ Input: Scan files from ~/.codeprobe/scans/ │
|
|
199
|
-
│ Output: Web UI at localhost:3000 │
|
|
200
|
-
└─────────────────────────────────────────────────────────┘
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## Files Changed
|
|
206
|
-
|
|
207
|
-
### Fixed (Reconciliation)
|
|
208
|
-
```
|
|
209
|
-
✅ package.json - Unified deps from all stages
|
|
210
|
-
✅ src/shared/types.ts - Merged CVE/ScanCVE/Scan/Report
|
|
211
|
-
✅ src/shared/constants.ts - Deduplicated PATHS, configs
|
|
212
|
-
bun.lock - Regenerated after deps fixed
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Tested (No Changes Needed)
|
|
216
|
-
```
|
|
217
|
-
✅ src/engine/* - All 8 tests passing
|
|
218
|
-
✅ src/cli/* - All 14 tests passing
|
|
219
|
-
✅ src/dashboard/* - All 3 tests passing
|
|
220
|
-
✅ src/api/* - Builds, ready to integrate
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
---
|
|
224
|
-
|
|
225
|
-
## What Each Stage Exports for Others
|
|
226
|
-
|
|
227
|
-
### Stage 1 (Engine) → Stages 2 & 3
|
|
228
|
-
```typescript
|
|
229
|
-
export async function runFullScan(
|
|
230
|
-
repoPath: string,
|
|
231
|
-
options?: { verbose?: boolean; onEvent?: (event: ScanEvent) => void }
|
|
232
|
-
): Promise<Report>
|
|
233
|
-
|
|
234
|
-
// Plus types:
|
|
235
|
-
export type Report { scan: Scan, summary }
|
|
236
|
-
export type Scan { id, timestamp, cves: ScanCVE[], risk_score, ... }
|
|
237
|
-
export type ScanCVE { id, package, version_vulnerable, exploitable, patch_diff, ... }
|
|
238
|
-
export type ScanEvent { phase, status, message, level, metadata }
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Stages 2 & 3 Use Stage 1's Output
|
|
242
|
-
- **CLI** (Stage 2): Calls `runFullScan()`, displays results, saves to disk
|
|
243
|
-
- **Dashboard** (Stage 3): Reads saved scans from disk, displays via API + React UI
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## Known Limitations (MVP)
|
|
248
|
-
|
|
249
|
-
1. **Engine currently mocked** — Uses demo data, not real Bright Data/Daytona APIs
|
|
250
|
-
- ✅ Structure is ready; swap in real API calls when available
|
|
251
|
-
|
|
252
|
-
2. **Dashboard reads static files** — No database, no real-time sync
|
|
253
|
-
- ✅ API serves from `~/.codeprobe/scans/`; can upgrade to DB later
|
|
254
|
-
|
|
255
|
-
3. **GitHub OAuth not fully wired** — Auth flow exists, needs app registration
|
|
256
|
-
- ✅ Implementation ready in `src/api/auth.ts`; requires env vars
|
|
257
|
-
|
|
258
|
-
4. **No multi-language support** — Node.js only
|
|
259
|
-
- ✅ This is intentional MVP scope
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
## What's Needed for Demo Day
|
|
264
|
-
|
|
265
|
-
### ✅ Already Done
|
|
266
|
-
- [x] CLI functional and tested
|
|
267
|
-
- [x] Dashboard frontend builds
|
|
268
|
-
- [x] API server compiles
|
|
269
|
-
- [x] All types reconciled across stages
|
|
270
|
-
- [x] All 25 tests passing
|
|
271
|
-
|
|
272
|
-
### ⏳ Before Going Live
|
|
273
|
-
- [ ] **Stage 1 Engine**: Wire real Bright Data API key (or use fallback cache)
|
|
274
|
-
- [ ] **Stage 1 Engine**: Wire real Daytona sandbox (or mock more CVEs)
|
|
275
|
-
- [ ] **Stage 3 Auth**: Register GitHub OAuth app, set env vars
|
|
276
|
-
- [ ] **Demo Data**: Generate 2-3 scan results with different CVE counts
|
|
277
|
-
- [ ] **Rehearsal**: Walk through CLI scan → Dashboard view 3-5 times
|
|
278
|
-
- [ ] **Fallback**: Pre-record 2-min video (demo data, pre-rendered scans)
|
|
279
|
-
|
|
280
|
-
### 🚀 Nice to Have
|
|
281
|
-
- Prism.js syntax highlighting in patch diff viewer (CDN ready)
|
|
282
|
-
- Mobile responsiveness testing on actual phone
|
|
283
|
-
- Error cases (network failure, invalid OAuth, no scans found)
|
|
284
|
-
|
|
285
|
-
---
|
|
286
|
-
|
|
287
|
-
## Next Steps
|
|
288
|
-
|
|
289
|
-
### Immediate (For You)
|
|
290
|
-
1. **Test the full flow**:
|
|
291
|
-
```bash
|
|
292
|
-
# Terminal 1: Start API server
|
|
293
|
-
bun run src/api/server.ts
|
|
294
|
-
|
|
295
|
-
# Terminal 2: Open dashboard
|
|
296
|
-
open http://localhost:3000
|
|
297
|
-
|
|
298
|
-
# Terminal 3: Run a scan
|
|
299
|
-
bun run src/cli/index.ts scan ./demo-vulnerable-app --json
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
2. **Verify Stage 1 integration** — Check if CLI can call real `runFullScan()` from Stage 1 engine (currently mocked)
|
|
303
|
-
|
|
304
|
-
3. **Set up OAuth** (if demoing auth):
|
|
305
|
-
- Register app at https://github.com/settings/developers
|
|
306
|
-
- Set `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` env vars
|
|
307
|
-
- Test login flow
|
|
308
|
-
|
|
309
|
-
### Longer Term
|
|
310
|
-
- Add real Bright Data API integration (if available)
|
|
311
|
-
- Implement real Daytona sandbox spawning
|
|
312
|
-
- Add database for persistent scans
|
|
313
|
-
- GitHub PR auto-commenting (Stage 3 extension)
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
## Summary
|
|
318
|
-
|
|
319
|
-
**The migration is complete.** All three stages now coexist in a single Bun project with reconciled types, unified configuration, and passing tests. The architecture is clean:
|
|
320
|
-
|
|
321
|
-
- **Stage 1** provides the engine layer (parsing, scraping, sandboxing, reporting)
|
|
322
|
-
- **Stage 2** provides the CLI layer (user interaction, git integration, local storage)
|
|
323
|
-
- **Stage 3** provides the web layer (auth, dashboard, visualization, sharing)
|
|
324
|
-
|
|
325
|
-
Each stage can be developed independently, but they share types and constants defined in `src/shared/`. The data flow is linear: Stage 1 output → Stage 2 storage → Stage 3 visualization.
|
|
326
|
-
|
|
327
|
-
No additional refactoring needed. Ready for feature work or demo day prep.
|