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: "