Files
urutau/deploy/host/urutau-containers-map
T
Lucas RayanandClaude Opus 5.5 432f521ed1
Release / Publish tags (push) Successful in 18s
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Successful in 1m47s
Release / Build image (amd64) (push) Successful in 21s
Release / Build image (arm64) (push) Successful in 28s
CI / Format and vet (push) Successful in 23s
CI / Tests (Linux, race detector) (push) Successful in 1m24s
CI / Dependency audit (push) Successful in 24s
CI / Docker image (build and smoke test) (push) Skipped
Release / Gitea release (push) Successful in 5s
feat: 1.4.1 pagination, network probes, survival by blocker, report polish
Backend pagination with one pager for sessions, IPs, campaigns and events;
network probe source (port-scan, T1046, second firewall reason port-scan);
host kit logs inbound probes; urutau call on the report cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 00:21:43 -03:00

33 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
# Urutau: writes "<ip> <container name>" for every running container, so the
# egress analysis can name workloads whose address changes on each redeploy.
set -eu
out=/var/log/urutau/containers.map
tmp=$(mktemp /var/log/urutau/.containers.map.XXXXXX)
trap 'rm -f "$tmp"' EXIT
docker ps -q | xargs -r docker inspect -f '{{$n := .Name}}{{range .NetworkSettings.Networks}}{{if .IPAddress}}{{.IPAddress}} {{$n}}
{{end}}{{if .GlobalIPv6Address}}{{.GlobalIPv6Address}} {{$n}}
{{end}}{{end}}' | sed 's# /# #' | grep -E '^[0-9a-fA-F.:]+ [A-Za-z0-9_.-]{1,128}$' > "$tmp" || true
chgrp adm "$tmp"; chmod 0640 "$tmp"
mv -f "$tmp" "$out"
trap - EXIT
# The real upstream resolvers (systemd-resolved hides them behind 127.0.0.53),
# so DNS to the provider resolver is not reported as a bypass.
r=/var/log/urutau/resolv.conf
{
resolvectl dns 2>/dev/null | tr ' ' '\n' | grep -E '^([0-9]{1,3}\.){3}[0-9]{1,3}$|^[0-9a-fA-F]*:[0-9a-fA-F:]+$' || true
awk '/^nameserver/ {print $2}' /run/systemd/resolve/resolv.conf 2>/dev/null || true
} | grep -vE '^127\.' | sort -u | sed 's/^/nameserver /' > "$r.tmp"
chgrp adm "$r.tmp"; chmod 0640 "$r.tmp"; mv -f "$r.tmp" "$r"
# Ports this host serves (listening sockets, including the ones Docker
# publishes): connections to any other port are logged as probes.
if nft list set inet urutau_egress open >/dev/null 2>&1; then
{
echo "flush set inet urutau_egress open"
ss -Hlnt | awk '{print $4}' | sed -n 's/.*:\([0-9][0-9]*\)$/tcp . \1/p'
ss -Hlnu | awk '{print $4}' | sed -n 's/.*:\([0-9][0-9]*\)$/udp . \1/p'
} | sort -u | awk 'NR==1 {print; next} {e = e (e ? ", " : "") $0} END {if (e) print "add element inet urutau_egress open { " e " }"}' | nft -f -
fi