Documentation
¶
Overview ¶
Package render provides certificate analysis visualization for terminal output.
The package renders certree analysis results as tree views for human consumption. It supports a default flat view (one line per certificate) and detailed mode (activated by the --fields flag or the fields config option), three themes (classic, terse, minimal), and optional ANSI color output that respects NO_COLOR and TTY detection.
Primary entry points:
- Trees: Produces tree output for one or more analyses
- Comparisons: Produces side-by-side before/after comparison
- Diffs: Produces unified diffs of before/after simulation
- ImpactSummary: Computes impact summary between two analyses
Terminal and theme utilities:
- ThemeNames: Returns available theme names
- LookupLogIcons: Returns log-level icons for a theme
- SpinnerFrames: Returns spinner animation frames for a theme
- TerminalWidth: Detects terminal width
- StderrColorEnabled: Reports whether stderr supports color
Index ¶
- Constants
- func Comparisons(pairs []AnalysisPair, opts Options, w io.Writer) error
- func Diffs(pairs []AnalysisPair, sources []string, opts Options, w io.Writer) error
- func ImpactSummary(before, after *certree.Analysis, indent, sep string, expiryWarningDays int) string
- func LabelSep(themeName string) string
- func OverrideColorLibrary(colorMode string)
- func SanitizeCertString(s string) string
- func SectionIndent(themeName string) string
- func SpinnerFrames(themeName string, useColor bool) []string
- func StderrColorEnabled() bool
- func TerminalWidth() int
- func ThemeNames() []string
- func Trees(analyses []*certree.Analysis, opts Options, w io.Writer) error
- type AnalysisPair
- type LogIcons
- type Options
Constants ¶
const DefaultThemeName = "classic"
DefaultThemeName is the name of the default built-in theme.
Variables ¶
This section is empty.
Functions ¶
func Comparisons ¶
func Comparisons(pairs []AnalysisPair, opts Options, w io.Writer) error
Comparisons renders multiple before/after pairs under a single "Before | After" header with dashed separators between sources.
func Diffs ¶
Diffs renders unified diffs for multiple before/after pairs. Each pair produces a separate diff section with the corresponding source identifier in the header.
func ImpactSummary ¶
func ImpactSummary(before, after *certree.Analysis, indent, sep string, expiryWarningDays int) string
ImpactSummary computes and formats the impact summary between two analyses. indent controls sub-field indentation (typically the theme's sectionIndent). sep is the spacing between "label:" and value (typically the theme's labelSep). expiryWarningDays must match the value used for the root label's path count to keep the numbers consistent.
func LabelSep ¶
LabelSep returns the label separator string for the named theme. If the theme name is empty or unknown, the classic theme separator is returned.
func OverrideColorLibrary ¶
func OverrideColorLibrary(colorMode string)
OverrideColorLibrary forces the fatih/color library to emit ANSI codes when --color=always is set. The library auto-detects non-TTY stdout and sets its global NoColor flag, which suppresses output from SprintFunc closures at call time. This override is only applied in the "always" mode. Must be called before any color.SprintFunc closures are invoked.
func SanitizeCertString ¶
SanitizeCertString strips ANSI escape sequences and replaces control characters (newlines, tabs, carriage returns, null bytes, and other C0/C1 controls) with a Unicode replacement character. This prevents malicious certificate fields from injecting fake output lines or terminal commands.
func SectionIndent ¶
SectionIndent returns the section content indentation string for the named theme. If the theme name is empty or unknown, the classic theme indent is returned.
func SpinnerFrames ¶
SpinnerFrames returns the spinner animation frames for the named theme. If the theme name is empty or unknown, the classic theme frames are returned. When useColor is true, the icon content inside brackets is colorized using the info (blue) color, matching the colorization style of status icons.
func StderrColorEnabled ¶
func StderrColorEnabled() bool
StderrColorEnabled reports whether stderr supports ANSI color output, using the same auto-detection logic as --color=auto (NO_COLOR, TERM, TTY check).
func TerminalWidth ¶
func TerminalWidth() int
TerminalWidth returns the detected stdout terminal width in columns.
func ThemeNames ¶
func ThemeNames() []string
ThemeNames returns the sorted list of built-in theme names.
Types ¶
type AnalysisPair ¶
type AnalysisPair struct {
// Before is the baseline analysis for comparison.
Before *certree.Analysis
// After is the updated analysis to compare against Before.
After *certree.Analysis
}
AnalysisPair holds a before/after analysis pair for batch operations.
type LogIcons ¶
LogIcons contains pre-formatted icon strings for each log level, ready for use as log message prefixes. Icons are pre-colorized when color is enabled.
func LookupLogIcons ¶
LookupLogIcons returns log-level icons for the named theme. If the theme name is empty or unknown, the classic theme icons are returned. When useColor is true, the icons are pre-colorized using the theme's color scheme.
type Options ¶
type Options struct {
// ThemeName selects the output theme ("classic", "terse", "minimal"); defaults to "classic".
ThemeName string
// ColorMode controls ANSI color output: "auto", "always", or "never".
ColorMode string
// ExpiryWarningDays is the threshold for expiry-soon warnings.
// Zero and negative values fall back to certree.DefaultExpiryWarningDays (30).
ExpiryWarningDays int
// ReverseOrder displays certificates in root-to-leaf order.
ReverseOrder bool
// WrapLines enables line wrapping for long field values.
WrapLines bool
// ShowAll enables all detail fields at once.
ShowAll bool
ShowSubject bool
ShowSAN bool
ShowIssuer bool
ShowValidity bool
ShowTrustStore bool
ShowSerial bool
ShowFingerprint bool
ShowAlgorithm bool
ShowExtensions bool
ShowAIA bool
ShowCRL bool
ShowSource bool
ShowDiagnostics bool
// Impact enables simulation impact display (runtime-only, not a detail flag).
Impact bool
// ShowAnnotations enables parenthesized status annotations on certificate
// and path nodes (e.g. "(expired)", "(self-signed, trusted)").
ShowAnnotations bool
// ShowPathIndex displays a right-aligned path index (#1, #2, ...) on
// path terminal certificates to identify which trust path each branch represents.
ShowPathIndex bool
// ExpandedView disables the default merged tree view and renders each
// TrustPath under its own "Trust Path N" node.
ExpandedView bool
}
Options configures visualization behavior.