package governance import ( "net/url" "strings" ) // ValidHTTPOrigin reports whether value is a bare http(s) origin: scheme, host // and an optional path, with no credentials, query string or fragment. It is // the single rule for every operator-supplied endpoint — the env-configured // probe address and the web-configured one — so an endpoint can never smuggle // a secret (https://user:pass@host, ?token=...) or an injection payload. func ValidHTTPOrigin(value string) bool { trimmed := strings.TrimSpace(value) if trimmed == "" || trimmed != value || len(trimmed) > 300 { return false } parsed, err := url.Parse(trimmed) if err != nil || (parsed.Scheme != "http" && parsed.Scheme != "https") || parsed.Host == "" { return false } return parsed.User == nil && parsed.RawQuery == "" && parsed.Fragment == "" }