feat(gui): implement polished vanilla dashboard with CVSS severity palette and SVG charts
This commit is contained in:
1 parent
3e41c169d0
commit
bc72dbffbd
8 files changed
+2833
-64
No files matched your search
@@ -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; }
|
||||
}
|
||||
+1281
File diff suppressed because it is too large.
Load diff
@@ -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',
|
||||
};
|
||||
@@ -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 } }));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
<!doctype html>
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Xexéu — Auditoria Contínua de Superfície de Ataque</title>
|
||||
<link rel="icon" href="/logo.png">
|
||||
<link rel="stylesheet" href="/app.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<aside class="sidebar">
|
||||
<div class="brand">
|
||||
<img class="logo" src="/logo.png" alt="Xexéu Logo">
|
||||
<div>
|
||||
<strong>Xexéu</strong>
|
||||
<small>superfície contínua e vulnerabilidades</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="side-title">Navegação</div>
|
||||
<nav class="nav" aria-label="Navegação principal">
|
||||
<button type="button" class="nav-item active" data-target="overview" aria-current="page">
|
||||
<span class="nav-icon">◈</span>
|
||||
<span><span class="nav-label">Visão geral</span><span class="nav-sub">estado e severidade</span></span>
|
||||
</button>
|
||||
<button type="button" class="nav-item" data-target="hosts">
|
||||
<span class="nav-icon">▤</span>
|
||||
<span><span class="nav-label">Hosts</span><span class="nav-sub">superfície e portas</span></span>
|
||||
</button>
|
||||
<button type="button" class="nav-item" data-target="findings">
|
||||
<span class="nav-icon">◎</span>
|
||||
<span><span class="nav-label">Achados</span><span class="nav-sub">CVEs e checagens</span></span>
|
||||
</button>
|
||||
<button type="button" class="nav-item" data-target="groups">
|
||||
<span class="nav-icon">⌁</span>
|
||||
<span><span class="nav-label">Grupos</span><span class="nav-sub">escopos e agendamento</span></span>
|
||||
</button>
|
||||
<button type="button" class="nav-item" data-target="changes">
|
||||
<span class="nav-icon">⟲</span>
|
||||
<span><span class="nav-label">Mudanças</span><span class="nav-sub">timeline de auditoria</span></span>
|
||||
</button>
|
||||
<button type="button" class="nav-item" data-target="settings">
|
||||
<span class="nav-icon">⚙</span>
|
||||
<span><span class="nav-label">Configurações</span><span class="nav-sub">idioma e tema</span></span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="side-foot">
|
||||
<div class="status-row">
|
||||
<span id="connection" class="pill"><span class="dot"></span><span id="connectionText">Conectando…</span></span>
|
||||
<span class="pill muted">v0.1.0</span>
|
||||
</div>
|
||||
<div class="status-row">
|
||||
<span id="version" class="mono">Xexéu v0.1.0</span>
|
||||
<span class="mono" id="feedsStatus">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="main">
|
||||
<header class="topbar">
|
||||
<div>
|
||||
<p class="eyebrow">Xexéu</p>
|
||||
<h1 id="viewTitle">Visão geral</h1>
|
||||
<p id="viewSub" class="sub">Auditoria contínua de superfície de ataque e identificação de vulnerabilidades</p>
|
||||
</div>
|
||||
<div class="top-actions">
|
||||
<span id="lastUpdated" class="mono last-updated">—</span>
|
||||
<button id="refreshBtn" type="button" class="btn">Atualizar status</button>
|
||||
<button id="settingsBtn" type="button" class="icon-btn" aria-label="Configurações" title="Configurações">⚙</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 1. VISÃO GERAL -->
|
||||
<section class="view active" id="overview">
|
||||
<div class="kpi-grid">
|
||||
<article class="kpi">
|
||||
<span class="kpi-label">Hosts ativos</span>
|
||||
<strong id="kpiHosts" class="kpi-value">—</strong>
|
||||
<span id="kpiHostsSub" class="kpi-sub">carregando…</span>
|
||||
</article>
|
||||
<article class="kpi">
|
||||
<span class="kpi-label">Portas abertas</span>
|
||||
<strong id="kpiPorts" class="kpi-value">—</strong>
|
||||
<span id="kpiPortsSub" class="kpi-sub">serviços expostos</span>
|
||||
</article>
|
||||
<article class="kpi">
|
||||
<span class="kpi-label">Achados críticos / KEV</span>
|
||||
<strong id="kpiCritical" class="kpi-value">—</strong>
|
||||
<span id="kpiCriticalSub" class="kpi-sub">prioridade máxima</span>
|
||||
</article>
|
||||
<article class="kpi">
|
||||
<span class="kpi-label">Base de vulnerabilidades</span>
|
||||
<strong id="kpiFeeds" class="kpi-value">—</strong>
|
||||
<span id="kpiFeedsSub" class="kpi-sub">NVD / CISA KEV</span>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="charts-grid">
|
||||
<section class="panel chart-panel">
|
||||
<div class="panel-head">
|
||||
<div>
|
||||
<h2>Distribuição de achados por severidade</h2>
|
||||
<p class="hint">Classificação por score CVSS. Clique em uma barra para filtrar os achados.</p>
|
||||
</div>
|
||||
<span class="panel-tag">CVSS v2/v3 · KEV</span>
|
||||
</div>
|
||||
<div class="chart-wrap">
|
||||
<svg id="severityChart" class="chart" role="img" aria-label="Distribuição de achados por severidade"></svg>
|
||||
<div id="severityTip" class="chart-tip" hidden></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel chart-panel">
|
||||
<div class="panel-head">
|
||||
<div>
|
||||
<h2>Top hosts expostos</h2>
|
||||
<p class="hint">Hosts com maior severidade CVSS e volume de achados. Clique para abrir detalhes.</p>
|
||||
</div>
|
||||
<span class="panel-tag">superfície de risco</span>
|
||||
</div>
|
||||
<div class="chart-wrap">
|
||||
<svg id="hostExposureChart" class="chart" role="img" aria-label="Top hosts por maior CVSS"></svg>
|
||||
<div id="hostExposureTip" class="chart-tip" hidden></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-head">
|
||||
<div>
|
||||
<h2>Achados prioritários</h2>
|
||||
<p class="hint">Vulnerabilidades com maior score CVSS ou catalogadas no CISA KEV (exploração ativa).</p>
|
||||
</div>
|
||||
<button id="seeAllFindings" type="button" class="btn">Ver todos os achados</button>
|
||||
</div>
|
||||
<div id="overviewFindings" class="overview-findings">
|
||||
<p class="empty">Nenhum achado de vulnerabilidade registrado ainda.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="notice">
|
||||
<strong>Uso autorizado.</strong>
|
||||
<span>Auditoria contínua e não-intrusiva estritamente nos escopos autorizados. Nenhum payload destrutivo ou exploit é disparado.</span>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<!-- 2. HOSTS -->
|
||||
<section class="view" id="hosts" hidden>
|
||||
<section class="panel">
|
||||
<div class="panel-head">
|
||||
<div>
|
||||
<h2>Hosts e Superfície Descoberta</h2>
|
||||
<p class="hint">Ativos mapeados no escopo. Clique em uma linha para ver as portas abertas, serviços e achados correlacionados.</p>
|
||||
</div>
|
||||
<span id="hostCount" class="panel-tag">—</span>
|
||||
</div>
|
||||
|
||||
<div class="toolbar toolbar-slim">
|
||||
<label class="field compact search-field">
|
||||
<span>Buscar host</span>
|
||||
<input id="hostSearch" type="search" placeholder="IP, grupo ou serviço..." autocomplete="off" spellcheck="false">
|
||||
</label>
|
||||
<div class="chips" id="hostStatusFilters" role="group" aria-label="Filtrar por status">
|
||||
<button type="button" class="chip active" data-status="all">Todos</button>
|
||||
<button type="button" class="chip" data-status="ativo">Ativos</button>
|
||||
<button type="button" class="chip" data-status="with-vulns">Com vulnerabilidades</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="host-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Host (IP)</th>
|
||||
<th scope="col">Grupo</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Portas Abertas</th>
|
||||
<th scope="col">Maior CVSS</th>
|
||||
<th scope="col">Achados</th>
|
||||
<th scope="col"><span class="sr-only">Detalhes</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="hostRows">
|
||||
<tr><td colspan="8" class="empty">Nenhum host carregado.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p class="footnote">Hosts detectados por varredura contínua de escopo. Ausências consecutivas acima do limite marcam o host como sumido.</p>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<!-- 3. ACHADOS -->
|
||||
<section class="view" id="findings" hidden>
|
||||
<section class="panel">
|
||||
<div class="panel-head">
|
||||
<div>
|
||||
<h2>Inventário de Vulnerabilidades e Checagens</h2>
|
||||
<p class="hint">Filtre, ordene e expanda cada achado para inspecionar a evidência determinística completa.</p>
|
||||
</div>
|
||||
<span id="findingsCount" class="panel-tag">—</span>
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
<div class="chips" id="severityFilters" role="group" aria-label="Filtrar por severidade">
|
||||
<button type="button" class="chip active" data-severity="all">Todos</button>
|
||||
<button type="button" class="chip" data-severity="critical">Crítico (9.0+)</button>
|
||||
<button type="button" class="chip" data-severity="high">Alto (7.0-8.9)</button>
|
||||
<button type="button" class="chip" data-severity="medium">Médio (4.0-6.9)</button>
|
||||
<button type="button" class="chip" data-severity="low">Baixo (0.1-3.9)</button>
|
||||
<button type="button" class="chip" data-severity="kev">No KEV</button>
|
||||
</div>
|
||||
<label class="field compact">
|
||||
<span>Ordenar</span>
|
||||
<select id="findingsSort">
|
||||
<option value="cvss-desc">Maior CVSS</option>
|
||||
<option value="cvss-asc">Menor CVSS</option>
|
||||
<option value="kev-first">KEV primeiro</option>
|
||||
<option value="id-asc">ID (CVE / Check)</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="field compact search-field">
|
||||
<span>Buscar</span>
|
||||
<input id="findingsSearch" type="search" placeholder="CVE-..., produto, host ou palavra-chave" autocomplete="off">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="findingsList" class="alert-cards">
|
||||
<p class="empty">Nenhum achado encontrado para os filtros selecionados.</p>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<!-- 4. GRUPOS E AGENDAMENTO -->
|
||||
<section class="view" id="groups" hidden>
|
||||
<section class="panel">
|
||||
<div class="panel-head">
|
||||
<div>
|
||||
<h2>Grupos e Cadência de Varredura</h2>
|
||||
<p class="hint">Definições de alvos, perfis de portas e próximas execuções do agendador contínuo.</p>
|
||||
</div>
|
||||
<span id="groupsCount" class="panel-tag">—</span>
|
||||
</div>
|
||||
|
||||
<div id="groupsGrid" class="groups-grid">
|
||||
<p class="empty">Carregando grupos da configuração…</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-head">
|
||||
<div>
|
||||
<h2>Estado dos Feeds e Motor</h2>
|
||||
<p class="hint">Informações de sincronização incremental NVD e catálogo CISA KEV.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="feedsSummary" class="summary-grid summary-grid-wide"></div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<!-- 5. MUDANÇAS -->
|
||||
<section class="view" id="changes" hidden>
|
||||
<section class="panel">
|
||||
<div class="panel-head">
|
||||
<div>
|
||||
<h2>Histórico de Mudanças na Superfície</h2>
|
||||
<p class="hint">Diferenças detectadas entre lotes: hosts novos ou sumidos, portas abertas/fechadas e alterações de serviço.</p>
|
||||
</div>
|
||||
<span id="changesCount" class="panel-tag">—</span>
|
||||
</div>
|
||||
|
||||
<div class="toolbar toolbar-slim">
|
||||
<div class="chips" id="changesPeriodFilters" role="group" aria-label="Filtrar por período">
|
||||
<button type="button" class="chip" data-period="1h">Última 1 hora</button>
|
||||
<button type="button" class="chip" data-period="6h">Últimas 6 horas</button>
|
||||
<button type="button" class="chip active" data-period="24h">Últimas 24 horas</button>
|
||||
<button type="button" class="chip" data-period="7d">Últimos 7 dias</button>
|
||||
</div>
|
||||
<label class="field compact search-field">
|
||||
<span>Filtrar eventos</span>
|
||||
<input id="changesSearch" type="search" placeholder="Filtrar por IP ou tipo de evento..." autocomplete="off">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="changesTimeline" class="timeline">
|
||||
<p class="empty">Nenhum evento registrado no período selecionado.</p>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<footer class="foot">
|
||||
<span>Xexéu · auditoria contínua de superfície de ataque</span>
|
||||
<span class="mono">MIT OR Apache-2.0</span>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- MODAL DE CONFIGURAÇÕES -->
|
||||
<dialog id="settingsDlg" aria-labelledby="settingsTitle">
|
||||
<form method="dialog">
|
||||
<div class="dialog-head">
|
||||
<h2 id="settingsTitle">Configurações</h2>
|
||||
<button type="button" id="closeSettings" class="icon-btn" aria-label="Fechar configurações" title="Fechar">×</button>
|
||||
</div>
|
||||
<label class="field">
|
||||
<span>Idioma</span>
|
||||
<select id="langSel">
|
||||
<option value="auto">Auto</option>
|
||||
<option value="pt">Português</option>
|
||||
<option value="en">English</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="field">
|
||||
<span>Tema</span>
|
||||
<div class="segmented" id="themePick">
|
||||
<button type="button" data-theme-pick="auto">Auto</button>
|
||||
<button type="button" data-theme-pick="light">Claro</button>
|
||||
<button type="button" data-theme-pick="dark">Escuro</button>
|
||||
</div>
|
||||
</div>
|
||||
<menu>
|
||||
<button type="button" id="doneSettings" class="btn primary">Fechar</button>
|
||||
</menu>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<script type="module" src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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#"<!DOCTYPE html>
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Xexéu — Painel de Auditoria Contínua</title>
|
||||
<style>
|
||||
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #0f172a; color: #f8fafc; margin: 0; padding: 28px; }
|
||||
h1 { font-size: 1.6rem; margin-bottom: 6px; color: #38bdf8; }
|
||||
.subtitle { color: #94a3b8; font-size: 0.95rem; margin-bottom: 24px; }
|
||||
.card { background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 18px; margin-bottom: 20px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
|
||||
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
|
||||
.badge-active { background: #065f46; color: #34d399; }
|
||||
.badge-open { background: #0284c7; color: #bae6fd; margin-right: 4px; font-family: monospace; }
|
||||
table { width: 100%; border-collapse: collapse; margin-top: 14px; }
|
||||
th, td { text-align: left; padding: 12px; border-bottom: 1px solid #334155; font-size: 0.9rem; }
|
||||
th { color: #94a3b8; font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Xexéu</h1>
|
||||
<div class="subtitle">Auditoria contínua de superfície de ataque e identificação de vulnerabilidades</div>
|
||||
<div id="status-card" class="card"><strong>Carregando status...</strong></div>
|
||||
<div class="card">
|
||||
<h2 style="font-size: 1.15rem; margin-top: 0; margin-bottom: 12px;">Ativos e Superfície Descoberta</h2>
|
||||
<div id="hosts-container">Carregando ativos...</div>
|
||||
</div>
|
||||
<script>
|
||||
async function loadData() {
|
||||
try {
|
||||
const sRes = await fetch('/api/status');
|
||||
const status = await sRes.json();
|
||||
document.getElementById('status-card').innerHTML = `
|
||||
<div><strong>Versão:</strong> ${status.version} | <strong>Lotes Ingeridos:</strong> ${status.sweeps_ingested} | <strong>CVEs:</strong> ${status.feeds_cve_count} (${status.feeds_kev_count} no KEV)</div>
|
||||
<div style="margin-top: 6px; font-size: 0.85rem; color: #94a3b8;">Configuração: <code>${status.config_path}</code> | <strong>Último Sync:</strong> ${status.feeds_last_sync || 'não executado'}</div>
|
||||
`;
|
||||
const hRes = await fetch('/api/hosts');
|
||||
const hosts = await hRes.json();
|
||||
if (hosts.length === 0) {
|
||||
document.getElementById('hosts-container').innerHTML = '<p style="color: #94a3b8; margin: 0;">Nenhum ativo ingerido ainda.</p>';
|
||||
return;
|
||||
}
|
||||
let html = '<table><thead><tr><th>IP</th><th>Grupo</th><th>Status</th><th>Portas Abertas</th><th>Visto em</th></tr></thead><tbody>';
|
||||
for (const h of hosts) {
|
||||
const ports = h.ports.filter(p => p.status === 'aberta').map(p => `<span class="badge badge-open">${p.protocol}/${p.port}</span>`).join(' ') || '—';
|
||||
html += `<tr><td><strong>${h.ip}</strong></td><td>${h.network}</td><td><span class="badge badge-active">${h.status}</span></td><td>${ports}</td><td>${h.last_seen}</td></tr>`;
|
||||
}
|
||||
html += '</tbody></table>';
|
||||
document.getElementById('hosts-container').innerHTML = html;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
loadData();
|
||||
setInterval(loadData, 5000);
|
||||
</script>
|
||||
</body>
|
||||
</html>"#;
|
||||
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<Duration> {
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user