report

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package report defines the analysis result model and its renderers (terminal, JSON, Markdown, HTML).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GradeOf added in v0.2.0

func GradeOf(score int) string

GradeOf maps a 0-100 score onto A-F.

func WriteClusterDashboard added in v0.2.0

func WriteClusterDashboard(w io.Writer, r *Report, apiBase, backLink string) error

WriteClusterDashboard renders a dashboard whose API calls are scoped to one fleet cluster (apiBase like "/api/clusters/prod"). backLink adds a navigation link to the fleet overview.

func WriteDashboard added in v0.2.0

func WriteDashboard(w io.Writer, r *Report) error

WriteDashboard renders the same report plus the live controls (auto-refresh and JSON/Markdown download) that need the serve-mode REST API.

func WriteHTML

func WriteHTML(w io.Writer, r *Report) error

WriteHTML renders a self-contained HTML report (no external assets), used for file export. Filtering, search and collapsible sections work offline.

func WriteJSON

func WriteJSON(w io.Writer, r *Report) error

WriteJSON renders the report as indented JSON.

func WriteMarkdown

func WriteMarkdown(w io.Writer, r *Report) error

WriteMarkdown renders the report as a Markdown document.

func WriteTerminal

func WriteTerminal(w io.Writer, r *Report, opts TerminalOptions)

WriteTerminal renders the report for humans in a terminal.

Types

type DiffResult added in v0.2.0

type DiffResult struct {
	New      []LocatedFinding `json:"new"`
	Resolved []LocatedFinding `json:"resolved"`
}

DiffResult lists findings that appeared in or disappeared from a report relative to an older one.

func Diff added in v0.2.0

func Diff(older, newer *Report) DiffResult

Diff compares two reports. OK findings never appear in the result.

type Finding

type Finding struct {
	Severity Severity `json:"severity"`
	Message  string   `json:"message"`
	Object   string   `json:"object,omitempty"`
	Hint     string   `json:"hint,omitempty"`
	// Controls lists compliance-framework controls this finding maps to,
	// e.g. "PSS/baseline:privileged".
	Controls []string `json:"controls,omitempty"`
}

Finding is a single observation about the cluster.

type LocatedFinding added in v0.2.0

type LocatedFinding struct {
	Location string `json:"location"`
	Finding
}

LocatedFinding is a finding plus where in the report it lives (a section title or "namespace <name>").

type NamespaceSection

type NamespaceSection struct {
	Name     string    `json:"name"`
	Findings []Finding `json:"findings"`
}

NamespaceSection holds per-namespace workload findings.

func (NamespaceSection) MaxSeverity

func (n NamespaceSection) MaxSeverity() Severity

MaxSeverity returns the highest severity among the namespace's findings.

type Report

type Report struct {
	ClusterName       string             `json:"clusterName"`
	Context           string             `json:"context,omitempty"`
	KubernetesVersion string             `json:"kubernetesVersion,omitempty"`
	GeneratedAt       time.Time          `json:"generatedAt"`
	Namespaces        []NamespaceSection `json:"namespaces"`
	Sections          []Section          `json:"sections"`
	Summary           Summary            `json:"summary"`
}

Report is the full analysis result.

func (*Report) FilterControls added in v0.2.0

func (r *Report) FilterControls(prefix string)

FilterControls keeps only findings tagged with a compliance control whose ID starts with prefix (case-insensitive) and recomputes the summary.

func (*Report) Finalize

func (r *Report) Finalize()

Finalize recomputes the summary from the collected findings.

func (*Report) MaxSeverity

func (r *Report) MaxSeverity() Severity

MaxSeverity returns the highest severity present anywhere in the report.

type Section

type Section struct {
	ID       string    `json:"id"`
	Title    string    `json:"title"`
	Icon     string    `json:"icon"`
	Findings []Finding `json:"findings"`
}

Section groups findings under a topic (Security, Monitoring, ...).

func (Section) Grade added in v0.2.0

func (s Section) Grade() string

Grade scores just this section's findings on the A-F scale.

func (Section) MaxSeverity

func (s Section) MaxSeverity() Severity

MaxSeverity returns the highest severity among the section's findings.

type Severity

type Severity int

Severity of a single finding.

const (
	SeverityOK Severity = iota
	SeverityInfo
	SeverityWarning
	SeverityCritical
)

Severity levels, ordered from least to most severe.

func (Severity) MarshalJSON

func (s Severity) MarshalJSON() ([]byte, error)

MarshalJSON encodes the severity as its string name.

func (Severity) String

func (s Severity) String() string

func (*Severity) UnmarshalJSON

func (s *Severity) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a severity from its string name.

type Summary

type Summary struct {
	Namespaces int    `json:"namespaces"`
	Total      int    `json:"totalFindings"`
	Info       int    `json:"info"`
	Warnings   int    `json:"warnings"`
	Critical   int    `json:"critical"`
	Score      int    `json:"score"`
	Grade      string `json:"grade"`
}

Summary aggregates finding counts across the whole report.

type TerminalOptions

type TerminalOptions struct {
	NoColor bool
	// Verbose prints remediation hints under each finding.
	Verbose bool
}

TerminalOptions configure the CLI renderer.

Jump to

Keyboard shortcuts

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