Documentation
¶
Overview ¶
Package report - HTML format generator with rich visualization
Package report - JSON format generator ¶
Package report provides multiple output formats for vulnerability analysis results.
Design Pattern: Strategy Pattern Each report format is implemented as a separate Generator, allowing: 1. Easy addition of new formats without modifying existing code 2. Runtime selection of output format 3. Consistent interface across all formats
Supported Formats: - Table: Human-readable CLI output with colors - JSON: Machine-readable structured output - HTML: Rich visual report with charts and styling
Package report - Table format generator for CLI output
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator interface {
// Generate produces a report from the consensus result.
Generate(result *models.ConsensusResult, w io.Writer) error
// Format returns the format name (e.g., "table", "json", "html").
Format() string
}
Generator defines the interface for report generators.
type HTMLGenerator ¶
type HTMLGenerator struct {
// contains filtered or unexported fields
}
HTMLGenerator produces rich HTML reports with styling and charts.
func NewHTMLGenerator ¶
func NewHTMLGenerator() *HTMLGenerator
NewHTMLGenerator creates a new HTML generator.
func NewHTMLGeneratorWithTemplate ¶
func NewHTMLGeneratorWithTemplate(templatePath string) *HTMLGenerator
NewHTMLGeneratorWithTemplate creates an HTML generator with a custom template.
func (*HTMLGenerator) Format ¶
func (h *HTMLGenerator) Format() string
Format returns the generator format name.
func (*HTMLGenerator) Generate ¶
func (h *HTMLGenerator) Generate(result *models.ConsensusResult, w io.Writer) error
Generate produces an HTML report.
type HTMLReportData ¶
type HTMLReportData struct {
Title string
Target string
Scanners []string
AnalysisTime string
TotalDuration string
TotalVulnerabilities int
ConsensusCount int
UniqueCount int
OverlapPercentage string
SuccessfulScanners int
TotalScanners int
// Severity counts
CriticalCount int
HighCount int
MediumCount int
LowCount int
UnknownCount int
// Consensus severity counts
ConsensusCritical int
ConsensusHigh int
ConsensusMedium int
ConsensusLow int
// Vulnerability lists
ConsensusVulns []HTMLVulnerability
UniqueFindings map[string][]HTMLVulnerability
AllVulns []HTMLVulnerability
// Scanner results
ScannerResults []HTMLScannerResult
}
HTMLReportData contains all data needed for the HTML template.
type HTMLScannerResult ¶
type HTMLScannerResult struct {
Name string
Success bool
StatusClass string
Error string
VulnCount int
Duration string
}
HTMLScannerResult is a scanner result formatted for HTML display.
type HTMLVulnerability ¶
type HTMLVulnerability struct {
CVE string
Package string
InstalledVersion string
FixedVersion string
Severity string
SeverityClass string
Title string
Description string
References []string
}
HTMLVulnerability is a vulnerability formatted for HTML display.
type JSONGenerator ¶
type JSONGenerator struct {
// contains filtered or unexported fields
}
JSONGenerator produces machine-readable JSON output.
func NewJSONGenerator ¶
func NewJSONGenerator() *JSONGenerator
NewJSONGenerator creates a new JSON generator with pretty printing enabled.
func NewJSONGeneratorWithOptions ¶
func NewJSONGeneratorWithOptions(prettyPrint bool) *JSONGenerator
NewJSONGeneratorWithOptions creates a JSON generator with custom options.
func (*JSONGenerator) Format ¶
func (j *JSONGenerator) Format() string
Format returns the generator format name.
func (*JSONGenerator) Generate ¶
func (j *JSONGenerator) Generate(result *models.ConsensusResult, w io.Writer) error
Generate produces a JSON report.
type JSONReport ¶
type JSONReport struct {
// Metadata about the report
Metadata ReportMetadata `json:"metadata"`
// Summary statistics
Summary ReportSummary `json:"summary"`
// Consensus vulnerabilities (found by all scanners)
Consensus []VulnerabilityEntry `json:"consensus"`
// Unique findings per scanner
UniqueFindings map[string][]VulnerabilityEntry `json:"unique_findings"`
// All vulnerabilities combined
AllVulnerabilities []VulnerabilityEntry `json:"all_vulnerabilities"`
// Scanner results and status
ScannerResults []ScannerResultEntry `json:"scanner_results"`
// Severity distribution
SeverityDistribution SeverityStats `json:"severity_distribution"`
}
JSONReport is the structure of the JSON output.
type MultiGenerator ¶
type MultiGenerator struct {
// contains filtered or unexported fields
}
MultiGenerator generates reports in multiple formats.
func NewMultiGenerator ¶
func NewMultiGenerator(registry *Registry) *MultiGenerator
NewMultiGenerator creates a generator that can output multiple formats.
func (*MultiGenerator) Generate ¶
func (m *MultiGenerator) Generate(result *models.ConsensusResult, formats []string, writers map[string]io.Writer) error
Generate produces reports in the specified formats.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds available report generators.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry creates a registry with all built-in generators.
type ReportMetadata ¶
type ReportMetadata struct {
Target string `json:"target"`
Scanners []string `json:"scanners"`
AnalysisTime time.Time `json:"analysis_time"`
TotalDuration string `json:"total_duration"`
Version string `json:"csvsa_version"`
}
ReportMetadata contains metadata about the analysis.
type ReportSummary ¶
type ReportSummary struct {
TotalVulnerabilities int `json:"total_vulnerabilities"`
ConsensusCount int `json:"consensus_count"`
UniqueCount int `json:"unique_count"`
OverlapPercentage float64 `json:"overlap_percentage"`
SuccessfulScanners int `json:"successful_scanners"`
TotalScanners int `json:"total_scanners"`
}
ReportSummary contains summary statistics.
type ScannerResultEntry ¶
type ScannerResultEntry struct {
Name string `json:"name"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
VulnerabilityCount int `json:"vulnerability_count"`
Duration string `json:"duration"`
}
ScannerResultEntry represents a scanner's result status.
type SeverityStats ¶
type SeverityStats struct {
Critical int `json:"critical"`
High int `json:"high"`
Medium int `json:"medium"`
Low int `json:"low"`
Unknown int `json:"unknown"`
}
SeverityStats contains severity distribution data.
type TableGenerator ¶
type TableGenerator struct {
// contains filtered or unexported fields
}
TableGenerator produces human-readable CLI table output.
func NewTableGenerator ¶
func NewTableGenerator() *TableGenerator
NewTableGenerator creates a new table generator.
func NewTableGeneratorWithOptions ¶
func NewTableGeneratorWithOptions(colorEnabled bool) *TableGenerator
NewTableGeneratorWithOptions creates a table generator with custom options.
func (*TableGenerator) Format ¶
func (t *TableGenerator) Format() string
Format returns the generator format name.
func (*TableGenerator) Generate ¶
func (t *TableGenerator) Generate(result *models.ConsensusResult, w io.Writer) error
Generate produces a CLI table report.
type VulnerabilityEntry ¶
type VulnerabilityEntry struct {
CVE string `json:"cve"`
Package string `json:"package"`
InstalledVersion string `json:"installed_version"`
FixedVersion string `json:"fixed_version,omitempty"`
Severity string `json:"severity"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
References []string `json:"references,omitempty"`
Scanners []string `json:"scanners,omitempty"`
}
VulnerabilityEntry represents a vulnerability in the JSON output.