From 0ce752a370635d8b3f73a7a88a295fa218880e88 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Sat, 14 Nov 2026 18:27:30 +0100 Subject: [PATCH] hub (unreleased): the end-date check reads the certificate's issuer too (the wire gate: a field the box sends must be modelled) Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS --- .../B/redproof-hub-end-dates.txt | 10 ++++++++++ hub/internal/monitor/end_dates.go | 10 ++++++++-- hub/internal/monitor/end_dates_test.go | 7 ++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/documentation/audits/night-build-2026-11-14/B/redproof-hub-end-dates.txt b/documentation/audits/night-build-2026-11-14/B/redproof-hub-end-dates.txt index 889cee96..7295ee46 100644 --- a/documentation/audits/night-build-2026-11-14/B/redproof-hub-end-dates.txt +++ b/documentation/audits/night-build-2026-11-14/B/redproof-hub-end-dates.txt @@ -58,3 +58,13 @@ r1383_wiring_test.go:72: main.go: end-date sweep — found 0 time(s), want 1 1 mutations, 0 not a red-proof +== MUTATION: the issuer name of a box is not checked + RED on the mutant, GREEN on the real file + --- FAIL: TestEndDates_TheBoxesWordsAreChecked (0.00s) + end_dates_test.go:146: an issuer that is not a plain name must be dropped and the certificate still told: +== MUTATION: the issuer is read and not kept + RED on the mutant, GREEN on the real file + --- FAIL: TestEndDates_FourteenDaysOnceThenEndedOnce (0.00s) + end_dates_test.go:71: the events lack "\"issuer\":\"YR2\"": + +2 mutations, 0 not a red-proof diff --git a/hub/internal/monitor/end_dates.go b/hub/internal/monitor/end_dates.go index c9193980..91459861 100644 --- a/hub/internal/monitor/end_dates.go +++ b/hub/internal/monitor/end_dates.go @@ -150,7 +150,7 @@ func (c *EndDateChecker) Check() { r.CustomerID, wc.Domain, wc.NotAfter.UTC().Format("2006-01-02")) } c.logger.Printf("[WARN] end-date check: web certificate of %s for %s %s — ends %s", r.CustomerID, wc.Domain, stage, wc.NotAfter.UTC().Format(time.RFC3339)) - details, _ := json.Marshal(map[string]any{"domain": wc.Domain, "not_after": wc.NotAfter.UTC().Format(time.RFC3339), "stage": stage}) + details, _ := json.Marshal(map[string]any{"domain": wc.Domain, "not_after": wc.NotAfter.UTC().Format(time.RFC3339), "stage": stage, "issuer": wc.Issuer}) c.onEvent(r.CustomerID, EventWebCertEndsSoon, sev, msg, string(details), "hub") } } @@ -159,6 +159,7 @@ func (c *EndDateChecker) Check() { type webCert struct { Domain string NotAfter time.Time + Issuer string // the issuer's name as the box read it from the certificate; "" when it is not a plain name } // parseWebCerts reads `web_certs` from a controller report: at most webCertsReadMax entries, each with a plain name @@ -169,6 +170,7 @@ func parseWebCerts(reportJSON string) []webCert { WebCerts []struct { Domain string `json:"domain"` NotAfter string `json:"not_after"` + Issuer string `json:"issuer"` } `json:"web_certs"` } if json.Unmarshal([]byte(reportJSON), &w) != nil { @@ -183,7 +185,11 @@ func parseWebCerts(reportJSON string) []webCert { if err != nil || !endDateNameRe.MatchString(c.Domain) || strings.Contains(c.Domain, "..") { continue } - out = append(out, webCert{Domain: c.Domain, NotAfter: at}) + issuer := c.Issuer + if !endDateTokenNameRe.MatchString(issuer) { + issuer = "" // the box's word: shown only when it is a plain name + } + out = append(out, webCert{Domain: c.Domain, NotAfter: at, Issuer: issuer}) } sort.Slice(out, func(i, j int) bool { return out[i].NotAfter.Before(out[j].NotAfter) }) return out diff --git a/hub/internal/monitor/end_dates_test.go b/hub/internal/monitor/end_dates_test.go index 739fda67..a2ce1348 100644 --- a/hub/internal/monitor/end_dates_test.go +++ b/hub/internal/monitor/end_dates_test.go @@ -66,7 +66,7 @@ func TestEndDates_FourteenDaysOnceThenEndedOnce(t *testing.T) { } all := strings.Join(f.events, "\n") for _, want := range []string{"|operator_token_ends_soon|warning|", "„CC hub token”", tokEnd.Format("2006-01-02"), "401", - "demo-hp|web_cert_ends_soon|warning|", "*.enkisfelhom.hu", certEnd.Format("2006-01-02"), "renewal has FAILED"} { + "demo-hp|web_cert_ends_soon|warning|", "*.enkisfelhom.hu", certEnd.Format("2006-01-02"), "renewal has FAILED", `"issuer":"YR2"`} { if !strings.Contains(all, want) { t.Errorf("the events lack %q:\n%s", want, all) } @@ -128,6 +128,8 @@ func TestEndDates_TheBoxesWordsAreChecked(t *testing.T) { {CustomerID: "many", ReportJSON: certReport(many...)}, {CustomerID: "evil", ReportJSON: certReport(cert("second-report.example.hu", soon))}, // a duplicate row of the same household } + // an issuer name that is not a plain name is dropped, the certificate is still told + f.reps = append(f.reps, BoxCertReport{CustomerID: "iss", ReportJSON: `{"web_certs":[{"domain":"x.example.hu","not_after":"` + soon.UTC().Format(time.RFC3339) + `","issuer":"CA"}]}`}) f.tokens = []EndingToken{{ID: 9, Name: "x", ExpiresAt: soon}} f.step(0) all := strings.Join(f.events, "\n") @@ -140,6 +142,9 @@ func TestEndDates_TheBoxesWordsAreChecked(t *testing.T) { if n := strings.Count(all, "many|web_cert_ends_soon"); n != webCertsReadMax { t.Errorf("household „many”: %d event(s), want the cap %d", n, webCertsReadMax) } + if !strings.Contains(all, "iss|web_cert_ends_soon") || strings.Contains(all, "") || !strings.Contains(all, `"issuer":""`) { + t.Errorf("an issuer that is not a plain name must be dropped and the certificate still told:\n%s", all) + } if !strings.Contains(all, "„token #9”") { t.Errorf("a token with a name that is not plain text must be named by its number:\n%s", all) }