Documentation
¶
Index ¶
- Constants
- Variables
- func Bar() string
- func Dimmed(text string) string
- func DisableColor()
- func FindingsSummaryLine(counts map[string]int, total int) string
- func Header(text string) string
- func Prefix() string
- func PrintFindingsTable(findings []rules.Finding, br bool)
- func PrintScoreDecomposition(d *scoring.ScoreDecomposition, br bool)
- func Resource(text string) string
- func ScanStatusLine(exitCode int, br bool) string
- func ScoreColor(score float64) string
- func SectionTitle(text string) string
- func SevColor(severity string) string
- func SevCountLine(severity string, label string, count int) string
- func SourceHeader(text string) string
- func SpinWhile[T any](message string, fn func() (T, error)) (T, error)
- func SpinWhileE(message string, fn func() error) error
- func VerdictSafe(text string) string
- func VerdictUnsafe(text string) string
- type SARIFArtifactLocation
- type SARIFDefaultConfig
- type SARIFDriver
- type SARIFLocation
- type SARIFMessage
- type SARIFMultiformatMessage
- type SARIFPhysicalLocation
- type SARIFReport
- type SARIFResult
- type SARIFRule
- type SARIFRuleProps
- type SARIFRun
- type SARIFTool
- type Spinner
- type Writer
- func (w *Writer) PrintSummary(result aggregator.ReviewResult)
- func (w *Writer) WriteHTML(result aggregator.ReviewResult, path string) error
- func (w *Writer) WriteJSON(result aggregator.ReviewResult, path string) error
- func (w *Writer) WriteJSONWriter(result aggregator.ReviewResult, dst io.Writer) error
- func (w *Writer) WriteMarkdown(result aggregator.ReviewResult, path string) error
- func (w *Writer) WriteSARIF(result aggregator.ReviewResult, path string) error
- func (w *Writer) WriteSARIFWriter(result aggregator.ReviewResult, dst io.Writer) error
- type WriterConfig
Constants ¶
const ( FormatPretty = "pretty" FormatCompact = "compact" FormatJSON = "json" FormatHTML = "html" )
Format constants for output mode.
const FormatSARIF = "sarif"
FormatSARIF is the SARIF output format constant.
Variables ¶
var ColorEnabled = true
ColorEnabled controls whether ANSI colors are emitted. Respects NO_COLOR env var (https://no-color.org/) and --no-color flag.
Functions ¶
func FindingsSummaryLine ¶ added in v0.7.0
FindingsSummaryLine returns "[TOTAL: N | CRITICAL: N | HIGH: N | ...]".
func Prefix ¶
func Prefix() string
Prefix returns the styled [terraview] prefix in Terraform's signature purple.
func PrintFindingsTable ¶ added in v0.7.0
PrintFindingsTable renders findings as an Orca-style bordered table.
func PrintScoreDecomposition ¶ added in v0.7.0
func PrintScoreDecomposition(d *scoring.ScoreDecomposition, br bool)
PrintScoreDecomposition prints the full score decomposition to stdout. Exposed so commands like `terraview status --explain-scores` can reuse the same rendering used by `terraview scan`.
func ScanStatusLine ¶ added in v0.7.0
ScanStatusLine returns the "SCAN STATUS: FAILED/WARNING/PASSED — detail" line.
func ScoreColor ¶
ScoreColor returns the score colored by value.
func SectionTitle ¶ added in v0.7.0
SectionTitle returns a bold+underline cyan section title (Orca-style).
func SevCountLine ¶
SevCountLine returns a colored severity label with count for the summary.
func SourceHeader ¶
SourceHeader returns the styled source group header.
func SpinWhile ¶
SpinWhile is a convenience helper that runs fn while displaying a spinner. It returns the values returned by fn. The spinner is stopped automatically with the appropriate success/failure indicator.
Usage:
result, err := output.SpinWhile("Running terraform plan...", func() (string, error) {
return e.runSilent("plan", "-out=tfplan")
})
func SpinWhileE ¶
SpinWhileE is like SpinWhile but for functions that return only an error.
func VerdictSafe ¶
VerdictSafe returns the styled SAFE verdict.
func VerdictUnsafe ¶
VerdictUnsafe returns the styled NOT SAFE verdict.
Types ¶
type SARIFArtifactLocation ¶
type SARIFArtifactLocation struct {
URI string `json:"uri"`
}
SARIFArtifactLocation is the file URI.
type SARIFDefaultConfig ¶
type SARIFDefaultConfig struct {
Level string `json:"level"`
}
SARIFDefaultConfig is the default severity config.
type SARIFDriver ¶
type SARIFDriver struct {
Name string `json:"name"`
Version string `json:"version"`
InformationURI string `json:"informationUri"`
Rules []SARIFRule `json:"rules"`
}
SARIFDriver is the tool driver with rules.
type SARIFLocation ¶
type SARIFLocation struct {
PhysicalLocation SARIFPhysicalLocation `json:"physicalLocation"`
Message *SARIFMessage `json:"message,omitempty"`
}
SARIFLocation is a finding location.
type SARIFMessage ¶
type SARIFMessage struct {
Text string `json:"text"`
}
SARIFMessage is a text message.
type SARIFMultiformatMessage ¶ added in v0.5.0
type SARIFMultiformatMessage struct {
Text string `json:"text"`
}
SARIFMultiformatMessage supports text (and optionally markdown) content.
type SARIFPhysicalLocation ¶
type SARIFPhysicalLocation struct {
ArtifactLocation SARIFArtifactLocation `json:"artifactLocation"`
}
SARIFPhysicalLocation points to a specific file.
type SARIFReport ¶
type SARIFReport struct {
Schema string `json:"$schema"`
Version string `json:"version"`
Runs []SARIFRun `json:"runs"`
}
SARIFReport is the top-level SARIF 2.1.0 structure.
type SARIFResult ¶
type SARIFResult struct {
RuleID string `json:"ruleId"`
RuleIndex int `json:"ruleIndex"`
Level string `json:"level"`
Message SARIFMessage `json:"message"`
Locations []SARIFLocation `json:"locations,omitempty"`
}
SARIFResult is a single finding result.
type SARIFRule ¶
type SARIFRule struct {
ID string `json:"id"`
Name string `json:"name"`
ShortDescription SARIFMessage `json:"shortDescription"`
DefaultConfig SARIFDefaultConfig `json:"defaultConfiguration"`
Help *SARIFMultiformatMessage `json:"help,omitempty"`
Properties SARIFRuleProps `json:"properties,omitempty"`
}
SARIFRule is a rule definition in SARIF.
type SARIFRuleProps ¶
type SARIFRuleProps struct {
Category string `json:"category,omitempty"`
}
SARIFRuleProps holds extra rule properties.
type SARIFRun ¶
type SARIFRun struct {
Tool SARIFTool `json:"tool"`
Results []SARIFResult `json:"results"`
}
SARIFRun represents a single analysis run.
type SARIFTool ¶
type SARIFTool struct {
Driver SARIFDriver `json:"driver"`
}
SARIFTool describes the analysis tool.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner displays an animated spinner in the terminal while a long-running operation is executing. It respects the global ColorEnabled flag.
func NewSpinner ¶
NewSpinner creates a Spinner with the given status message. When stderr is not a terminal (CI, pipe, 2>&1), the spinner is created in noop mode: Start() prints a single log line and Stop() prints the result — no animation frames are emitted.
func (*Spinner) SetMessage ¶ added in v0.10.0
SetMessage atomically swaps the status text shown next to the animated frame. Safe to call concurrently from any goroutine while the spinner is running.
In noop mode (non-TTY/CI), prints a fresh log line so the user still gets progress feedback — without this, long-running ops in CI look hung.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer generates output files from review results.
func NewWriterWithConfig ¶
func NewWriterWithConfig(config WriterConfig) *Writer
NewWriterWithConfig creates a Writer with the given config.
func (*Writer) PrintSummary ¶
func (w *Writer) PrintSummary(result aggregator.ReviewResult)
PrintSummary prints the review summary to stdout.
func (*Writer) WriteHTML ¶ added in v0.7.0
func (w *Writer) WriteHTML(result aggregator.ReviewResult, path string) error
WriteHTML writes the review result as a self-contained HTML report.
func (*Writer) WriteJSON ¶
func (w *Writer) WriteJSON(result aggregator.ReviewResult, path string) error
WriteJSON writes the review result as structured JSON to the given file path. The parent directory is created automatically if it does not exist.
func (*Writer) WriteJSONWriter ¶ added in v0.9.0
func (w *Writer) WriteJSONWriter(result aggregator.ReviewResult, dst io.Writer) error
WriteJSONWriter serializes the review result as JSON to an arbitrary io.Writer. Used when --format json is requested without an explicit -o directory (stdout).
func (*Writer) WriteMarkdown ¶
func (w *Writer) WriteMarkdown(result aggregator.ReviewResult, path string) error
WriteMarkdown writes the review result as a formatted Markdown report.
func (*Writer) WriteSARIF ¶
func (w *Writer) WriteSARIF(result aggregator.ReviewResult, path string) error
WriteSARIF writes the review result as a SARIF 2.1.0 report to the given file path. The parent directory is created automatically if it does not exist.
func (*Writer) WriteSARIFWriter ¶ added in v0.9.0
func (w *Writer) WriteSARIFWriter(result aggregator.ReviewResult, dst io.Writer) error
WriteSARIFWriter serializes the review result as SARIF to an arbitrary io.Writer. Used when --format sarif is requested without an explicit -o directory (stdout).
type WriterConfig ¶
type WriterConfig struct {
Format string // "pretty", "compact", "json"
Lang string // "pt-BR" for Brazilian Portuguese
Version string // application version for SARIF reports
ExplainScores bool // show detailed score decomposition
}
WriterConfig configures output behavior.
func (WriterConfig) IsBR ¶
func (c WriterConfig) IsBR() bool
IsBR returns true if output should be in Brazilian Portuguese.
func (WriterConfig) IsCompact ¶
func (c WriterConfig) IsCompact() bool
IsCompact returns true if format is compact.
func (WriterConfig) IsJSON ¶
func (c WriterConfig) IsJSON() bool
IsJSON returns true if format is json-only.