common

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package common provides common types and interfaces for the reporting system

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = NewFormatterRegistry()

DefaultRegistry is the default formatter registry

Functions

func RegisterFormatter

func RegisterFormatter(format ReportFormat, creator FormatterCreator)

RegisterFormatter registers a formatter creator in the default registry

Types

type FormatterCreator

type FormatterCreator func(options map[string]interface{}) (ReportFormatter, error)

FormatterCreator is a function that creates a formatter with the given options

func GetFormatterCreator

func GetFormatterCreator(format ReportFormat) (FormatterCreator, bool)

GetFormatterCreator returns a formatter creator from the default registry

func GetFormatterCreatorFromDefault

func GetFormatterCreatorFromDefault(format ReportFormat) (FormatterCreator, bool)

GetFormatterCreatorFromDefault returns a formatter creator from the default registry for a specific format, or returns an error if not found

type FormatterFactory

type FormatterFactory struct {
	// contains filtered or unexported fields
}

FormatterFactory is a factory for creating formatters

func NewFormatterFactory

func NewFormatterFactory() *FormatterFactory

NewFormatterFactory creates a new formatter factory

func (*FormatterFactory) CreateFormatter

func (f *FormatterFactory) CreateFormatter(format ReportFormat, options map[string]interface{}) (ReportFormatter, error)

CreateFormatter creates a formatter for a specific format

func (*FormatterFactory) GetFormatterCreator

func (f *FormatterFactory) GetFormatterCreator(format ReportFormat) (FormatterCreator, bool)

GetFormatterCreator returns a formatter creator for a specific format

func (*FormatterFactory) ListFormats

func (f *FormatterFactory) ListFormats() []ReportFormat

ListFormats returns a list of supported formats

func (*FormatterFactory) RegisterFormatter

func (f *FormatterFactory) RegisterFormatter(format ReportFormat, creator FormatterCreator)

RegisterFormatter registers a formatter creator for a specific format

type FormatterRegistry

type FormatterRegistry struct {
	// contains filtered or unexported fields
}

FormatterRegistry is a registry for formatter creators

func NewFormatterRegistry

func NewFormatterRegistry() *FormatterRegistry

NewFormatterRegistry creates a new formatter registry

func (*FormatterRegistry) CreateFormatter

func (r *FormatterRegistry) CreateFormatter(format ReportFormat, options map[string]interface{}) (ReportFormatter, error)

CreateFormatter creates a formatter for a specific format

func (*FormatterRegistry) GetFormatterCreator

func (r *FormatterRegistry) GetFormatterCreator(format ReportFormat) (FormatterCreator, bool)

GetFormatterCreator returns a formatter creator for a specific format

func (*FormatterRegistry) ListFormats

func (r *FormatterRegistry) ListFormats() []ReportFormat

ListFormats returns a list of supported formats

func (*FormatterRegistry) RegisterFormatter

func (r *FormatterRegistry) RegisterFormatter(format ReportFormat, creator FormatterCreator)

RegisterFormatter registers a formatter creator for a specific format

type ReportFormat

type ReportFormat string

ReportFormat defines the format of a report

const (
	JSONFormat     ReportFormat = "json"
	JSONLFormat    ReportFormat = "jsonl"
	CSVFormat      ReportFormat = "csv"
	ExcelFormat    ReportFormat = "excel"
	TextFormat     ReportFormat = "text"
	MarkdownFormat ReportFormat = "markdown"
	PDFFormat      ReportFormat = "pdf"
	HTMLFormat     ReportFormat = "html"
)

Report formats

type ReportFormatter

type ReportFormatter interface {
	// GetFormat returns the format of the formatter
	GetFormat() ReportFormat
	// Format formats a report
	Format(ctx context.Context, report interface{}, options interface{}) ([]byte, error)
	// WriteToFile writes a report to a file
	WriteToFile(ctx context.Context, report interface{}, options interface{}, filePath string) error
}

ReportFormatter is the interface for report formatters

func CreateFormatter

func CreateFormatter(format ReportFormat, options map[string]interface{}) (ReportFormatter, error)

CreateFormatter creates a formatter using the default factory

type ReportGenerator

type ReportGenerator interface {
	// GenerateReport generates a report from test results
	GenerateReport(ctx context.Context, testSuites interface{}, options interface{}) (interface{}, error)
	// RegisterFormatter registers a formatter for a specific format
	RegisterFormatter(formatter ReportFormatter)
	// GetFormatter returns a formatter for a specific format
	GetFormatter(format ReportFormat) (ReportFormatter, bool)
	// ListFormats returns a list of supported formats
	ListFormats() []ReportFormat
}

ReportGenerator is the interface for report generators

type SeverityLevel

type SeverityLevel string

SeverityLevel defines the severity level of a test result

const (
	Critical SeverityLevel = "critical"
	High     SeverityLevel = "high"
	Medium   SeverityLevel = "medium"
	Low      SeverityLevel = "low"
	Info     SeverityLevel = "info"
)

Severity levels

type TestResult

type TestResult struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Severity    SeverityLevel          `json:"severity"`
	Category    string                 `json:"category"`
	Status      string                 `json:"status"`
	Details     string                 `json:"details,omitempty"`
	RawData     interface{}            `json:"raw_data,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

TestResult represents the result of a security test

type TestResults

type TestResults []*TestResult

TestResults is a collection of test results

Directories

Path Synopsis
Package common provides common types and interfaces for the reporting system
Package common provides common types and interfaces for the reporting system
Package common provides common types and interfaces for the reporting system
Package common provides common types and interfaces for the reporting system

Jump to

Keyboard shortcuts

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