diff --git a/apps/gui/ui/app.css b/apps/gui/ui/app.css
new file mode 100644
index 0000000..c631056
--- /dev/null
+++ b/apps/gui/ui/app.css
@@ -0,0 +1,721 @@
+:root {
+ color-scheme: dark;
+ --bg: #070d14;
+ --bg-2: #0b1420;
+ --panel: rgba(13, 25, 38, 0.82);
+ --panel-solid: #0d1a29;
+ --line: rgba(148, 188, 205, 0.16);
+ --line-strong: rgba(148, 188, 205, 0.32);
+ --text: #e8f2f4;
+ --muted: #8ea5b0;
+ --accent: #38bdf8;
+ --accent-2: #f0b35b;
+ --danger: #ef4444;
+
+ /* CVSS Severity Palette */
+ --sev-critical: #ef4444;
+ --sev-critical-soft: rgba(239, 68, 68, 0.16);
+ --sev-high: #f97316;
+ --sev-high-soft: rgba(249, 115, 22, 0.16);
+ --sev-medium: #f59e0b;
+ --sev-medium-soft: rgba(245, 158, 11, 0.16);
+ --sev-low: #10b981;
+ --sev-low-soft: rgba(16, 185, 129, 0.16);
+ --sev-info: #64748b;
+ --sev-info-soft: rgba(100, 116, 139, 0.16);
+
+ --kev: #dc2626;
+ --kev-soft: rgba(220, 38, 38, 0.2);
+
+ --shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
+ --radius: 16px;
+ --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
+ --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
+}
+
+html[data-theme="light"] {
+ color-scheme: light;
+ --bg: #f0f4f8;
+ --bg-2: #e2eaf0;
+ --panel: rgba(255, 255, 255, 0.88);
+ --panel-solid: #ffffff;
+ --line: rgba(20, 48, 64, 0.12);
+ --line-strong: rgba(20, 48, 64, 0.24);
+ --text: #0f1f26;
+ --muted: #536b75;
+ --accent: #0284c7;
+ --accent-2: #d97706;
+ --danger: #dc2626;
+
+ --sev-critical: #dc2626;
+ --sev-critical-soft: rgba(220, 38, 38, 0.12);
+ --sev-high: #ea580c;
+ --sev-high-soft: rgba(234, 88, 12, 0.12);
+ --sev-medium: #d97706;
+ --sev-medium-soft: rgba(217, 119, 6, 0.12);
+ --sev-low: #059669;
+ --sev-low-soft: rgba(5, 150, 105, 0.12);
+ --sev-info: #475569;
+ --sev-info-soft: rgba(71, 85, 105, 0.12);
+
+ --kev: #b91c1c;
+ --kev-soft: rgba(185, 28, 28, 0.15);
+
+ --shadow: 0 20px 50px rgba(20, 48, 64, 0.1);
+}
+
+* { box-sizing: border-box; }
+html, body { min-height: 100%; }
+
+body {
+ margin: 0;
+ font-family: var(--sans);
+ color: var(--text);
+ background:
+ radial-gradient(900px 520px at 10% -8%, rgba(56, 189, 248, 0.12), transparent 60%),
+ radial-gradient(760px 480px at 92% 0%, rgba(239, 68, 68, 0.08), transparent 58%),
+ linear-gradient(150deg, var(--bg), var(--bg-2));
+ background-attachment: fixed;
+}
+
+button, input, select { font: inherit; color: inherit; }
+button { cursor: pointer; }
+h1, h2, h3, p { margin: 0; }
+
+.app {
+ display: grid;
+ grid-template-columns: 286px minmax(0, 1fr);
+ min-height: 100vh;
+}
+
+/* ------------------------------------------------------------------ SIDEBAR */
+.sidebar {
+ display: flex;
+ flex-direction: column;
+ gap: 22px;
+ padding: 28px 22px;
+ border-right: 1px solid var(--line);
+ background: linear-gradient(180deg, rgba(7, 15, 24, 0.78), rgba(7, 15, 24, 0.4));
+ backdrop-filter: blur(18px);
+ position: sticky;
+ top: 0;
+ height: 100vh;
+}
+
+html[data-theme="light"] .sidebar {
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.45));
+}
+
+.brand { display: flex; align-items: center; gap: 12px; }
+.logo { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
+.brand strong { display: block; font-size: 1.18rem; letter-spacing: 0.01em; color: var(--text); }
+.brand small { display: block; color: var(--muted); font-size: 0.76rem; margin-top: 2px; }
+
+.side-title {
+ color: var(--muted);
+ font-size: 0.68rem;
+ letter-spacing: 0.16em;
+ text-transform: uppercase;
+}
+
+.nav { display: grid; gap: 6px; }
+.nav-item {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ width: 100%;
+ padding: 11px 12px;
+ border: 1px solid transparent;
+ border-radius: 12px;
+ background: transparent;
+ text-align: left;
+ color: var(--muted);
+ transition: 150ms ease;
+}
+.nav-item:hover { border-color: var(--line); background: rgba(56, 189, 248, 0.06); color: var(--text); }
+.nav-item.active { border-color: var(--line-strong); background: rgba(56, 189, 248, 0.12); color: var(--text); }
+.nav-icon { width: 20px; color: var(--accent); text-align: center; font-size: 1.05rem; }
+.nav-label { display: block; font-size: 0.92rem; font-weight: 600; }
+.nav-sub { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
+
+.side-foot { margin-top: auto; display: grid; gap: 12px; }
+.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
+.pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ padding: 5px 9px;
+ border: 1px solid var(--line);
+ border-radius: 999px;
+ font-size: 0.72rem;
+ color: var(--text);
+ background: rgba(255, 255, 255, 0.03);
+}
+.pill.muted { color: var(--muted); }
+.dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 10px #10b981; }
+.pill.offline .dot { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
+.mono { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
+
+/* ------------------------------------------------------------------ MAIN */
+.main { padding: 36px clamp(20px, 4vw, 54px) 42px; min-width: 0; }
+.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
+.eyebrow { color: var(--accent); font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 8px; font-weight: 600; }
+h1 { font-size: clamp(1.8rem, 3.2vw, 2.8rem); line-height: 1.06; letter-spacing: -0.035em; }
+.sub { color: var(--muted); margin-top: 8px; font-size: 0.95rem; }
+h2 { font-size: 1.08rem; letter-spacing: -0.01em; }
+
+.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
+.last-updated { white-space: nowrap; }
+
+.icon-btn {
+ display: inline-grid;
+ place-items: center;
+ width: 40px;
+ height: 40px;
+ border: 1px solid var(--line);
+ border-radius: 12px;
+ background: var(--panel);
+ color: var(--text);
+ font-size: 1.05rem;
+ transition: border-color 140ms ease;
+}
+.icon-btn:hover { border-color: var(--line-strong); }
+
+.view:not(.active) { display: none !important; }
+
+/* ------------------------------------------------------------------ KPIS */
+.kpi-grid {
+ display: grid;
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ gap: 14px;
+}
+.kpi {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ min-height: 128px;
+ padding: 18px 20px;
+ border: 1px solid var(--line);
+ border-radius: var(--radius);
+ background: linear-gradient(160deg, var(--panel), rgba(13, 25, 38, 0.4));
+ box-shadow: var(--shadow);
+}
+html[data-theme="light"] .kpi { background: linear-gradient(160deg, var(--panel), rgba(255, 255, 255, 0.6)); }
+.kpi-label { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; }
+.kpi-value { margin-top: auto; font-family: var(--mono); font-size: clamp(1.6rem, 2.5vw, 2.1rem); line-height: 1; letter-spacing: -0.04em; }
+.kpi-sub { color: var(--muted); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+
+/* ------------------------------------------------------------------ CHARTS */
+.charts-grid {
+ display: grid;
+ grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
+ gap: 16px;
+ margin-top: 16px;
+}
+.chart-panel { margin-top: 0; }
+.panel-tag {
+ align-self: flex-start;
+ padding: 4px 10px;
+ border: 1px solid var(--line);
+ border-radius: 999px;
+ color: var(--muted);
+ font-family: var(--mono);
+ font-size: 0.68rem;
+ white-space: nowrap;
+}
+.chart-wrap { position: relative; width: 100%; min-height: 220px; }
+.chart { display: block; width: 100%; height: auto; overflow: visible; }
+.axis-line { stroke: var(--line); stroke-width: 1; }
+.axis-line.strong { stroke: var(--line-strong); }
+.axis-label { fill: var(--muted); font-family: var(--mono); font-size: 11px; }
+.bar-track { fill: rgba(255, 255, 255, 0.04); rx: 4px; }
+html[data-theme="light"] .bar-track { fill: rgba(20, 48, 64, 0.06); }
+.bar-fill { rx: 4px; transition: filter 140ms ease, opacity 140ms ease; }
+.bar-fill.critical { fill: var(--sev-critical); }
+.bar-fill.high { fill: var(--sev-high); }
+.bar-fill.medium { fill: var(--sev-medium); }
+.bar-fill.low { fill: var(--sev-low); }
+.bar-fill.info { fill: var(--sev-info); }
+.bar-label { fill: var(--text); font-family: var(--sans); font-size: 12px; font-weight: 500; }
+.bar-value { fill: var(--text); font-family: var(--mono); font-size: 12px; font-weight: 700; }
+
+.bar-row { outline: none; cursor: pointer; }
+.bar-row:hover .bar-fill, .bar-row:focus-visible .bar-fill { filter: brightness(1.25); }
+.bar-row:hover .bar-track, .bar-row:focus-visible .bar-track { fill: rgba(255, 255, 255, 0.08); }
+
+.chart-empty { fill: var(--muted); font-family: var(--sans); font-size: 13px; }
+.chart-tip {
+ position: absolute;
+ z-index: 10;
+ display: grid;
+ gap: 4px;
+ max-width: 320px;
+ padding: 10px 13px;
+ border: 1px solid var(--line-strong);
+ border-radius: 10px;
+ background: var(--panel-solid);
+ box-shadow: var(--shadow);
+ color: var(--text);
+ font-size: 0.74rem;
+ line-height: 1.35;
+ pointer-events: none;
+}
+.chart-tip strong { font-family: var(--mono); font-size: 0.8rem; }
+.chart-tip span { color: var(--muted); }
+
+/* ------------------------------------------------------------------ PANELS & CARDS */
+.panel {
+ margin-top: 16px;
+ padding: 22px;
+ border: 1px solid var(--line);
+ border-radius: var(--radius);
+ background: var(--panel);
+ box-shadow: var(--shadow);
+}
+.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
+.hint { color: var(--muted); font-size: 0.84rem; line-height: 1.5; margin-top: 5px; }
+
+.notice {
+ display: flex;
+ gap: 10px;
+ align-items: baseline;
+ padding: 14px 16px;
+ margin-top: 16px;
+ border: 1px solid var(--line);
+ border-radius: 12px;
+ background: var(--panel);
+ color: var(--muted);
+ font-size: 0.85rem;
+ line-height: 1.5;
+}
+.notice strong { color: var(--text); white-space: nowrap; }
+
+/* ------------------------------------------------------------------ TOOLBAR & CHIPS */
+.toolbar {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-end;
+ gap: 14px;
+ padding-bottom: 16px;
+ border-bottom: 1px solid var(--line);
+ margin-bottom: 16px;
+}
+.toolbar-slim { align-items: center; justify-content: space-between; }
+.field.compact { flex: 0 0 auto; min-width: 140px; }
+.field.compact > span { font-size: 0.68rem; }
+.field.compact input, .field.compact select { padding: 8px 10px; }
+.search-field { flex: 1 1 240px; }
+.chips { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 1px; }
+.chip {
+ padding: 8px 13px;
+ border: 1px solid var(--line);
+ border-radius: 999px;
+ background: transparent;
+ color: var(--muted);
+ font-size: 0.76rem;
+ font-weight: 600;
+ transition: 140ms ease;
+}
+.chip:hover { border-color: var(--line-strong); color: var(--text); }
+.chip.active { border-color: var(--accent); background: rgba(56, 189, 248, 0.12); color: var(--text); }
+
+.field { display: grid; gap: 6px; flex: 1; }
+.field > span { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
+input, select {
+ width: 100%;
+ padding: 10px 12px;
+ border: 1px solid var(--line-strong);
+ border-radius: 10px;
+ background: rgba(0, 0, 0, 0.22);
+ outline: none;
+ color: var(--text);
+ font-size: 0.85rem;
+}
+html[data-theme="light"] input, html[data-theme="light"] select { background: rgba(255, 255, 255, 0.8); }
+input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14); }
+
+.btn {
+ padding: 10px 15px;
+ border: 1px solid var(--line-strong);
+ border-radius: 10px;
+ background: rgba(255, 255, 255, 0.04);
+ color: var(--text);
+ font-size: 0.84rem;
+ font-weight: 600;
+ white-space: nowrap;
+ transition: 140ms ease;
+}
+.btn:hover { border-color: var(--accent); }
+.btn.primary { background: var(--accent); border-color: var(--accent); color: #041b24; font-weight: 700; }
+.btn.primary:hover { filter: brightness(1.08); }
+.btn.small { padding: 6px 10px; font-size: 0.72rem; }
+
+/* ------------------------------------------------------------------ SEVERITY BADGES */
+.sev-badge {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ padding: 3px 8px;
+ border: 1px solid transparent;
+ border-radius: 6px;
+ font-family: var(--mono);
+ font-size: 0.7rem;
+ font-weight: 700;
+ letter-spacing: 0.03em;
+ white-space: nowrap;
+}
+.sev-badge.critical { color: #fca5a5; background: var(--sev-critical-soft); border-color: rgba(239, 68, 68, 0.35); }
+.sev-badge.high { color: #fdba74; background: var(--sev-high-soft); border-color: rgba(249, 115, 22, 0.35); }
+.sev-badge.medium { color: #fcd34d; background: var(--sev-medium-soft); border-color: rgba(245, 158, 11, 0.35); }
+.sev-badge.low { color: #6ee7b7; background: var(--sev-low-soft); border-color: rgba(16, 185, 129, 0.35); }
+.sev-badge.info { color: #cbd5e1; background: var(--sev-info-soft); border-color: rgba(100, 116, 139, 0.35); }
+
+.kev-badge {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 7px;
+ border: 1px solid rgba(220, 38, 38, 0.45);
+ border-radius: 6px;
+ background: var(--kev-soft);
+ color: #fca5a5;
+ font-family: var(--mono);
+ font-size: 0.66rem;
+ font-weight: 700;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ box-shadow: 0 0 10px rgba(220, 38, 38, 0.2);
+}
+
+.conf-badge {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 6px;
+ border: 1px solid var(--line);
+ border-radius: 5px;
+ color: var(--muted);
+ font-size: 0.66rem;
+ font-weight: 600;
+}
+
+.tag-badge {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 7px;
+ border: 1px solid var(--line);
+ border-radius: 6px;
+ background: rgba(255, 255, 255, 0.03);
+ font-family: var(--mono);
+ font-size: 0.72rem;
+ color: var(--text);
+ white-space: nowrap;
+}
+
+/* ------------------------------------------------------------------ TABLE */
+.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
+.host-table { width: 100%; border-collapse: collapse; min-width: 760px; }
+.host-table thead th {
+ position: sticky;
+ top: 0;
+ z-index: 1;
+ padding: 11px 13px;
+ border-bottom: 1px solid var(--line);
+ background: var(--panel-solid);
+ color: var(--muted);
+ font-size: 0.68rem;
+ font-weight: 600;
+ letter-spacing: 0.1em;
+ text-align: left;
+ text-transform: uppercase;
+}
+.host-table td { padding: 12px 13px; border-top: 1px solid var(--line); font-size: 0.83rem; vertical-align: middle; }
+.host-table tbody tr:first-child td { border-top: 0; }
+.host-row { cursor: pointer; outline: none; transition: background 120ms ease; }
+.host-row:hover, .host-row:focus-visible { background: rgba(56, 189, 248, 0.06); }
+.host-row.open { background: rgba(56, 189, 248, 0.05); }
+.host-row .rank { color: var(--muted); font-family: var(--mono); font-size: 0.74rem; width: 44px; }
+.host-name { font-size: 0.86rem; color: var(--text); }
+.chevron-cell { color: var(--muted); text-align: right; width: 36px; font-size: 1.1rem; }
+
+.status-indicator {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 0.76rem;
+ font-weight: 600;
+}
+.status-indicator.active { color: #34d399; }
+.status-indicator.gone { color: #f87171; }
+.status-indicator .sdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
+
+/* ------------------------------------------------------------------ HOST DETAIL EXPANSION */
+.host-detail-row td { padding: 0; background: rgba(0, 0, 0, 0.12); }
+html[data-theme="light"] .host-detail-row td { background: rgba(20, 48, 64, 0.03); }
+.host-detail-wrap { padding: 16px; display: grid; gap: 14px; }
+.ports-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; }
+.port-card {
+ padding: 14px;
+ border: 1px solid var(--line);
+ border-radius: 10px;
+ background: var(--panel);
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+}
+.port-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
+.port-num { font-family: var(--mono); font-size: 0.96rem; font-weight: 700; color: var(--accent); }
+.port-product { font-size: 0.82rem; color: var(--text); }
+.cpe-block {
+ padding: 6px 8px;
+ border-radius: 6px;
+ background: rgba(0, 0, 0, 0.2);
+ font-family: var(--mono);
+ font-size: 0.7rem;
+ color: var(--muted);
+ overflow-x: auto;
+ white-space: nowrap;
+}
+.port-findings-list { display: grid; gap: 6px; }
+.port-finding-mini {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ padding: 6px 9px;
+ border: 1px solid var(--line);
+ border-radius: 7px;
+ background: rgba(255, 255, 255, 0.02);
+ font-size: 0.74rem;
+}
+
+/* ------------------------------------------------------------------ FINDINGS CARDS */
+.alert-cards { display: grid; gap: 10px; }
+.alert-card {
+ border: 1px solid var(--line);
+ border-left: 3px solid var(--line-strong);
+ border-radius: 12px;
+ background: rgba(255, 255, 255, 0.02);
+ overflow: hidden;
+ transition: border-color 140ms ease;
+}
+.alert-card.critical { border-left-color: var(--sev-critical); }
+.alert-card.high { border-left-color: var(--sev-high); }
+.alert-card.medium { border-left-color: var(--sev-medium); }
+.alert-card.low { border-left-color: var(--sev-low); }
+.alert-card.info { border-left-color: var(--sev-info); }
+
+.alert-head {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto 20px;
+ gap: 14px;
+ align-items: center;
+ width: 100%;
+ padding: 14px 16px;
+ border: 0;
+ background: transparent;
+ color: inherit;
+ text-align: left;
+ cursor: pointer;
+}
+.alert-head:hover { background: rgba(56, 189, 248, 0.04); }
+.alert-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
+.alert-main { display: grid; gap: 4px; min-width: 0; }
+.alert-title { font-size: 0.88rem; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.alert-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 0.72rem; }
+.alert-target { font-family: var(--mono); color: var(--text); }
+.alert-body {
+ display: grid;
+ gap: 14px;
+ padding: 16px;
+ border-top: 1px solid var(--line);
+ background: rgba(0, 0, 0, 0.12);
+}
+html[data-theme="light"] .alert-body { background: rgba(20, 48, 64, 0.025); }
+
+.metrics { display: flex; flex-wrap: wrap; gap: 8px; }
+.metric {
+ display: grid;
+ gap: 3px;
+ min-width: 90px;
+ padding: 8px 10px;
+ border: 1px solid var(--line);
+ border-radius: 8px;
+ background: rgba(255, 255, 255, 0.02);
+}
+.metric-label { color: var(--muted); font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
+.metric-value { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; overflow-wrap: anywhere; }
+
+.evidence-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
+.evidence-head h3 { margin: 0; font-size: 0.82rem; letter-spacing: 0.02em; }
+.kv { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
+.kv th {
+ width: 32%;
+ padding: 6px 10px;
+ border-top: 1px solid var(--line);
+ color: var(--muted);
+ font-size: 0.72rem;
+ font-weight: 500;
+ text-align: left;
+ vertical-align: top;
+}
+.kv td { padding: 6px 10px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 0.74rem; overflow-wrap: anywhere; }
+.kv tr:first-child th, .kv tr:first-child td { border-top: 0; }
+
+/* ------------------------------------------------------------------ OVERVIEW PRIORITIES */
+.overview-findings { display: grid; gap: 8px; }
+.ov-item {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ gap: 14px;
+ align-items: center;
+ width: 100%;
+ padding: 12px 14px;
+ border: 1px solid var(--line);
+ border-left: 3px solid var(--line-strong);
+ border-radius: 11px;
+ background: rgba(255, 255, 255, 0.02);
+ color: inherit;
+ text-align: left;
+ cursor: pointer;
+ transition: 130ms ease;
+}
+.ov-item:hover { border-color: var(--line-strong); background: rgba(56, 189, 248, 0.05); }
+.ov-item.critical { border-left-color: var(--sev-critical); }
+.ov-item.high { border-left-color: var(--sev-high); }
+.ov-item.medium { border-left-color: var(--sev-medium); }
+
+/* ------------------------------------------------------------------ GROUPS & SCHEDULE */
+.groups-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
+ gap: 14px;
+}
+.group-card {
+ padding: 18px;
+ border: 1px solid var(--line);
+ border-radius: var(--radius);
+ background: linear-gradient(160deg, var(--panel), rgba(13, 25, 38, 0.35));
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+}
+.group-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
+.group-name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
+.cron-tag {
+ padding: 4px 8px;
+ border-radius: 6px;
+ background: rgba(0, 0, 0, 0.2);
+ font-family: var(--mono);
+ font-size: 0.72rem;
+ color: var(--accent);
+}
+.group-next { display: grid; gap: 3px; font-size: 0.78rem; color: var(--muted); }
+.group-next strong { color: var(--text); font-family: var(--mono); }
+
+.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
+.summary-grid-wide { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-top: 0; }
+.summary-tile {
+ display: grid;
+ gap: 4px;
+ padding: 12px 14px;
+ border: 1px solid var(--line);
+ border-radius: 10px;
+ background: rgba(255, 255, 255, 0.02);
+}
+.summary-label { color: var(--muted); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
+.summary-value { font-family: var(--mono); font-size: 0.84rem; font-weight: 600; overflow-wrap: anywhere; }
+
+/* ------------------------------------------------------------------ TIMELINE */
+.timeline { display: grid; gap: 10px; }
+.timeline-item {
+ display: grid;
+ grid-template-columns: 28px minmax(0, 1fr) auto;
+ gap: 14px;
+ align-items: center;
+ padding: 12px 14px;
+ border: 1px solid var(--line);
+ border-radius: 10px;
+ background: rgba(255, 255, 255, 0.02);
+}
+.timeline-dot {
+ width: 24px;
+ height: 24px;
+ border-radius: 50%;
+ display: inline-grid;
+ place-items: center;
+ font-size: 0.75rem;
+ font-weight: 700;
+}
+.timeline-dot.host_new { background: rgba(16, 185, 129, 0.2); color: #34d399; }
+.timeline-dot.port_opened { background: rgba(239, 68, 68, 0.2); color: #f87171; }
+.timeline-dot.service_changed { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
+.timeline-dot.port_closed, .timeline-dot.host_gone { background: rgba(100, 116, 139, 0.2); color: #94a3b8; }
+.timeline-dot.default { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
+
+.timeline-info { display: grid; gap: 3px; min-width: 0; }
+.timeline-title { font-size: 0.84rem; font-weight: 600; }
+.timeline-sub { font-size: 0.72rem; color: var(--muted); font-family: var(--mono); }
+.timeline-time { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
+
+/* ------------------------------------------------------------------ DIALOG */
+dialog {
+ width: min(440px, calc(100vw - 32px));
+ padding: 22px;
+ border: 1px solid var(--line-strong);
+ border-radius: var(--radius);
+ background: var(--panel-solid);
+ color: var(--text);
+ box-shadow: var(--shadow);
+}
+dialog::backdrop { background: rgba(2, 6, 10, 0.65); backdrop-filter: blur(4px); }
+.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
+dialog .field { margin-bottom: 14px; }
+dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 20px 0 0; padding: 0; }
+.segmented { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; }
+.segmented button { flex: 1; padding: 7px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
+.segmented button.active { background: rgba(56, 189, 248, 0.16); color: var(--text); }
+
+.empty {
+ color: var(--muted);
+ font-size: 0.84rem;
+ line-height: 1.5;
+ margin: 0;
+ padding: 16px;
+ border: 1px dashed var(--line);
+ border-radius: 10px;
+ text-align: center;
+}
+
+.footnote { margin-top: 14px; color: var(--muted); font-size: 0.74rem; line-height: 1.5; }
+.foot { display: flex; justify-content: space-between; gap: 16px; margin-top: 28px; color: var(--muted); font-size: 0.74rem; }
+
+/* ------------------------------------------------------------------ RESPONSIVE */
+@media (max-width: 1280px) {
+ .charts-grid { grid-template-columns: 1fr; }
+}
+
+@media (max-width: 1120px) {
+ .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
+ .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
+}
+
+@media (max-width: 820px) {
+ .app { grid-template-columns: 1fr; }
+ .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
+ .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
+ .side-foot { margin-top: 0; }
+ .main { padding-top: 24px; }
+ .toolbar-slim { align-items: flex-end; }
+ .alert-head { grid-template-columns: auto minmax(0, 1fr) 20px; }
+ .last-updated { display: none; }
+}
+
+@media (max-width: 640px) {
+ .kpi-grid { grid-template-columns: 1fr; }
+ .summary-grid { grid-template-columns: 1fr; }
+ .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
+ .alert-head { grid-template-columns: auto minmax(0, 1fr) 20px; }
+ .ov-item { grid-template-columns: auto minmax(0, 1fr); }
+ .toolbar { gap: 10px; }
+ .field.compact, .search-field { flex: 1 1 100%; min-width: 0; }
+ .foot { flex-direction: column; }
+}
diff --git a/apps/gui/ui/app.js b/apps/gui/ui/app.js
new file mode 100644
index 0000000..1a055e9
--- /dev/null
+++ b/apps/gui/ui/app.js
@@ -0,0 +1,1281 @@
+import { setLang, tr, LOC, resolveLang, currentLang } from './i18n.js';
+
+const SVG_NS = 'http://www.w3.org/2000/svg';
+const $ = (selector) => document.querySelector(selector);
+const $$ = (selector) => document.querySelectorAll(selector);
+
+// DOM Elements
+const connection = $('#connection');
+const connectionText = $('#connectionText');
+const versionEl = $('#version');
+const feedsStatusEl = $('#feedsStatus');
+const refreshBtn = $('#refreshBtn');
+const viewTitle = $('#viewTitle');
+const viewSub = $('#viewSub');
+const lastUpdated = $('#lastUpdated');
+const settingsBtn = $('#settingsBtn');
+const settingsDlg = $('#settingsDlg');
+const closeSettings = $('#closeSettings');
+const doneSettings = $('#doneSettings');
+const langSel = $('#langSel');
+const themePick = $('#themePick');
+
+// KPIs
+const kpiHosts = $('#kpiHosts');
+const kpiHostsSub = $('#kpiHostsSub');
+const kpiPorts = $('#kpiPorts');
+const kpiPortsSub = $('#kpiPortsSub');
+const kpiCritical = $('#kpiCritical');
+const kpiCriticalSub = $('#kpiCriticalSub');
+const kpiFeeds = $('#kpiFeeds');
+const kpiFeedsSub = $('#kpiFeedsSub');
+
+// Overview Charts & Priority
+const severityChart = $('#severityChart');
+const severityTip = $('#severityTip');
+const hostExposureChart = $('#hostExposureChart');
+const hostExposureTip = $('#hostExposureTip');
+const overviewFindings = $('#overviewFindings');
+const seeAllFindingsBtn = $('#seeAllFindings');
+
+// Hosts View
+const hostCount = $('#hostCount');
+const hostSearch = $('#hostSearch');
+const hostStatusFilters = $('#hostStatusFilters');
+const hostRows = $('#hostRows');
+
+// Findings View
+const findingsCount = $('#findingsCount');
+const severityFilters = $('#severityFilters');
+const findingsSort = $('#findingsSort');
+const findingsSearch = $('#findingsSearch');
+const findingsList = $('#findingsList');
+
+// Groups View
+const groupsCount = $('#groupsCount');
+const groupsGrid = $('#groupsGrid');
+const feedsSummary = $('#feedsSummary');
+
+// Changes View
+const changesCount = $('#changesCount');
+const changesPeriodFilters = $('#changesPeriodFilters');
+const changesSearch = $('#changesSearch');
+const changesTimeline = $('#changesTimeline');
+
+// Application State
+const state = {
+ view: 'overview',
+ health: null,
+ status: null,
+ hosts: [],
+ changes: [],
+ lastUpdated: null,
+ pollTimer: null,
+ expandedHosts: new Set(),
+ expandedFindings: new Set(),
+ filters: {
+ hostSearch: '',
+ hostStatus: 'all',
+ findingSeverity: 'all',
+ findingSort: 'cvss-desc',
+ findingSearch: '',
+ changesPeriod: '24h',
+ changesSearch: '',
+ },
+};
+
+const VIEW_META = {
+ overview: {
+ title: 'Visão geral',
+ sub: 'Auditoria contínua de superfície de ataque e identificação de vulnerabilidades',
+ },
+ hosts: {
+ title: 'Hosts e Superfície',
+ sub: 'Ativos identificados no escopo autorizado e portas abertas observadas',
+ },
+ findings: {
+ title: 'Inventário de Vulnerabilidades',
+ sub: 'Correlação de versões com feeds NVD, checagens de configuração e CISA KEV',
+ },
+ groups: {
+ title: 'Grupos e Agendamento',
+ sub: 'Alvos configurados, perfis de portas e cadência contínua',
+ },
+ changes: {
+ title: 'Mudanças na Superfície',
+ sub: 'Linha do tempo de novas portas, hosts sumidos e alterações observadas',
+ },
+};
+
+// Utilities
+function t(key) {
+ return tr(key);
+}
+
+function el(tag, className, text) {
+ const node = document.createElement(tag);
+ if (className) node.className = className;
+ if (text !== undefined && text !== null) node.textContent = text;
+ return node;
+}
+
+function svgEl(tag, attributes = {}, text) {
+ const node = document.createElementNS(SVG_NS, tag);
+ for (const [key, value] of Object.entries(attributes)) {
+ node.setAttribute(key, String(value));
+ }
+ if (text !== undefined && text !== null) node.textContent = text;
+ return node;
+}
+
+function formatInt(value) {
+ return new Intl.NumberFormat(LOC(), { maximumFractionDigits: 0 }).format(value);
+}
+
+function formatScore(score) {
+ if (score === null || score === undefined) return '—';
+ return Number(score).toFixed(1);
+}
+
+function cvssSeverity(cvss) {
+ if (cvss === null || cvss === undefined) return 'info';
+ const score = Number(cvss);
+ if (score >= 9.0) return 'critical';
+ if (score >= 7.0) return 'high';
+ if (score >= 4.0) return 'medium';
+ if (score > 0) return 'low';
+ return 'info';
+}
+
+function severityLabel(sev) {
+ switch (sev) {
+ case 'critical': return t('Crítico');
+ case 'high': return t('Alto');
+ case 'medium': return t('Médio');
+ case 'low': return t('Baixo');
+ default: return t('Informativo');
+ }
+}
+
+function timeAgo(dateString) {
+ if (!dateString) return '—';
+ const date = new Date(dateString);
+ const diffSec = Math.floor((Date.now() - date.getTime()) / 1000);
+ if (isNaN(diffSec) || diffSec < 0) return dateString;
+ if (diffSec < 60) return `${diffSec}s atrás`;
+ const diffMin = Math.floor(diffSec / 60);
+ if (diffMin < 60) return `${diffMin}min atrás`;
+ const diffH = Math.floor(diffMin / 60);
+ if (diffH < 24) return `${diffH}h atrás`;
+ const diffD = Math.floor(diffH / 24);
+ return `${diffD}d atrás`;
+}
+
+function timeUntil(dateString) {
+ if (!dateString) return '—';
+ const date = new Date(dateString);
+ const diffSec = Math.floor((date.getTime() - Date.now()) / 1000);
+ if (isNaN(diffSec)) return dateString;
+ if (diffSec <= 0) return t('executando agora…');
+ if (diffSec < 60) return `em ${diffSec}s`;
+ const diffMin = Math.floor(diffSec / 60);
+ if (diffMin < 60) return `em ${diffMin}min`;
+ const diffH = Math.floor(diffMin / 60);
+ return `em ${diffH}h`;
+}
+
+// Flat list of all findings across all hosts and ports
+function getAllFindings() {
+ const list = [];
+ for (const host of state.hosts) {
+ for (const port of host.ports || []) {
+ for (const finding of port.findings || []) {
+ list.push({
+ ...finding,
+ hostIp: host.ip,
+ hostNetwork: host.network,
+ port: port.port,
+ protocol: port.protocol,
+ product: port.product,
+ version: port.version,
+ cpe: port.cpe,
+ uid: `${host.ip}:${port.port}:${finding.id}`,
+ });
+ }
+ }
+ }
+ return list;
+}
+
+// Data Fetching
+async function fetchData() {
+ try {
+ const period = state.filters.changesPeriod || '24h';
+ const [healthRes, statusRes, hostsRes, changesRes] = await Promise.all([
+ fetch('/api/health').catch(() => null),
+ fetch('/api/status').catch(() => null),
+ fetch('/api/hosts').catch(() => null),
+ fetch(`/api/changes?since=${encodeURIComponent(period)}`).catch(() => null),
+ ]);
+
+ if (!healthRes || !statusRes || !hostsRes) {
+ throw new Error('Falha ao comunicar com a API do Xexéu');
+ }
+
+ state.health = await healthRes.json();
+ state.status = await statusRes.json();
+ state.hosts = await hostsRes.json();
+ state.changes = changesRes && changesRes.ok ? await changesRes.json() : [];
+
+ state.lastUpdated = new Date();
+ connection.classList.remove('offline');
+ connectionText.textContent = t('Conectado');
+ if (state.health && state.health.version) {
+ versionEl.textContent = `Xexéu v${state.health.version}`;
+ }
+ if (state.status) {
+ feedsStatusEl.textContent = `${formatInt(state.status.feeds_cve_count || 0)} CVEs`;
+ }
+ lastUpdated.textContent = state.lastUpdated.toLocaleTimeString(LOC());
+
+ render();
+ } catch (err) {
+ console.error('fetchData error:', err);
+ connection.classList.add('offline');
+ connectionText.textContent = t('Desconectado');
+ }
+}
+
+// Navigation
+function switchView(target) {
+ if (target === 'settings') {
+ openSettingsDialog();
+ return;
+ }
+ if (!VIEW_META[target]) return;
+ state.view = target;
+
+ $$('.nav-item').forEach((item) => {
+ const isActive = item.dataset.target === target;
+ item.classList.toggle('active', isActive);
+ if (isActive) item.setAttribute('aria-current', 'page');
+ else item.removeAttribute('aria-current');
+ });
+
+ $$('.view').forEach((view) => {
+ view.classList.toggle('active', view.id === target);
+ view.hidden = view.id !== target;
+ });
+
+ const meta = VIEW_META[target];
+ viewTitle.textContent = t(meta.title);
+ viewSub.textContent = t(meta.sub);
+
+ render();
+}
+
+// Master Render
+function render() {
+ renderOverview();
+ renderHosts();
+ renderFindings();
+ renderGroups();
+ renderChanges();
+}
+
+// ------------------------------------------------------------------ OVERVIEW
+function renderOverview() {
+ const allFindings = getAllFindings();
+ const activeHosts = state.hosts.filter((h) => h.status === 'ativo');
+ let openPortsCount = 0;
+ for (const h of state.hosts) {
+ openPortsCount += (h.ports || []).filter((p) => p.status === 'aberta').length;
+ }
+
+ const criticalFindings = allFindings.filter((f) => cvssSeverity(f.cvss) === 'critical' || f.kev);
+
+ kpiHosts.textContent = formatInt(activeHosts.length);
+ kpiHostsSub.textContent = `${state.hosts.length} ${t('descobertos em escopo')}`;
+
+ kpiPorts.textContent = formatInt(openPortsCount);
+ kpiPortsSub.textContent = t('serviços expostos');
+
+ kpiCritical.textContent = formatInt(criticalFindings.length);
+ const kevCount = allFindings.filter((f) => f.kev).length;
+ kpiCriticalSub.textContent = `${kevCount} ${t('no KEV')}`;
+
+ const cveCount = state.status ? state.status.feeds_cve_count || 0 : 0;
+ const kevFeedsCount = state.status ? state.status.feeds_kev_count || 0 : 0;
+ kpiFeeds.textContent = formatInt(cveCount);
+ kpiFeedsSub.textContent = `${kevFeedsCount} ${t('no KEV')}`;
+
+ renderSeverityChart(allFindings);
+ renderHostExposureChart();
+ renderOverviewFindings(allFindings);
+}
+
+// 1. Severity Distribution SVG Chart
+function renderSeverityChart(allFindings) {
+ const counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
+ for (const f of allFindings) {
+ const sev = cvssSeverity(f.cvss);
+ counts[sev] = (counts[sev] || 0) + 1;
+ }
+
+ const total = allFindings.length;
+ if (total === 0) {
+ severityChart.setAttribute('viewBox', '0 0 680 220');
+ chartEmpty(severityChart, t('Nenhum achado para exibir no gráfico.'));
+ return;
+ }
+
+ const width = 680;
+ const rowHeight = 36;
+ const top = 16;
+ const labelWidth = 120;
+ const rightPad = 48;
+ const plotWidth = width - labelWidth - rightPad;
+ const rows = [
+ { key: 'critical', label: t('Crítico (9.0+)'), count: counts.critical, color: 'critical' },
+ { key: 'high', label: t('Alto (7.0-8.9)'), count: counts.high, color: 'high' },
+ { key: 'medium', label: t('Médio (4.0-6.9)'), count: counts.medium, color: 'medium' },
+ { key: 'low', label: t('Baixo (0.1-3.9)'), count: counts.low, color: 'low' },
+ { key: 'info', label: t('Informativo'), count: counts.info, color: 'info' },
+ ];
+
+ const maxVal = Math.max(...rows.map((r) => r.count), 1);
+ const height = top + rows.length * rowHeight + 24;
+ severityChart.setAttribute('viewBox', `0 0 ${width} ${height}`);
+ severityChart.replaceChildren();
+
+ // Grid Lines
+ const axis = svgEl('g', { class: 'axis' });
+ for (const tick of [0, 0.25, 0.5, 0.75, 1]) {
+ const x = labelWidth + plotWidth * tick;
+ axis.append(
+ svgEl('line', {
+ x1: x,
+ x2: x,
+ y1: top - 4,
+ y2: height - 22,
+ class: tick === 0 ? 'axis-line strong' : 'axis-line',
+ }),
+ );
+ }
+ severityChart.append(axis);
+
+ // Bars
+ rows.forEach((row, index) => {
+ const y = top + index * rowHeight;
+ const barWidth = Math.max(2, (row.count / maxVal) * plotWidth);
+
+ const group = svgEl('g', {
+ class: 'bar-row',
+ tabindex: '0',
+ role: 'button',
+ 'aria-label': `${row.label}: ${row.count}`,
+ });
+
+ group.append(
+ svgEl(
+ 'text',
+ { x: labelWidth - 10, y: y + 16, 'text-anchor': 'end', class: 'bar-label' },
+ row.label,
+ ),
+ );
+
+ group.append(
+ svgEl('rect', {
+ x: labelWidth,
+ y: y + 2,
+ width: plotWidth,
+ height: 18,
+ class: 'bar-track',
+ }),
+ );
+
+ if (row.count > 0) {
+ group.append(
+ svgEl('rect', {
+ x: labelWidth,
+ y: y + 2,
+ width: barWidth,
+ height: 18,
+ class: `bar-fill ${row.color}`,
+ }),
+ );
+ }
+
+ group.append(
+ svgEl(
+ 'text',
+ {
+ x: labelWidth + (row.count > 0 ? barWidth + 8 : 8),
+ y: y + 16,
+ class: 'bar-value',
+ },
+ formatInt(row.count),
+ ),
+ );
+
+ group.addEventListener('mousemove', (e) => {
+ const pct = total > 0 ? ((row.count / total) * 100).toFixed(1) : '0';
+ fillTip(severityTip, row.label, [
+ `${formatInt(row.count)} ${t('achados')}`,
+ `${pct}% do total de vulnerabilidades`,
+ 'Clique para filtrar os achados',
+ ]);
+ positionTip(severityTip, e, severityChart.parentElement);
+ severityTip.hidden = false;
+ });
+
+ group.addEventListener('mouseleave', () => {
+ severityTip.hidden = true;
+ });
+
+ group.addEventListener('click', () => {
+ state.filters.findingSeverity = row.key;
+ switchView('findings');
+ });
+
+ severityChart.append(group);
+ });
+}
+
+// 2. Top Exposed Hosts SVG Chart
+function renderHostExposureChart() {
+ const hostScores = state.hosts.map((h) => {
+ let maxCvss = 0;
+ let count = 0;
+ let hasKev = false;
+ for (const p of h.ports || []) {
+ for (const f of p.findings || []) {
+ count += 1;
+ if (f.cvss && f.cvss > maxCvss) maxCvss = f.cvss;
+ if (f.kev) hasKev = true;
+ }
+ }
+ return {
+ ip: h.ip,
+ network: h.network,
+ maxCvss,
+ count,
+ hasKev,
+ };
+ });
+
+ hostScores.sort((a, b) => b.maxCvss - a.maxCvss || b.count - a.count);
+ const topHosts = hostScores.slice(0, 6);
+
+ if (topHosts.length === 0 || topHosts.every((h) => h.count === 0 && h.maxCvss === 0)) {
+ hostExposureChart.setAttribute('viewBox', '0 0 520 220');
+ chartEmpty(hostExposureChart, t('Nenhum host com achados para exibir.'));
+ return;
+ }
+
+ const width = 520;
+ const rowHeight = 36;
+ const top = 16;
+ const labelWidth = 110;
+ const rightPad = 46;
+ const plotWidth = width - labelWidth - rightPad;
+ const height = top + topHosts.length * rowHeight + 24;
+ hostExposureChart.setAttribute('viewBox', `0 0 ${width} ${height}`);
+ hostExposureChart.replaceChildren();
+
+ // Grid
+ const axis = svgEl('g', { class: 'axis' });
+ for (const tick of [0, 2.5, 5.0, 7.5, 10.0]) {
+ const x = labelWidth + (tick / 10.0) * plotWidth;
+ axis.append(
+ svgEl('line', {
+ x1: x,
+ x2: x,
+ y1: top - 4,
+ y2: height - 22,
+ class: tick === 0 ? 'axis-line strong' : 'axis-line',
+ }),
+ );
+ axis.append(
+ svgEl('text', { x, y: height - 8, 'text-anchor': 'middle', class: 'axis-label' }, tick.toFixed(1)),
+ );
+ }
+ hostExposureChart.append(axis);
+
+ topHosts.forEach((host, index) => {
+ const y = top + index * rowHeight;
+ const barWidth = Math.max(3, (host.maxCvss / 10.0) * plotWidth);
+ const sev = cvssSeverity(host.maxCvss);
+
+ const group = svgEl('g', {
+ class: 'bar-row',
+ tabindex: '0',
+ role: 'button',
+ 'aria-label': `${host.ip}: Max CVSS ${host.maxCvss}`,
+ });
+
+ group.append(
+ svgEl('text', { x: labelWidth - 10, y: y + 16, 'text-anchor': 'end', class: 'bar-label mono' }, host.ip),
+ );
+
+ group.append(
+ svgEl('rect', {
+ x: labelWidth,
+ y: y + 2,
+ width: plotWidth,
+ height: 18,
+ class: 'bar-track',
+ }),
+ );
+
+ group.append(
+ svgEl('rect', {
+ x: labelWidth,
+ y: y + 2,
+ width: barWidth,
+ height: 18,
+ class: `bar-fill ${sev}`,
+ }),
+ );
+
+ group.append(
+ svgEl(
+ 'text',
+ {
+ x: labelWidth + barWidth + 8,
+ y: y + 16,
+ class: 'bar-value',
+ },
+ host.maxCvss > 0 ? host.maxCvss.toFixed(1) : '—',
+ ),
+ );
+
+ group.addEventListener('mousemove', (e) => {
+ fillTip(hostExposureTip, host.ip, [
+ `Grupo: ${host.network}`,
+ `Maior CVSS: ${host.maxCvss > 0 ? host.maxCvss.toFixed(1) : '—'} (${severityLabel(sev)})`,
+ `${formatInt(host.count)} vulnerabilidade(s) observada(s)`,
+ host.hasKev ? 'Contém vulnerabilidade no CISA KEV!' : '',
+ 'Clique para abrir na tabela de hosts',
+ ]);
+ positionTip(hostExposureTip, e, hostExposureChart.parentElement);
+ hostExposureTip.hidden = false;
+ });
+
+ group.addEventListener('mouseleave', () => {
+ hostExposureTip.hidden = true;
+ });
+
+ group.addEventListener('click', () => {
+ state.filters.hostSearch = host.ip;
+ state.expandedHosts.add(host.ip);
+ switchView('hosts');
+ });
+
+ hostExposureChart.append(group);
+ });
+}
+
+// 3. Priority Findings List
+function renderOverviewFindings(allFindings) {
+ overviewFindings.replaceChildren();
+ if (allFindings.length === 0) {
+ overviewFindings.append(el('p', 'empty', t('Nenhum achado de vulnerabilidade registrado ainda.')));
+ return;
+ }
+
+ // Sort by KEV first, then highest CVSS
+ const sorted = [...allFindings].sort((a, b) => {
+ if (a.kev !== b.kev) return a.kev ? -1 : 1;
+ return (b.cvss || 0) - (a.cvss || 0);
+ });
+
+ const topItems = sorted.slice(0, 5);
+ topItems.forEach((finding) => {
+ const sev = cvssSeverity(finding.cvss);
+ const item = el('div', `ov-item ${sev}`);
+ item.tabIndex = 0;
+ item.role = 'button';
+
+ const left = el('div');
+ const badge = el('span', `sev-badge ${sev}`);
+ badge.textContent = `${formatScore(finding.cvss)} ${severityLabel(sev)}`;
+ left.append(badge);
+ if (finding.kev) {
+ const kb = el('span', 'kev-badge', t('KEV ATIVO'));
+ kb.style.marginLeft = '6px';
+ left.append(kb);
+ }
+
+ const mid = el('div');
+ const title = el('strong', '', finding.id);
+ const desc = el('p', 'hint', finding.title || finding.description || '');
+ desc.style.margin = '2px 0 0';
+ desc.style.whiteSpace = 'nowrap';
+ desc.style.overflow = 'hidden';
+ desc.style.textOverflow = 'ellipsis';
+ mid.append(title, desc);
+
+ const right = el('div', 'mono', `${finding.hostIp}:${finding.port}`);
+
+ item.append(left, mid, right);
+ item.addEventListener('click', () => {
+ state.filters.findingSearch = finding.id;
+ state.expandedFindings.add(finding.uid);
+ switchView('findings');
+ });
+
+ overviewFindings.append(item);
+ });
+}
+
+function chartEmpty(svg, text) {
+ const viewBox = svg.getAttribute('viewBox') || '0 0 680 220';
+ const [, , width, height] = viewBox.split(' ').map(Number);
+ svg.replaceChildren();
+ const label = svgEl(
+ 'text',
+ {
+ x: width / 2,
+ y: height / 2,
+ 'text-anchor': 'middle',
+ class: 'chart-empty',
+ },
+ text,
+ );
+ svg.append(label);
+}
+
+function positionTip(tip, event, container) {
+ const rect = container.getBoundingClientRect();
+ const width = tip.offsetWidth || 220;
+ const height = tip.offsetHeight || 90;
+ let x = event.clientX - rect.left + 14;
+ let y = event.clientY - rect.top + 14;
+ if (x + width + 12 > rect.width) x = Math.max(8, event.clientX - rect.left - width - 14);
+ if (y + height + 12 > rect.height) y = Math.max(8, event.clientY - rect.top - height - 14);
+ tip.style.left = `${x}px`;
+ tip.style.top = `${y}px`;
+}
+
+function fillTip(tip, title, lines) {
+ tip.replaceChildren();
+ tip.append(el('strong', '', title));
+ for (const line of lines) {
+ if (line) tip.append(el('span', '', line));
+ }
+}
+
+// ------------------------------------------------------------------ HOSTS VIEW
+function renderHosts() {
+ const q = state.filters.hostSearch.trim().toLowerCase();
+ const statusFilter = state.filters.hostStatus;
+
+ const filtered = state.hosts.filter((h) => {
+ if (statusFilter === 'ativo' && h.status !== 'ativo') return false;
+ if (statusFilter === 'with-vulns') {
+ const hasVuln = (h.ports || []).some((p) => (p.findings || []).length > 0);
+ if (!hasVuln) return false;
+ }
+ if (!q) return true;
+ return (
+ h.ip.toLowerCase().includes(q) ||
+ h.network.toLowerCase().includes(q) ||
+ (h.ports || []).some(
+ (p) =>
+ String(p.port).includes(q) ||
+ (p.product && p.product.toLowerCase().includes(q)) ||
+ (p.version && p.version.toLowerCase().includes(q)),
+ )
+ );
+ });
+
+ hostCount.textContent = `${filtered.length} de ${state.hosts.length} hosts`;
+ hostRows.replaceChildren();
+
+ if (state.hosts.length === 0) {
+ const row = document.createElement('tr');
+ const cell = el('td', 'empty', t('Nenhum host carregado.'));
+ cell.colSpan = 8;
+ row.append(cell);
+ hostRows.append(row);
+ return;
+ }
+
+ if (filtered.length === 0) {
+ const row = document.createElement('tr');
+ const cell = el('td', 'empty', t('Nenhum host corresponde aos filtros.'));
+ cell.colSpan = 8;
+ row.append(cell);
+ hostRows.append(row);
+ return;
+ }
+
+ filtered.forEach((host, index) => {
+ const isExpanded = state.expandedHosts.has(host.ip);
+ const row = document.createElement('tr');
+ row.className = `host-row${isExpanded ? ' open' : ''}`;
+ row.tabIndex = 0;
+
+ let maxCvss = 0;
+ let totalFindings = 0;
+ const openPorts = [];
+ for (const p of host.ports || []) {
+ if (p.status === 'aberta') openPorts.push(p.port);
+ for (const f of p.findings || []) {
+ totalFindings += 1;
+ if (f.cvss && f.cvss > maxCvss) maxCvss = f.cvss;
+ }
+ }
+
+ const rankCell = el('td', 'rank', formatInt(index + 1));
+ const ipCell = el('td');
+ ipCell.append(el('strong', 'mono host-name', host.ip));
+
+ const groupCell = el('td', '', host.network);
+
+ const statusCell = el('td');
+ const statusWrap = el(
+ 'span',
+ `status-indicator ${host.status === 'ativo' ? 'active' : 'gone'}`,
+ );
+ statusWrap.append(el('span', 'sdot'), el('span', '', t(host.status)));
+ statusCell.append(statusWrap);
+
+ const portsCell = el('td');
+ if (openPorts.length > 0) {
+ const badges = openPorts.slice(0, 4).map((p) => el('span', 'tag-badge', `TCP/${p}`));
+ if (openPorts.length > 4) {
+ badges.push(el('span', 'mono', `+${openPorts.length - 4}`));
+ }
+ badges.forEach((b) => {
+ b.style.marginRight = '4px';
+ portsCell.append(b);
+ });
+ } else {
+ portsCell.textContent = '—';
+ }
+
+ const maxCvssCell = el('td');
+ if (maxCvss > 0) {
+ const sev = cvssSeverity(maxCvss);
+ const cvssBadge = el('span', `sev-badge ${sev}`, `${maxCvss.toFixed(1)} ${severityLabel(sev)}`);
+ maxCvssCell.append(cvssBadge);
+ } else {
+ maxCvssCell.textContent = '—';
+ }
+
+ const findingsCell = el('td', 'mono', formatInt(totalFindings));
+ const chevronCell = el('td', 'chevron-cell', isExpanded ? '⌄' : '›');
+
+ row.append(
+ rankCell,
+ ipCell,
+ groupCell,
+ statusCell,
+ portsCell,
+ maxCvssCell,
+ findingsCell,
+ chevronCell,
+ );
+
+ row.addEventListener('click', () => {
+ toggleHostExpansion(host.ip);
+ });
+
+ hostRows.append(row);
+
+ if (isExpanded) {
+ const detailRow = document.createElement('tr');
+ detailRow.className = 'host-detail-row';
+ const cell = document.createElement('td');
+ cell.colSpan = 8;
+ cell.append(renderHostDetail(host));
+ detailRow.append(cell);
+ hostRows.append(detailRow);
+ }
+ });
+}
+
+function toggleHostExpansion(ip) {
+ if (state.expandedHosts.has(ip)) state.expandedHosts.delete(ip);
+ else state.expandedHosts.add(ip);
+ renderHosts();
+}
+
+function renderHostDetail(host) {
+ const wrap = el('div', 'host-detail-wrap');
+ const portsGrid = el('div', 'ports-grid');
+
+ if (!host.ports || host.ports.length === 0) {
+ wrap.append(el('p', 'empty', t('Sem portas abertas detectadas.')));
+ return wrap;
+ }
+
+ host.ports.forEach((port) => {
+ const card = el('div', 'port-card');
+ const head = el('div', 'port-card-head');
+ head.append(
+ el('span', 'port-num', `${port.protocol.toUpperCase()}/${port.port}`),
+ el('span', `sev-badge ${port.status === 'aberta' ? 'low' : 'info'}`, t(port.status)),
+ );
+ card.append(head);
+
+ if (port.product || port.version) {
+ const prodText = `${port.product || 'Serviço desconhecido'} ${port.version || ''}`.trim();
+ card.append(el('div', 'port-product', prodText));
+ }
+
+ if (port.cpe) {
+ card.append(el('div', 'cpe-block', port.cpe));
+ }
+
+ const findingsList = el('div', 'port-findings-list');
+ const portFindings = port.findings || [];
+ if (portFindings.length > 0) {
+ card.append(el('strong', 'hint', `${portFindings.length} vulnerabilidade(s) nesta porta:`));
+ portFindings.slice(0, 8).forEach((f) => {
+ const item = el('div', 'port-finding-mini');
+ const left = el('span');
+ const sev = cvssSeverity(f.cvss);
+ left.append(el('strong', '', f.id), el('span', 'dim', ` · ${f.title || ''}`));
+
+ const right = el('span');
+ const badge = el('span', `sev-badge ${sev}`, formatScore(f.cvss));
+ right.append(badge);
+ if (f.kev) {
+ const kb = el('span', 'kev-badge', 'KEV');
+ kb.style.marginLeft = '4px';
+ right.append(kb);
+ }
+
+ item.append(left, right);
+ findingsList.append(item);
+ });
+ if (portFindings.length > 8) {
+ const more = el('button', 'btn small', `+${portFindings.length - 8} achados adicionais...`);
+ more.type = 'button';
+ more.addEventListener('click', () => {
+ state.filters.findingSearch = host.ip;
+ switchView('findings');
+ });
+ findingsList.append(more);
+ }
+ } else {
+ findingsList.append(el('p', 'hint', t('Sem achados nesta porta.')));
+ }
+ card.append(findingsList);
+ portsGrid.append(card);
+ });
+
+ wrap.append(portsGrid);
+ return wrap;
+}
+
+// ------------------------------------------------------------------ FINDINGS VIEW
+function renderFindings() {
+ const allFindings = getAllFindings();
+ const q = state.filters.findingSearch.trim().toLowerCase();
+ const sevFilter = state.filters.findingSeverity;
+ const sort = state.filters.findingSort;
+
+ const filtered = allFindings.filter((f) => {
+ if (sevFilter === 'kev' && !f.kev) return false;
+ if (sevFilter !== 'all' && sevFilter !== 'kev') {
+ if (cvssSeverity(f.cvss) !== sevFilter) return false;
+ }
+ if (!q) return true;
+ return (
+ f.id.toLowerCase().includes(q) ||
+ (f.title && f.title.toLowerCase().includes(q)) ||
+ (f.description && f.description.toLowerCase().includes(q)) ||
+ f.hostIp.toLowerCase().includes(q) ||
+ (f.product && f.product.toLowerCase().includes(q))
+ );
+ });
+
+ // Sorting
+ filtered.sort((a, b) => {
+ if (sort === 'cvss-desc') return (b.cvss || 0) - (a.cvss || 0);
+ if (sort === 'cvss-asc') return (a.cvss || 0) - (b.cvss || 0);
+ if (sort === 'kev-first') {
+ if (a.kev !== b.kev) return a.kev ? -1 : 1;
+ return (b.cvss || 0) - (a.cvss || 0);
+ }
+ if (sort === 'id-asc') return a.id.localeCompare(b.id);
+ return 0;
+ });
+
+ findingsCount.textContent = `${filtered.length} de ${allFindings.length} achados`;
+ findingsList.replaceChildren();
+
+ if (filtered.length === 0) {
+ findingsList.append(
+ el('p', 'empty', t('Nenhum achado encontrado para os filtros selecionados.')),
+ );
+ return;
+ }
+
+ filtered.forEach((finding) => {
+ const isExpanded = state.expandedFindings.has(finding.uid);
+ const sev = cvssSeverity(finding.cvss);
+ const card = el('div', `alert-card ${sev}`);
+
+ const head = el('button', 'alert-head');
+ head.type = 'button';
+ head.setAttribute('aria-expanded', isExpanded ? 'true' : 'false');
+
+ const badge = el('span', `sev-badge ${sev}`, `${formatScore(finding.cvss)} ${severityLabel(sev)}`);
+
+ const main = el('div', 'alert-main');
+ const title = el('div', 'alert-title', `${finding.id} — ${finding.title || finding.description || ''}`);
+ const meta = el('div', 'alert-meta');
+ meta.append(
+ el('span', 'alert-target', `${finding.hostIp}:${finding.port}`),
+ el('span', 'dim', '·'),
+ el('span', '', `${finding.product || 'Serviço'} ${finding.version || ''}`.trim()),
+ );
+ if (finding.kev) {
+ meta.append(el('span', 'kev-badge', t('KEV ATIVO')));
+ }
+ if (finding.confianca) {
+ meta.append(el('span', 'conf-badge', finding.confianca.toUpperCase()));
+ }
+ main.append(title, meta);
+
+ const right = el('div', 'mono', `${finding.protocol.toUpperCase()}/${finding.port}`);
+ const chevron = el('div', 'chevron', isExpanded ? '⌄' : '›');
+
+ head.append(badge, main, right, chevron);
+ head.addEventListener('click', () => {
+ toggleFindingExpansion(finding.uid);
+ });
+ card.append(head);
+
+ if (isExpanded) {
+ const body = el('div', 'alert-body');
+
+ if (finding.description) {
+ body.append(el('p', '', finding.description));
+ }
+
+ // Metrics grid
+ const metrics = el('div', 'metrics');
+ const addMetric = (label, val) => {
+ if (!val) return;
+ const m = el('div', 'metric');
+ m.append(el('span', 'metric-label', label), el('span', 'metric-value', val));
+ metrics.append(m);
+ };
+ addMetric('Score CVSS', formatScore(finding.cvss));
+ addMetric('Host Alvo', finding.hostIp);
+ addMetric('Porta', `${finding.protocol.toUpperCase()}/${finding.port}`);
+ addMetric('Produto', finding.product);
+ addMetric('Versão', finding.version);
+ addMetric('Confiança', finding.confianca);
+ addMetric('Catálogo KEV', finding.kev ? 'Sim (Ativamente explorado)' : 'Não');
+ body.append(metrics);
+
+ if (finding.cpe) {
+ const cpeBox = el('div');
+ cpeBox.append(el('span', 'metric-label', 'CPE Normalizado: '));
+ cpeBox.append(el('span', 'cpe-block', finding.cpe));
+ body.append(cpeBox);
+ }
+
+ // Evidência Determinística
+ if (finding.evidencia && typeof finding.evidencia === 'object') {
+ const evHead = el('div', 'evidence-head');
+ evHead.append(el('h3', '', t('Evidência determinística')));
+ body.append(evHead);
+
+ const table = el('table', 'kv');
+ for (const [k, v] of Object.entries(finding.evidencia)) {
+ const tr = document.createElement('tr');
+ const th = el('th', '', k);
+ const td = el('td', '', typeof v === 'object' ? JSON.stringify(v) : String(v));
+ tr.append(th, td);
+ table.append(tr);
+ }
+ body.append(table);
+ }
+
+ card.append(body);
+ }
+
+ findingsList.append(card);
+ });
+}
+
+function toggleFindingExpansion(uid) {
+ if (state.expandedFindings.has(uid)) state.expandedFindings.delete(uid);
+ else state.expandedFindings.add(uid);
+ renderFindings();
+}
+
+// ------------------------------------------------------------------ GROUPS VIEW
+function renderGroups() {
+ groupsGrid.replaceChildren();
+ feedsSummary.replaceChildren();
+
+ const groups = state.status ? state.status.groups || [] : [];
+ groupsCount.textContent = `${groups.length} ${t('grupos configurados')}`;
+
+ if (groups.length === 0) {
+ groupsGrid.append(el('p', 'empty', t('Nenhum grupo configurado.')));
+ } else {
+ groups.forEach((g) => {
+ const card = el('div', 'group-card');
+ const head = el('div', 'group-card-head');
+ head.append(
+ el('span', 'group-name', g.group),
+ el('span', 'cron-tag', g.cron),
+ );
+ card.append(head);
+
+ const details = el('div', 'hint');
+ details.append(
+ el('span', '', `${t('Perfil:')} `),
+ el('strong', 'tag-badge', g.profile),
+ );
+ card.append(details);
+
+ const next = el('div', 'group-next');
+ next.append(
+ el('span', '', t('Próxima execução:')),
+ el('strong', '', `${timeUntil(g.next_run)} (${g.next_run ? new Date(g.next_run).toLocaleTimeString(LOC()) : '—'})`),
+ );
+ card.append(next);
+
+ groupsGrid.append(card);
+ });
+ }
+
+ // Feeds summary
+ if (state.status) {
+ const tiles = [
+ { label: t('Total de CVEs'), val: formatInt(state.status.feeds_cve_count || 0) },
+ { label: t('Total no KEV'), val: formatInt(state.status.feeds_kev_count || 0) },
+ { label: t('Lotes ingeridos'), val: formatInt(state.status.sweeps_ingested || 0) },
+ {
+ label: t('Último Sync'),
+ val: state.status.feeds_last_sync
+ ? `${timeAgo(state.status.feeds_last_sync)} (${new Date(state.status.feeds_last_sync).toLocaleTimeString(LOC())})`
+ : t('não executado'),
+ },
+ ];
+ tiles.forEach((item) => {
+ const tile = el('div', 'summary-tile');
+ tile.append(el('span', 'summary-label', item.label), el('strong', 'summary-value', item.val));
+ feedsSummary.append(tile);
+ });
+ }
+}
+
+// ------------------------------------------------------------------ CHANGES VIEW
+function renderChanges() {
+ changesTimeline.replaceChildren();
+ const q = state.filters.changesSearch.trim().toLowerCase();
+
+ const filtered = state.changes.filter((c) => {
+ if (!q) return true;
+ return (
+ (c.asset_key && c.asset_key.toLowerCase().includes(q)) ||
+ (c.kind && c.kind.toLowerCase().includes(q)) ||
+ (c.group && c.group.toLowerCase().includes(q))
+ );
+ });
+
+ changesCount.textContent = `${filtered.length} ${t('eventos')}`;
+
+ if (filtered.length === 0) {
+ changesTimeline.append(
+ el('p', 'empty', t('Nenhum evento registrado no período selecionado.')),
+ );
+ return;
+ }
+
+ filtered.forEach((event) => {
+ const item = el('div', 'timeline-item');
+ const kind = event.kind || 'default';
+
+ const dot = el('div', `timeline-dot ${kind}`);
+ dot.textContent = eventKindSymbol(kind);
+
+ const info = el('div', 'timeline-info');
+ info.append(
+ el('div', 'timeline-title', eventKindLabel(kind)),
+ el('div', 'timeline-sub', `${event.asset_key || ''} · grupo ${event.group || ''}`),
+ );
+
+ const time = el('div', 'timeline-time', timeAgo(event.occurred_at));
+
+ item.append(dot, info, time);
+ changesTimeline.append(item);
+ });
+}
+
+function eventKindSymbol(kind) {
+ switch (kind) {
+ case 'host_new': return '+';
+ case 'port_opened': return '▲';
+ case 'service_changed': return '⟳';
+ case 'port_closed': return '▼';
+ case 'host_gone': return '×';
+ default: return '•';
+ }
+}
+
+function eventKindLabel(kind) {
+ switch (kind) {
+ case 'host_new': return t('Novo host descoberto');
+ case 'host_gone': return t('Host ausente/sumido');
+ case 'host_returned': return t('Host retornado');
+ case 'port_opened': return t('Nova porta aberta');
+ case 'port_closed': return t('Porta fechada');
+ case 'service_changed': return t('Serviço alterado');
+ default: return kind;
+ }
+}
+
+// ------------------------------------------------------------------ SETTINGS & THEME
+function initSettings() {
+ const savedLang = localStorage.getItem('xexeu-lang') || 'auto';
+ langSel.value = savedLang;
+ setLang(resolveLang(savedLang));
+
+ const savedTheme = localStorage.getItem('xexeu-theme') || 'auto';
+ applyTheme(savedTheme);
+
+ langSel.addEventListener('change', () => {
+ const val = langSel.value;
+ localStorage.setItem('xexeu-lang', val);
+ setLang(resolveLang(val));
+ render();
+ });
+
+ themePick.querySelectorAll('button').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ const mode = btn.dataset.themePick;
+ localStorage.setItem('xexeu-theme', mode);
+ applyTheme(mode);
+ });
+ });
+
+ settingsBtn.addEventListener('click', openSettingsDialog);
+ closeSettings.addEventListener('click', () => settingsDlg.close());
+ doneSettings.addEventListener('click', () => settingsDlg.close());
+
+ // Listen to language change to trigger re-render
+ document.addEventListener('xexeu:lang', () => {
+ render();
+ });
+}
+
+function applyTheme(mode) {
+ themePick.querySelectorAll('button').forEach((b) => {
+ b.classList.toggle('active', b.dataset.themePick === mode);
+ });
+ if (mode === 'light') {
+ document.documentElement.setAttribute('data-theme', 'light');
+ } else if (mode === 'dark') {
+ document.documentElement.removeAttribute('data-theme');
+ } else {
+ // Auto
+ const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches;
+ if (prefersLight) document.documentElement.setAttribute('data-theme', 'light');
+ else document.documentElement.removeAttribute('data-theme');
+ }
+}
+
+function openSettingsDialog() {
+ settingsDlg.showModal();
+}
+
+// ------------------------------------------------------------------ EVENT LISTENERS
+function initEvents() {
+ // Navigation
+ $$('.nav-item').forEach((item) => {
+ item.addEventListener('click', () => {
+ switchView(item.dataset.target);
+ });
+ });
+
+ // Topbar refresh
+ refreshBtn.addEventListener('click', () => {
+ refreshBtn.disabled = true;
+ fetchData().finally(() => {
+ refreshBtn.disabled = false;
+ });
+ });
+
+ seeAllFindingsBtn.addEventListener('click', () => {
+ state.filters.findingSeverity = 'all';
+ switchView('findings');
+ });
+
+ // Hosts View Filters
+ hostSearch.addEventListener('input', (e) => {
+ state.filters.hostSearch = e.target.value;
+ renderHosts();
+ });
+
+ hostStatusFilters.querySelectorAll('button').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ hostStatusFilters.querySelectorAll('button').forEach((b) => b.classList.remove('active'));
+ btn.classList.add('active');
+ state.filters.hostStatus = btn.dataset.status;
+ renderHosts();
+ });
+ });
+
+ // Findings View Filters
+ findingsSearch.addEventListener('input', (e) => {
+ state.filters.findingSearch = e.target.value;
+ renderFindings();
+ });
+
+ findingsSort.addEventListener('change', (e) => {
+ state.filters.findingSort = e.target.value;
+ renderFindings();
+ });
+
+ severityFilters.querySelectorAll('button').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ severityFilters.querySelectorAll('button').forEach((b) => b.classList.remove('active'));
+ btn.classList.add('active');
+ state.filters.findingSeverity = btn.dataset.severity;
+ renderFindings();
+ });
+ });
+
+ // Changes View Filters
+ changesSearch.addEventListener('input', (e) => {
+ state.filters.changesSearch = e.target.value;
+ renderChanges();
+ });
+
+ changesPeriodFilters.querySelectorAll('button').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ changesPeriodFilters.querySelectorAll('button').forEach((b) => b.classList.remove('active'));
+ btn.classList.add('active');
+ state.filters.changesPeriod = btn.dataset.period;
+ fetchData();
+ });
+ });
+
+ // Keyboard shortcut for settings: Escape to close dialog
+ settingsDlg.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') settingsDlg.close();
+ });
+}
+
+// ------------------------------------------------------------------ INITIALIZATION
+function init() {
+ initSettings();
+ initEvents();
+ fetchData();
+ state.pollTimer = setInterval(fetchData, 10000);
+}
+
+document.addEventListener('DOMContentLoaded', init);
diff --git a/apps/gui/ui/i18n-en.js b/apps/gui/ui/i18n-en.js
new file mode 100644
index 0000000..67ef946
--- /dev/null
+++ b/apps/gui/ui/i18n-en.js
@@ -0,0 +1,155 @@
+export const EN = {
+ 'Xexéu': 'Xexéu',
+ 'superfície contínua e vulnerabilidades': 'continuous attack surface and vulnerabilities',
+ 'Navegação': 'Navigation',
+ 'Visão geral': 'Overview',
+ 'estado e severidade': 'status and severity',
+ 'Hosts': 'Hosts',
+ 'superfície e portas': 'attack surface and ports',
+ 'Achados': 'Findings',
+ 'CVEs e checagens': 'CVEs and checks',
+ 'Grupos': 'Groups',
+ 'escopos e agendamento': 'scopes and schedule',
+ 'Mudanças': 'Changes',
+ 'timeline de auditoria': 'audit timeline',
+ 'Configurações': 'Settings',
+ 'idioma e tema': 'language and theme',
+ 'Conectando…': 'Connecting…',
+ 'Conectado': 'Connected',
+ 'Desconectado': 'Disconnected',
+ 'Atualizar status': 'Refresh status',
+ 'Auditoria contínua de superfície de ataque e identificação de vulnerabilidades': 'Continuous attack surface auditing and vulnerability identification',
+
+ // KPIs
+ 'Hosts ativos': 'Active hosts',
+ 'Portas abertas': 'Open ports',
+ 'Achados críticos / KEV': 'Critical findings / KEV',
+ 'Base de vulnerabilidades': 'Vulnerability database',
+ 'carregando…': 'loading…',
+ 'descobertos em escopo': 'discovered in scope',
+ 'serviços expostos': 'exposed services',
+ 'prioridade máxima': 'highest priority',
+ 'NVD / CISA KEV': 'NVD / CISA KEV',
+ '{n} no KEV': '{n} in KEV',
+ '{n} CVEs': '{n} CVEs',
+
+ // Charts
+ 'Distribuição de achados por severidade': 'Findings distribution by severity',
+ 'Classificação por score CVSS. Clique em uma barra para filtrar os achados.': 'Classification by CVSS score. Click a bar to filter findings.',
+ 'Top hosts expostos': 'Top exposed hosts',
+ 'Hosts com maior severidade CVSS e volume de achados. Clique para abrir detalhes.': 'Hosts with highest CVSS severity and findings volume. Click for details.',
+ 'Crítico': 'Critical',
+ 'Alto': 'High',
+ 'Médio': 'Medium',
+ 'Baixo': 'Low',
+ 'Informativo': 'Informational',
+ 'Nenhum achado para exibir no gráfico.': 'No findings to display in chart.',
+ 'Nenhum host com achados para exibir.': 'No hosts with findings to display.',
+
+ // Priorities
+ 'Achados prioritários': 'Priority findings',
+ 'Vulnerabilidades com maior score CVSS ou catalogadas no CISA KEV (exploração ativa).': 'Vulnerabilities with highest CVSS score or listed in CISA KEV (active exploitation).',
+ 'Ver todos os achados': 'View all findings',
+ 'Nenhum achado de vulnerabilidade registrado ainda.': 'No vulnerability findings recorded yet.',
+
+ // Notice & Footnotes
+ 'Uso autorizado.': 'Authorized use.',
+ 'Auditoria contínua e não-intrusiva estritamente nos escopos autorizados. Nenhum payload destrutivo ou exploit é disparado.': 'Continuous, non-intrusive auditing strictly on authorized scopes. No destructive payload or exploit is fired.',
+ 'Xexéu · auditoria contínua de superfície de ataque': 'Xexéu · continuous attack surface auditing',
+
+ // Hosts View
+ 'Hosts e Superfície Descoberta': 'Hosts and Discovered Surface',
+ 'Ativos mapeados no escopo. Clique em uma linha para ver as portas abertas, serviços e achados correlacionados.': 'Assets mapped in scope. Click a row to see open ports, services and correlated findings.',
+ 'Buscar host': 'Search host',
+ 'Todos': 'All',
+ 'Ativos': 'Active',
+ 'Com vulnerabilidades': 'With vulnerabilities',
+ 'Host (IP)': 'Host (IP)',
+ 'Grupo': 'Group',
+ 'Status': 'Status',
+ 'Portas Abertas': 'Open Ports',
+ 'Maior CVSS': 'Highest CVSS',
+ 'Detalhes': 'Details',
+ 'Nenhum host carregado.': 'No hosts loaded.',
+ 'Nenhum host corresponde aos filtros.': 'No hosts match the filters.',
+ 'Hosts detectados por varredura contínua de escopo. Ausências consecutivas acima do limite marcam o host como sumido.': 'Hosts detected via continuous scope scanning. Consecutive absences beyond the limit mark the host as gone.',
+ '{n} de {n} hosts': '{n} of {n} hosts',
+ 'Sem portas abertas detectadas.': 'No open ports detected.',
+ 'Sem achados nesta porta.': 'No findings on this port.',
+ 'ativo': 'active',
+ 'sumido': 'gone',
+ 'aberta': 'open',
+ 'fechada': 'closed',
+
+ // Findings View
+ 'Inventário de Vulnerabilidades e Checagens': 'Vulnerabilities and Checks Inventory',
+ 'Filtre, ordene e expanda cada achado para inspecionar a evidência determinística completa.': 'Filter, sort and expand each finding to inspect the complete deterministic evidence.',
+ 'Crítico (9.0+)': 'Critical (9.0+)',
+ 'Alto (7.0-8.9)': 'High (7.0-8.9)',
+ 'Médio (4.0-6.9)': 'Medium (4.0-6.9)',
+ 'Baixo (0.1-3.9)': 'Low (0.1-3.9)',
+ 'No KEV': 'In KEV',
+ 'Ordenar': 'Sort by',
+ 'Maior CVSS': 'Highest CVSS',
+ 'Menor CVSS': 'Lowest CVSS',
+ 'KEV primeiro': 'KEV first',
+ 'ID (CVE / Check)': 'ID (CVE / Check)',
+ 'Buscar': 'Search',
+ 'Nenhum achado encontrado para os filtros selecionados.': 'No findings found matching selected filters.',
+ '{n} achados': '{n} findings',
+ '{n} de {n} achados': '{n} of {n} findings',
+ 'KEV ATIVO': 'KEV ACTIVE',
+ 'CONFIRMADA': 'CONFIRMED',
+ 'PROVÁVEL': 'PROBABLE',
+ 'INDETERMINADA': 'INDETERMINATE',
+ 'Evidência determinística': 'Deterministic evidence',
+ 'Sem evidência registrada.': 'No evidence recorded.',
+
+ // Groups View
+ 'Grupos e Cadência de Varredura': 'Groups and Scan Cadence',
+ 'Definições de alvos, perfis de portas e próximas execuções do agendador contínuo.': 'Target definitions, port profiles and upcoming runs of the continuous scheduler.',
+ 'Carregando grupos da configuração…': 'Loading groups from configuration…',
+ 'Nenhum grupo configurado.': 'No groups configured.',
+ '{n} grupos configurados': '{n} configured groups',
+ 'Perfil:': 'Profile:',
+ 'Cron:': 'Cron:',
+ 'Próxima execução:': 'Next execution:',
+ 'em {n}': 'in {n}',
+ 'executando agora…': 'running now…',
+ 'Estado dos Feeds e Motor': 'Feeds and Engine Status',
+ 'Total de CVEs': 'Total CVEs',
+ 'Total no KEV': 'Total in KEV',
+ 'Lotes ingeridos': 'Ingested sweeps',
+ 'Último Sync': 'Last Sync',
+ 'não executado': 'not performed',
+
+ // Changes View
+ 'Histórico de Mudanças na Superfície': 'Attack Surface Change History',
+ 'Diferenças detectadas entre lotes: hosts novos ou sumidos, portas abertas/fechadas e alterações de serviço.': 'Diffs detected between sweeps: new or gone hosts, open/closed ports and service changes.',
+ 'Última 1 hora': 'Last 1 hour',
+ 'Últimas 6 horas': 'Last 6 hours',
+ 'Últimas 24 horas': 'Last 24 hours',
+ 'Últimos 7 dias': 'Last 7 days',
+ 'Filtrar eventos': 'Filter events',
+ 'Nenhum evento registrado no período selecionado.': 'No events recorded in the selected period.',
+ '{n} eventos': '{n} events',
+ 'Novo host descoberto': 'New host discovered',
+ 'Host ausente/sumido': 'Host absent/gone',
+ 'Host retornado': 'Host returned',
+ 'Nova porta aberta': 'New port opened',
+ 'Porta fechada': 'Port closed',
+ 'Serviço alterado': 'Service changed',
+ 'Novo achado de segurança': 'New security finding',
+ 'Achado resolvido': 'Finding resolved',
+
+ // Settings
+ 'Fechar configurações': 'Close settings',
+ 'Fechar': 'Close',
+ 'Idioma': 'Language',
+ 'Tema': 'Theme',
+ 'Claro': 'Light',
+ 'Escuro': 'Dark',
+ 'Auto': 'Auto',
+ 'Português': 'Português',
+ 'English': 'English',
+};
diff --git a/apps/gui/ui/i18n.js b/apps/gui/ui/i18n.js
new file mode 100644
index 0000000..270b92e
--- /dev/null
+++ b/apps/gui/ui/i18n.js
@@ -0,0 +1,134 @@
+import { EN } from './i18n-en.js';
+
+let lang = 'pt';
+export const isEn = () => lang === 'en';
+export const currentLang = () => lang;
+export const LOC = () => (lang === 'en' ? 'en-US' : 'pt-BR');
+
+export function resolveLang(pref) {
+ if (pref === 'pt' || pref === 'en') return pref;
+ return (navigator.language || 'pt').toLowerCase().startsWith('pt') ? 'pt' : 'en';
+}
+
+const ATTRS = ['placeholder', 'title', 'aria-label', 'alt', 'data-empty'];
+const SKIP = '.mono, pre, code, input, textarea, script, style, [data-i18n-skip]';
+
+const exact = new Map(Object.entries(EN).filter(([key]) => !key.includes('{n}')));
+const patterns = Object.entries(EN)
+ .filter(([key]) => key.includes('{n}'))
+ .map(([key, value]) => {
+ const parts = key.split('{n}').map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
+ return { re: new RegExp('^' + parts.join('(.+?)') + '$', 's'), to: value };
+ })
+ .sort((a, b) => b.re.source.length - a.re.source.length);
+
+const cache = new Map();
+export function tr(text) {
+ if (!isEn()) return text;
+ const lead = text.match(/^\s*/)[0];
+ const trail = text.match(/\s*$/)[0];
+ const core = text.trim();
+ if (!core) return text;
+ if (cache.has(core)) return lead + cache.get(core) + trail;
+ let out = exact.get(core);
+ if (out === undefined) {
+ for (const pattern of patterns) {
+ const match = core.match(pattern.re);
+ if (match) {
+ let index = 0;
+ out = pattern.to.replace(/\{n\}/g, () => tr(match[++index] ?? ''));
+ break;
+ }
+ }
+ }
+ if (out === undefined) out = core;
+ if (cache.size > 5000) cache.clear();
+ cache.set(core, out);
+ return lead + out + trail;
+}
+
+const original = new WeakMap();
+let observer = null;
+
+function translateNode(node) {
+ if (node.nodeType === 3) {
+ if (node.parentElement?.closest(SKIP)) return;
+ const source = original.get(node) ?? node.nodeValue;
+ const translated = tr(source);
+ if (translated !== node.nodeValue) {
+ if (!original.has(node)) original.set(node, source);
+ node.nodeValue = translated;
+ }
+ } else if (node.nodeType === 1) {
+ if (node.matches?.(SKIP) && node.tagName !== 'INPUT') return;
+ for (const attribute of ATTRS) {
+ if (node.hasAttribute?.(attribute)) {
+ const key = `i18n-${attribute}`;
+ const source = node[key] ?? node.getAttribute(attribute);
+ const translated = tr(source);
+ if (translated !== node.getAttribute(attribute)) {
+ node[key] = source;
+ node.setAttribute(attribute, translated);
+ }
+ }
+ }
+ for (const child of node.childNodes) translateNode(child);
+ }
+}
+
+function restoreAll(root) {
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
+ let node;
+ while ((node = walker.nextNode())) {
+ if (original.has(node)) {
+ node.nodeValue = original.get(node);
+ original.delete(node);
+ }
+ }
+ root.querySelectorAll('*').forEach((element) => {
+ for (const attribute of ATTRS) {
+ const key = `i18n-${attribute}`;
+ if (element[key] !== undefined) {
+ element.setAttribute(attribute, element[key]);
+ delete element[key];
+ }
+ }
+ });
+}
+
+function start() {
+ translateNode(document.body);
+ if (!observer) {
+ observer = new MutationObserver((mutations) => {
+ if (!isEn()) return;
+ for (const mutation of mutations) {
+ if (mutation.type === 'childList') {
+ for (const added of mutation.addedNodes) translateNode(added);
+ } else if (mutation.type === 'characterData') {
+ translateNode(mutation.target);
+ }
+ }
+ });
+ observer.observe(document.body, { childList: true, subtree: true, characterData: true });
+ }
+}
+
+export function setLang(next) {
+ if (next !== 'pt' && next !== 'en') next = 'pt';
+ const changed = lang !== next;
+ lang = next;
+ cache.clear();
+ document.documentElement.lang = next === 'en' ? 'en' : 'pt-BR';
+ if (changed) {
+ if (isEn()) {
+ start();
+ } else {
+ if (observer) {
+ observer.disconnect();
+ observer = null;
+ }
+ restoreAll(document.body);
+ }
+ document.dispatchEvent(new CustomEvent('xexeu:lang', { detail: { lang } }));
+ }
+}
diff --git a/apps/gui/ui/index.html b/apps/gui/ui/index.html
new file mode 100644
index 0000000..83fb72a
--- /dev/null
+++ b/apps/gui/ui/index.html
@@ -0,0 +1,332 @@
+
+
+
+
+
+Xexéu — Auditoria Contínua de Superfície de Ataque
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Hosts ativos
+ —
+ carregando…
+
+
+ Portas abertas
+ —
+ serviços expostos
+
+
+ Achados críticos / KEV
+ —
+ prioridade máxima
+
+
+ Base de vulnerabilidades
+ —
+ NVD / CISA KEV
+
+
+
+
+
+
+
+
Distribuição de achados por severidade
+
Classificação por score CVSS. Clique em uma barra para filtrar os achados.
+
+
CVSS v2/v3 · KEV
+
+
+
+
+
+
+
+
Top hosts expostos
+
Hosts com maior severidade CVSS e volume de achados. Clique para abrir detalhes.
+
+
superfície de risco
+
+
+
+
+
+
+
+
+
Achados prioritários
+
Vulnerabilidades com maior score CVSS ou catalogadas no CISA KEV (exploração ativa).
+
+
+
+
+
Nenhum achado de vulnerabilidade registrado ainda.
+
+
+
+
+ Uso autorizado.
+ Auditoria contínua e não-intrusiva estritamente nos escopos autorizados. Nenhum payload destrutivo ou exploit é disparado.
+
+
+
+
+
+
+
+
+
Hosts e Superfície Descoberta
+
Ativos mapeados no escopo. Clique em uma linha para ver as portas abertas, serviços e achados correlacionados.
+
+
—
+
+
+
+
+
+
+
+
+ | # |
+ Host (IP) |
+ Grupo |
+ Status |
+ Portas Abertas |
+ Maior CVSS |
+ Achados |
+ Detalhes |
+
+
+
+ | Nenhum host carregado. |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Inventário de Vulnerabilidades e Checagens
+
Filtre, ordene e expanda cada achado para inspecionar a evidência determinística completa.
+
+
—
+
+
+
+
+
+
Nenhum achado encontrado para os filtros selecionados.
+
+
+
+
+
+
+
+
+
+
Grupos e Cadência de Varredura
+
Definições de alvos, perfis de portas e próximas execuções do agendador contínuo.
+
+
—
+
+
+
+
Carregando grupos da configuração…
+
+
+
+
+
+
+
Estado dos Feeds e Motor
+
Informações de sincronização incremental NVD e catálogo CISA KEV.
+
+
+
+
+
+
+
+
+
+
+
+
Histórico de Mudanças na Superfície
+
Diferenças detectadas entre lotes: hosts novos ou sumidos, portas abertas/fechadas e alterações de serviço.
+
+
—
+
+
+
+
+
+
Nenhum evento registrado no período selecionado.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/crates/xexeu-cli/src/main.rs b/crates/xexeu-cli/src/main.rs
index f9d1fb8..0c387b4 100644
--- a/crates/xexeu-cli/src/main.rs
+++ b/crates/xexeu-cli/src/main.rs
@@ -8,8 +8,8 @@ use std::sync::Arc;
use std::time::Duration;
use axum::extract::{Query, State};
-use axum::http::StatusCode;
-use axum::response::Html;
+use axum::http::{header, StatusCode};
+use axum::response::IntoResponse;
use axum::{Json, Router};
use chrono::{DateTime, Utc};
use clap::{Parser, Subcommand};
@@ -883,65 +883,56 @@ async fn changes_handler(
Ok(Json(events))
}
-async fn dashboard_handler() -> Html<&'static str> {
- const HTML: &str = r#"
-
-
-
- Xexéu — Painel de Auditoria Contínua
-
-
-
- Xexéu
- Auditoria contínua de superfície de ataque e identificação de vulnerabilidades
- Carregando status...
-
-
Ativos e Superfície Descoberta
-
Carregando ativos...
-
-
-
-"#;
- Html(HTML)
+const INDEX_HTML: &str = include_str!("../../../apps/gui/ui/index.html");
+const APP_CSS: &str = include_str!("../../../apps/gui/ui/app.css");
+const APP_JS: &str = include_str!("../../../apps/gui/ui/app.js");
+const I18N_JS: &str = include_str!("../../../apps/gui/ui/i18n.js");
+const I18N_EN_JS: &str = include_str!("../../../apps/gui/ui/i18n-en.js");
+const LOGO_PNG: &[u8] = include_bytes!("../../../logo.png");
+
+async fn index_handler() -> impl IntoResponse {
+ (
+ [(header::CONTENT_TYPE, "text/html; charset=utf-8")],
+ INDEX_HTML,
+ )
+}
+
+async fn css_handler() -> impl IntoResponse {
+ ([(header::CONTENT_TYPE, "text/css; charset=utf-8")], APP_CSS)
+}
+
+async fn js_handler() -> impl IntoResponse {
+ (
+ [(
+ header::CONTENT_TYPE,
+ "application/javascript; charset=utf-8",
+ )],
+ APP_JS,
+ )
+}
+
+async fn i18n_js_handler() -> impl IntoResponse {
+ (
+ [(
+ header::CONTENT_TYPE,
+ "application/javascript; charset=utf-8",
+ )],
+ I18N_JS,
+ )
+}
+
+async fn i18n_en_js_handler() -> impl IntoResponse {
+ (
+ [(
+ header::CONTENT_TYPE,
+ "application/javascript; charset=utf-8",
+ )],
+ I18N_EN_JS,
+ )
+}
+
+async fn logo_handler() -> impl IntoResponse {
+ ([(header::CONTENT_TYPE, "image/png")], LOGO_PNG)
}
fn parse_duration_str(raw: &str) -> Option {
@@ -1070,8 +1061,13 @@ async fn run_serve(
.route("/api/status", axum::routing::get(status_handler))
.route("/api/hosts", axum::routing::get(hosts_handler))
.route("/api/changes", axum::routing::get(changes_handler))
- .route("/", axum::routing::get(dashboard_handler))
- .route("/dashboard", axum::routing::get(dashboard_handler))
+ .route("/", axum::routing::get(index_handler))
+ .route("/dashboard", axum::routing::get(index_handler))
+ .route("/app.css", axum::routing::get(css_handler))
+ .route("/app.js", axum::routing::get(js_handler))
+ .route("/i18n.js", axum::routing::get(i18n_js_handler))
+ .route("/i18n-en.js", axum::routing::get(i18n_en_js_handler))
+ .route("/logo.png", axum::routing::get(logo_handler))
.with_state(state);
let listener = tokio::net::TcpListener::bind(bind)
diff --git a/crates/xexeu-cli/tests/serve_e2e.rs b/crates/xexeu-cli/tests/serve_e2e.rs
index 60de767..2cab144 100644
--- a/crates/xexeu-cli/tests/serve_e2e.rs
+++ b/crates/xexeu-cli/tests/serve_e2e.rs
@@ -189,12 +189,41 @@ alvos = ["127.0.0.1/32"]
"changes events: {body}"
);
- // 10. Verify / and /dashboard return HTML
+ // 10. Verify / and /dashboard return HTML, and static assets are served
let (status, body) = http_get(&server_addr, "/");
assert_eq!(status, 200);
assert!(body.contains("Xexéu"), "dashboard html: {body}");
+ assert!(body.contains("app.css"), "dashboard html links css: {body}");
let (status, body) = http_get(&server_addr, "/dashboard");
assert_eq!(status, 200);
assert!(body.contains("Xexéu"), "dashboard html: {body}");
+
+ let (status, body) = http_get(&server_addr, "/app.css");
+ assert_eq!(status, 200);
+ assert!(
+ body.contains("--sev-critical"),
+ "app.css contains severity tokens"
+ );
+
+ let (status, body) = http_get(&server_addr, "/app.js");
+ assert_eq!(status, 200);
+ assert!(
+ body.contains("renderSeverityChart"),
+ "app.js contains chart logic"
+ );
+
+ let (status, body) = http_get(&server_addr, "/i18n.js");
+ assert_eq!(status, 200);
+ assert!(
+ body.contains("export function tr"),
+ "i18n.js contains tr function"
+ );
+
+ let (status, body) = http_get(&server_addr, "/i18n-en.js");
+ assert_eq!(status, 200);
+ assert!(
+ body.contains("export const EN"),
+ "i18n-en.js contains dictionary"
+ );
}
diff --git a/crates/xexeu-cli/tests/validate_real_dvwa_e2e.rs b/crates/xexeu-cli/tests/validate_real_dvwa_e2e.rs
new file mode 100644
index 0000000..a069dfa
--- /dev/null
+++ b/crates/xexeu-cli/tests/validate_real_dvwa_e2e.rs
@@ -0,0 +1,121 @@
+use std::io::{BufRead, BufReader, Read, Write};
+use std::net::TcpStream;
+use std::path::Path;
+use std::process::{Command, Stdio};
+use std::time::{Duration, Instant};
+
+struct ChildGuard(std::process::Child);
+
+impl Drop for ChildGuard {
+ fn drop(&mut self) {
+ let _ = self.0.kill();
+ let _ = self.0.wait();
+ }
+}
+
+fn http_get(addr: &str, path: &str) -> (u16, String) {
+ let mut stream = TcpStream::connect(addr).expect("connect to server");
+ stream
+ .set_read_timeout(Some(Duration::from_secs(3)))
+ .expect("set read timeout");
+ let request = format!("GET {path} HTTP/1.1\r\nHost: {addr}\r\nConnection: close\r\n\r\n");
+ stream.write_all(request.as_bytes()).expect("write request");
+ let mut bytes = Vec::new();
+ stream.read_to_end(&mut bytes).expect("read response");
+ let response = String::from_utf8_lossy(&bytes).to_string();
+ let status_line = response.lines().next().unwrap_or("");
+ let code: u16 = status_line
+ .split_whitespace()
+ .nth(1)
+ .unwrap_or("0")
+ .parse()
+ .unwrap_or(0);
+ let body = response.split("\r\n\r\n").nth(1).unwrap_or("").to_string();
+ (code, body)
+}
+
+#[test]
+fn serve_validates_against_real_dvwa_scan_data() {
+ let validate_dir = Path::new("/tmp/xexeu-validate");
+ if !validate_dir.exists() {
+ eprintln!("skip: /tmp/xexeu-validate does not exist");
+ return;
+ }
+
+ let config_path = validate_dir.join("xexeu.toml");
+ let sweeps_dir = validate_dir.join("sweeps");
+ let data_dir = validate_dir.join("data");
+
+ let mut child = Command::new(env!("CARGO_BIN_EXE_xexeu"))
+ .args([
+ "serve",
+ "--bind",
+ "127.0.0.1:0",
+ "--config",
+ config_path.to_str().expect("config"),
+ "--sweeps",
+ sweeps_dir.to_str().expect("sweeps"),
+ "--data-dir",
+ data_dir.to_str().expect("data"),
+ ])
+ .stdout(Stdio::piped())
+ .stderr(Stdio::inherit())
+ .spawn()
+ .expect("spawn xexeu serve");
+
+ let stdout = child.stdout.take().expect("take stdout");
+ let mut reader = BufReader::new(stdout);
+ let mut server_addr = None;
+ let deadline = Instant::now() + Duration::from_secs(5);
+
+ while Instant::now() < deadline {
+ let mut line = String::new();
+ if reader.read_line(&mut line).unwrap_or(0) > 0 {
+ if let Some(pos) = line.find("http://") {
+ let rest = &line[pos + "http://".len()..];
+ let addr = rest.split_whitespace().next().unwrap_or("").trim();
+ server_addr = Some(addr.to_string());
+ break;
+ }
+ }
+ }
+
+ let _guard = ChildGuard(child);
+ let server_addr = server_addr.expect("server listening addr");
+
+ // Poll /api/hosts
+ let poll_deadline = Instant::now() + Duration::from_secs(6);
+ let mut dvwa_found = false;
+ while Instant::now() < poll_deadline {
+ let (status, body) = http_get(&server_addr, "/api/hosts");
+ if status == 200 && body.contains("172.30.0.10") && body.contains("CVE-2017-3167") {
+ dvwa_found = true;
+ assert!(body.contains("Apache HTTP Server"));
+ assert!(body.contains("2.4.25"));
+ assert!(body.contains(r#""cvss":9.8"#));
+ break;
+ }
+ std::thread::sleep(Duration::from_millis(300));
+ }
+
+ assert!(
+ dvwa_found,
+ "expected DVWA host 172.30.0.10 with CVE-2017-3167 in /api/hosts"
+ );
+
+ // Check dashboard and static assets
+ let (status, body) = http_get(&server_addr, "/");
+ assert_eq!(status, 200);
+ assert!(body.contains("Xexéu"));
+
+ let (status, body) = http_get(&server_addr, "/app.css");
+ assert_eq!(status, 200);
+ assert!(body.contains("--sev-critical"));
+
+ let (status, body) = http_get(&server_addr, "/app.js");
+ assert_eq!(status, 200);
+ assert!(body.contains("renderSeverityChart"));
+
+ let (status, _) = http_get(&server_addr, "/logo.png");
+ assert_eq!(status, 200);
+}