From 81a30a597658028c220502c2eac8625dff2c4b2b Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Fri, 25 Sep 2026 23:39:28 +0200 Subject: [PATCH] fix(mail): accurate and grammatical new-findings mail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mail promised an AI assessment, code evidence and a fix for every finding, which is not true for CVE, manual or pentest findings; it now says what each finding shows and that uncertain ones are marked "Zu prüfen" / "Needs review". One finding reads in the singular (the count arrives from JSON as a float, so the template compares its printed form), the headline names the target, and severity rows with zero are left out. Wording agreed with the Prüfwerk session. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB --- internal/mail/mail_test.go | 13 ++++++-- internal/mail/templates/de_findings.new.tmpl | 32 +++++++++++--------- internal/mail/templates/en_findings.new.tmpl | 32 +++++++++++--------- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/internal/mail/mail_test.go b/internal/mail/mail_test.go index f0031da..c195ab9 100644 --- a/internal/mail/mail_test.go +++ b/internal/mail/mail_test.go @@ -37,11 +37,18 @@ func TestRender_findingsEnglishAndDefaults(t *testing.T) { if err != nil { t.Fatal(err) } - if m.Subject != "3 new findings in Pump" || !strings.Contains(m.Text, "Critical 1") || !strings.Contains(m.Text, "High 0") { + if m.Subject != "3 new findings in Pump" || !strings.Contains(m.Text, "Critical 1") || strings.Contains(m.Text, "High ") { t.Fatalf("%q\n%s", m.Subject, m.Text) } - if de, _ := Render(KindFindingsNew, "fr", View{D: map[string]any{"new_count": 1}}); !strings.Contains(de.Subject, "neue Befunde") { - t.Fatalf("fallback locale: %q", de.Subject) + if !strings.Contains(m.HTML, "Needs review") || strings.Contains(m.HTML, "AI assessment") { + t.Fatalf("html: %s", m.HTML) + } + // JSON numbers arrive as float64: one finding still reads in the singular. + if de, _ := Render(KindFindingsNew, "fr", View{D: map[string]any{"new_count": float64(1), "target_name": "Presse"}}); de.Subject != "1 neuer Befund in Presse" || !strings.Contains(de.Text, "1 Befund ergeben, den es vorher nicht gab") { + t.Fatalf("fallback locale singular: %q\n%s", de.Subject, de.Text) + } + if en, _ := Render(KindFindingsNew, "en", View{D: map[string]any{"new_count": float64(1), "target_name": "Press"}}); en.Subject != "1 new finding in Press" { + t.Fatalf("english singular: %q", en.Subject) } if _, err := Render("nope", "de", View{}); err == nil { t.Fatal("unknown kind rendered") diff --git a/internal/mail/templates/de_findings.new.tmpl b/internal/mail/templates/de_findings.new.tmpl index a787c64..b453e06 100644 --- a/internal/mail/templates/de_findings.new.tmpl +++ b/internal/mail/templates/de_findings.new.tmpl @@ -1,27 +1,29 @@ -{{define "subject"}}{{.D.new_count}} neue Befunde in {{.D.target_name}}{{end}} +{{define "subject"}}{{if eq (printf "%v" .D.new_count) "1"}}1 neuer Befund{{else}}{{.D.new_count}} neue Befunde{{end}} in {{.D.target_name}}{{end}} {{define "button"}}Befunde ansehen{{end}} {{define "footer"}}Sie erhalten diese E-Mail, weil Sie den Arbeitsbereich {{.Tenant}} verwalten.{{end}} -{{define "html"}}

Prüfwerk hat neue Befunde gefunden

-

Die letzte Prüfung von {{.D.target_name}} im Arbeitsbereich {{.Tenant}} hat {{.D.new_count}} Befunde ergeben, die es vorher nicht gab.

+{{define "html"}}

Neue Befunde in {{.D.target_name}}

+

Die letzte Prüfung von {{.D.target_name}} im Arbeitsbereich {{.Tenant}} hat {{if eq (printf "%v" .D.new_count) "1"}}1 Befund ergeben, den es vorher nicht gab.{{else}}{{.D.new_count}} Befunde ergeben, die es vorher nicht gab.{{end}}

- - - - +{{if .D.critical}}{{end}} +{{if .D.high}}{{end}} +{{if .D.medium}}{{end}} +{{if .D.low}}{{end}}
Kritisch{{or .D.critical 0}}
Hoch{{or .D.high 0}}
Mittel{{or .D.medium 0}}
Niedrig / Info{{or .D.low 0}}
Kritisch{{.D.critical}}
Hoch{{.D.high}}
Mittel{{.D.medium}}
Niedrig / Info{{.D.low}}
-

Jeder Befund hat eine KI-Bewertung, einen Beleg im Code und einen Behebungsvorschlag.

{{end}} -{{define "text"}}Prüfwerk hat neue Befunde gefunden +

Im Befund sehen Sie Fundstelle, Schweregrad und, soweit zugeordnet, die betroffene CRA-Anforderung. Was die automatische Bewertung nicht sicher einordnen konnte, steht auf „Zu prüfen“.

{{end}} +{{define "text"}}Neue Befunde in {{.D.target_name}} -Die letzte Prüfung von {{.D.target_name}} im Arbeitsbereich {{.Tenant}} hat {{.D.new_count}} Befunde ergeben, die es vorher nicht gab: +Die letzte Prüfung von {{.D.target_name}} im Arbeitsbereich {{.Tenant}} hat {{if eq (printf "%v" .D.new_count) "1"}}1 Befund ergeben, den es vorher nicht gab:{{else}}{{.D.new_count}} Befunde ergeben, die es vorher nicht gab:{{end}} +{{if .D.critical}} + Kritisch {{.D.critical}}{{end}}{{if .D.high}} + Hoch {{.D.high}}{{end}}{{if .D.medium}} + Mittel {{.D.medium}}{{end}}{{if .D.low}} + Niedrig / Info {{.D.low}}{{end}} - Kritisch {{or .D.critical 0}} - Hoch {{or .D.high 0}} - Mittel {{or .D.medium 0}} - Niedrig / Info {{or .D.low 0}} +Im Befund sehen Sie Fundstelle, Schweregrad und, soweit zugeordnet, die betroffene CRA-Anforderung. Was die automatische Bewertung nicht sicher einordnen konnte, steht auf „Zu prüfen“. Befunde ansehen: {{.URL}} -- Sie erhalten diese E-Mail, weil Sie den Arbeitsbereich {{.Tenant}} verwalten. -BreakPilot GmbH · https://breakpilot.com/impressum{{end}} +Breakpilot GmbH · https://breakpilot.com/impressum{{end}} diff --git a/internal/mail/templates/en_findings.new.tmpl b/internal/mail/templates/en_findings.new.tmpl index 5f7429d..66da66b 100644 --- a/internal/mail/templates/en_findings.new.tmpl +++ b/internal/mail/templates/en_findings.new.tmpl @@ -1,27 +1,29 @@ -{{define "subject"}}{{.D.new_count}} new findings in {{.D.target_name}}{{end}} +{{define "subject"}}{{if eq (printf "%v" .D.new_count) "1"}}1 new finding{{else}}{{.D.new_count}} new findings{{end}} in {{.D.target_name}}{{end}} {{define "button"}}View the findings{{end}} {{define "footer"}}You receive this email because you administer the {{.Tenant}} workspace.{{end}} -{{define "html"}}

Prüfwerk found new findings

-

The latest scan of {{.D.target_name}} in the {{.Tenant}} workspace produced {{.D.new_count}} findings that were not there before.

+{{define "html"}}

New findings in {{.D.target_name}}

+

The latest scan of {{.D.target_name}} in the {{.Tenant}} workspace produced {{if eq (printf "%v" .D.new_count) "1"}}1 finding that was not there before.{{else}}{{.D.new_count}} findings that were not there before.{{end}}

- - - - +{{if .D.critical}}{{end}} +{{if .D.high}}{{end}} +{{if .D.medium}}{{end}} +{{if .D.low}}{{end}}
Critical{{or .D.critical 0}}
High{{or .D.high 0}}
Medium{{or .D.medium 0}}
Low / info{{or .D.low 0}}
Critical{{.D.critical}}
High{{.D.high}}
Medium{{.D.medium}}
Low / info{{.D.low}}
-

Every finding comes with an AI assessment, the code evidence and a suggested fix.

{{end}} -{{define "text"}}Prüfwerk found new findings +

Each finding shows where it is, how severe it is and, where mapped, the CRA requirement it concerns. Anything the automated review could not place with confidence is marked “Needs review”.

{{end}} +{{define "text"}}New findings in {{.D.target_name}} -The latest scan of {{.D.target_name}} in the {{.Tenant}} workspace produced {{.D.new_count}} findings that were not there before: +The latest scan of {{.D.target_name}} in the {{.Tenant}} workspace produced {{if eq (printf "%v" .D.new_count) "1"}}1 finding that was not there before:{{else}}{{.D.new_count}} findings that were not there before:{{end}} +{{if .D.critical}} + Critical {{.D.critical}}{{end}}{{if .D.high}} + High {{.D.high}}{{end}}{{if .D.medium}} + Medium {{.D.medium}}{{end}}{{if .D.low}} + Low / info {{.D.low}}{{end}} - Critical {{or .D.critical 0}} - High {{or .D.high 0}} - Medium {{or .D.medium 0}} - Low / info {{or .D.low 0}} +Each finding shows where it is, how severe it is and, where mapped, the CRA requirement it concerns. Anything the automated review could not place with confidence is marked “Needs review”. View the findings: {{.URL}} -- You receive this email because you administer the {{.Tenant}} workspace. -BreakPilot GmbH · https://breakpilot.com/impressum{{end}} +Breakpilot GmbH · https://breakpilot.com/impressum{{end}}