formatters

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVFormatter

type CSVFormatter struct{}

CSVFormatter formats scan results as CSV output.

func NewCSVFormatter

func NewCSVFormatter() *CSVFormatter

NewCSVFormatter creates a new CSVFormatter instance.

func (*CSVFormatter) FileExtension

func (f *CSVFormatter) FileExtension() string

FileExtension returns "csv" for CSV formatted output.

func (*CSVFormatter) Format

func (f *CSVFormatter) Format(results []types.ScanResult) (string, error)

Format converts scan results to CSV for spreadsheet import and analysis.

func (*CSVFormatter) FormatWithSummary

func (f *CSVFormatter) FormatWithSummary(results []types.ScanResult, summary types.ScanSummary) (string, error)

FormatWithSummary formats CSV with summary info as header comment rows.

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter formats scan results as JSON output.

func NewJSONFormatter

func NewJSONFormatter() *JSONFormatter

NewJSONFormatter creates a new JSONFormatter instance.

func (*JSONFormatter) FileExtension

func (f *JSONFormatter) FileExtension() string

FileExtension returns "json" for JSON formatted output.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(results []types.ScanResult) (string, error)

Format converts scan results to compact JSON for SIEM and machine consumption.

func (*JSONFormatter) FormatWithSummary

func (f *JSONFormatter) FormatWithSummary(results []types.ScanResult, summary types.ScanSummary) (string, error)

FormatWithSummary wraps JSON results in a metadata envelope.

type OutputFormatter

type OutputFormatter interface {
	// Format takes scan results and returns formatted output string.
	// Returns an error if formatting fails.
	Format(results []types.ScanResult) (string, error)

	// FormatWithSummary formats scan results with an accompanying scan summary.
	// For JSON/YAML, wraps results in a metadata envelope.
	// For CSV/Table/Text, appends summary after the data.
	FormatWithSummary(results []types.ScanResult, summary types.ScanSummary) (string, error)

	// FileExtension returns the file extension for this format (e.g., "json", "yaml", "txt").
	FileExtension() string
}

OutputFormatter defines the interface for all output formatters. Implementations of this interface can format scan results into various output formats such as JSON, YAML, CSV, or table formats.

type TableFormatter

type TableFormatter struct{}

TableFormatter formats scan results as ASCII tables for terminal display.

func NewTableFormatter

func NewTableFormatter() *TableFormatter

NewTableFormatter creates a new TableFormatter instance.

func (*TableFormatter) FileExtension

func (f *TableFormatter) FileExtension() string

FileExtension returns "txt" for table formatted output.

func (*TableFormatter) Format

func (f *TableFormatter) Format(results []types.ScanResult) (string, error)

Format converts scan results to an ASCII table string.

func (*TableFormatter) FormatWithSummary

func (f *TableFormatter) FormatWithSummary(results []types.ScanResult, summary types.ScanSummary) (string, error)

FormatWithSummary formats results as a table with a summary section appended.

type TextFormatter

type TextFormatter struct{}

TextFormatter formats scan results as colorized text output, replicating the existing terminal output produced by utils.PrintResult().

func NewTextFormatter

func NewTextFormatter() *TextFormatter

NewTextFormatter creates a new TextFormatter instance.

func (*TextFormatter) FileExtension

func (f *TextFormatter) FileExtension() string

FileExtension returns "txt" for text formatted output.

func (*TextFormatter) Format

func (f *TextFormatter) Format(results []types.ScanResult) (string, error)

Format converts scan results to colorized text output. Each result is formatted as: [ServiceName] [MethodName] [severity] ResourceType: ResourceName

func (*TextFormatter) FormatWithSummary

func (f *TextFormatter) FormatWithSummary(results []types.ScanResult, summary types.ScanSummary) (string, error)

FormatWithSummary formats results as text with a summary section appended.

type YAMLFormatter

type YAMLFormatter struct{}

YAMLFormatter formats scan results as YAML output.

func NewYAMLFormatter

func NewYAMLFormatter() *YAMLFormatter

NewYAMLFormatter creates a new YAMLFormatter instance.

func (*YAMLFormatter) FileExtension

func (f *YAMLFormatter) FileExtension() string

FileExtension returns "yaml" for YAML formatted output.

func (*YAMLFormatter) Format

func (f *YAMLFormatter) Format(results []types.ScanResult) (string, error)

Format converts scan results to YAML for human-readable structured output.

func (*YAMLFormatter) FormatWithSummary

func (f *YAMLFormatter) FormatWithSummary(results []types.ScanResult, summary types.ScanSummary) (string, error)

FormatWithSummary wraps YAML results in a metadata envelope.

Jump to

Keyboard shortcuts

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