Documentation
¶
Overview ¶
Package report defines the analysis result model and its renderers (terminal, JSON, Markdown, HTML).
Index ¶
- func GradeOf(score int) string
- func WriteClusterDashboard(w io.Writer, r *Report, apiBase, backLink string) error
- func WriteDashboard(w io.Writer, r *Report) error
- func WriteHTML(w io.Writer, r *Report) error
- func WriteJSON(w io.Writer, r *Report) error
- func WriteMarkdown(w io.Writer, r *Report) error
- func WriteTerminal(w io.Writer, r *Report, opts TerminalOptions)
- type DiffResult
- type Finding
- type LocatedFinding
- type NamespaceSection
- type Report
- type Section
- type Severity
- type Summary
- type TerminalOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteClusterDashboard ¶ added in v0.2.0
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
WriteDashboard renders the same report plus the live controls (auto-refresh and JSON/Markdown download) that need the serve-mode REST API.
func WriteHTML ¶
WriteHTML renders a self-contained HTML report (no external assets), used for file export. Filtering, search and collapsible sections work offline.
func WriteMarkdown ¶
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
LocatedFinding is a finding plus where in the report it lives (a section title or "namespace <name>").
type NamespaceSection ¶
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
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 ¶
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) MaxSeverity ¶
MaxSeverity returns the highest severity among the section's findings.
type Severity ¶
type Severity int
Severity of a single finding.
Severity levels, ordered from least to most severe.
func (Severity) MarshalJSON ¶
MarshalJSON encodes the severity as its string name.
func (*Severity) UnmarshalJSON ¶
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.