fix: host filter accepts all and comma lists; hub no longer drops traefik lines after a copytruncate rotation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
19afd221e2
commit
7b90d9e40f
15 files changed
+329
-85
No files matched your search
@@ -290,13 +290,10 @@ func (s *Server) incidentList(w http.ResponseWriter, r *http.Request) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
hosts := s.incHosts()
|
||||
if q.Host != "" && q.Host != "all" {
|
||||
hosts = []string{q.Host}
|
||||
if s.incStore(q.Host) == nil {
|
||||
writeJSON(w, 200, qPage{Items: []qSummary{}, Counts: map[string]int{}, Hosts: s.incHosts()})
|
||||
return
|
||||
}
|
||||
hosts := s.incSelect(q.Host)
|
||||
if hosts == nil {
|
||||
writeJSON(w, 200, qPage{Items: []qSummary{}, Counts: map[string]int{}, Hosts: s.incHosts()})
|
||||
return
|
||||
}
|
||||
q.Host = ""
|
||||
if len(hosts) == 1 {
|
||||
@@ -480,10 +477,7 @@ func (s *Server) incidentCSV(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Disposition", `attachment; filename="incidents.csv"`)
|
||||
cw := csv.NewWriter(w)
|
||||
cw.Write([]string{"id", "status", "severity", "host", "kind", "workload", "dst", "dport", "proto", "title", "first_seen", "last_seen", "count", "assignee", "tags", "verdict", "suppress", "created_at", "updated_at"})
|
||||
hosts := s.incHosts()
|
||||
if q.Host != "" && q.Host != "all" {
|
||||
hosts = []string{q.Host}
|
||||
}
|
||||
hosts := s.incSelect(q.Host)
|
||||
q.Host = ""
|
||||
var rows []qSummary
|
||||
for _, h := range hosts {
|
||||
@@ -504,3 +498,26 @@ func (s *Server) incidentCSV(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
cw.Flush()
|
||||
}
|
||||
|
||||
// incSelect resolves the host filter of the ticket queries: "" or "all" is
|
||||
// every host with a store, otherwise the listed ones (comma list) that have
|
||||
// one. It returns nil when a selection names none.
|
||||
func (s *Server) incSelect(raw string) []string {
|
||||
if raw == "" || raw == "all" {
|
||||
return s.incHosts()
|
||||
}
|
||||
var out []string
|
||||
seen := map[string]bool{}
|
||||
for _, n := range strings.Split(raw, ",") {
|
||||
n = strings.TrimSpace(n)
|
||||
if n == "all" {
|
||||
return s.incHosts()
|
||||
}
|
||||
if n == "" || seen[n] || s.incStore(n) == nil {
|
||||
continue
|
||||
}
|
||||
seen[n] = true
|
||||
out = append(out, n)
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user