fix(ip): show egress destination view instead of ambiguous 404

Add GET /api/v1/ip/{ip}/egress and Engine.Dst; the IP page renders who
connected, findings and linked incidents, or a definitive never-seen message.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-16 20:22:20 -03:00
1 parent 19afd221e2
commit 0db50c05c4
5 files changed
+351 -6

No files matched your search

+99 -6
View File
@@ -29,8 +29,21 @@
'ip.loading': 'Loading the analysis.',
'ip.invalid': 'This is not a valid IP address.',
'ip.error': 'Could not load this IP.',
'ip.notfound': 'No activity from this IP in the selected period.',
'ip.notfound.hint': 'Pick a longer period above, or the IP was never seen.',
'ip.never': 'This IP was never seen by Urutau (neither as a source nor as an egress destination).',
'ip.dst.title': 'Egress destination',
'ip.dst.lead': 'Our workloads connected to this address; it never attacked us.',
'ip.dst.hint': 'Outbound connections from this installation to the IP, not inbound attacks.',
'ip.dst.host': 'Host',
'ip.dst.workloads': 'Workloads',
'ip.dst.ports': 'Ports',
'ip.dst.conns': 'Connections',
'ip.dst.net': 'Network',
'ip.dst.findings': 'Findings',
'ip.dst.incidents': 'Linked incidents',
'ip.dst.nofind': 'No finding in this period.',
'ip.dst.last': 'Last: {when}',
'ip.dst.inb.after': 'Last seen as an attacker (inbound) on {when}, outside the selected period.',
'ip.dst.inb.btn': 'Show the last 30 days',
'ip.retry': 'Try again',
'ip.lead.hostile': 'Hostile: {events} {range}',
'ip.lead.suspicious': 'Suspicious: {events} {range}',
@@ -354,8 +367,21 @@
'ip.loading': 'Carregando a análise.',
'ip.invalid': 'Este não é um endereço IP válido.',
'ip.error': 'Não foi possível carregar este IP.',
'ip.notfound': 'Nenhuma atividade deste IP no período selecionado.',
'ip.notfound.hint': 'Escolha um período maior acima, ou o IP nunca foi visto.',
'ip.never': 'Este IP nunca foi visto pelo Urutau (nem como origem nem como destino de saída).',
'ip.dst.title': 'Destino de saída',
'ip.dst.lead': 'Nossas cargas de trabalho conectaram a este endereço; ele nunca nos atacou.',
'ip.dst.hint': 'Conexões de saída desta instalação para o IP, não ataques de entrada.',
'ip.dst.host': 'Host',
'ip.dst.workloads': 'Cargas de trabalho',
'ip.dst.ports': 'Portas',
'ip.dst.conns': 'Conexões',
'ip.dst.net': 'Rede',
'ip.dst.findings': 'Achados',
'ip.dst.incidents': 'Incidentes ligados',
'ip.dst.nofind': 'Nenhum achado neste período.',
'ip.dst.last': 'Último: {when}',
'ip.dst.inb.after': 'Visto pela última vez como atacante (entrada) em {when}, fora do período selecionado.',
'ip.dst.inb.btn': 'Mostrar os últimos 30 dias',
'ip.retry': 'Tentar de novo',
'ip.lead.hostile': 'Hostil: {events} {range}',
'ip.lead.suspicious': 'Suspeito: {events} {range}',
@@ -1988,7 +2014,7 @@
h('div', 'ipx-skel-b'), h('div', 'ipx-skel-b short'), h('div', 'ipx-skel-b'));
}
function errorNode(s, key, withRetry) {
var box = h('div', 'ipx-card state-error ipx-state', h('p', 'ipx-empty-t', t(key)), key === 'ip.notfound' ? h('p', 'ipx-empty-h', t('ip.notfound.hint')) : null);
var box = h('div', 'ipx-card state-error ipx-state', h('p', 'ipx-empty-t', t(key)));
if (withRetry) {
var b = h('button', 'ipx-btn', { type: 'button' }, t('ip.retry'));
b.addEventListener('click', function () { load(s); });
@@ -2029,6 +2055,72 @@
watchScrollFade(s, toc);
}
// ---------------------------------------------------------------- egress destination (no inbound data)
function dstBadge(sev) { return h('span', 'ipx-chip', str(sev)); }
function egressNode(s, d) {
var eg = arr(d.egress).filter(isObj), fs = arr(d.findings).filter(isObj), ics = arr(d.incidents).filter(isObj);
var c = card('ip.dst.title', 'ip.dst.hint', 12);
c.body.appendChild(h('p', 'ipx-lead', t('ip.dst.lead')));
if (eg.length) {
var tb = h('tbody');
eg.forEach(function (x) {
var cc = str(x.cc).toUpperCase(), net = [x.asn ? str(x.asn) : '', clip(x.org, 60)].filter(Boolean).join(' ');
tb.appendChild(h('tr', null,
h('td', null, str(x.host)),
h('td', null, arr(x.workloads).join(', ') || '-'),
h('td', 'ipx-mono', arr(x.ports).join(', ') || '-'),
h('td', 'ipx-num', N(num(x.conns))),
h('td', null, (cc && fmt.flag ? fmt.flag(cc) + ' ' : '') + (cc && fmt.country ? fmt.country(cc) : cc) + (net ? ' · ' + net : ''))));
});
c.body.appendChild(h('div', 'ipx-tbl-w', h('table', 'ipx-tbl ipx-ctbl', h('thead', null, h('tr', null,
h('th', null, t('ip.dst.host')), h('th', null, t('ip.dst.workloads')), h('th', null, t('ip.dst.ports')), h('th', null, t('ip.dst.conns')), h('th', null, t('ip.dst.net')))), tb)));
}
c.body.appendChild(sub('ip.dst.findings'));
if (!fs.length) c.body.appendChild(h('p', 'ipx-muted', t('ip.dst.nofind')));
else {
var fb = h('tbody');
fs.forEach(function (f) {
fb.appendChild(h('tr', null, h('td', null, str(f.host)), h('td', null, str(f.kind)), h('td', null, dstBadge(f.severity)), h('td', null, str(f.workload)),
h('td', 'ipx-mono', (str(f.proto) + '/' + num(f.dport))), h('td', null, clip(f.detail, 120)), h('td', null, dt(num(f.last)))));
});
c.body.appendChild(h('div', 'ipx-tbl-w', h('table', 'ipx-tbl ipx-ctbl', fb)));
}
if (ics.length) {
c.body.appendChild(sub('ip.dst.incidents'));
var ul = h('ul', 'ipx-list');
ics.forEach(function (i) {
var id = str(i.id), parts = id.split('/');
var href = '#/incidents/' + encodeURIComponent(parts[0]) + '/' + encodeURIComponent(parts.slice(1).join('/'));
ul.appendChild(h('li', null, h('a', null, { href: href }, id), ' ', dstBadge(i.severity), ' ', h('span', 'ipx-muted', str(i.status) + ' · ' + clip(i.title, 100))));
});
c.body.appendChild(ul);
}
return c.node;
}
function loadEgress(s, my) {
var p = Object.assign({}, rParams(s.ctx));
if (s.ctx && s.ctx.host && s.ctx.host !== 'all') p.host = s.ctx.host;
U.api('/api/v1/ip/' + encodeURIComponent(s.ip) + '/egress', p).then(function (d) {
if (!s.alive || my !== s.seq) return;
if (!isObj(d)) throw new Error('bad payload');
var has1 = arr(d.egress).length || arr(d.findings).length || arr(d.incidents).length, last = num(d.last_seen_inbound);
if (has1) { showState(s, egressNode(s, d)); return; }
if (last) {
var box = h('div', 'ipx-card ipx-state', h('p', 'ipx-empty-t', t('ip.dst.inb.after', { when: dt(last) })));
var b = h('button', 'ipx-btn', { type: 'button' }, t('ip.dst.inb.btn'));
b.addEventListener('click', function () { location.hash = '#/ip/' + encodeURIComponent(s.ip) + '?r=30d'; });
box.appendChild(b);
showState(s, box);
return;
}
showState(s, errorNode(s, 'ip.never', false));
}).catch(function (e) {
if (!s.alive || my !== s.seq) return;
if (e && e.message === 'unauthorized') return;
showState(s, errorNode(s, 'ip.error', true));
});
}
function load(s) {
var my = ++s.seq;
s.ip = ipFromCtx(s.ctx);
@@ -2048,7 +2140,8 @@
if (!s.alive || my !== s.seq) return;
if (e && e.message === 'unauthorized') return;
s.data = null;
showState(s, errorNode(s, e && e.status === 404 ? 'ip.notfound' : 'ip.error', !(e && e.status === 404)));
if (e && e.status === 404) { loadEgress(s, my); return; }
showState(s, errorNode(s, e && e.status === 404 ? 'ip.never' : 'ip.error', !(e && e.status === 404)));
});
}