// SPDX-License-Identifier: MIT package checker import ( "encoding/json" "fmt" "html" "sort" "strings" "time" sdk "git.happydns.org/checker-sdk-go/checker" ) // GetHTMLReport produces a self-contained HTML page that: // // - Banners the overall DNSViz status of the queried domain. // - Lists "Fix these first": the curated common-failure matches and any // critical state, with the human-readable hint pulled from CheckState.Meta. // - Renders one block per zone in the chain (root → … → leaf), with the // zone's status, errors and warnings, so a recursive DNSSEC failure // can be located at the exact level it broke. // - Falls back to a raw-JSON dump when no rule states were threaded in. func (p *dnsvizProvider) GetHTMLReport(ctx sdk.ReportContext) (string, error) { var data DNSVizData if raw := ctx.Data(); len(raw) > 0 { if err := json.Unmarshal(raw, &data); err != nil { return "", fmt.Errorf("decoding DNSViz data: %w", err) } } states := ctx.States() var b strings.Builder b.WriteString(`
`) b.WriteString(`%s
No DNSViz data and no rule states. The check probably failed before producing any output.
`) b.WriteString(``) return b.String(), nil } writeOverallBanner(&b, &data, states) writeFixFirst(&b, states) writeChain(&b, &data) writeAllStates(&b, states) writeRawSection(&b, &data) b.WriteString(`