Compare commits

..

2 commits

Author SHA1 Message Date
59af24f695 Remove redundant RunAt field from CAAData
All checks were successful
continuous-integration/drone/push Build is passing
The observation timestamp is already stored by the core; there is no
need to duplicate it inside the payload.
2026-05-16 13:05:05 +08:00
8b7df15883 Include certificate count in issuer check state messages
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Add a per-issuer certificate counter to issuerAgg and append the count
to each CheckState message and Meta map, so operators can see how many
certificates were observed per issuer at a glance.
2026-05-15 21:59:56 +08:00
3 changed files with 8 additions and 8 deletions

View file

@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"time"
sdk "git.happydns.org/checker-sdk-go/checker"
)
@ -64,7 +63,6 @@ func (p *caaProvider) Collect(ctx context.Context, opts sdk.CheckerOptions) (any
return &CAAData{
Domain: domain,
Records: records,
RunAt: time.Now().UTC().Format(time.RFC3339),
}, nil
}

View file

@ -31,6 +31,7 @@ type issuerAgg struct {
code string
msg string
endpoints map[string]bool
count int // number of certificates observed from this issuer
}
type allowList struct {
@ -152,6 +153,7 @@ func (r *caaRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, opts
cur = &issuerAgg{sample: p, endpoints: map[string]bool{}}
agg[k] = cur
}
cur.count++
if severityRank(severity) >= severityRank(cur.severity) {
cur.severity = severity
cur.code = code
@ -233,22 +235,23 @@ func (r *caaRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, opts
endpoints = append(endpoints, ep)
}
sort.Strings(endpoints)
meta := map[string]any{"endpoints": endpoints}
meta := map[string]any{"endpoints": endpoints, "cert_count": a.count}
certSuffix := fmt.Sprintf(" (%d certificate(s) checked)", a.count)
switch a.severity {
case SeverityCrit:
out = append(out, sdk.CheckState{
Status: sdk.StatusCrit, Message: a.msg, Code: a.code,
Status: sdk.StatusCrit, Message: a.msg + certSuffix, Code: a.code,
Subject: subject, Meta: meta,
})
case SeverityWarn:
out = append(out, sdk.CheckState{
Status: sdk.StatusWarn, Message: a.msg, Code: a.code,
Status: sdk.StatusWarn, Message: a.msg + certSuffix, Code: a.code,
Subject: subject, Meta: meta,
})
case SeverityInfo:
out = append(out, sdk.CheckState{
Status: sdk.StatusInfo, Message: a.msg, Code: a.code,
Status: sdk.StatusInfo, Message: a.msg + certSuffix, Code: a.code,
Subject: subject, Meta: meta,
})
default:
@ -257,7 +260,7 @@ func (r *caaRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, opts
msg = "Certificate observed; no CAA records published"
}
out = append(out, sdk.CheckState{
Status: sdk.StatusOK, Message: msg, Code: CodeOK,
Status: sdk.StatusOK, Message: msg + certSuffix, Code: CodeOK,
Subject: subject, Meta: meta,
})
}

View file

@ -40,7 +40,6 @@ const (
type CAAData struct {
Domain string `json:"domain,omitempty"`
Records []CAARecord `json:"records,omitempty"`
RunAt string `json:"run_at,omitempty"`
}
type CAARecord struct {