report

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package report provides formatters that render a CrawlResult for human or machine consumption.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllReporters

func AllReporters() map[string]Reporter

AllReporters returns a map of all available reporters keyed by name.

func FilterIssues

func FilterIssues(issues []model.Issue, severities, categories string) []model.Issue

FilterIssues returns only issues matching the given criteria. severities: comma-separated list of severities (e.g. "critical,warning") categories: comma-separated list of category prefixes (e.g. "seo,performance") If a filter is empty string, all issues pass that filter.

func GroupIssues

func GroupIssues(issues []model.Issue, key string) map[string][]model.Issue

GroupIssues groups issues by the given key. key: "severity", "category", or "url" Returns a map[string][]model.Issue.

Types

type CSVReporter

type CSVReporter struct{}

CSVReporter writes the CrawlResult issues as a CSV document.

func (*CSVReporter) Name

func (r *CSVReporter) Name() string

Name returns "csv".

func (*CSVReporter) Write

func (r *CSVReporter) Write(_ context.Context, result *model.CrawlResult, w io.Writer) error

Write renders the issues from result as CSV rows and writes them to w. The header row is: url,severity,check,message,detail. Issues are written in their existing order (assumed pre-sorted by severity).

type HTMLReporter

type HTMLReporter struct{}

HTMLReporter writes the CrawlResult as a self-contained HTML document.

func (*HTMLReporter) Name

func (r *HTMLReporter) Name() string

Name returns "html".

func (*HTMLReporter) Write

func (r *HTMLReporter) Write(_ context.Context, result *model.CrawlResult, w io.Writer) error

Write renders result as an HTML report and writes it to w.

type JSONLReporter

type JSONLReporter struct{}

JSONLReporter writes the CrawlResult as JSON Lines — one JSON object per line.

func (*JSONLReporter) Name

func (r *JSONLReporter) Name() string

Name returns "jsonl".

func (*JSONLReporter) Write

func (r *JSONLReporter) Write(_ context.Context, result *model.CrawlResult, w io.Writer) error

Write renders result as JSONL (one JSON object per line) and writes it to w.

type JSONReporter

type JSONReporter struct{}

JSONReporter writes the CrawlResult as pretty-printed JSON.

func (*JSONReporter) Name

func (r *JSONReporter) Name() string

Name returns "json".

func (*JSONReporter) Write

func (r *JSONReporter) Write(_ context.Context, result *model.CrawlResult, w io.Writer) error

Write serialises result as indented JSON and writes it to w.

type JUnitReporter

type JUnitReporter struct{}

JUnitReporter writes the CrawlResult issues as JUnit XML.

func (*JUnitReporter) Name

func (r *JUnitReporter) Name() string

Name returns "junit".

func (*JUnitReporter) Write

func (r *JUnitReporter) Write(_ context.Context, result *model.CrawlResult, w io.Writer) error

Write renders result as JUnit XML and writes it to w.

type MarkdownReporter

type MarkdownReporter struct{}

MarkdownReporter writes the CrawlResult as a Markdown document.

func (*MarkdownReporter) Name

func (r *MarkdownReporter) Name() string

Name returns "markdown".

func (*MarkdownReporter) Write

func (r *MarkdownReporter) Write(_ context.Context, result *model.CrawlResult, w io.Writer) error

Write renders result as Markdown and writes it to w.

type PDFReporter

type PDFReporter struct{}

PDFReporter renders a CrawlResult as a PDF document by first generating an HTML report and then printing it to PDF via a headless browser.

func (*PDFReporter) Name

func (r *PDFReporter) Name() string

Name returns "pdf".

func (*PDFReporter) Write

func (r *PDFReporter) Write(ctx context.Context, result *model.CrawlResult, w io.Writer) error

Write generates a PDF report and writes it to w. Note: each invocation launches a new headless browser instance to render the HTML-to-PDF conversion. This is intentional as the browser is short-lived and isolated per report generation.

type Reporter

type Reporter interface {
	// Name returns the short identifier of this reporter (e.g. "terminal").
	Name() string
	// Write renders result and writes the formatted output to w.
	Write(ctx context.Context, result *model.CrawlResult, w io.Writer) error
}

Reporter formats and writes a CrawlResult to an output destination.

type SARIFReporter

type SARIFReporter struct {
	Version string
}

SARIFReporter writes the CrawlResult issues in SARIF 2.1.0 format. Set Version to override the default "dev" tool version in the output.

func (*SARIFReporter) Name

func (r *SARIFReporter) Name() string

Name returns "sarif".

func (*SARIFReporter) Write

func (r *SARIFReporter) Write(_ context.Context, result *model.CrawlResult, w io.Writer) error

Write renders result as SARIF 2.1.0 JSON and writes it to w.

type SummaryStats

type SummaryStats struct {
	TotalIssues  int                    `json:"total_issues"`
	BySeverity   map[model.Severity]int `json:"by_severity"`
	ByCategory   map[string]int         `json:"by_category"`
	TopURLs      []URLIssueCount        `json:"top_urls"`
	PagesScanned int                    `json:"pages_scanned"`
}

SummaryStats holds aggregated statistics about audit results.

func ComputeSummary

func ComputeSummary(result *model.CrawlResult) SummaryStats

ComputeSummary calculates summary statistics from a CrawlResult.

type TerminalReporter

type TerminalReporter struct{}

TerminalReporter renders a human-readable audit report to a terminal, using lipgloss for color and go-pretty for tables.

func (*TerminalReporter) Name

func (r *TerminalReporter) Name() string

Name returns "terminal".

func (*TerminalReporter) Write

func (r *TerminalReporter) Write(_ context.Context, result *model.CrawlResult, w io.Writer) error

Write formats result as a colourful terminal report and writes it to w.

type URLIssueCount

type URLIssueCount struct {
	URL   string `json:"url"`
	Count int    `json:"count"`
}

URLIssueCount pairs a URL with its issue count.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL