Documentation
¶
Index ¶
- Constants
- func IsTerminal() bool
- func Render(entries []*Entry, layout []LayoutLine, totalResults, shownResults int) string
- func RenderDetailed(entry *Entry, colors *ColorConfig) string
- func RenderWithColors(entries []*Entry, layout []LayoutLine, totalResults, shownResults int, ...) string
- type ColorConfig
- func (c *ColorConfig) ColorAgeUrgency(ageInDays int) string
- func (c *ColorConfig) ColorArrow(arrow string) string
- func (c *ColorConfig) ColorBoolean(checkmark string) string
- func (c *ColorConfig) ColorCVEID(cveID string) string
- func (c *ColorConfig) ColorCVSSScore(score float64) string
- func (c *ColorConfig) ColorEPSSScore(score float64) string
- func (c *ColorConfig) ColorExploitAvailability(available bool, pocCount int, kevStatus bool) string
- func (c *ColorConfig) ColorExposure(exposure string) string
- func (c *ColorConfig) ColorFooter(footer string) string
- func (c *ColorConfig) ColorKEVStatus(isKEV bool) string
- func (c *ColorConfig) ColorLabel(label string) string
- func (c *ColorConfig) ColorMetric(metric string) string
- func (c *ColorConfig) ColorNumber(number string) string
- func (c *ColorConfig) ColorResultSeparator(separator string) string
- func (c *ColorConfig) ColorSeparator(separator string) string
- func (c *ColorConfig) ColorSeverity(severity string) string
- func (c *ColorConfig) ColorTag(tag string) string
- func (c *ColorConfig) ColorTitle(title string) string
- func (c *ColorConfig) ColorValue(value string) string
- func (c *ColorConfig) Colorize(text, color string) string
- func (c *ColorConfig) ColorizeFormattedLine(line string, lineNum int) string
- type Entry
- type LayoutLine
Examples ¶
Constants ¶
const ( Reset = "\033[0m" Bold = "\033[1m" Dim = "\033[2m" // Colors Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Magenta = "\033[35m" Cyan = "\033[36m" White = "\033[37m" Gray = "\033[90m" // Bright colors BrightRed = "\033[91m" BrightGreen = "\033[92m" BrightYellow = "\033[93m" BrightBlue = "\033[94m" BrightMagenta = "\033[95m" BrightCyan = "\033[96m" BrightWhite = "\033[97m" )
Color constants for ANSI escape codes
Variables ¶
This section is empty.
Functions ¶
func Render ¶
func Render(entries []*Entry, layout []LayoutLine, totalResults, shownResults int) string
Render generates formatted output for vulnerability entries using the provided layout
Example ¶
// Define layout configuration
layoutJSON := `[
{
"line": 1,
"format": "[{doc_id}] {severity} - {title}",
"omit_if": []
},
{
"line": 2,
"format": "↳ Template Authors: {authors} | Vuln Age: {age_in_days}d | EPSS: {epss_score} | CVSS: {cvss_score}",
"omit_if": ["authors.length == 0", "epss_score == 0", "cvss_score == 0"]
},
{
"line": 3,
"format": "↳ Exposure: {exposure} | Vendors: {vendors} | Products: {products}",
"omit_if": ["exposure == 0", "vendors.length == 0", "products.length == 0"]
},
{
"line": 4,
"format": "↳ Patch: {patch} | POCs: {poc_count} | KEV: {kev_enhanced} | Nuclei Template: {template} | Exploit Seen: {exploit_seen} | HackerOne: {hackerone}",
"omit_if": []
},
{
"line": 5,
"format": "↳ Tags: {tags}",
"omit_if": ["tags.length == 0"]
}
]`
// Parse layout
layout, err := ParseLayout([]byte(layoutJSON))
if err != nil {
log.Fatal(err)
}
// Create sample vulnerability data
vuln := &cvemap.Vulnerability{
DocID: "CVE-2024-1234",
Name: "Example Vulnerability",
Severity: "critical",
Author: []string{"security-team", "researcher"},
AgeInDays: 30,
EpssScore: 0.85,
CvssScore: 9.1,
Exposure: &cvemap.VulnExposure{
MaxHosts: 15000,
},
AffectedProducts: []*cvemap.ProductInfo{
{Vendor: "example-corp", Product: "webapp"},
{Vendor: "example-corp", Product: "api-server"},
},
IsPatchAvailable: true,
PocCount: 2,
IsKev: true,
Kev: []*cvemap.KevInfo{
{Source: "cisa"},
{Source: "vulcheck"},
},
IsTemplate: false,
H1: &cvemap.H1Stats{Reports: 5},
Tags: []string{"rce", "auth-bypass"},
Description: "Critical vulnerability that has been exploited in the wild",
}
// Convert to Entry and render
entry := FromVulnerability(vuln)
entries := []*Entry{entry}
result := RenderWithColors(entries, layout, 1, 1, NoColorConfig())
fmt.Println(result)
Output: [CVE-2024-1234] Critical - Example Vulnerability ↳ Template Authors: security-team, researcher | Vuln Age: 30d | EPSS: 0.85 | CVSS: 9.1 ↳ Exposure: ~15.0K | Vendors: example-corp | Products: webapp, api-server ↳ Patch: ✔ | POCs: 2 | KEV: ✔ (CISA, VULCHECK) | Nuclei Template: ✘ | Exploit Seen: ✔ | HackerOne: ✔ ↳ Tags: rce, auth-bypass ↳ Showing 1 of 1 total results
func RenderDetailed ¶
func RenderDetailed(entry *Entry, colors *ColorConfig) string
RenderDetailed generates detailed formatted output for a single vulnerability
func RenderWithColors ¶
func RenderWithColors(entries []*Entry, layout []LayoutLine, totalResults, shownResults int, colors *ColorConfig) string
RenderWithColors generates formatted output with color support
Types ¶
type ColorConfig ¶
type ColorConfig struct {
Enabled bool
// CVE ID and severity
CveID string
Critical string
High string
Medium string
Low string
Unknown string
// Content elements
Title string
Arrow string
Label string
Value string
Separator string
// Status indicators
Success string
Warning string
Error string
Info string
// Numbers and metrics
Number string
Metric string
// Tags
Tag string
Footer string
}
ColorConfig holds color configuration
func DefaultColorConfig ¶
func DefaultColorConfig() *ColorConfig
DefaultColorConfig returns a default color configuration
func NoColorConfig ¶
func NoColorConfig() *ColorConfig
NoColorConfig returns a color configuration with no colors
func (*ColorConfig) ColorAgeUrgency ¶
func (c *ColorConfig) ColorAgeUrgency(ageInDays int) string
ColorAgeUrgency colors vulnerability age with urgency indicators
func (*ColorConfig) ColorArrow ¶
func (c *ColorConfig) ColorArrow(arrow string) string
ColorArrow colors the arrow symbol
func (*ColorConfig) ColorBoolean ¶
func (c *ColorConfig) ColorBoolean(checkmark string) string
ColorBoolean colors boolean checkmarks
func (*ColorConfig) ColorCVEID ¶
func (c *ColorConfig) ColorCVEID(cveID string) string
ColorCVEID colors CVE ID
func (*ColorConfig) ColorCVSSScore ¶
func (c *ColorConfig) ColorCVSSScore(score float64) string
ColorCVSSScore colors CVSS score with severity indicators
func (*ColorConfig) ColorEPSSScore ¶
func (c *ColorConfig) ColorEPSSScore(score float64) string
ColorEPSSScore colors EPSS score with probability indicators
func (*ColorConfig) ColorExploitAvailability ¶
func (c *ColorConfig) ColorExploitAvailability(available bool, pocCount int, kevStatus bool) string
ColorExploitAvailability colors exploit availability with urgency
func (*ColorConfig) ColorExposure ¶
func (c *ColorConfig) ColorExposure(exposure string) string
ColorExposure colors exposure values with appropriate colors
func (*ColorConfig) ColorFooter ¶
func (c *ColorConfig) ColorFooter(footer string) string
ColorFooter colors footer text
func (*ColorConfig) ColorKEVStatus ¶
func (c *ColorConfig) ColorKEVStatus(isKEV bool) string
ColorKEVStatus colors KEV status with high visibility
func (*ColorConfig) ColorLabel ¶
func (c *ColorConfig) ColorLabel(label string) string
ColorLabel colors field labels
func (*ColorConfig) ColorMetric ¶
func (c *ColorConfig) ColorMetric(metric string) string
ColorMetric colors metrics (CVSS, EPSS)
func (*ColorConfig) ColorNumber ¶
func (c *ColorConfig) ColorNumber(number string) string
ColorNumber colors numeric values
func (*ColorConfig) ColorResultSeparator ¶
func (c *ColorConfig) ColorResultSeparator(separator string) string
ColorResultSeparator colors the separator between results with special styling
func (*ColorConfig) ColorSeparator ¶
func (c *ColorConfig) ColorSeparator(separator string) string
ColorSeparator colors separators
func (*ColorConfig) ColorSeverity ¶
func (c *ColorConfig) ColorSeverity(severity string) string
ColorSeverity colors severity text based on severity level
func (*ColorConfig) ColorTag ¶
func (c *ColorConfig) ColorTag(tag string) string
ColorTag colors tags
func (*ColorConfig) ColorTitle ¶
func (c *ColorConfig) ColorTitle(title string) string
ColorTitle colors title
func (*ColorConfig) ColorValue ¶
func (c *ColorConfig) ColorValue(value string) string
ColorValue colors field values
func (*ColorConfig) Colorize ¶
func (c *ColorConfig) Colorize(text, color string) string
Colorize applies color to text if colors are enabled
func (*ColorConfig) ColorizeFormattedLine ¶
func (c *ColorConfig) ColorizeFormattedLine(line string, lineNum int) string
ColorizeFormattedLine applies colors to a formatted line
type Entry ¶
type Entry struct {
DocID string `json:"doc_id"`
Name string `json:"name"`
Severity string `json:"severity"`
Author []string `json:"author"`
AgeInDays int `json:"age_in_days"`
EpssScore float64 `json:"epss_score"`
CvssScore float64 `json:"cvss_score"`
Exposure *cvemap.VulnExposure `json:"exposure"`
AffectedProducts []*cvemap.ProductInfo `json:"affected_products"`
IsPatchAvailable bool `json:"is_patch_available"`
PocCount int `json:"poc_count"`
IsKev bool `json:"is_kev"`
Kev []*cvemap.KevInfo `json:"kev"`
IsTemplate bool `json:"is_template"`
H1 *cvemap.H1Stats `json:"h1"`
Tags []string `json:"tags"`
Pocs []*cvemap.POC `json:"pocs"`
Citations []*cvemap.Citation `json:"citations"`
Description string `json:"description"`
Impact string `json:"impact"`
Remediation string `json:"remediation"`
TemplateURI string `json:"template_uri"`
TemplateRaw string `json:"template_raw"`
}
Entry represents a vulnerability entry with all fields needed for rendering
func FromVulnerability ¶
func FromVulnerability(v *cvemap.Vulnerability) *Entry
FromVulnerability converts a cvemap.Vulnerability to an Entry
type LayoutLine ¶
type LayoutLine struct {
Line int `json:"line"`
Format string `json:"format"`
OmitIf []string `json:"omit_if"`
}
LayoutLine represents a single line in the layout configuration
func ParseLayout ¶
func ParseLayout(layoutJSON []byte) ([]LayoutLine, error)
ParseLayout parses layout JSON into LayoutLine structs