checker: harden HTTP collection and stabilize report ordering

Validate the federation tester URI placeholder, escape the domain, set
a client timeout, cap the response body, and ship CA certificates in
the scratch image so HTTPS calls succeed. Sort hosts, connection
reports, and errors when rendering so output is deterministic, and
deduplicate TLS problems. Drop the deprecated aggregate Rule() and add
tests for collection and rules.
This commit is contained in:
nemunaire 2026-04-26 03:56:38 +07:00
commit 2af16d3ab9
13 changed files with 363 additions and 41 deletions

View file

@ -3,6 +3,7 @@ package checker
import (
"context"
"fmt"
"sort"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
@ -30,28 +31,44 @@ func (r *tlsChecksRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter,
return []sdk.CheckState{unknownState("matrix.tls_checks.skipped", "No endpoint reached: TLS posture could not be assessed.")}
}
out := make([]sdk.CheckState, 0, len(data.ConnectionReports))
for addr, cr := range data.ConnectionReports {
addrs := make([]string, 0, len(data.ConnectionReports))
for addr := range data.ConnectionReports {
addrs = append(addrs, addr)
}
sort.Strings(addrs)
out := make([]sdk.CheckState, 0, len(addrs))
for _, addr := range addrs {
cr := data.ConnectionReports[addr]
var problems []string
seen := make(map[string]struct{})
add := func(p string) {
if p == "" {
return
}
if _, ok := seen[p]; ok {
return
}
seen[p] = struct{}{}
problems = append(problems, p)
}
if !cr.Checks.MatchingServerName {
problems = append(problems, "server name does not match certificate")
add("server name does not match certificate")
}
if !cr.Checks.FutureValidUntilTS {
problems = append(problems, "certificate expired or near expiry")
add("certificate expired or near expiry")
}
if !cr.Checks.ValidCertificates {
problems = append(problems, "certificate chain is invalid")
add("certificate chain is invalid")
}
if !cr.Checks.HasEd25519Key {
problems = append(problems, "no Ed25519 signing key advertised")
add("no Ed25519 signing key advertised")
}
if !cr.Checks.AllEd25519ChecksOK {
problems = append(problems, "Ed25519 key verification failed")
add("Ed25519 key verification failed")
}
for _, e := range cr.Errors {
if e != "" {
problems = append(problems, e)
}
add(e)
}
if len(problems) == 0 && cr.Checks.AllChecksOK {