checker: thread rule states into ReportContext

Reporters can now read rule output via ctx.States() instead of
re-deriving severity/hints from the raw payload, keeping the rules
screen and the HTML report aligned on a single source of truth.
This commit is contained in:
nemunaire 2026-04-24 16:58:16 +07:00
commit 3382f62f57
6 changed files with 252 additions and 25 deletions

View file

@ -96,14 +96,15 @@ func (s *Server) handleCheckForm(w http.ResponseWriter, r *http.Request) {
}
func (s *Server) handleCheckSubmit(w http.ResponseWriter, r *http.Request) {
fields := s.interactive.RenderForm()
if err := r.ParseForm(); err != nil {
s.renderCheckForm(w, s.interactive.RenderForm(), fmt.Sprintf("invalid form: %v", err))
s.renderCheckForm(w, fields, fmt.Sprintf("invalid form: %v", err))
return
}
opts, err := s.interactive.ParseForm(r)
if err != nil {
s.renderCheckForm(w, s.interactive.RenderForm(), err.Error())
s.renderCheckForm(w, fields, err.Error())
return
}
@ -135,7 +136,7 @@ func (s *Server) handleCheckSubmit(w http.ResponseWriter, r *http.Request) {
result.States = s.evaluateRules(r.Context(), obs, opts, nil)
}
ctx := checker.NewReportContext(raw, related)
ctx := checker.NewReportContext(raw, related, result.States)
if reporter, ok := s.provider.(checker.CheckerHTMLReporter); ok {
html, rerr := reporter.GetHTMLReport(ctx)