diff --git a/web/public/app.js b/web/public/app.js index 5f36395..7255c69 100644 --- a/web/public/app.js +++ b/web/public/app.js @@ -172,7 +172,7 @@ function switchView(viewName) { const runHist = $('#sbRunHistory'); if (runHist) runHist.style.display = ['live','detail'].includes(viewName) ? '' : 'none'; if (viewName === 'wizard') loadProjectOptions(); - if (viewName === 'pentests') loadPentests(); + if (viewName === 'pentests') { loadPentests(); loadDashboardStats(); } if (viewName === 'issues') loadIssues(); if (viewName === 'repos') loadRepos(); if (viewName === 'projects') loadProjects(); @@ -1459,9 +1459,18 @@ async function loadDashboardStats() { : 'File storage'; const totalRuns = stats?.total_runs || state.runs.length || 0; - const totalFindings = stats?.total_findings || 0; - const critFindings = stats?.critical_findings || 0; - const highFindings = stats?.high_findings || 0; + let totalFindings = stats?.total_findings || 0; + let critFindings = stats?.critical_findings || 0; + let highFindings = stats?.high_findings || 0; + if (!totalFindings && state.runs.length) { + for (const r of state.runs) { + const n = r.findings ?? r.validated ?? 0; + totalFindings += n; + const sev = r.severity || {}; + critFindings += sev.critical || 0; + highFindings += sev.high || 0; + } + } const costUsd = cost?.total_usd ? `$${Number(cost.total_usd).toFixed(4)}` : '—'; const budgetUsd = cost?.budget_usd ? `$${Number(cost.budget_usd).toFixed(2)}` : '∞'; @@ -1472,20 +1481,25 @@ async function loadDashboardStats() { const gaps = coverage?.gaps || []; const topGaps = gaps.slice(0, 5).map(g => `${esc(typeof g === 'string' ? g : g.class || g.name || '')}`).join(''); + const medFindings = stats?.medium_findings || 0; + const lowFindings = stats?.low_findings || 0; + const infoFindings = stats?.info_findings || 0; + el.innerHTML = ` -
-
Storage
${dbBadge}
-
Total Runs
${totalRuns}
-
Findings
${totalFindings}
-
Critical
${critFindings}
-
High
${highFindings}
+
+
${totalFindings}
Findings
+
${critFindings}
Critical
+
${highFindings}
High
+
${medFindings}
Medium
+
${lowFindings}
Low
-
+
+
Runs
${totalRuns}
+
Coverage
${covPct}%
Cost
${costUsd}
Budget
${budgetUsd}
-
Coverage
${covPct}% (${covCovered}/${covTotal})
- ${topGaps ? `
Top Gaps
${topGaps}
` : ''} + ${topGaps ? `
Coverage Gaps
${topGaps}
` : ''} `; } catch { /* dashboard stats are non-critical */ } } @@ -3558,6 +3572,7 @@ async function renderDashboard() { $$('#dashBody tbody tr[data-target]').forEach((tr) => tr.addEventListener('click', () => { state.runFilter = tr.dataset.target; $('#runFilter').value = tr.dataset.target; + switchView('pentests'); renderSidebar(); })); // A top contributor is a specific finding in a specific run — clicking it @@ -6285,6 +6300,49 @@ async function loadPrReviews() { } catch (e) { body.innerHTML = `
Failed to load: ${esc(e.message)}
`; } } +$('#btnNewPrReview')?.addEventListener('click', () => { + const existing = $('#prReviewModal'); + if (existing) { existing.hidden = false; return; } + document.body.insertAdjacentHTML('beforeend', ` + `); + $('#btnClosePrReview').addEventListener('click', () => $('#prReviewModal').hidden = true); + $('#btnPrReviewCancel').addEventListener('click', () => $('#prReviewModal').hidden = true); + $('#prReviewModal').addEventListener('click', (e) => { if (e.target.id === 'prReviewModal') e.target.hidden = true; }); + $('#btnPrReviewRun').addEventListener('click', async () => { + const repo = $('#prReviewRepo').value.trim(); + const num = $('#prReviewNumber').value.trim(); + const errEl = $('#prReviewError'); + if (!repo || !num) { if (errEl) errEl.textContent = 'Repository and PR number are required.'; return; } + if (errEl) errEl.textContent = ''; + try { + await api('/api/start', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ target: `${repo}#${num}`, mode: 'pr' }), + }); + $('#prReviewModal').hidden = true; + switchView('live'); + } catch (e) { + if (errEl) errEl.textContent = e.message || 'Failed to start review'; + } + }); +}); + async function loadIssues() { const tableBody = $('#issuesTableBody'); if (!tableBody) return; diff --git a/web/public/index.html b/web/public/index.html index aefd3d2..8f03f90 100644 --- a/web/public/index.html +++ b/web/public/index.html @@ -102,9 +102,6 @@
- - - diff --git a/web/public/style.css b/web/public/style.css index ffbe2f8..57d748c 100644 --- a/web/public/style.css +++ b/web/public/style.css @@ -3212,3 +3212,18 @@ details.ag-sec > summary::-webkit-details-marker { display: none; } .dash-ok { background: color-mix(in srgb, var(--sev-low-bar) 20%, transparent); color: var(--sev-low-fg); border: 1px solid var(--sev-low-bar); } .dash-warn { background: color-mix(in srgb, var(--sev-medium-bar) 20%, transparent); color: var(--sev-medium-fg); border: 1px solid var(--sev-medium-bar); } .dash-gap { display: inline-block; font-size: 11px; background: var(--surface-3, var(--surface-2)); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; margin: 2px 4px 2px 0; color: var(--text-dim); } +.dash-row-main { gap: 12px; } +.dash-row-main .dash-card { text-align: center; padding: 16px 12px; } +.dash-row-meta .dash-card { text-align: center; } +.dash-val-big { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1; } +.dash-row-main .dash-label { margin-top: 6px; margin-bottom: 0; } +.dash-card-accent { border-color: var(--accent, #7c5cff); } +.dash-card-accent .dash-val-big { color: var(--accent, #7c5cff); } +.dash-sev-crit { border-color: var(--sev-critical-bar, #e53e3e); } +.dash-sev-crit .dash-val-big { color: var(--sev-critical-fg, #fc8181); } +.dash-sev-high { border-color: var(--sev-high-bar, #dd6b20); } +.dash-sev-high .dash-val-big { color: var(--sev-high-fg, #fbd38d); } +.dash-sev-med { border-color: var(--sev-medium-bar, #d69e2e); } +.dash-sev-med .dash-val-big { color: var(--sev-medium-fg, #fefcbf); } +.dash-sev-low { border-color: var(--sev-low-bar, #38a169); } +.dash-sev-low .dash-val-big { color: var(--sev-low-fg, #9ae6b4); } diff --git a/web/server.js b/web/server.js index 1dacafe..ff86926 100644 --- a/web/server.js +++ b/web/server.js @@ -312,17 +312,19 @@ const PORT = Number(process.env.NEUROSPLOIT_WEB_PORT || process.env.PORT || 4173 async function toolsCall(args) { const out = await runCli(['tools', ...args, '--json']); - const text = stripAnsi(out.buf || '').trim(); + const text = (out.buf || '').trim(); if (out.code !== 0) { - let msg = text || 'tool command failed'; + let msg = text || out.stderr || 'tool command failed'; try { const v = JSON.parse(text); msg = v.error || msg; } catch { /* keep text */ } throw new Error(msg); } try { return JSON.parse(text); } catch { - const m = text.match(/\{[\s\S]*\}\s*$/); - if (m) { try { return JSON.parse(m[0]); } catch { /* fall through */ } } - throw new Error(text || 'tool command returned no JSON'); + const arrMatch = text.match(/\[[\s\S]*\]\s*$/); + if (arrMatch) { try { return JSON.parse(arrMatch[0]); } catch { /* fall through */ } } + const objMatch = text.match(/\{[\s\S]*\}\s*$/); + if (objMatch) { try { return JSON.parse(objMatch[0]); } catch { /* fall through */ } } + throw new Error((text || '').slice(0, 200) || 'tool command returned no JSON'); } } @@ -343,9 +345,9 @@ const C2_PROFILE_KEYS = ['sliver', 'havoc', 'mythic', 'adaptix', 'cobaltstrike'] async function c2xCall(args) { const out = await runCli(['c2x', ...args, '--json']); - const text = stripAnsi(out.buf || '').trim(); + const text = (out.buf || '').trim(); if (out.code !== 0) { - let msg = text || 'c2x command failed'; + let msg = text || out.stderr || 'c2x command failed'; try { const v = JSON.parse(text); msg = v.error || msg; } catch { /* keep */ } throw new Error(msg); } @@ -1764,11 +1766,12 @@ function runCli(args) { return new Promise((resolve) => { if (!BIN) return resolve({ code: -1, buf: 'neurosploit binary not found — run `cargo build --release` in neurosploit-rs/' }); const child = spawn(BIN, args, { cwd: ROOT, env: { ...process.env, ...envOverrides() } }); - let buf = ''; - child.stdout.on('data', (c) => { buf += c.toString('utf8'); }); - child.stderr.on('data', (c) => { buf += c.toString('utf8'); }); - child.on('close', (code) => resolve({ code, buf: stripAnsi(buf) })); - child.on('error', (e) => resolve({ code: -1, buf: e.message })); + let stdout = ''; + let stderr = ''; + child.stdout.on('data', (c) => { stdout += c.toString('utf8'); }); + child.stderr.on('data', (c) => { stderr += c.toString('utf8'); }); + child.on('close', (code) => resolve({ code, buf: stripAnsi(stdout), stderr: stripAnsi(stderr) })); + child.on('error', (e) => resolve({ code: -1, buf: e.message, stderr: '' })); }); }