feat: 1.4.0 second firewall, egress analysis and HTML report
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 28s
CI / Dependency audit (push) Successful in 16s
CI / Tests (Linux, race detector) (push) Successful in 1m3s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 3s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 28s
CI / Dependency audit (push) Successful in 16s
CI / Tests (Linux, race detector) (push) Successful in 1m3s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 3s
Optional second firewall (URUTAU_ENFORCE off/observe/on) through the host fail2ban, outbound traffic analysis (beaconing, mining, spam, DNS bypass, unauthorised scans) with authorised scanner workloads, host kit in deploy/host and a printable HTML report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3adaa007ec
commit
c33cca22e3
59 files changed
+7364
-24
No files matched your search
@@ -0,0 +1,355 @@
|
||||
/* Urutau - EGRESS page: what the workloads of your servers talk to on the
|
||||
internet (outbound traffic). Beacons, scans, odd ports, known-bad
|
||||
destinations, DNS bypass, new countries, and the summarised scans of the
|
||||
authorised scanner. Data: /api/v1/egress. Log data is hostile: dynamic text
|
||||
goes through textContent only. */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var SEV = { high: 0, medium: 1, low: 2 };
|
||||
var SEV_TONE = { high: 'danger', medium: 'warn', low: 'info' };
|
||||
var KINDS = ['beacon', 'scan', 'port', 'bad_dst', 'dns_bypass', 'new_geo'];
|
||||
var KIND_HELP = { beacon: 'term.beaconing', scan: 'term.fanout', port: 'term.stratum', bad_dst: 'term.c2', dns_bypass: 'term.dot', new_geo: 'term.new_geo' };
|
||||
|
||||
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.lead.none': 'No outbound connections {range}',
|
||||
'eg.lead.none.sub': 'Nothing left the watched workloads in this window.',
|
||||
'eg.lead.ok': '{n} outbound connections {range}, nothing suspicious',
|
||||
'eg.lead.ok.sub': 'No findings in this window. Authorised scans, if any, are summarised below.',
|
||||
'eg.lead.bad': '{f} findings in {n} outbound connections {range}',
|
||||
'eg.lead.bad.sub': '{h} high, {m} medium and {l} low severity. Start with the high ones.',
|
||||
'eg.src': 'Log source: {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': 'error',
|
||||
'eg.kpi.conns': 'Connections',
|
||||
'eg.kpi.conns.sub': 'new outbound connections',
|
||||
'eg.kpi.dsts': 'Destinations',
|
||||
'eg.kpi.dsts.sub': 'different addresses reached',
|
||||
'eg.kpi.find': 'Findings',
|
||||
'eg.kpi.find.sub': '{h} high · {m} medium · {l} low',
|
||||
'eg.workloads': 'Workloads',
|
||||
'eg.workloads.hint': 'Each workload is a program or container that makes outbound connections.',
|
||||
'eg.wl.conns': 'connections',
|
||||
'eg.wl.dsts': 'destinations',
|
||||
'eg.wl.ports': 'ports',
|
||||
'eg.wl.findings': 'findings',
|
||||
'eg.wl.suppressed': '{n} scan connections summarised',
|
||||
'eg.role.scanner': 'authorised scans summarised',
|
||||
'eg.role.app': 'application',
|
||||
'eg.role.proxy': 'proxy',
|
||||
'eg.role.database': 'database',
|
||||
'eg.role.system': 'system',
|
||||
'eg.timeline': 'Connections over time',
|
||||
'eg.timeline.hint': 'Stacked by workload.',
|
||||
'eg.findings': 'Findings',
|
||||
'eg.findings.hint': 'Sorted by severity. Each one explains what the pattern usually means.',
|
||||
'eg.findings.none': 'No findings in this window.',
|
||||
'eg.sev.high': 'High',
|
||||
'eg.sev.medium': 'Medium',
|
||||
'eg.sev.low': 'Low',
|
||||
'eg.kind.beacon': 'Regular conversation',
|
||||
'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.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.f.to': 'To',
|
||||
'eg.f.count': '{n} connections',
|
||||
'eg.f.interval': 'every {s} s (variation {j}%)',
|
||||
'eg.f.first': 'first {t}',
|
||||
'eg.f.last': 'last {t}',
|
||||
'eg.f.host': 'server {h}',
|
||||
'eg.dst': 'Top destinations',
|
||||
'eg.dst.hint': 'Where the connections went.',
|
||||
'eg.dst.none': 'No destinations in this window.',
|
||||
'eg.col.ip': 'Address',
|
||||
'eg.col.country': 'Country',
|
||||
'eg.col.asn': 'Network (ASN)',
|
||||
'eg.col.conns': 'Connections',
|
||||
'eg.col.who': 'Workloads',
|
||||
'eg.col.ports': 'Ports',
|
||||
'eg.scan': 'Authorised scans',
|
||||
'eg.scan.hint': 'Scans your own scanner runs on purpose. They are summarised here instead of raising findings.',
|
||||
'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.targets': '{n} targets',
|
||||
'eg.scan.nets': 'networks',
|
||||
'eg.scan.ports': 'ports',
|
||||
'eg.scan.conns': '{n} connections',
|
||||
'eg.scan.when': '{a} to {b}',
|
||||
'eg.col.who1': 'Workload',
|
||||
'eg.col.when': 'When',
|
||||
'eg.col.targets': 'Targets',
|
||||
'eg.col.nets': 'Networks',
|
||||
'eg.col.badhits': 'Bad destinations hit'
|
||||
},
|
||||
'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.lead.none': 'Nenhuma conexão de saída {range}',
|
||||
'eg.lead.none.sub': 'Nada saiu dos workloads monitorados nesta janela.',
|
||||
'eg.lead.ok': '{n} conexões de saída {range}, nada suspeito',
|
||||
'eg.lead.ok.sub': 'Nenhum achado nesta janela. As varreduras autorizadas, se houver, aparecem resumidas abaixo.',
|
||||
'eg.lead.bad': '{f} achados em {n} conexões de saída {range}',
|
||||
'eg.lead.bad.sub': '{h} de gravidade alta, {m} média e {l} baixa. Comece pelos de gravidade alta.',
|
||||
'eg.src': 'Origem do registro: {state} · {lines} linhas lidas · {bad} ilegíveis',
|
||||
'eg.src.following': 'sendo acompanhado',
|
||||
'eg.src.waiting': 'aguardando o arquivo',
|
||||
'eg.src.missing': 'arquivo não encontrado',
|
||||
'eg.src.error': 'erro',
|
||||
'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 diferentes alcançados',
|
||||
'eg.kpi.find': 'Achados',
|
||||
'eg.kpi.find.sub': '{h} altos · {m} médios · {l} baixos',
|
||||
'eg.workloads': 'Workloads',
|
||||
'eg.workloads.hint': 'Cada workload é um programa ou contêiner que faz conexões de saída.',
|
||||
'eg.wl.conns': 'conexões',
|
||||
'eg.wl.dsts': 'destinos',
|
||||
'eg.wl.ports': 'portas',
|
||||
'eg.wl.findings': 'achados',
|
||||
'eg.wl.suppressed': '{n} conexões de varredura resumidas',
|
||||
'eg.role.scanner': 'varreduras autorizadas resumidas',
|
||||
'eg.role.app': 'aplicação',
|
||||
'eg.role.proxy': 'proxy',
|
||||
'eg.role.database': 'banco de dados',
|
||||
'eg.role.system': 'sistema',
|
||||
'eg.timeline': 'Conexões ao longo do tempo',
|
||||
'eg.timeline.hint': 'Empilhadas por workload.',
|
||||
'eg.findings': 'Achados',
|
||||
'eg.findings.hint': 'Ordenados por gravidade. Cada um explica o que o padrão costuma significar.',
|
||||
'eg.findings.none': 'Nenhum achado nesta janela.',
|
||||
'eg.sev.high': 'Alta',
|
||||
'eg.sev.medium': 'Média',
|
||||
'eg.sev.low': 'Baixa',
|
||||
'eg.kind.beacon': 'Conversa 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.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.f.to': 'Para',
|
||||
'eg.f.count': '{n} conexões',
|
||||
'eg.f.interval': 'a cada {s} s (variação {j}%)',
|
||||
'eg.f.first': 'primeira {t}',
|
||||
'eg.f.last': 'última {t}',
|
||||
'eg.f.host': 'servidor {h}',
|
||||
'eg.dst': 'Principais destinos',
|
||||
'eg.dst.hint': 'Para onde foram as conexões.',
|
||||
'eg.dst.none': 'Nenhum destino nesta janela.',
|
||||
'eg.col.ip': 'Endereço',
|
||||
'eg.col.country': 'País',
|
||||
'eg.col.asn': 'Rede (ASN)',
|
||||
'eg.col.conns': 'Conexões',
|
||||
'eg.col.who': 'Workloads',
|
||||
'eg.col.ports': 'Portas',
|
||||
'eg.scan': 'Varreduras autorizadas',
|
||||
'eg.scan.hint': 'Varreduras que o seu próprio scanner faz de propósito. Aparecem resumidas aqui em vez de gerar achados.',
|
||||
'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.targets': '{n} alvos',
|
||||
'eg.scan.nets': 'redes',
|
||||
'eg.scan.ports': 'portas',
|
||||
'eg.scan.conns': '{n} conexões',
|
||||
'eg.scan.when': '{a} a {b}',
|
||||
'eg.col.who1': 'Workload',
|
||||
'eg.col.when': 'Quando',
|
||||
'eg.col.targets': 'Alvos',
|
||||
'eg.col.nets': 'Redes',
|
||||
'eg.col.badhits': 'Destinos ruins atingidos'
|
||||
}
|
||||
});
|
||||
|
||||
var el = U.el, t = U.t, nf = U.fmt.num;
|
||||
var root = null, seq = 0, alive = false, ctx = null, data = null, failed = false;
|
||||
|
||||
function clear(n) { while (n.firstChild) n.removeChild(n.firstChild); }
|
||||
function tbl(cols, rows) {
|
||||
var tb = el('tbody');
|
||||
rows.forEach(function (r) { tb.appendChild(el('tr', null, r.map(function (c, i) { return el('td', { class: cols[i].cls || '' }, c); }))); });
|
||||
return el('div', { class: 'eg-scroll' }, el('table', { class: 'eg-table' },
|
||||
el('thead', null, el('tr', null, cols.map(function (c) { return el('th', { class: c.cls || '' }, c.label); }))), tb));
|
||||
}
|
||||
function ipLink(ip) { return el('a', { href: U.href('ip', [ip]), class: 'mono' }, ip); }
|
||||
function when(ts) { return ts ? U.fmt.clock(ts) : '-'; }
|
||||
function help(node, key) { if (U.help) U.help(node, key); return node; }
|
||||
function roleLabel(r) { var k = 'eg.role.' + r; return t(k) !== k ? t(k) : (r || '-'); }
|
||||
function list(a) { return (a || []).join(', ') || '-'; }
|
||||
|
||||
function workloadCard(w, multi) {
|
||||
var scanner = w.role === 'scanner';
|
||||
var h = el('h3', { class: 'eg-wl-name' }, w.name);
|
||||
var head = el('div', { class: 'eg-wl-head' }, h);
|
||||
if (w.role) {
|
||||
var b = U.ui.badge(roleLabel(w.role), scanner ? 'info' : 'neutral');
|
||||
head.appendChild(b);
|
||||
if (scanner) help(head, 'term.authorized_scanner');
|
||||
}
|
||||
var stats = el('dl', { class: 'eg-wl-stats' });
|
||||
[['conns', w.conns], ['dsts', w.dsts], ['ports', w.ports], ['findings', w.findings]].forEach(function (p) {
|
||||
stats.appendChild(el('div', null, el('dd', { class: 'num' + (p[0] === 'findings' && p[1] ? ' eg-warn' : '') }, nf(p[1] || 0)), el('dt', null, t('eg.wl.' + p[0]))));
|
||||
});
|
||||
var card = el('div', { class: 'card-metric eg-wl' }, head, stats);
|
||||
if (w.suppressed_scan_conns) card.appendChild(el('p', { class: 'cm-sub' }, t('eg.wl.suppressed', { n: nf(w.suppressed_scan_conns) })));
|
||||
if (multi && w.host) card.appendChild(el('p', { class: 'cm-sub' }, t('eg.f.host', { h: w.host })));
|
||||
return card;
|
||||
}
|
||||
|
||||
function findingNode(f, multi) {
|
||||
var kind = KINDS.indexOf(f.kind) >= 0 ? f.kind : null;
|
||||
var sev = SEV[f.severity] !== undefined ? f.severity : 'low';
|
||||
var title = el('strong', { class: 'eg-f-title' }, kind ? t('eg.kind.' + kind) : String(f.kind || '-'));
|
||||
if (kind) help(title, KIND_HELP[kind]);
|
||||
var top = el('div', { class: 'eg-f-top' }, U.ui.badge(t('eg.sev.' + sev), SEV_TONE[sev]), title);
|
||||
var bits = [];
|
||||
bits.push(el('span', { class: 'mono' }, f.workload || '-'));
|
||||
bits.push(' → ');
|
||||
if (f.dst) bits.push(ipLink(f.dst));
|
||||
if (f.dport) bits.push(el('span', { class: 'mono' }, ':' + f.dport + (f.proto ? '/' + f.proto : '')));
|
||||
var meta = [];
|
||||
if (f.count) meta.push(t('eg.f.count', { n: nf(f.count) }));
|
||||
if (f.interval_s) meta.push(t('eg.f.interval', { s: Math.round(f.interval_s * 10) / 10, j: Math.round((f.jitter || 0) * 100) }));
|
||||
if (f.first) meta.push(t('eg.f.first', { t: when(f.first) }));
|
||||
if (f.last) meta.push(t('eg.f.last', { t: when(f.last) }));
|
||||
if (multi && f.host) meta.push(t('eg.f.host', { h: f.host }));
|
||||
var li = el('li', { class: 'eg-f eg-sev-' + sev }, top, el('p', { class: 'eg-f-line' }, bits));
|
||||
if (kind) li.appendChild(el('p', { class: 'eg-f-why' }, t('eg.why.' + kind)));
|
||||
if (f.detail) li.appendChild(el('p', { class: 'eg-f-detail mono' }, f.detail));
|
||||
if (meta.length) li.appendChild(el('p', { class: 'hint eg-f-meta' }, meta.join(' · ')));
|
||||
return li;
|
||||
}
|
||||
|
||||
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 d = data, range = U.rangeLabel({ inline: true });
|
||||
var wls = d.workloads || [], fnd = (d.findings || []).slice();
|
||||
fnd.sort(function (a, b) { var x = SEV[a.severity], y = SEV[b.severity]; x = x === undefined ? 3 : x; y = y === undefined ? 3 : y; return x - y || (b.count || 0) - (a.count || 0); });
|
||||
var conns = 0, nsev = { high: 0, medium: 0, low: 0 };
|
||||
wls.forEach(function (w) { conns += w.conns || 0; });
|
||||
fnd.forEach(function (f) { if (nsev[f.severity] !== undefined) nsev[f.severity]++; });
|
||||
var hosts = {};
|
||||
wls.forEach(function (w) { if (w.host) hosts[w.host] = 1; });
|
||||
fnd.forEach(function (f) { if (f.host) hosts[f.host] = 1; });
|
||||
var multi = Object.keys(hosts).length > 1;
|
||||
var dsts = d.top_dst || [];
|
||||
|
||||
if (!conns && !fnd.length) root.appendChild(U.ui.lead(t('eg.lead.none', { range: range }), t('eg.lead.none.sub'), 'neutral'));
|
||||
else if (!fnd.length) root.appendChild(U.ui.lead(t('eg.lead.ok', { n: nf(conns), range: range }), t('eg.lead.ok.sub'), 'ok'));
|
||||
else root.appendChild(U.ui.lead(t('eg.lead.bad', { f: nf(fnd.length), n: nf(conns), range: range }), t('eg.lead.bad.sub', { h: nsev.high, m: nsev.medium, l: nsev.low }), nsev.high ? 'danger' : 'ok'));
|
||||
var src = d.source || {};
|
||||
var sk = 'eg.src.' + src.state;
|
||||
root.appendChild(el('p', { class: 'hint' }, t('eg.src', { state: t(sk) !== sk ? t(sk) : (src.state || '-'), lines: nf(src.lines || 0), bad: nf(src.malformed || 0) })));
|
||||
|
||||
var kp = el('div', { class: 'grid-12 eg-kpis' });
|
||||
function k(node) { node.classList.add('span-4'); kp.appendChild(node); }
|
||||
k(U.ui.metric(t('eg.kpi.conns'), nf(conns), { sub: t('eg.kpi.conns.sub') }));
|
||||
k(U.ui.metric(t('eg.kpi.dsts'), nf(dsts.length), { sub: t('eg.kpi.dsts.sub') }));
|
||||
k(U.ui.metric(t('eg.kpi.find'), nf(fnd.length), { sub: t('eg.kpi.find.sub', { h: nsev.high, m: nsev.medium, l: nsev.low }), tone: nsev.high ? 'danger' : fnd.length ? 'warn' : 'ok' }));
|
||||
root.appendChild(kp);
|
||||
|
||||
var grid = el('div', { class: 'grid-12' });
|
||||
if (wls.length) {
|
||||
var wp = U.ui.panel({ title: t('eg.workloads'), hint: t('eg.workloads.hint'), cls: 'span-12', help: 'term.workload' });
|
||||
var wg = el('div', { class: 'eg-wl-grid' });
|
||||
wls.forEach(function (w) { wg.appendChild(workloadCard(w, multi)); });
|
||||
wp.body.appendChild(wg);
|
||||
grid.appendChild(wp);
|
||||
}
|
||||
|
||||
var tl = d.timeline || {}, ser = tl.series || {}, names = Object.keys(ser);
|
||||
var tp = U.ui.panel({ title: t('eg.timeline'), hint: t('eg.timeline.hint'), cls: 'span-12', variant: 'chart' });
|
||||
if (U.charts && U.charts.stackedArea && names.length) tp.body.appendChild(U.charts.stackedArea(names.map(function (n) { return { key: n, label: n, values: ser[n] }; }), tl.step || 3600, { start: tl.start || 0, title: t('eg.timeline') }));
|
||||
else tp.body.appendChild(U.ui.empty(t('eg.lead.none', { range: range })));
|
||||
grid.appendChild(tp);
|
||||
|
||||
var fp = U.ui.panel({ title: t('eg.findings'), hint: t('eg.findings.hint'), cls: 'span-12' });
|
||||
if (!fnd.length) fp.body.appendChild(U.ui.empty(t('eg.findings.none')));
|
||||
else { var ul = el('ul', { class: 'eg-findings' }); fnd.forEach(function (f) { ul.appendChild(findingNode(f, multi)); }); fp.body.appendChild(ul); }
|
||||
grid.appendChild(fp);
|
||||
|
||||
var dp = U.ui.panel({ title: t('eg.dst'), hint: t('eg.dst.hint'), cls: 'span-12', variant: 'list' });
|
||||
if (!dsts.length) dp.body.appendChild(U.ui.empty(t('eg.dst.none')));
|
||||
else dp.body.appendChild(tbl([{ label: t('eg.col.ip') }, { label: t('eg.col.country') }, { label: t('eg.col.asn') }, { label: t('eg.col.conns'), cls: 'num' }, { label: t('eg.col.who') }, { label: t('eg.col.ports') }],
|
||||
dsts.map(function (x) {
|
||||
return [ipLink(x.ip), (x.cc ? U.fmt.flag(x.cc) + ' ' + U.fmt.country(x.cc) : '-'), (x.asn || '') + (x.org ? ' ' + x.org : '') || '-', nf(x.conns || 0), list(x.workloads), list(x.ports)];
|
||||
})));
|
||||
grid.appendChild(dp);
|
||||
|
||||
var bursts = (d.scanner && d.scanner.bursts) || [];
|
||||
var sp = U.ui.panel({ title: t('eg.scan'), hint: t('eg.scan.hint'), cls: 'span-12', variant: 'list', help: 'term.authorized_scanner' });
|
||||
if (!bursts.length) sp.body.appendChild(U.ui.empty(t('eg.scan.none')));
|
||||
else {
|
||||
var bad = 0;
|
||||
bursts.forEach(function (b) { bad += b.bad_dst_hits || 0; });
|
||||
if (bad > 0) sp.body.appendChild(el('div', { class: 'state-error eg-scanwarn' }, el('strong', null, t('eg.scan.warn', { n: nf(bad) }))));
|
||||
sp.body.appendChild(tbl([{ label: t('eg.col.who1') }, { label: t('eg.col.when') }, { label: t('eg.col.targets'), cls: 'num' }, { label: t('eg.col.nets') }, { label: t('eg.col.ports') }, { label: t('eg.col.conns'), cls: 'num' }, { label: t('eg.col.badhits'), cls: 'num' }],
|
||||
bursts.map(function (b) {
|
||||
return [b.workload || '-', t('eg.scan.when', { a: when(b.start), b: when(b.end) }), nf(b.targets || 0), list(b.nets), list(b.ports), nf(b.conns || 0),
|
||||
el('span', { class: b.bad_dst_hits ? 'eg-warn' : '' }, nf(b.bad_dst_hits || 0))];
|
||||
})));
|
||||
}
|
||||
grid.appendChild(sp);
|
||||
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;
|
||||
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);
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user