Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fail closed invalid monitored-system matches

rcourtman18559f924141
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index a7e17ab4ea..b8780e8f2b 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -276,6 +276,10 @@ and update consumers must ask the unified-resource layer whether candidate or
preview records change the deduped top-level monitored-system count, including
replacement-aware projection and VMware host-UUID identity, instead of
rebuilding handler-local counting heuristics.
+Candidate matching must fail closed when the prospective monitored-system
+candidate cannot resolve to a canonical top-level resource; malformed or
+whitespace-only inputs are not allowed to masquerade as an already-counted
+system simply because their no-op projection has zero additional count.
That shared consumer ownership now includes same-tab summary hydration too.
`frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
may keep an in-memory remount cache for canonical resource charts, but the key
diff --git a/internal/unifiedresources/monitored_systems.go b/internal/unifiedresources/monitored_systems.go
index 97877ecb7c..e4f88660c5 100644
--- a/internal/unifiedresources/monitored_systems.go
+++ b/internal/unifiedresources/monitored_systems.go
@@ -113,6 +113,9 @@ func MonitoredSystems(rs ReadState) []MonitoredSystemRecord {
// HasMatchingMonitoredSystem reports whether a prospective monitored system
// would dedupe onto an already-counted top-level monitored system.
func HasMatchingMonitoredSystem(rs ReadState, candidate MonitoredSystemCandidate) bool {
+ if monitoredSystemCandidateResource(candidate) == nil {
+ return false
+ }
return ProjectMonitoredSystemCandidate(rs, candidate).AdditionalCount == 0
}
diff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.go
index ad5bd8ed7c..d6f8aa5310 100644
--- a/internal/unifiedresources/registry_test.go
+++ b/internal/unifiedresources/registry_test.go
@@ -2059,6 +2059,43 @@ func TestRegistryHasMatchingMonitoredSystemUsesCanonicalHostIdentity(t *testing.
}
}
+func TestRegistryHasMatchingMonitoredSystemRejectsInvalidCandidate(t *testing.T) {
+ rr := NewRegistry(nil)
+ rr.IngestRecords(SourceAgent, []IngestRecord{
+ {
+ SourceID: "host-1",
+ Resource: Resource{
+ ID: "host-1",
+ Type: ResourceTypeAgent,
+ Name: "lab-a",
+ Status: StatusOnline,
+ Agent: &AgentData{
+ AgentID: "agent-1",
+ Hostname: "lab-a",
+ MachineID: "machine-1",
+ },
+ Identity: ResourceIdentity{
+ MachineID: "machine-1",
+ Hostnames: []string{"lab-a"},
+ },
+ },
+ },
+ })
+
+ if HasMatchingMonitoredSystem(rr, MonitoredSystemCandidate{}) {
+ t.Fatal("expected empty candidate not to match an existing counted system")
+ }
+
+ if HasMatchingMonitoredSystem(rr, MonitoredSystemCandidate{
+ Source: SourceAgent,
+ Name: " ",
+ Hostname: " ",
+ HostURL: " ",
+ }) {
+ t.Fatal("expected whitespace-only candidate not to match an existing counted system")
+ }
+}
+
func TestProjectMonitoredSystemRecords_DedupesVMwareHostAgainstExistingAgentCount(t *testing.T) {
rr := NewRegistry(nil)
now := time.Date(2026, 4, 7, 12, 0, 0, 0, time.UTC)