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
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user