From 7e429a7be05611b7dc9ae5476e9962246b3843f4 Mon Sep 17 00:00:00 2001 From: Veillax <126523099+Veillax@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:57:35 -0600 Subject: [PATCH] Show services discovered by site agents as suggested targets Stores the sanitised list per site, serves it at /sites/{id}/discovered and adds it to the target picker. Needs a Reef release containing model.DiscoveredService. Co-Authored-By: Claude Sonnet 5.5 --- agent.go | 1 + discovered_test.go | 36 ++++++++++++++++++++++++++++++++++++ infra.go | 42 ++++++++++++++++++++++++++++++++++++++++++ server.go | 1 + store.go | 8 +++++--- web/index.html | 9 +++++---- 6 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 discovered_test.go diff --git a/agent.go b/agent.go index b62b621..bfa150c 100644 --- a/agent.go +++ b/agent.go @@ -259,6 +259,7 @@ func (s *Server) siteReport(w http.ResponseWriter, r *http.Request) { answered := noteUpdateReport(&st.Version, &st.AutoUpdate, &st.UpdateID, &st.UpdateMsg, in.Version, in.AutoUpdate, in.UpdateID, in.UpdateMsg) s.recordUpdateProgress(st.ID, in.UpdateID, in.UpdateStage, in.UpdatePct, in.UpdateLog, oldVersion, st.Version) s.containers[st.ID] = in.Containers + s.discovered[st.ID] = cleanDiscovered(in.Discovered) for _, x := range s.st.MailEgress { if x.SiteID != st.ID { continue diff --git a/discovered_test.go b/discovered_test.go new file mode 100644 index 0000000..604a158 --- /dev/null +++ b/discovered_test.go @@ -0,0 +1,36 @@ +package hammerhead + +import ( + "strings" + "testing" + + "git.veillax.com/Veillax/reef/model" +) + +func TestCleanDiscoveredDropsBadEntriesAndBoundsText(t *testing.T) { + in := []model.DiscoveredService{ + {Host: "192.168.1.5", Port: 22, Proto: "udp", Service: "ssh", Detail: "SSH-2.0", Source: "scan"}, + {Host: "127.0.0.1", Port: 8080, Service: strings.Repeat("x", 100), Detail: strings.Repeat("d", 1000), Source: "local"}, + {Host: "