api

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package api provides common types and interfaces for the reporting system

Package api provides common types and interfaces for the reporting system

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = NewFormatterRegistry()

DefaultRegistry is the global formatter registry

View Source
var SeverityLevelMapping = map[string]SeverityLevel{
	"critical": Critical,
	"high":     High,
	"medium":   Medium,
	"low":      Low,
	"info":     Info,
}

SeverityLevelMapping maps string representations to SeverityLevel constants

Functions

func RegisterFormatter

func RegisterFormatter(format ReportFormat, creator FormatterCreator)

RegisterFormatter registers a formatter creator with the default registry

Types

type FormatterCreator

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

FormatterCreator is a function that creates a formatter

func GetFormatterCreator

func GetFormatterCreator(format ReportFormat) (FormatterCreator, bool)

GetFormatterCreator returns a formatter creator from the default registry

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 the specified format

func (*FormatterRegistry) GetFormatterCreator

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

GetFormatterCreator returns the formatter creator for a specific format

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 report
	GetFormat() ReportFormat
	// FormatReport formats a report and writes it to the given writer
	FormatReport(results TestResults, writer io.Writer) 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 registry

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

Jump to

Keyboard shortcuts

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