output

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package output renders analysis results to various output formats (terminal, JSON, HTML, badges).

HTML report generation uses Go's embedded template system (//go:embed) to bundle templates at compile time, producing self-contained binaries with no runtime dependencies. The generated HTML is fully standalone: all CSS, JavaScript, and chart rendering code is inlined, allowing reports to be viewed offline without external CDN dependencies.

CRITICAL MAINTENANCE NOTE: Templates are embedded at compile time. After modifying templates/report.html or templates/styles.css, you MUST rebuild the binary with `go build -o ars .` for changes to take effect. Hot-reloading does NOT work.

Security: All user-generated content (file paths, evidence, scores) is sanitized via template.JSEscape() before embedding in <script> tags to prevent XSS attacks.

Package output renders analysis results to various output formats (terminal, JSON, HTML, badges).

Terminal rendering uses hierarchical display with automatic color encoding (green/yellow/red) based on score thresholds. Colors convey metric health at a glance without requiring users to interpret numeric scores. NO_COLOR environment variable support ensures compatibility with screen readers, CI/CD pipelines, and accessibility tools per https://no-color.org standards.

The package handles evidence formatting, section expansion/collapse for verbose output, and tier classification display with visual indicators (emojis, color, progress bars).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildJSONReport

func BuildJSONReport(scored *types.ScoredResult, recs []recommend.Recommendation, verbose bool, includeBadge bool, meta *types.RepoMetadata) *jsonReport

BuildJSONReport converts a ScoredResult and recommendations into a jsonReport. The verbose parameter is deprecated; sub_scores are always included. When includeBadge is true, badge URL and markdown are included.

func NewHTMLGenerator

func NewHTMLGenerator() (*htmlGenerator, error)

NewHTMLGenerator creates a generator with embedded templates.

func NewTraceData added in v0.0.8

func NewTraceData(cfg *scoring.ScoringConfig, results []*types.AnalysisResult, langs []string) *traceData

NewTraceData constructs trace data for HTML report rendering. Pass the result to GenerateReport; nil is accepted when trace rendering is not needed.

func ParseJSONBaseline added in v0.0.8

func ParseJSONBaseline(data []byte) (*types.ScoredResult, error)

ParseJSONBaseline parses a JSON report byte slice and extracts the baseline scoring result needed for trend comparison. It returns a minimal ScoredResult containing composite score, tier, and per-category scores/weights.

func RenderBadge

func RenderBadge(w io.Writer, scored *types.ScoredResult)

RenderBadge prints the shields.io badge markdown to w.

func RenderC7Debug

func RenderC7Debug(w io.Writer, analysisResults []*types.AnalysisResult)

RenderC7Debug renders detailed C7 debug data (prompts, responses, scores, traces) to the provided writer. This is called only when --debug-c7 is active.

func RenderJSON

func RenderJSON(w io.Writer, report *jsonReport) error

RenderJSON writes the JSON report to w with pretty-printed indentation.

func RenderRecommendations

func RenderRecommendations(w io.Writer, recs []recommend.Recommendation)

RenderRecommendations prints ranked improvement recommendations to w.

func RenderRepoMetadata added in v0.0.8

func RenderRepoMetadata(w io.Writer, meta *types.RepoMetadata)

RenderRepoMetadata prints repository metadata to w.

func RenderScores

func RenderScores(w io.Writer, scored *types.ScoredResult, verbose bool)

RenderScores prints a formatted scoring section showing per-category scores, composite score, and tier rating.

func RenderSummary

func RenderSummary(w io.Writer, result *types.ScanResult, analysisResults []*types.AnalysisResult, verbose bool)

RenderSummary prints a formatted scan summary to w.

Types

This section is empty.

Jump to

Keyboard shortcuts

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