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.

Keep malformed saved pins distinct from explicit empty trust

pulse-triage[bot]6420aee87ffb
diff --git a/internal/config/config_load_test.go b/internal/config/config_load_test.go
index 596ceaec9e..609c064d22 100644
--- a/internal/config/config_load_test.go
+++ b/internal/config/config_load_test.go
@@ -761,3 +761,11 @@ func TestPVEEndpointTrustOverrideSurvivesMerge(t *testing.T) {
t.Fatal("consolidation ignored contradictory explicit authority trust")
}
}
+
+func TestPVEEndpointTrustEmptyAndMalformedChoicesConflict(t *testing.T) {
+ a := PVEInstance{Host: "https://primary.test:8006", TLSFingerprintOverrides: map[string]string{"https://member.test:8006": ""}}
+ b := PVEInstance{Host: a.Host, TLSFingerprintOverrides: map[string]string{"https://MEMBER.test:8006/": ":"}}
+ if !pveClusterInstancesHaveFingerprintConflict(a, b) {
+ t.Fatal("merge treated an invalid nonempty pin as deliberate empty CA policy")
+ }
+}
diff --git a/internal/config/pve_instances.go b/internal/config/pve_instances.go
index 542436054d..8860bf7482 100644
--- a/internal/config/pve_instances.go
+++ b/internal/config/pve_instances.go
@@ -100,7 +100,7 @@ func pveClusterInstancesHaveFingerprintConflict(a, b PVEInstance) bool {
}
for endpoint, fingerprint := range a.TLSFingerprintOverrides {
other, known, err := proxmox.ResolveEndpointFingerprint(endpoint, b.TLSFingerprintOverrides)
- if err != nil || (known && strings.ToLower(strings.ReplaceAll(fingerprint, ":", "")) != strings.ToLower(strings.ReplaceAll(other, ":", ""))) {
+ if err != nil || (known && ((fingerprint == "") != (other == "") || strings.ToLower(strings.ReplaceAll(fingerprint, ":", "")) != strings.ToLower(strings.ReplaceAll(other, ":", "")))) {
return true
}
}
diff --git a/pkg/proxmox/cluster_client.go b/pkg/proxmox/cluster_client.go
index 3def2ce8dd..2811aa3f09 100644
--- a/pkg/proxmox/cluster_client.go
+++ b/pkg/proxmox/cluster_client.go
@@ -265,7 +265,7 @@ func (cc *ClusterClient) knownEndpointFingerprintLocked(endpoint string) (string
// Exact URL spelling must not choose a winner over another saved pin
// for this authority, nor may Go map order decide which leaf is trusted.
normalized := strings.ToLower(strings.ReplaceAll(fp, ":", ""))
- if known && strings.ToLower(strings.ReplaceAll(fingerprint, ":", "")) != normalized {
+ if known && ((fingerprint == "") != (fp == "") || strings.ToLower(strings.ReplaceAll(fingerprint, ":", "")) != normalized) {
return "", true, errConflictingEndpointFingerprints
}
// Keep a nonempty, malformed saved pin nonempty: returning its empty
diff --git a/pkg/proxmox/cluster_client_api_test.go b/pkg/proxmox/cluster_client_api_test.go
index 8689aa9f3f..7f33569ede 100644
--- a/pkg/proxmox/cluster_client_api_test.go
+++ b/pkg/proxmox/cluster_client_api_test.go
@@ -1044,3 +1044,20 @@ func TestClusterExplicitEmptyEndpointTrust(t *testing.T) {
}
}
}
+
+func TestClusterExplicitEmptyTrustCannotEraseMalformedNonemptyPin(t *testing.T) {
+ endpoint := "https://member.test:8006"
+ for _, malformed := range []string{":", "::", " "} {
+ pins := map[string]string{endpoint: malformed, "https://MEMBER.test:8006/": ""}
+ for _, spelling := range []string{endpoint, "https://MEMBER.test:8006/"} {
+ if _, _, err := ResolveEndpointFingerprint(spelling, pins); !errors.Is(err, errConflictingEndpointFingerprints) {
+ t.Fatalf("malformed nonempty pin %q became CA policy through alias %s: %v", malformed, spelling, err)
+ }
+ }
+ delete(pins, "https://MEMBER.test:8006/")
+ got, known, err := ResolveEndpointFingerprint(endpoint, pins)
+ if err != nil || !known || got != malformed {
+ t.Fatal("malformed saved pin was erased")
+ }
+ }
+}