output

package
v0.1.5-beta Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IconCVE      = "🔍"
	IconMetadata = "📦"
	IconSandbox  = "🏗️"
	IconYARA     = "🎯"
	IconClamAV   = "🛡️"
	IconDoctor   = "🏥"
	IconConfig   = "⚙️"
	IconScan     = "🔎"
	IconAuto     = "🤖"
	IconReport   = "📊"
	IconSuccess  = "✅"
	IconError    = "❌"
	IconWarning  = "⚠️"
	IconInfo     = "ℹ️"
	IconArrow    = "→"
	IconBullet   = "•"
	IconCheck    = "✓"
	IconCross    = "✗"
)

Layer icons as emoji

View Source
const (
	PackageNameWidth = 25
	VersionWidth     = 15
	EcosystemWidth   = 12
	SeverityWidth    = 10
	LayerWidth       = 12
	ReasonWidth      = 40
)

Width calculations for table alignment

View Source
const SARIFSchemaURI = "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json"

SARIFSchemaURI is the JSON schema URI

View Source
const SARIFVersion = "2.1.0"

SARIFVersion is the SARIF specification version

Variables

View Source
var (
	// Header styles
	HeaderStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(colorPrimary).
				MarginBottom(1)

	SubheaderStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(colorSecondary).
					MarginTop(1).
					MarginBottom(1)

	// Severity badge styles
	CriticalStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(colorWhite).
					Background(colorCritical).
					Padding(0, 1)

	HighStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(colorWhite).
				Background(colorHigh).
				Padding(0, 1)

	MediumStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(colorWhite).
				Background(colorMedium).
				Padding(0, 1)

	LowStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(colorWhite).
				Background(colorLow).
				Padding(0, 1)

	CleanStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(colorWhite).
				Background(colorClean).
				Padding(0, 1)

	// Text styles
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(colorPrimary).
				MarginBottom(1)

	DescriptionStyle = lipgloss.NewStyle().
						Foreground(colorMuted).
						MarginBottom(1)

	SuccessTextStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(colorSuccess)

	ErrorTextStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(colorError)

	WarningTextStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(colorWarning)

	InfoTextStyle = lipgloss.NewStyle().
					Foreground(colorInfo)

	MutedTextStyle = lipgloss.NewStyle().
					Foreground(colorMuted)

	// Table styles
	TableHeaderStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(colorWhite).
						Background(colorPrimary).
						Padding(0, 1)

	TableCellStyle = lipgloss.NewStyle().
					Foreground(colorLight).
					Padding(0, 1)

	TableBorderStyle = lipgloss.NewStyle().
						Foreground(colorMuted)

	// Box/Panel styles
	BoxStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(colorPrimary).
				Padding(1, 2).
				Margin(1, 0)

	InfoBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(colorInfo).
					Padding(1, 2).
					Margin(1, 0)

	WarningBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(colorWarning).
					Padding(1, 2).
					Margin(1, 0)

	ErrorBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(colorError).
					Padding(1, 2).
					Margin(1, 0)

	SuccessBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(colorSuccess).
					Padding(1, 2).
					Margin(1, 0)

	// Progress bar styles
	ProgressBarStyle = lipgloss.NewStyle().
						Foreground(colorPrimary)

	ProgressFillStyle = lipgloss.NewStyle().
						Background(colorPrimary).
						Foreground(colorWhite)

	ProgressEmptyStyle = lipgloss.NewStyle().
						Background(colorMuted).
						Foreground(colorMuted)

	// Layer icon styles
	LayerIconStyle = lipgloss.NewStyle().
					Bold(true).
					Width(2)
)

Styles for different UI components

Functions

func GetLayerIcon

func GetLayerIcon(layer string) string

GetLayerIcon returns the appropriate icon for a scan layer

func GetSeverityColor

func GetSeverityColor(severity string) lipgloss.Color

GetSeverityColor returns the color for a severity level

func GetSeverityStyle

func GetSeverityStyle(severity string) lipgloss.Style

GetSeverityStyle returns the appropriate style for a severity level

func NoopProgressCallback

func NoopProgressCallback(pkg, version, layer string, completed, finding, hasError bool)

NoopProgressCallback is a callback that does nothing (for non-interactive mode)

func RenderSeverityBadge

func RenderSeverityBadge(severity string) string

RenderSeverityBadge renders a severity string as a styled badge

func WriteSARIFFile

func WriteSARIFFile(results []*scanner.ScanResult, filename string, version string) error

WriteSARIFFile writes SARIF output to a file

Types

type DoneMsg

type DoneMsg struct{}

DoneMsg signals the scan is complete

type Formatter

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

Formatter handles different output formats for scan results

func NewFormatter

func NewFormatter(format string, showClean, verbose bool) *Formatter

NewFormatter creates a new output formatter

func (*Formatter) Format

func (f *Formatter) Format(results []*scanner.ScanResult) (string, error)

Format formats scan results according to the configured format

func (*Formatter) FormatDoctor

func (f *Formatter) FormatDoctor(checks []HealthCheck) string

FormatDoctor formats health check results

func (*Formatter) FormatRisk

func (f *Formatter) FormatRisk(result *scanner.ScanResult, finding *scanner.Finding) string

FormatRisk formats a single risk finding for interactive mode

func (*Formatter) FormatStatus

func (f *Formatter) FormatStatus(status map[string]interface{}) string

FormatStatus formats system status information

func (*Formatter) FormatSummary

func (f *Formatter) FormatSummary(summary ScanSummary) string

FormatSummary formats a scan summary

type HealthCheck

type HealthCheck struct {
	Name       string
	Passed     bool
	Message    string
	Suggestion string
}

HealthCheck represents a health check result

type ProgressModel

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

ProgressModel is a Bubbletea model for displaying scan progress

func NewProgressModel

func NewProgressModel(totalPackages int) ProgressModel

NewProgressModel creates a new progress model

func (ProgressModel) Init

func (m ProgressModel) Init() tea.Cmd

Init initializes the progress model

func (ProgressModel) Update

func (m ProgressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (ProgressModel) View

func (m ProgressModel) View() string

View renders the progress UI

type ProgressMsg

type ProgressMsg struct {
	Package   string
	Version   string
	Layer     string
	Completed bool
	Finding   bool
	Error     bool
}

ProgressMsg updates the progress state

type ProgressState

type ProgressState struct {
	CurrentPackage string
	CurrentVersion string
	CurrentLayer   string
	TotalPackages  int
	Completed      int
	Findings       int
	Errors         int
	StartTime      time.Time
}

ProgressState represents the current state of a scan progress

type SARIFArtifactLocation

type SARIFArtifactLocation struct {
	URI string `json:"uri,omitempty"`
}

SARIFArtifactLocation represents the artifact location

type SARIFConfiguration

type SARIFConfiguration struct {
	Level string `json:"level,omitempty"`
}

SARIFConfiguration represents rule configuration

type SARIFDocument

type SARIFDocument struct {
	Version string     `json:"version"`
	Schema  string     `json:"$schema"`
	Runs    []SARIFRun `json:"runs"`
}

SARIFDocument represents the root SARIF document

type SARIFDriver

type SARIFDriver struct {
	Name           string      `json:"name"`
	Version        string      `json:"version"`
	InformationURI string      `json:"informationUri"`
	Rules          []SARIFRule `json:"rules,omitempty"`
}

SARIFDriver represents the tool driver

type SARIFFormatter

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

SARIFFormatter generates SARIF output

func NewSARIFFormatter

func NewSARIFFormatter(version string) *SARIFFormatter

NewSARIFFormatter creates a new SARIF formatter

func (*SARIFFormatter) Format

func (f *SARIFFormatter) Format(results []*scanner.ScanResult) (string, error)

Format converts scan results to SARIF format

type SARIFInvocation

type SARIFInvocation struct {
	ExecutionSuccessful bool      `json:"executionSuccessful"`
	StartTimeUTC        time.Time `json:"startTimeUtc,omitempty"`
	EndTimeUTC          time.Time `json:"endTimeUtc,omitempty"`
}

SARIFInvocation represents tool invocation details

type SARIFLocation

type SARIFLocation struct {
	PhysicalLocation SARIFPhysicalLocation `json:"physicalLocation,omitempty"`
}

SARIFLocation represents where a finding was found

type SARIFMessage

type SARIFMessage struct {
	Text     string `json:"text,omitempty"`
	Markdown string `json:"markdown,omitempty"`
}

SARIFMessage represents a text message

type SARIFPhysicalLocation

type SARIFPhysicalLocation struct {
	ArtifactLocation SARIFArtifactLocation `json:"artifactLocation,omitempty"`
	Region           *SARIFRegion          `json:"region,omitempty"`
}

SARIFPhysicalLocation represents the physical location

type SARIFRegion

type SARIFRegion struct {
	StartLine   int `json:"startLine,omitempty"`
	StartColumn int `json:"startColumn,omitempty"`
	EndLine     int `json:"endLine,omitempty"`
	EndColumn   int `json:"endColumn,omitempty"`
}

SARIFRegion represents a specific region in the artifact

type SARIFResult

type SARIFResult struct {
	RuleID     string                 `json:"ruleId"`
	Level      string                 `json:"level"`
	Message    SARIFMessage           `json:"message"`
	Locations  []SARIFLocation        `json:"locations,omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty"`
}

SARIFResult represents a single finding

type SARIFRule

type SARIFRule struct {
	ID                   string                 `json:"id"`
	Name                 string                 `json:"name,omitempty"`
	ShortDescription     SARIFMessage           `json:"shortDescription,omitempty"`
	FullDescription      SARIFMessage           `json:"fullDescription,omitempty"`
	DefaultConfiguration SARIFConfiguration     `json:"defaultConfiguration,omitempty"`
	Properties           map[string]interface{} `json:"properties,omitempty"`
}

SARIFRule represents a rule that was violated

type SARIFRun

type SARIFRun struct {
	Tool        SARIFTool         `json:"tool"`
	Results     []SARIFResult     `json:"results"`
	Invocations []SARIFInvocation `json:"invocations,omitempty"`
}

SARIFRun represents a single run of a tool

type SARIFTool

type SARIFTool struct {
	Driver SARIFDriver `json:"driver"`
}

SARIFTool represents the tool information

type ScanProgressCallback

type ScanProgressCallback func(pkg, version, layer string, completed, finding, hasError bool)

ScanProgressCallback is a function called during scanning to report progress

type ScanSummary

type ScanSummary struct {
	Total    int
	Clean    int
	Low      int
	Medium   int
	High     int
	Critical int
	Duration string
}

ScanSummary represents a summary of scan results

type SimpleProgressWriter

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

SimpleProgressWriter is a non-interactive progress writer for CI environments

func NewSimpleProgressWriter

func NewSimpleProgressWriter(w io.Writer, totalPackages int) *SimpleProgressWriter

NewSimpleProgressWriter creates a simple progress writer

func (*SimpleProgressWriter) Finish

func (p *SimpleProgressWriter) Finish()

Finish prints the final summary

func (*SimpleProgressWriter) Update

func (p *SimpleProgressWriter) Update(pkg, version, layer string, completed, finding, hasError bool)

Update updates the progress state and prints if needed

Jump to

Keyboard shortcuts

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