package main func init() { register(Check{ Seq: 220, ID: "22", Title: "No hand-rolled HTML sanitization (use bluemonday)", Run: func(ctx *ScanContext, rep *Reporter) { var htmlSanViolations []htmlSanitizeViolation for _, target := range ctx.backendTargets { for _, v := range checkHTMLSanitize(target.root) { v.file = prefixDisplayPath(target.display, v.file) htmlSanViolations = append(htmlSanViolations, v) } } for _, target := range ctx.pluginTargets { for _, v := range checkHTMLSanitize(target.root) { v.file = prefixDisplayPath(target.display, v.file) htmlSanViolations = append(htmlSanViolations, v) } } if len(htmlSanViolations) > 0 { rep.Fail("%d hand-rolled HTML sanitization pattern(s) — use bluemonday", len(htmlSanViolations)) for _, v := range htmlSanViolations { rep.Findingf("%s:%d [%s] %s", v.file, v.line, v.rule, v.snippet) } } else { rep.OK("No hand-rolled HTML sanitization detected") } }, }) }