The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
doctor: probe the ingest socket instead of only looking at it
Claudecaf6ce906525
diff --git a/cli/beacon/internal/endpoint/diagnostics/logaccess.go b/cli/beacon/internal/endpoint/diagnostics/logaccess.goindex 141c4387..de0c9cab 100644--- a/cli/beacon/internal/endpoint/diagnostics/logaccess.go+++ b/cli/beacon/internal/endpoint/diagnostics/logaccess.go@@ -100,14 +100,26 @@ func checkLogAccess(cfg endpointconfig.Config, ingest localingest.Deliverer) CheMessage: "the endpoint config says restricted but the log is not marked, so the collector will make it world-writable again at its next write",Evidence: "log_access_marker_missing", Action: repairSystemAction}}- switch err := ingest.Client.Available(); {+ // A probe, not a look at the socket file: a collector that was killed leaves its socket behind,+ // and only a connection tells a live collector from that.+ probe := ingest.Client+ probe.LogPath = path+ switch err := probe.Probe(); {case errors.Is(err, localingest.ErrNoSocket):return Check{Name: name, Target: ingestSocketPath(ingest), Status: StatusFail, Severity: SeverityHigh,Message: "the collector is not serving the ingest socket, so hooks cannot record events and are spooling them; start the collector",Evidence: "ingest_socket_missing", Action: repairSystemAction}- case err != nil:+ case errors.Is(err, localingest.ErrUntrustedSocket):return Check{Name: name, Target: ingestSocketPath(ingest), Status: StatusFail, Severity: SeverityHigh,Message: "hooks will not send to the ingest socket: " + err.Error(), Evidence: "ingest_socket_untrusted", Action: repairSystemAction}+ case errors.Is(err, localingest.ErrLogMismatch):+ return Check{Name: name, Target: ingestSocketPath(ingest), Status: StatusFail, Severity: SeverityHigh,+ Message: "the collector behind the ingest socket writes a different runtime log, so hooks writing " + path + " are spooling their events",+ Evidence: "ingest_log_mismatch", Action: repairSystemAction}+ case err != nil:+ return Check{Name: name, Target: ingestSocketPath(ingest), Status: StatusFail, Severity: SeverityHigh,+ Message: "the ingest socket is there but the collector does not answer (" + err.Error() + "), so hooks are spooling their events; restart the collector",+ Evidence: "ingest_socket_unresponsive", Action: repairSystemAction}}if pending, err := ingest.Pending(path); err == nil && pending > 0 {return Check{Name: name, Target: localingest.DefaultSpoolDir(), Status: StatusWarn, Severity: SeverityLow,diff --git a/cli/beacon/internal/endpoint/diagnostics/logaccess_unix_test.go b/cli/beacon/internal/endpoint/diagnostics/logaccess_unix_test.goindex 6e01a70f..f92a2293 100644--- a/cli/beacon/internal/endpoint/diagnostics/logaccess_unix_test.go+++ b/cli/beacon/internal/endpoint/diagnostics/logaccess_unix_test.go@@ -104,6 +104,39 @@ func TestLogAccessRestrictedWithAnUntrustedSocket(t *testing.T) {}}+// A collector that was killed leaves its socket behind. Only a connection tells that from a live+// one, so doctor must not report the endpoint healthy.+func TestLogAccessRestrictedWithADeadSocket(t *testing.T) {+ markRestricted(t, true)+ env := newIngestEnv(t, false)+ l, err := localingest.Listen(env.sock)+ if err != nil {+ t.Fatal(err)+ }+ l.SetUnlinkOnClose(false)+ _ = l.Close()+ c := checkLogAccess(systemConfig(t, "restricted"), env.deliverer)+ if c.Status != StatusFail || c.Evidence != "ingest_socket_unresponsive" {+ t.Fatalf("check = %+v", c)+ }+}++func TestLogAccessRestrictedWithACollectorForAnotherLog(t *testing.T) {+ markRestricted(t, true)+ env := newIngestEnv(t, false)+ l, err := localingest.Listen(env.sock)+ if err != nil {+ t.Fatal(err)+ }+ s := &localingest.Server{LogPath: "/elsewhere/runtime.jsonl", Append: func([]byte) error { return nil }}+ go func() { _ = s.Serve(l) }()+ t.Cleanup(func() { _ = s.Close() })+ c := checkLogAccess(systemConfig(t, "restricted"), env.deliverer)+ if c.Status != StatusFail || c.Evidence != "ingest_log_mismatch" {+ t.Fatalf("check = %+v", c)+ }+}+func TestLogAccessRestrictedAndHealthy(t *testing.T) {markRestricted(t, true)c := checkLogAccess(systemConfig(t, "restricted"), newIngestEnv(t, true).deliverer)