Files
Pulse/internal/api/metadata_helpers.go
T
rcourtman cda968500a Bound metadata and journal writes and isolate PVE node identities
Refuse metadata and journal writes that exceed their loader's size limit
across HostMetadataStore, GuestMetadataStore, DockerMetadataStore,
HostContinuityStore, and DockerReportOrderStore, rolling back rejected
in-memory mutations. Reserve half of host_metadata.json for command
policy updates via SetCommandsEnabled, cap polled guest identity names
at 255 bytes, and return size refusals in GuestMetadataStore.save before
advancing revision or lastWriteErr so monitor reloads stay healthy.

Prevent a PVE cluster or endpoint-reported node name from claiming
another configured connection's node identity or namespace in
EnsurePVEClusterNodeIdentities, pveNodeIdentityScope, and
DerivePVENodeIdentity. Restrict guest parent node resolution in
ResourceRegistry to nodes on the guest's own connection, and never
interpret a bare reported node name as another node's canonical
resource ID when routing commands.

Contract-Neutral: Security hardening fix without public contract change
2026-11-24 12:28:52 +00:00

47 lines
1.4 KiB
Go

package api
import (
"errors"
"fmt"
"net/url"
"strings"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
)
// validateCustomURL validates a custom URL string.
// Returns an error message if invalid, or empty string if valid or empty input.
func validateCustomURL(rawURL string) string {
if rawURL == "" {
return ""
}
parsedURL, err := url.Parse(rawURL)
if err != nil {
return "Invalid URL format: " + err.Error()
}
if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" {
return "URL must use http:// or https:// scheme"
}
if parsedURL.Host == "" {
return "Invalid URL: missing host/domain (e.g., use https://192.168.1.100:8006 or https://myhost.local)"
}
if strings.HasSuffix(parsedURL.Host, ".") && !strings.Contains(parsedURL.Host, "..") {
return fmt.Sprintf("Incomplete URL: '%s' - please enter a complete domain or IP address", rawURL)
}
return ""
}
// metadataSaveErrorMessage returns a user-friendly error message for metadata save failures.
func metadataSaveErrorMessage(err error) string {
if errors.Is(err, config.ErrMetadataFileTooLarge) {
return "Metadata storage is full - remove metadata that is no longer needed"
}
if strings.Contains(err.Error(), "permission") {
return "Permission denied - check file permissions"
}
if strings.Contains(err.Error(), "no space") {
return "Disk full - cannot save metadata"
}
return "Failed to save metadata"
}