Each server runs an ultralight probe (scratch image, ~7 MiB RSS) that tails the logs, ships raw lines to the hub over HTTPS with an on-disk spool, and applies enforce decisions locally. The hub keeps one node per probe (primary node = the 1.x data dir, unchanged), does all analysis and serves the UI. Peer federation is removed. 'urutau import' brings 1.x data dirs in with hash and count verification. UI: probes page, host qualified incidents, IPs never wrap, egress heatmap labels, live and replay globes no longer auto-rotate, replay repeat, live traffic metrics. BREAKING CHANGE: URUTAU_PEERS, URUTAU_PEER_* and /api/v1/peer/* are gone; log path variables move from the hub to the probe. See docs/migration-2.0.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
647 lines
44 KiB
JavaScript
647 lines
44 KiB
JavaScript
/* Urutau - EGRESS page: what the workloads of your servers talk to on the
|
||
internet (outbound traffic). A verdict in plain words, evidence cards per
|
||
finding (beacon rhythm drawn from real connection times), a world map of
|
||
destinations, workload x hour activity, the workloads table, the authorised
|
||
scanner bursts on a time axis and the top destinations.
|
||
Data: /api/v1/egress (+ /api/v1/summary for the server locations).
|
||
Log data is hostile: dynamic text goes through textContent only. */
|
||
(function () {
|
||
'use strict';
|
||
|
||
var SEV = { high: 0, medium: 1, low: 2 };
|
||
var SEV_NAME = ['high', 'medium', 'low'];
|
||
var SEV_TONE = { high: 'danger', medium: 'warn', low: 'info' };
|
||
var KINDS = ['beacon', 'scan', 'port', 'bad_dst', 'dns_bypass', 'new_geo', 'tor'];
|
||
var KIND_HELP = { beacon: 'term.beaconing', scan: 'term.fanout', port: 'term.stratum', bad_dst: 'term.eg_baddst', dns_bypass: 'term.dot', new_geo: 'term.new_geo', tor: 'term.tor' };
|
||
var LAT_TOP = 84, LAT_SPAN = 142;
|
||
var TICKET_STATUS = ['open', 'investigating', 'true_positive', 'false_positive', 'benign', 'resolved'];
|
||
var TICKET_TONE = { open: 'warn', investigating: 'info', true_positive: 'danger', false_positive: 'neutral', benign: 'neutral', resolved: 'ok' };
|
||
|
||
function boot() {
|
||
var U = window.Urutau;
|
||
if (!U || !U.registerPage) return false;
|
||
U.registerI18n({
|
||
en: {
|
||
'eg.title': 'Outbound traffic',
|
||
'eg.error': 'Could not load the outbound traffic data.',
|
||
'eg.retry': 'Try again',
|
||
'eg.disabled': 'Outbound traffic is not being watched',
|
||
'eg.disabled.sub': 'This page shows connections that leave your servers. To see them, add an outbound firewall rule on the server that logs new connections, and set the variable URUTAU_EGRESS so Urutau reads that log.',
|
||
'eg.v.ok': 'No sign of a compromised server',
|
||
'eg.v.ok.sub': '{n} outbound connections {range} from {w} workloads, all with normal behaviour.',
|
||
'eg.v.none': 'No outbound connections {range}',
|
||
'eg.v.none.sub': 'Nothing left the watched workloads in this window.',
|
||
'eg.v.bad.1': '1 sign to investigate',
|
||
'eg.v.bad.n': '{n} signs to investigate',
|
||
'eg.v.bad.sub': 'Found among {c} outbound connections {range}. Start with the first card below.',
|
||
'eg.src': 'Log {state} · {lines} lines read · {bad} unreadable',
|
||
'eg.src.following': 'being followed',
|
||
'eg.src.waiting': 'waiting for the file',
|
||
'eg.src.missing': 'file not found',
|
||
'eg.src.error': 'with errors',
|
||
'eg.kpi.conns': 'Connections',
|
||
'eg.kpi.conns.sub': 'new outbound connections',
|
||
'eg.kpi.dsts': 'Destinations',
|
||
'eg.kpi.dsts.sub': 'addresses in {c} countries',
|
||
'eg.kpi.wl': 'Workloads',
|
||
'eg.kpi.wl.sub': '{n} talking to the internet',
|
||
'eg.kpi.find': 'Findings',
|
||
'eg.kpi.find.sub': '{h} high · {m} medium · {l} low',
|
||
'eg.findings': 'Evidence',
|
||
'eg.findings.hint': 'Each card is one suspicious pattern, most serious first, with what it means and what to do.',
|
||
'eg.calm': 'All quiet',
|
||
'eg.calm.sub': 'No workload is beaconing, scanning, mining or talking to known-bad addresses. Urutau keeps watching every new connection.',
|
||
'eg.sev.high': 'High',
|
||
'eg.sev.medium': 'Medium',
|
||
'eg.sev.low': 'Low',
|
||
'eg.kind.beacon': 'Regular check-ins',
|
||
'eg.kind.scan': 'Mass connection attempts',
|
||
'eg.kind.port': 'Unusual port',
|
||
'eg.kind.bad_dst': 'Known-bad destination',
|
||
'eg.kind.dns_bypass': 'DNS outside the resolver',
|
||
'eg.kind.new_geo': 'New country',
|
||
'eg.kind.tor': 'Talking to the Tor network',
|
||
'eg.why.tor': 'The workload connected to a relay of the Tor network (anonymous routing). On a server this is common in malware, command-and-control and data exfiltration.',
|
||
'eg.do.tor': 'Find the process that opened the connection. Unless Tor is intended on this server, treat it as compromised and rebuild it from a clean image.',
|
||
'eg.infra': 'Regular connections with provider services ({n})',
|
||
'eg.infra.hint': 'Not counted as findings: the host talking to its own cloud provider (agents, metadata, updates).',
|
||
'eg.why.beacon': 'The workload talks to the same destination at regular intervals, like a clock. This is the typical pattern of malware checking in with its controller.',
|
||
'eg.why.scan': 'The workload tried to connect to many different addresses in a short time. A server that scans the internet usually means it was taken over.',
|
||
'eg.why.port': 'Connection to a port used by mining pools or remote-control tools, which normal software on this server does not use.',
|
||
'eg.why.bad_dst': 'The destination is on a list of addresses known for malware or attacks. Nothing on your server should talk to it.',
|
||
'eg.why.dns_bypass': 'The workload asked for names directly from an outside DNS server instead of your resolver. Malware does this to hide what it looks up.',
|
||
'eg.why.new_geo': 'The workload connected to a country it had never reached before in this window. It may be harmless, but is worth a look.',
|
||
'eg.do.beacon': 'Check whether the program is supposed to call this address (an update or monitoring agent). If not, isolate the container, look for unknown processes and rotate its credentials.',
|
||
'eg.do.scan': 'Stop the workload, find which process opened the connections and rebuild it from a clean image.',
|
||
'eg.do.port': 'Look for a crypto miner (high CPU use, unknown binaries) in the workload and rebuild it from a clean image.',
|
||
'eg.do.bad_dst': 'Block the destination at the firewall and investigate the workload as compromised.',
|
||
'eg.do.dns_bypass': 'Force DNS through your resolver at the firewall and check which process made the queries.',
|
||
'eg.do.new_geo': 'Confirm that the service in that country is expected (a CDN or API). If not, treat it as a lead.',
|
||
'eg.f.means': 'What it means',
|
||
'eg.f.todo': 'What to do',
|
||
'eg.f.conns': 'connections',
|
||
'eg.f.every': 'interval',
|
||
'eg.f.jitter': 'variation',
|
||
'eg.f.when': 'first and last',
|
||
'eg.f.host': 'server {h}',
|
||
'eg.f.from': 'workload',
|
||
'eg.f.rhythm': 'Connection rhythm',
|
||
'eg.f.rhythm.sub': 'Each tick is one connection. Evenly spaced ticks mean a machine, not a person.',
|
||
'eg.f.hist': 'Time between connections',
|
||
'eg.f.median': 'typical {s}',
|
||
'eg.f.open': 'Investigate address',
|
||
'eg.map': 'Where the traffic goes',
|
||
'eg.map.hint': 'Lines go from your servers to the countries of the destinations; bigger circles, more connections. Red marks a country with a finding.',
|
||
'eg.map.alt': 'World map of outbound destinations by country.',
|
||
'eg.map.unknown': 'unknown',
|
||
'eg.heat': 'Activity by hour',
|
||
'eg.heat.hint': 'Connections per workload per hour. A lit row at night, or a perfectly even row, deserves a look.',
|
||
'eg.wl': 'Workloads',
|
||
'eg.wl.hint': 'Each workload is a program or container that opens connections to the internet.',
|
||
'eg.wl.col.name': 'Workload',
|
||
'eg.wl.col.conns': 'Connections',
|
||
'eg.wl.col.dsts': 'Destinations',
|
||
'eg.wl.col.ports': 'Ports',
|
||
'eg.wl.col.trend': 'Last 24 h',
|
||
'eg.wl.col.find': 'Findings',
|
||
'eg.wl.supp': '{n} scan connections summarised · beaconing still watched',
|
||
'eg.role.scanner': 'authorised scans summarised',
|
||
'eg.role.default': 'application',
|
||
'eg.role.app': 'application',
|
||
'eg.role.proxy': 'proxy',
|
||
'eg.role.resolver': 'DNS resolver',
|
||
'eg.role.database': 'database',
|
||
'eg.role.system': 'system',
|
||
'eg.scan': 'Authorised scans',
|
||
'eg.scan.hint': 'Bursts of your own scanner on a time axis (taller bar, more targets). They are summarised instead of raising findings, but if the scanner itself starts beaconing it is still flagged.',
|
||
'eg.scan.none': 'No scan bursts in this window.',
|
||
'eg.scan.warn': 'A scan reached {n} known-bad destinations: check that the scanner is not aiming at the wrong targets.',
|
||
'eg.scan.ok': 'No scan touched a known-bad destination.',
|
||
'eg.scan.targets': '{n} targets',
|
||
'eg.scan.conns': '{n} connections',
|
||
'eg.scan.bad': '{n} bad destinations',
|
||
'eg.scan.more': '+{n} networks',
|
||
'eg.dst': 'Top destinations',
|
||
'eg.dst.hint': 'The addresses that received the most connections. Click one to investigate it.',
|
||
'eg.dst.none': 'No destinations in this window.',
|
||
'eg.col.ip': 'Address',
|
||
'eg.col.net': 'Network',
|
||
'eg.col.conns': 'Connections',
|
||
'eg.col.who': 'Workloads',
|
||
'eg.col.ports': 'Ports',
|
||
'help.term.eg_baddst': 'An address that public threat lists mark as used by malware, botnets or attackers.',
|
||
'help.term.eg_baddst.do': 'Nothing legitimate should talk to it: block it and investigate the workload.',
|
||
'help.term.eg_asn': 'The ASN (autonomous system number) identifies the company or provider that owns the destination network, such as a cloud, an ISP or a VPN service.',
|
||
'help.term.eg_jitter': 'How much the time between connections changes. Near 0% means the connections come like clockwork, which people never do.',
|
||
'help.term.eg_port': 'A port is the numbered "door" a connection uses on the destination: 443 is secure web, 53 is DNS, 3333 is often a mining pool.'
|
||
},
|
||
'pt-BR': {
|
||
'eg.title': 'Tráfego de saída',
|
||
'eg.error': 'Não foi possível carregar os dados de tráfego de saída.',
|
||
'eg.retry': 'Tentar de novo',
|
||
'eg.disabled': 'O tráfego de saída não está sendo monitorado',
|
||
'eg.disabled.sub': 'Esta página mostra as conexões que saem dos seus servidores. Para vê-las, crie no servidor uma regra de firewall de saída que registre as conexões novas e defina a variável URUTAU_EGRESS para o Urutau ler esse registro.',
|
||
'eg.v.ok': 'Nenhum sinal de servidor comprometido',
|
||
'eg.v.ok.sub': '{n} conexões de saída {range} vindas de {w} workloads, todas com comportamento normal.',
|
||
'eg.v.none': 'Nenhuma conexão de saída {range}',
|
||
'eg.v.none.sub': 'Nada saiu dos workloads monitorados nesta janela.',
|
||
'eg.v.bad.1': '1 sinal a investigar',
|
||
'eg.v.bad.n': '{n} sinais a investigar',
|
||
'eg.v.bad.sub': 'Encontrados entre {c} conexões de saída {range}. Comece pelo primeiro cartão abaixo.',
|
||
'eg.src': 'Registro {state} · {lines} linhas lidas · {bad} ilegíveis',
|
||
'eg.src.following': 'sendo acompanhado',
|
||
'eg.src.waiting': 'aguardando o arquivo',
|
||
'eg.src.missing': 'não encontrado',
|
||
'eg.src.error': 'com erros',
|
||
'eg.kpi.conns': 'Conexões',
|
||
'eg.kpi.conns.sub': 'novas conexões de saída',
|
||
'eg.kpi.dsts': 'Destinos',
|
||
'eg.kpi.dsts.sub': 'endereços em {c} países',
|
||
'eg.kpi.wl': 'Workloads',
|
||
'eg.kpi.wl.sub': '{n} falando com a internet',
|
||
'eg.kpi.find': 'Achados',
|
||
'eg.kpi.find.sub': '{h} altos · {m} médios · {l} baixos',
|
||
'eg.findings': 'Evidências',
|
||
'eg.findings.hint': 'Cada cartão é um padrão suspeito, do mais grave ao menos grave, com o que significa e o que fazer.',
|
||
'eg.calm': 'Tudo tranquilo',
|
||
'eg.calm.sub': 'Nenhum workload está fazendo contatos regulares, varrendo, minerando ou falando com endereços sabidamente ruins. O Urutau continua vigiando cada conexão nova.',
|
||
'eg.sev.high': 'Alta',
|
||
'eg.sev.medium': 'Média',
|
||
'eg.sev.low': 'Baixa',
|
||
'eg.kind.beacon': 'Contatos em intervalos regulares',
|
||
'eg.kind.scan': 'Tentativas de conexão em massa',
|
||
'eg.kind.port': 'Porta incomum',
|
||
'eg.kind.bad_dst': 'Destino sabidamente ruim',
|
||
'eg.kind.dns_bypass': 'DNS fora do resolvedor',
|
||
'eg.kind.new_geo': 'País novo',
|
||
'eg.kind.tor': 'Conversa com a rede Tor',
|
||
'eg.why.tor': 'O workload conectou a um relay da rede Tor (roteamento anônimo). Em um servidor isso é comum em malware, comando e controle e exfiltração de dados.',
|
||
'eg.do.tor': 'Descubra o processo que abriu a conexão. Se o Tor não é esperado neste servidor, trate-o como comprometido e reconstrua a partir de uma imagem limpa.',
|
||
'eg.infra': 'Conexões regulares com serviços do provedor ({n})',
|
||
'eg.infra.hint': 'Não contam como achados: o servidor falando com a própria nuvem (agentes, metadados, atualizações).',
|
||
'eg.why.beacon': 'O workload fala com o mesmo destino em intervalos regulares, como um relógio. É o padrão típico de um malware avisando seu controlador que está vivo.',
|
||
'eg.why.scan': 'O workload tentou conectar a muitos endereços diferentes em pouco tempo. Um servidor que varre a internet costuma ter sido invadido.',
|
||
'eg.why.port': 'Conexão a uma porta usada por mineração de criptomoeda ou ferramentas de controle remoto, que os programas normais deste servidor não usam.',
|
||
'eg.why.bad_dst': 'O destino está numa lista de endereços conhecidos por malware ou ataques. Nada no seu servidor deveria falar com ele.',
|
||
'eg.why.dns_bypass': 'O workload consultou nomes direto num servidor DNS de fora, em vez do seu resolvedor. Malware faz isso para esconder o que procura.',
|
||
'eg.why.new_geo': 'O workload conectou a um país que ainda não tinha alcançado nesta janela. Pode ser inofensivo, mas vale olhar.',
|
||
'eg.do.beacon': 'Confira se o programa deveria chamar este endereço (um agente de atualização ou monitoramento). Se não, isole o contêiner, procure processos desconhecidos e troque as credenciais dele.',
|
||
'eg.do.scan': 'Pare o workload, descubra qual processo abriu as conexões e recrie-o a partir de uma imagem limpa.',
|
||
'eg.do.port': 'Procure um minerador de criptomoeda (CPU alta, binários desconhecidos) no workload e recrie-o a partir de uma imagem limpa.',
|
||
'eg.do.bad_dst': 'Bloqueie o destino no firewall e investigue o workload como comprometido.',
|
||
'eg.do.dns_bypass': 'Obrigue o DNS a passar pelo seu resolvedor no firewall e veja qual processo fez as consultas.',
|
||
'eg.do.new_geo': 'Confirme se o serviço naquele país é esperado (uma CDN ou API). Se não for, trate como pista.',
|
||
'eg.f.means': 'O que significa',
|
||
'eg.f.todo': 'O que fazer',
|
||
'eg.f.conns': 'conexões',
|
||
'eg.f.every': 'intervalo',
|
||
'eg.f.jitter': 'variação',
|
||
'eg.f.when': 'primeira e última',
|
||
'eg.f.host': 'servidor {h}',
|
||
'eg.f.from': 'workload',
|
||
'eg.f.rhythm': 'Ritmo das conexões',
|
||
'eg.f.rhythm.sub': 'Cada traço é uma conexão. Traços igualmente espaçados indicam uma máquina, não uma pessoa.',
|
||
'eg.f.hist': 'Tempo entre conexões',
|
||
'eg.f.median': 'típico {s}',
|
||
'eg.f.open': 'Investigar endereço',
|
||
'eg.map': 'Para onde vai o tráfego',
|
||
'eg.map.hint': 'As linhas saem dos seus servidores para os países dos destinos; círculos maiores, mais conexões. Vermelho marca um país com achado.',
|
||
'eg.map.alt': 'Mapa-múndi dos destinos de saída por país.',
|
||
'eg.map.unknown': 'desconhecido',
|
||
'eg.heat': 'Atividade por hora',
|
||
'eg.heat.hint': 'Conexões por workload em cada hora. Uma linha acesa de madrugada, ou perfeitamente uniforme, merece atenção.',
|
||
'eg.wl': 'Workloads',
|
||
'eg.wl.hint': 'Cada workload é um programa ou contêiner que abre conexões para a internet.',
|
||
'eg.wl.col.name': 'Workload',
|
||
'eg.wl.col.conns': 'Conexões',
|
||
'eg.wl.col.dsts': 'Destinos',
|
||
'eg.wl.col.ports': 'Portas',
|
||
'eg.wl.col.trend': 'Últimas 24 h',
|
||
'eg.wl.col.find': 'Achados',
|
||
'eg.wl.supp': '{n} conexões de varredura resumidas · contatos regulares continuam vigiados',
|
||
'eg.role.scanner': 'varreduras autorizadas resumidas',
|
||
'eg.role.default': 'aplicação',
|
||
'eg.role.app': 'aplicação',
|
||
'eg.role.proxy': 'proxy',
|
||
'eg.role.resolver': 'resolvedor DNS',
|
||
'eg.role.database': 'banco de dados',
|
||
'eg.role.system': 'sistema',
|
||
'eg.scan': 'Varreduras autorizadas',
|
||
'eg.scan.hint': 'Rajadas do seu próprio scanner num eixo de tempo (barra mais alta, mais alvos). Ficam resumidas em vez de gerar achados, mas se o próprio scanner passar a fazer contatos regulares isso ainda é apontado.',
|
||
'eg.scan.none': 'Nenhuma rajada de varredura nesta janela.',
|
||
'eg.scan.warn': 'Uma varredura atingiu {n} destinos sabidamente ruins: confira se o scanner não está mirando os alvos errados.',
|
||
'eg.scan.ok': 'Nenhuma varredura tocou um destino sabidamente ruim.',
|
||
'eg.scan.targets': '{n} alvos',
|
||
'eg.scan.conns': '{n} conexões',
|
||
'eg.scan.bad': '{n} destinos ruins',
|
||
'eg.scan.more': '+{n} redes',
|
||
'eg.dst': 'Principais destinos',
|
||
'eg.dst.hint': 'Os endereços que mais receberam conexões. Clique em um para investigá-lo.',
|
||
'eg.dst.none': 'Nenhum destino nesta janela.',
|
||
'eg.col.ip': 'Endereço',
|
||
'eg.col.net': 'Rede',
|
||
'eg.col.conns': 'Conexões',
|
||
'eg.col.who': 'Workloads',
|
||
'eg.col.ports': 'Portas',
|
||
'help.term.eg_baddst': 'Um endereço que listas públicas de ameaças marcam como usado por malware, botnets ou atacantes.',
|
||
'help.term.eg_baddst.do': 'Nada legítimo deveria falar com ele: bloqueie e investigue o workload.',
|
||
'help.term.eg_asn': 'O ASN (número de sistema autônomo) identifica a empresa ou provedor dono da rede de destino, como uma nuvem, um provedor de internet ou um serviço de VPN.',
|
||
'help.term.eg_jitter': 'Quanto o tempo entre as conexões muda. Perto de 0% quer dizer que as conexões chegam como um relógio, coisa que pessoas nunca fazem.',
|
||
'help.term.eg_port': 'A porta é a "entrada" numerada que a conexão usa no destino: 443 é web segura, 53 é DNS, 3333 costuma ser um pool de mineração.'
|
||
}
|
||
});
|
||
|
||
var el = U.el, t = U.t, nf = U.fmt.num;
|
||
var root = null, seq = 0, alive = false, ctx = null, data = null, hosts = null, showSup = false;
|
||
|
||
function clear(n) { while (n.firstChild) n.removeChild(n.firstChild); }
|
||
function help(node, key) { if (U.help) U.help(node, key); return node; }
|
||
function ipLink(ip) { return el('a', { href: U.href('ip', [ip]), class: 'mono eg-ip' }, ip); }
|
||
function roleLabel(r) { var k = 'eg.role.' + (r || 'default'); return t(k) !== k ? t(k) : r; }
|
||
function flag(cc) { return cc ? U.fmt.flag(cc) : '\u{1F310}'; }
|
||
function country(cc) { return cc ? U.fmt.country(cc) : t('eg.map.unknown'); }
|
||
function dur(s) {
|
||
s = Math.round(s || 0);
|
||
if (s < 120) return s + ' s';
|
||
if (s < 7200) return Math.round(s / 6) / 10 + ' min';
|
||
return Math.round(s / 360) / 10 + ' h';
|
||
}
|
||
function sevOf(f) { return SEV[f.severity] !== undefined ? f.severity : 'low'; }
|
||
function chips(list, cls) { return el('span', { class: 'eg-chips' }, (list || []).map(function (x) { return el('span', { class: 'chip mono' + (cls ? ' ' + cls : '') }, String(x)); })); }
|
||
function tip(node, text) { var ti = el('title'); ti.textContent = text; node.appendChild(ti); return node; }
|
||
|
||
// ------------------------------------------------------------ verdict + KPIs
|
||
function verdict(d, st, range) {
|
||
var n = st.fnd.length, tone = !n ? (st.conns ? 'ok' : 'neutral') : st.sev.high ? 'danger' : st.sev.medium ? 'warn' : 'info';
|
||
var title = !n ? (st.conns ? t('eg.v.ok') : t('eg.v.none', { range: range })) : n === 1 ? t('eg.v.bad.1') : t('eg.v.bad.n', { n: nf(n) });
|
||
var sub = !n ? (st.conns ? t('eg.v.ok.sub', { n: nf(st.conns), range: range, w: nf(st.active) }) : t('eg.v.none.sub'))
|
||
: t('eg.v.bad.sub', { c: nf(st.conns), range: range });
|
||
var src = d.source || {}, sk = 'eg.src.' + src.state;
|
||
var srcLine = el('p', { class: 'eg-v-src' }, el('span', { class: 'eg-dot eg-dot-' + (src.state === 'following' ? 'ok' : 'warn') }),
|
||
t('eg.src', { state: t(sk) !== sk ? t(sk) : (src.state || '-'), lines: nf(src.lines || 0), bad: nf(src.malformed || 0) }));
|
||
var pills = el('div', { class: 'eg-v-pills' });
|
||
SEV_NAME.forEach(function (s) { if (st.sev[s]) pills.appendChild(U.ui.badge(st.sev[s] + ' ' + t('eg.sev.' + s).toLowerCase(), SEV_TONE[s])); });
|
||
return el('section', { class: 'eg-verdict tone-' + tone },
|
||
el('span', { class: 'eg-v-ico', 'aria-hidden': 'true' }, !n ? '✓' : '!'),
|
||
el('div', { class: 'eg-v-txt' }, el('h2', null, title), el('p', null, sub), pills.firstChild ? pills : null, srcLine));
|
||
}
|
||
|
||
function infraLine(st) {
|
||
var box = el('details', { class: 'eg-infra hint' }, el('summary', { title: t('eg.infra.hint') }, t('eg.infra', { n: nf(st.infra.length) })));
|
||
var ul = el('ul', null);
|
||
st.infra.slice(0, 50).forEach(function (f) {
|
||
var li = el('li', { class: 'mono' }, (f.workload || '-') + ' → ' + (f.dst || '-') + (f.dport ? ':' + f.dport : ''));
|
||
if (f.detail) li.appendChild(el('span', null, ' · ' + f.detail));
|
||
ul.appendChild(li);
|
||
});
|
||
box.appendChild(ul);
|
||
return box;
|
||
}
|
||
|
||
function kpis(st) {
|
||
var kp = el('div', { class: 'eg-kpis' });
|
||
kp.appendChild(U.ui.metric(t('eg.kpi.conns'), nf(st.conns), { sub: t('eg.kpi.conns.sub'), spark: st.total }));
|
||
kp.appendChild(U.ui.metric(t('eg.kpi.dsts'), nf(st.ndst), { sub: t('eg.kpi.dsts.sub', { c: nf(st.ncc) }) }));
|
||
kp.appendChild(U.ui.metric(t('eg.kpi.wl'), nf(st.wls.length), { sub: t('eg.kpi.wl.sub', { n: nf(st.active) }), help: 'term.workload' }));
|
||
kp.appendChild(U.ui.metric(t('eg.kpi.find'), nf(st.fnd.length), { sub: t('eg.kpi.find.sub', { h: st.sev.high, m: st.sev.medium, l: st.sev.low }), tone: st.sev.high ? 'danger' : st.fnd.length ? 'warn' : 'ok' }));
|
||
return kp;
|
||
}
|
||
|
||
// ------------------------------------------------------------ evidence cards
|
||
function rhythm(samples) {
|
||
var a = samples[0], b = samples[samples.length - 1], span = Math.max(1, b - a), W = 600, H = 46;
|
||
var svg = el('svg', { viewBox: '0 0 ' + W + ' ' + H, preserveAspectRatio: 'none', class: 'eg-rhythm', role: 'img', 'aria-label': t('eg.f.rhythm') });
|
||
svg.appendChild(el('line', { x1: 0, y1: H - 6, x2: W, y2: H - 6, class: 'eg-axis' }));
|
||
samples.forEach(function (s) {
|
||
var x = 4 + (s - a) / span * (W - 8);
|
||
svg.appendChild(tip(el('line', { x1: x, y1: 6, x2: x, y2: H - 6, class: 'eg-tick' }), U.fmt.clock(s)));
|
||
});
|
||
return el('div', { class: 'eg-ev-viz' }, el('p', { class: 'eg-ev-lab' }, t('eg.f.rhythm')), svg,
|
||
el('div', { class: 'eg-ev-axis' }, el('span', null, U.fmt.clock(a)), el('span', null, U.fmt.clock(b))),
|
||
el('p', { class: 'hint' }, t('eg.f.rhythm.sub')));
|
||
}
|
||
function histogram(samples, med) {
|
||
var iv = [];
|
||
for (var i = 1; i < samples.length; i++) iv.push(samples[i] - samples[i - 1]);
|
||
if (iv.length < 3) return null;
|
||
var c = med || iv.slice().sort(function (x, y) { return x - y; })[iv.length >> 1];
|
||
var lo = Math.min(Math.min.apply(null, iv), c * 0.5), hi = Math.max(Math.max.apply(null, iv), c * 1.5);
|
||
var nb = 15, bw = (hi - lo) / nb || 1, bins = [];
|
||
for (i = 0; i < nb; i++) bins.push(0);
|
||
iv.forEach(function (v) { bins[Math.max(0, Math.min(nb - 1, Math.floor((v - lo) / bw)))]++; });
|
||
var mx = Math.max.apply(null, bins), W = 300, H = 64;
|
||
var svg = el('svg', { viewBox: '0 0 ' + W + ' ' + H, preserveAspectRatio: 'none', class: 'eg-hist', role: 'img', 'aria-label': t('eg.f.hist') });
|
||
svg.appendChild(el('line', { x1: 0, y1: H - 0.5, x2: W, y2: H - 0.5, class: 'eg-axis' }));
|
||
bins.forEach(function (n, k) {
|
||
var h = n ? Math.max(3, n / mx * (H - 4)) : 0, bx = k * W / nb, on = c >= lo + k * bw && c < lo + (k + 1) * bw;
|
||
svg.appendChild(tip(el('rect', { x: bx + 2, y: H - h, width: W / nb - 4, height: h, rx: 2, class: 'eg-bin' + (on ? ' on' : '') }), dur(lo + k * bw) + ' – ' + dur(lo + (k + 1) * bw) + ': ' + n));
|
||
});
|
||
return el('div', { class: 'eg-ev-viz' }, el('p', { class: 'eg-ev-lab' }, t('eg.f.hist')), svg,
|
||
el('div', { class: 'eg-ev-axis' }, el('span', null, dur(lo)), el('strong', null, t('eg.f.median', { s: dur(c) })), el('span', null, dur(hi))));
|
||
}
|
||
|
||
function evidence(f, st) {
|
||
var kind = KINDS.indexOf(f.kind) >= 0 ? f.kind : null, sev = sevOf(f), dst = st.dstBy[f.dst] || {};
|
||
var title = el('h3', { class: 'eg-ev-title' }, kind ? t('eg.kind.' + kind) : String(f.kind || '-'));
|
||
if (kind) help(title, KIND_HELP[kind]);
|
||
var head = el('div', { class: 'eg-ev-head' }, U.ui.badge(t('eg.sev.' + sev), SEV_TONE[sev]), title);
|
||
if (st.multi && f.host) head.appendChild(el('span', { class: 'chip' }, t('eg.f.host', { h: f.host })));
|
||
if (f.ticket_id) {
|
||
var ts = TICKET_STATUS.indexOf(f.ticket_status) >= 0 ? f.ticket_status : 'open';
|
||
head.appendChild(el('a', { class: 'eg-ticket', href: U.href('incidents', [String(f.ticket_id)]), title: t('eg.f.ticket', { id: String(f.ticket_id) }) },
|
||
el('span', { class: 'mono' }, String(f.ticket_id)), U.ui.badge(t('inc.status.' + ts), TICKET_TONE[ts])));
|
||
}
|
||
if (f.suppressed) head.appendChild(el('span', { class: 'chip' }, t('eg.suppressed.chip')));
|
||
|
||
var route = el('div', { class: 'eg-route' },
|
||
el('span', { class: 'eg-node' }, el('span', { class: 'eg-node-k' }, t('eg.f.from')), el('strong', { class: 'mono' }, f.workload || '-')),
|
||
el('span', { class: 'eg-arrow', 'aria-hidden': 'true' }),
|
||
el('span', { class: 'eg-node eg-node-dst' }, el('span', { class: 'eg-node-k' }, flag(dst.cc) + ' ' + country(dst.cc)),
|
||
el('span', { class: 'eg-node-ip' }, f.dst ? ipLink(f.dst) : '-', f.dport ? el('span', { class: 'mono eg-port' }, ':' + f.dport + (f.proto ? '/' + f.proto : '')) : null),
|
||
dst.asn || dst.org ? el('span', { class: 'eg-node-org' }, (dst.asn || '') + (dst.org ? ' · ' + dst.org : '')) : null));
|
||
|
||
var facts = el('div', { class: 'eg-facts' });
|
||
function fact(v, k, hk) { var lab = el('span', null, k); if (hk) help(lab, hk); facts.appendChild(el('span', { class: 'eg-fact' }, el('strong', { class: 'num' }, v), lab)); }
|
||
if (f.count) fact(nf(f.count), t('eg.f.conns'));
|
||
if (f.interval_s) { fact(dur(f.interval_s), t('eg.f.every')); fact(Math.round((f.jitter || 0) * 100) + '%', t('eg.f.jitter'), 'term.eg_jitter'); }
|
||
if (f.first) fact(U.fmt.clock(f.first) + ' → ' + U.fmt.clock(f.last || f.first), t('eg.f.when'));
|
||
|
||
var body = el('div', { class: 'eg-ev-body' }, el('div', { class: 'eg-ev-top' }, route, facts));
|
||
var samples = (f.samples || []).filter(function (x) { return typeof x === 'number' && isFinite(x); }).sort(function (x, y) { return x - y; });
|
||
if (samples.length >= 3) body.appendChild(el('div', { class: 'eg-ev-vizrow' }, rhythm(samples), histogram(samples, f.interval_s)));
|
||
if (f.detail) body.appendChild(el('p', { class: 'eg-ev-detail mono' }, f.detail));
|
||
if (kind) {
|
||
body.appendChild(el('div', { class: 'eg-ev-advice' },
|
||
el('div', null, el('p', { class: 'eg-ev-lab' }, t('eg.f.means')), el('p', null, t('eg.why.' + kind))),
|
||
el('div', { class: 'eg-ev-todo' }, el('p', { class: 'eg-ev-lab' }, t('eg.f.todo')), el('p', null, t('eg.do.' + kind)))));
|
||
}
|
||
if (f.dst) body.appendChild(el('a', { class: 'btn eg-ev-btn', href: U.href('ip', [f.dst]) }, t('eg.f.open') + ' →'));
|
||
return el('article', { class: 'eg-ev eg-sev-' + sev + (f.suppressed ? ' eg-ev-sup' : '') }, head, body);
|
||
}
|
||
|
||
// ------------------------------------------------------------ map
|
||
function worldMap(st) {
|
||
var world = U.world || window.URUTAU_WORLD;
|
||
if (!world || !world.paths) return null;
|
||
var W = world.w, Hh = world.h, cen = world.centroids || {};
|
||
var svg = el('svg', { viewBox: '0 0 ' + W + ' ' + Math.round(Hh * 0.86), class: 'eg-map', role: 'img', 'aria-label': t('eg.map.alt') });
|
||
var hit = {}, mx = st.cc.length ? st.cc[0].conns || 1 : 1;
|
||
st.cc.forEach(function (c) { if (c.cc) hit[c.cc] = c; });
|
||
Object.keys(world.paths).forEach(function (k) {
|
||
var c = hit[k], lvl = c ? 1 + Math.min(4, Math.floor(c.conns / mx * 4.99)) : 0;
|
||
var p = el('path', { d: world.paths[k], class: 'eg-land' + (lvl ? ' s' + lvl : '') });
|
||
if (c) tip(p, country(k) + ': ' + nf(c.conns));
|
||
svg.appendChild(p);
|
||
});
|
||
var srcs = (hosts || []).map(function (h) { return [(h.lon + 180) / 360 * W, (LAT_TOP - h.lat) / LAT_SPAN * Hh, h.name]; });
|
||
var bad = {};
|
||
st.fnd.forEach(function (f) { var d = st.dstBy[f.dst]; if (d && d.cc) bad[d.cc] = Math.min(bad[d.cc] === undefined ? 9 : bad[d.cc], SEV[sevOf(f)]); });
|
||
var arcs = el('g'), dots = el('g');
|
||
st.cc.forEach(function (c) {
|
||
var p = cen[c.cc]; if (!p) return;
|
||
var b = bad[c.cc], cls = b === 0 ? ' danger' : b === 1 ? ' warn' : '';
|
||
srcs.forEach(function (s) {
|
||
var dx = p[0] - s[0], dy = p[1] - s[1], dist = Math.sqrt(dx * dx + dy * dy);
|
||
if (dist < 4) return;
|
||
var qx = (s[0] + p[0]) / 2, qy = (s[1] + p[1]) / 2 - dist * 0.25;
|
||
arcs.appendChild(el('path', { d: 'M' + s[0].toFixed(1) + ' ' + s[1].toFixed(1) + 'Q' + qx.toFixed(1) + ' ' + qy.toFixed(1) + ' ' + p[0] + ' ' + p[1], class: 'eg-arc' + cls }));
|
||
});
|
||
dots.appendChild(tip(el('circle', { cx: p[0], cy: p[1], r: (7 + Math.sqrt(c.conns / mx) * 18).toFixed(1), class: 'eg-dst' + cls }), country(c.cc) + ': ' + nf(c.conns)));
|
||
});
|
||
srcs.forEach(function (s) {
|
||
dots.appendChild(el('circle', { cx: s[0], cy: s[1], r: 16, class: 'eg-src-halo' }));
|
||
dots.appendChild(tip(el('circle', { cx: s[0], cy: s[1], r: 7, class: 'eg-src' }), s[2]));
|
||
});
|
||
svg.appendChild(arcs); svg.appendChild(dots);
|
||
return svg;
|
||
}
|
||
function countryBars(st) {
|
||
var list = el('ol', { class: 'eg-cc' }), mx = st.cc.length ? st.cc[0].conns || 1 : 1;
|
||
st.cc.slice(0, 8).forEach(function (c) {
|
||
list.appendChild(el('li', null, el('span', { class: 'eg-cc-name' }, flag(c.cc) + ' ' + country(c.cc)),
|
||
el('span', { class: 'eg-cc-n num' }, nf(c.conns)),
|
||
el('span', { class: 'eg-bar' }, el('span', { style: { width: Math.max(2, c.conns / mx * 100) + '%' } }))));
|
||
});
|
||
return list;
|
||
}
|
||
|
||
// ------------------------------------------------------------ workloads
|
||
function seriesOf(st, w) { return st.ser[(w.host ? w.host + '/' : '') + w.name] || st.ser[w.name] || []; }
|
||
function workloadsTable(st) {
|
||
var tb = el('tbody');
|
||
st.wls.forEach(function (w) {
|
||
var scanner = w.role === 'scanner', s = seriesOf(st, w).slice(-24);
|
||
var badge = U.ui.badge(roleLabel(w.role), scanner ? 'info' : 'neutral');
|
||
var name = el('div', { class: 'eg-wl-name' }, el('strong', { class: 'mono' }, w.name), badge);
|
||
if (scanner) help(badge, 'term.authorized_scanner');
|
||
if (st.multi && w.host) name.appendChild(el('span', { class: 'chip' }, w.host));
|
||
if (scanner || w.suppressed_scan_conns) name.appendChild(el('span', { class: 'hint eg-wl-supp' }, t('eg.wl.supp', { n: nf(w.suppressed_scan_conns || 0) })));
|
||
var sp = s.length > 1 && Math.max.apply(null, s) > 0 && U.charts && U.charts.sparkline ? U.charts.sparkline(s) : null;
|
||
tb.appendChild(el('tr', { class: w.findings ? 'eg-row-bad' : '' },
|
||
el('td', { class: 'eg-c-name' }, name),
|
||
el('td', { class: 'num', 'data-l': t('eg.wl.col.conns') }, nf(w.conns || 0)),
|
||
el('td', { class: 'num', 'data-l': t('eg.wl.col.dsts') }, nf(w.dsts || 0)),
|
||
el('td', { class: 'num', 'data-l': t('eg.wl.col.ports') }, nf(w.ports || 0)),
|
||
el('td', { class: 'eg-spark', 'data-l': t('eg.wl.col.trend') }, sp || el('span', { class: 'hint' }, '–')),
|
||
el('td', { class: 'num', 'data-l': t('eg.wl.col.find') }, w.findings ? U.ui.badge(nf(w.findings), 'danger') : el('span', { class: 'eg-ok' }, '✓'))));
|
||
});
|
||
var th = el('tr', null, [['name', ''], ['conns', 'num'], ['dsts', 'num'], ['ports', 'num'], ['trend', ''], ['find', 'num']].map(function (c) { return el('th', { class: c[1] }, t('eg.wl.col.' + c[0])); }));
|
||
help(th.children[3], 'term.eg_port');
|
||
return el('table', { class: 'eg-table eg-wl-table' }, el('thead', null, th), tb);
|
||
}
|
||
|
||
function heat(st) {
|
||
if (!U.charts || !U.charts.heatmap || !st.wls.length) return null;
|
||
var rows = [], labels = [], step = st.tl.step || 3600;
|
||
st.wls.forEach(function (w) { var s = seriesOf(st, w); if (s.length) { rows.push(s.slice(-24)); labels.push(String(w.name)); } });
|
||
if (!rows.length) return null;
|
||
var n = rows[0].length, start = (st.tl.start || 0) + (st.tlLen - n) * step, xl = [];
|
||
for (var i = 0; i < n; i++) xl.push(('0' + new Date((start + i * step) * 1000).getHours()).slice(-2) + 'h');
|
||
return U.charts.heatmap(rows, xl, labels, { title: t('eg.heat') });
|
||
}
|
||
|
||
// ------------------------------------------------------------ scanner
|
||
function scans(st) {
|
||
var bursts = st.bursts.slice().sort(function (a, b) { return (a.start || 0) - (b.start || 0); });
|
||
var box = el('div', { class: 'eg-scan' }), bad = 0;
|
||
bursts.forEach(function (b) { bad += b.bad_dst_hits || 0; });
|
||
box.appendChild(bad ? el('div', { class: 'state-error eg-scanwarn' }, el('strong', null, t('eg.scan.warn', { n: nf(bad) })))
|
||
: el('p', { class: 'eg-scan-ok' }, el('span', { class: 'eg-dot eg-dot-ok' }), t('eg.scan.ok')));
|
||
var t0 = Infinity, t1 = -Infinity, mxT = 1;
|
||
bursts.forEach(function (b) { t0 = Math.min(t0, b.start); t1 = Math.max(t1, b.end || b.start); mxT = Math.max(mxT, b.targets || 0); });
|
||
var span = Math.max(3600, t1 - t0), W = 1000, H = 60;
|
||
var svg = el('svg', { viewBox: '0 0 ' + W + ' ' + H, preserveAspectRatio: 'none', class: 'eg-scan-tl', role: 'img', 'aria-label': t('eg.scan') });
|
||
svg.appendChild(el('line', { x1: 0, y1: H - 1, x2: W, y2: H - 1, class: 'eg-axis' }));
|
||
bursts.forEach(function (b) {
|
||
var x = (b.start - t0) / span * (W - 14) + 2, w = Math.max(10, ((b.end || b.start) - b.start) / span * W), h = 12 + (b.targets || 0) / mxT * (H - 16);
|
||
svg.appendChild(tip(el('rect', { x: x, y: H - 1 - h, width: w, height: h, rx: 2, class: 'eg-burst' + (b.bad_dst_hits ? ' bad' : '') }), U.fmt.clock(b.start) + ' · ' + t('eg.scan.targets', { n: nf(b.targets || 0) })));
|
||
});
|
||
box.appendChild(el('div', { class: 'eg-ev-viz' }, svg, el('div', { class: 'eg-ev-axis' }, el('span', null, U.fmt.clock(t0)), el('span', null, U.fmt.clock(t1)))));
|
||
var ul = el('ul', { class: 'eg-bursts' });
|
||
bursts.slice().reverse().slice(0, 6).forEach(function (b) {
|
||
var nets = (b.nets || []).slice(0, 3), more = (b.nets || []).length - nets.length;
|
||
ul.appendChild(el('li', { class: b.bad_dst_hits ? 'bad' : '' },
|
||
el('span', { class: 'eg-b-when mono' }, U.fmt.clock(b.start)),
|
||
el('span', { class: 'eg-b-main' }, el('strong', null, t('eg.scan.targets', { n: nf(b.targets || 0) })),
|
||
el('span', { class: 'hint' }, ' · ' + t('eg.scan.conns', { n: nf(b.conns || 0) }) + (st.multi && b.host ? ' · ' + b.host : '')),
|
||
b.bad_dst_hits ? U.ui.badge(t('eg.scan.bad', { n: nf(b.bad_dst_hits) }), 'danger') : null),
|
||
el('span', { class: 'eg-b-chips' }, chips(nets), more > 0 ? el('span', { class: 'hint' }, t('eg.scan.more', { n: more })) : null, chips(b.ports, 'eg-chip-port'))));
|
||
});
|
||
box.appendChild(ul);
|
||
return box;
|
||
}
|
||
|
||
// ------------------------------------------------------------ destinations
|
||
function destinations(st) {
|
||
var tb = el('tbody'), mx = st.dsts.length ? st.dsts[0].conns || 1 : 1;
|
||
st.dsts.slice(0, 15).forEach(function (x) {
|
||
var flagged = st.badDst[x.ip];
|
||
tb.appendChild(el('tr', { class: flagged !== undefined ? 'eg-row-bad' : '' },
|
||
el('td', { class: 'eg-c-name' }, el('span', { class: 'eg-dst-ip' }, el('span', { class: 'eg-flag', title: country(x.cc) }, flag(x.cc)), ipLink(x.ip),
|
||
flagged !== undefined ? U.ui.badge(t('eg.sev.' + flagged), SEV_TONE[flagged]) : null)),
|
||
el('td', { 'data-l': t('eg.col.net') }, el('span', { class: 'eg-org' }, el('span', { class: 'mono eg-asn' }, x.asn || ''), ' ', x.org || country(x.cc))),
|
||
el('td', { class: 'num eg-conns', 'data-l': t('eg.col.conns') }, nf(x.conns || 0), el('span', { class: 'eg-bar' }, el('span', { style: { width: Math.max(2, (x.conns || 0) / mx * 100) + '%' } }))),
|
||
el('td', { 'data-l': t('eg.col.ports') }, chips(x.ports, 'eg-chip-port')),
|
||
el('td', { 'data-l': t('eg.col.who') }, chips(x.workloads))));
|
||
});
|
||
var th = el('tr', null, [['ip', ''], ['net', ''], ['conns', 'num'], ['ports', ''], ['who', '']].map(function (c) { return el('th', { class: c[1] }, t('eg.col.' + c[0])); }));
|
||
help(th.children[1], 'term.eg_asn');
|
||
return el('table', { class: 'eg-table eg-dst-table' }, el('thead', null, th), tb);
|
||
}
|
||
|
||
// ------------------------------------------------------------ paint
|
||
function stats(d) {
|
||
var st = { wls: d.workloads || [], fnd: (d.findings || []).slice(), dsts: d.top_dst || [], bursts: (d.scanner && d.scanner.bursts) || [], tl: d.timeline || {} };
|
||
st.infra = st.fnd.filter(function (f) { return f.severity === 'info' || f.kind === 'infra'; });
|
||
st.fnd = st.fnd.filter(function (f) { return f.severity !== 'info' && f.kind !== 'infra'; });
|
||
st.fnd.sort(function (a, b) { return SEV[sevOf(a)] - SEV[sevOf(b)] || (b.last || 0) - (a.last || 0); });
|
||
st.ser = st.tl.series || {};
|
||
st.conns = 0; st.active = 0; st.sev = { high: 0, medium: 0, low: 0 };
|
||
st.wls.forEach(function (w) { st.conns += w.conns || 0; if (w.conns) st.active++; });
|
||
st.fnd.forEach(function (f) { st.sev[sevOf(f)]++; });
|
||
var hs = {};
|
||
st.wls.forEach(function (w) { if (w.host) hs[w.host] = 1; });
|
||
st.multi = Object.keys(hs).length > 1;
|
||
st.dstBy = {}; st.dsts.forEach(function (x) { if (!st.dstBy[x.ip]) st.dstBy[x.ip] = x; });
|
||
st.badDst = {}; st.fnd.forEach(function (f) { if (f.dst && st.badDst[f.dst] === undefined) st.badDst[f.dst] = sevOf(f); });
|
||
st.tlLen = 0; var tot = [];
|
||
Object.keys(st.ser).forEach(function (k) { var v = st.ser[k] || []; st.tlLen = Math.max(st.tlLen, v.length); v.forEach(function (x, i) { tot[i] = (tot[i] || 0) + (x || 0); }); });
|
||
for (var i = 0; i < st.tlLen; i++) tot[i] = tot[i] || 0;
|
||
st.total = tot.slice(-48);
|
||
st.cc = (d.by_country || []).slice();
|
||
if (!st.cc.length) {
|
||
var m = {};
|
||
st.dsts.forEach(function (x) { var c = m[x.cc] || (m[x.cc] = { cc: x.cc, conns: 0, dsts: 0 }); c.conns += x.conns || 0; c.dsts++; });
|
||
st.cc = Object.keys(m).map(function (k) { return m[k]; }).sort(function (a, b) { return b.conns - a.conns; });
|
||
}
|
||
st.ndst = 0; st.cc.forEach(function (c) { st.ndst += c.dsts || 0; });
|
||
if (!st.ndst) st.ndst = st.dsts.length;
|
||
st.ncc = st.cc.filter(function (c) { return c.cc; }).length;
|
||
return st;
|
||
}
|
||
|
||
function paint() {
|
||
if (!root) return;
|
||
clear(root);
|
||
if (!data) { root.appendChild(el('div', { class: 'skeleton', style: { height: '8rem' } })); return; }
|
||
if (!data.enabled) { root.appendChild(U.ui.empty(t('eg.disabled'), t('eg.disabled.sub'))); return; }
|
||
var st = stats(data), range = U.rangeLabel({ inline: true });
|
||
root.appendChild(verdict(data, st, range));
|
||
root.appendChild(kpis(st));
|
||
if (st.infra.length) root.appendChild(infraLine(st));
|
||
|
||
var grid = el('div', { class: 'grid-12' });
|
||
var supN = data.suppressed_count || 0, fpActs = null;
|
||
if (supN || showSup) {
|
||
var cb = el('input', { type: 'checkbox', id: 'eg-sup' });
|
||
cb.checked = showSup;
|
||
cb.addEventListener('change', function () { showSup = cb.checked; load(); });
|
||
fpActs = el('label', { class: 'eg-sup-toggle', for: 'eg-sup' }, cb, el('span', null, t('eg.suppressed.toggle', { n: nf(supN) })));
|
||
}
|
||
var fp = U.ui.panel({ title: t('eg.findings'), hint: t('eg.findings.hint'), cls: 'span-12', actions: fpActs });
|
||
if (!st.fnd.length) {
|
||
fp.body.appendChild(el('div', { class: 'eg-calm' }, el('span', { class: 'eg-calm-ico', 'aria-hidden': 'true' }, '✓'),
|
||
el('div', null, el('strong', null, t('eg.calm')), el('p', null, t('eg.calm.sub')))));
|
||
} else {
|
||
var list = el('div', { class: 'eg-evs' });
|
||
st.fnd.slice(0, 20).forEach(function (f) { list.appendChild(evidence(f, st)); });
|
||
fp.body.appendChild(list);
|
||
}
|
||
grid.appendChild(fp);
|
||
|
||
if (st.cc.length) {
|
||
var mp = U.ui.panel({ title: t('eg.map'), hint: t('eg.map.hint'), cls: 'span-12', variant: 'map' });
|
||
var m = worldMap(st);
|
||
mp.body.appendChild(el('div', { class: 'eg-mapwrap' }, m ? el('div', { class: 'eg-mapbox' }, m) : null, countryBars(st)));
|
||
grid.appendChild(mp);
|
||
}
|
||
|
||
var hm = heat(st);
|
||
if (hm) {
|
||
var hp = U.ui.panel({ title: t('eg.heat'), hint: t('eg.heat.hint'), cls: 'span-12', variant: 'chart' });
|
||
hp.body.appendChild(hm);
|
||
grid.appendChild(hp);
|
||
}
|
||
|
||
if (st.wls.length) {
|
||
var wp = U.ui.panel({ title: t('eg.wl'), hint: t('eg.wl.hint'), cls: 'span-12', variant: 'list', help: 'term.workload' });
|
||
wp.body.appendChild(workloadsTable(st));
|
||
grid.appendChild(wp);
|
||
}
|
||
|
||
var sp = U.ui.panel({ title: t('eg.scan'), hint: t('eg.scan.hint'), cls: 'span-12', help: 'term.authorized_scanner' });
|
||
if (!st.bursts.length) sp.body.appendChild(U.ui.empty(t('eg.scan.none')));
|
||
else sp.body.appendChild(scans(st));
|
||
grid.appendChild(sp);
|
||
|
||
var dp = U.ui.panel({ title: t('eg.dst'), hint: t('eg.dst.hint'), cls: 'span-12', variant: 'list' });
|
||
if (!st.dsts.length) dp.body.appendChild(U.ui.empty(t('eg.dst.none')));
|
||
else dp.body.appendChild(destinations(st));
|
||
grid.appendChild(dp);
|
||
root.appendChild(grid);
|
||
}
|
||
|
||
function load() {
|
||
var my = ++seq;
|
||
var p = Object.assign({}, U.rangeParams());
|
||
if (ctx && ctx.host && ctx.host !== 'all') p.host = ctx.host;
|
||
if (showSup) p.suppressed = 1;
|
||
if (!hosts) {
|
||
hosts = [];
|
||
U.api('/api/v1/summary', { range: '1h', host: 'all' }).then(function (s) {
|
||
if (!alive) return;
|
||
(Array.isArray(s && s.hosts) ? s.hosts : []).forEach(function (h) {
|
||
var l = h && h.location;
|
||
if (l && typeof l.lat === 'number' && typeof l.lon === 'number' && Math.abs(l.lat) <= 90 && Math.abs(l.lon) <= 180) hosts.push({ name: String(h.name || '').slice(0, 64), lat: l.lat, lon: l.lon });
|
||
});
|
||
if (data) paint();
|
||
}).catch(function () { });
|
||
}
|
||
U.api('/api/v1/egress', p).then(function (d) {
|
||
if (!alive || my !== seq) return;
|
||
data = d; paint();
|
||
}).catch(function () {
|
||
if (!alive || my !== seq || data) return;
|
||
clear(root);
|
||
var b = el('button', { type: 'button', class: 'btn' }, t('eg.retry'));
|
||
b.addEventListener('click', load);
|
||
root.appendChild(el('div', { class: 'state-error' }, el('strong', null, t('eg.error')), b));
|
||
});
|
||
}
|
||
|
||
U.registerPage({
|
||
id: 'egress', group: 'investigate', titleKey: 'eg.title',
|
||
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><rect x="3" y="5" width="12" height="14" rx="2"/><path d="M11 12h10"/><path d="M17 8l4 4-4 4"/></svg>',
|
||
mount: function (node, cx) { root = el('div', { class: 'eg-page' }); node.appendChild(root); ctx = cx; alive = true; data = null; paint(); load(); },
|
||
update: function (cx) { ctx = cx; load(); },
|
||
refresh: function () { load(); },
|
||
unmount: function () { alive = false; seq++; if (root && root.parentNode) root.parentNode.removeChild(root); root = null; data = null; }
|
||
});
|
||
return true;
|
||
}
|
||
|
||
if (!boot()) {
|
||
var tries = 0, iv = setInterval(function () { if (boot() || ++tries > 50) clearInterval(iv); }, 100);
|
||
}
|
||
})();
|