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

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:
Lucas RayanandClaude Opus 5.5 committed 2026-11-14 23:35:34 -03:00
1 parent 3adaa007ec
commit c33cca22e3
59 files changed
+7364 -24

No files matched your search

+29 -7
View File
@@ -121,10 +121,31 @@ var attackCats = []string{"scanner", "exploit", "bruteforce", "ssh-fail", "ssh-p
// report: GET /api/v1/report, the aggregate behind the executive report.
func (s *Server) report(w http.ResponseWriter, r *http.Request) {
if f := r.URL.Query().Get("format"); f != "" && f != "json" {
badRequest(w, "format must be json")
f := r.URL.Query().Get("format")
if f != "" && f != "json" && f != "html" {
badRequest(w, "format must be json or html")
return
}
rc, ok := s.buildReport(w, r)
if !ok {
return
}
if f == "html" {
s.writeReportHTML(w, r, rc)
return
}
writeJSON(w, 200, rc.out)
}
// reportCtx is the computed report plus the window it covers.
type reportCtx struct {
out reportOut
rg store.Range
host string
from, to int64
}
func (s *Server) buildReport(w http.ResponseWriter, r *http.Request) (*reportCtx, bool) {
if r.URL.Query().Get("range") == "" && r.URL.Query().Get("from") == "" {
q := r.URL.Query()
q.Set("range", "7d")
@@ -132,14 +153,14 @@ func (s *Server) report(w http.ResponseWriter, r *http.Request) {
}
rg, ok := s.rangeOf(w, r)
if !ok {
return
return nil, false
}
host := r.URL.Query().Get("host")
if host == "" {
host = "all"
}
if !s.knownHost(w, host) {
return
return nil, false
}
now := s.opt.Now().Unix()
info := rg.Info(now)
@@ -149,7 +170,7 @@ func (s *Server) report(w http.ResponseWriter, r *http.Request) {
// period study (families, techniques, ASNs, campaigns, escalations)
per, ok := s.periodStudy(w, r)
if !ok {
return
return nil, false
}
// summary of the period and of the previous one
parts, all := s.parts(r.Context(), rg, host)
@@ -262,13 +283,14 @@ func (s *Server) report(w http.ResponseWriter, r *http.Request) {
// defence metrics (same study and slot as /metrics)
m, ok := s.reportMetrics(w, r, rg, host)
if !ok {
return
return nil, false
}
d := &out.Defense
d.MTTBMedianS, d.MTTBP90S, d.MTTBPrevMedianS, d.MTTBN = m.MTTB.MedianS, m.MTTB.P90S, m.MTTB.PrevMed, m.MTTB.N
d.BanCoverage, d.BanCoveragePrev = m.BanCoverage.Value, m.BanCoverage.Prev
d.BlocklistCover, d.ExposureRate, d.ExploitsRefused = m.BlocklistCoverage.Value, m.ExposureRate.Value, m.ExploitsRefused.Value
writeJSON(w, 200, out)
f, t := rg.Bounds(now)
return &reportCtx{out: out, rg: rg, host: host, from: f, to: t}, true
}
func capCounts(c []store.Count, n int) []store.Count {