output

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxApplied         = 20
	MaxCVEs            = 12
	MaxSkippedPerGroup = 5
)
View Source
const (
	SoftBudget         = 15
	HardBudget         = 30
	AbsoluteMax        = 200
	OverwhelmThreshold = 1000

	DefaultOverwhelmLink = "https://www.psychologytoday.com/us/basics/anxiety"
)
View Source
const BannerArtANSI = ""

BannerArtANSI is empty unless built with -tags banner_art. The generated constant lives in banner_art_gen.go (gitignored).

Variables

View Source
var DefaultOverwhelmMessage = []string{"…maybe start here:"}

Functions

func Banner(w io.Writer, info BannerInfo, color bool)

Banner prints the StageFreight logo banner with version info. Two rendering paths:

  • Color + generated art: composited text (left) + ANSI art (right)
  • No-color or no art: text-only identity output

func CIHeader

func CIHeader(w io.Writer)

CIHeader prints a compact pipeline context block at the start of a CI run.

func ContextBlock

func ContextBlock(w io.Writer, kv []KV)

ContextBlock prints the pipeline context header. Replaces the old CIHeader with an aligned key-value layout.

func Dimmed

func Dimmed(text string, color bool) string

Dimmed returns dimmed text if color is enabled.

func FindingsSummaryLine

func FindingsSummaryLine(total, critical, warning, info, filesScanned int, color bool) string

FindingsSummaryLine returns a one-line findings summary, optionally colored.

func IsCI

func IsCI() bool

func IsGitLabCI

func IsGitLabCI() bool

func LintTable

func LintTable(w io.Writer, stats []lint.ModuleStats, _ bool)

LintTable writes a per-module stats table inside a section.

func PhaseResult

func PhaseResult(w io.Writer, name, status, detail string, elapsed time.Duration)

PhaseResult prints a compact single-line phase summary.

func RowStatus

func RowStatus(sec *Section, label, detail, status string, color bool)

RowStatus writes a row with label, detail, and a status icon.

func ScanAuditRows

func ScanAuditRows(sec *Section, audit ScanAudit)

ScanAuditRows renders the engine/OS audit lines (skips empty fields).

func SectionApplied

func SectionApplied(sec *Section, header string, updates []AppliedDep, color bool)

SectionApplied renders the "Applied (N)" or "Would update (N)" block.

func SectionCVEs

func SectionCVEs(sec *Section, cves []CVEFixed, color bool)

SectionCVEs renders the "CVEs Fixed (N)" table (truncates at MaxCVEs).

func SectionEnd

func SectionEnd(w io.Writer, id string)

func SectionFindings

func SectionFindings(sec *Section, findings []lint.Finding, color bool)

SectionFindings renders findings grouped by file inside a section. Files are sorted lexicographically; findings within each file by line, col, module, message.

func SectionSkipped

func SectionSkipped(sec *Section, header string, groups []SkippedGroup, color bool)

SectionSkipped renders the "Skipped (N)" or "Would skip (N)" block (pre-aggregated).

func SectionSkippedItemized added in v0.3.2

func SectionSkippedItemized(sec *Section, header string, groups []SkippedItemGroup, color bool)

SectionSkippedItemized renders the "Skipped (N)" block with per-item detail.

func SectionStart

func SectionStart(w io.Writer, id, name string)

func SectionStartCollapsed

func SectionStartCollapsed(w io.Writer, id, name string)

SectionStartCollapsed starts a section that is collapsed by default.

func SectionVulns

func SectionVulns(sec *Section, vulns []VulnRow, color bool, budget int, ux SecurityUX)

SectionVulns renders the "Vulnerabilities (N)" block with severity-prioritized truncation. budget: max rows to display (15 for detailed, 30 for full). CRITICAL and HIGH always shown regardless of budget (up to AbsoluteMax).

func StatusIcon

func StatusIcon(status string, color bool) string

StatusIcon returns a colored status icon.

func SummaryRow

func SummaryRow(w io.Writer, name, status, detail string, color bool)

SummaryRow writes a summary line with status icon.

func SummaryTotal

func SummaryTotal(w io.Writer, elapsed time.Duration, status string, color bool)

SummaryTotal writes the final total line.

func UseColor

func UseColor() bool

UseColor returns true if colored output should be used. Respects NO_COLOR env, TERM=dumb, and terminal detection.

func VulnSeverityTag

func VulnSeverityTag(severity string, color bool) string

VulnSeverityTag returns a short severity label, optionally colored. CRITICAL→"CRIT" red, HIGH→"HIGH" red, MEDIUM/MODERATE→"MOD " yellow, LOW→"LOW " gray, UNKNOWN/empty→"UNK " gray.

func VulnURL

func VulnURL(id string) string

VulnURL derives an advisory URL from a vulnerability ID. GHSA- → github.com/advisories, GO- → pkg.go.dev/vuln, default → osv.dev/vulnerability.

func WriteLintJUnit

func WriteLintJUnit(dir string, findings []lint.Finding, files []lint.FileInfo, modules []string, elapsed time.Duration) error

WriteLintJUnit writes lint findings as JUnit XML for GitLab test reporting. Each lint module becomes a test suite, each scanned file becomes a test case.

Types

type AppliedDep

type AppliedDep struct {
	Name       string
	OldVer     string
	NewVer     string
	UpdateType string   // "major", "minor", "patch", "tag"
	CVEsFixed  []string // IDs only
}

AppliedDep is the view model for a single applied update.

type BannerInfo

type BannerInfo struct {
	Version string
	SHA     string
	Branch  string
	Date    string
}

BannerInfo holds the identity fields displayed alongside the logo.

func NewBannerInfo

func NewBannerInfo(version, sha, branch string) BannerInfo

NewBannerInfo creates a BannerInfo with today's date. Version, SHA, and Branch should be populated from gitver.VersionInfo.

type CVEFixed

type CVEFixed struct {
	ID       string // "CVE-2024-45337", "GHSA-xxxx-yyyy-zzzz"
	Severity string // "LOW", "MODERATE", "HIGH", "CRITICAL"
	Summary  string
	FixedIn  string // "v0.37.0"
	FixedBy  string // "golang.org/x/crypto"
}

CVEFixed is the view model for a vulnerability resolved by an update.

type JUnitFailure

type JUnitFailure struct {
	Message string `xml:"message,attr"`
	Type    string `xml:"type,attr"`
	Body    string `xml:",chardata"`
}

type JUnitTestCase

type JUnitTestCase struct {
	Name      string        `xml:"name,attr"`
	Classname string        `xml:"classname,attr"`
	Time      string        `xml:"time,attr"`
	Failure   *JUnitFailure `xml:"failure,omitempty"`
}

type JUnitTestSuite

type JUnitTestSuite struct {
	Name     string          `xml:"name,attr"`
	Tests    int             `xml:"tests,attr"`
	Failures int             `xml:"failures,attr"`
	Time     string          `xml:"time,attr"`
	Cases    []JUnitTestCase `xml:"testcase"`
}

type JUnitTestSuites

type JUnitTestSuites struct {
	XMLName  xml.Name         `xml:"testsuites"`
	Name     string           `xml:"name,attr"`
	Tests    int              `xml:"tests,attr"`
	Failures int              `xml:"failures,attr"`
	Time     string           `xml:"time,attr"`
	Suites   []JUnitTestSuite `xml:"testsuite"`
}

type KV

type KV struct {
	Key   string
	Value string
}

KV is a key-value pair for the context block.

type Printer

type Printer struct {
	Writer io.Writer
	Color  bool
}

Printer formats and writes lint findings.

func NewPrinter

func NewPrinter() *Printer

NewPrinter creates a printer writing to stdout with color auto-detection.

func (*Printer) Print

func (p *Printer) Print(findings []lint.Finding) bool

Print outputs findings grouped by file, returns true if any critical findings exist.

func (*Printer) Summary

func (p *Printer) Summary(total, critical, warning, info int, filesScanned int)

Summary prints a final summary line.

type ScanAudit

type ScanAudit struct {
	Engine string // "Trivy 0.58.1"
	OS     string // "alpine 3.21.3"
}

ScanAudit holds metadata for the audit block at the top of the section.

type Section

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

Section renders a box-drawing framed output section.

func NewSection

func NewSection(w io.Writer, name string, elapsed time.Duration, color bool) *Section

NewSection creates a section and writes its header. If elapsed is non-zero, it appears right-aligned in the header.

func (*Section) Close

func (s *Section) Close()

Close writes the section footer.

func (*Section) Row

func (s *Section) Row(format string, args ...any)

Row writes a content line inside the section frame.

func (*Section) Separator

func (s *Section) Separator()

Separator writes a mid-section divider.

type SecurityUX

type SecurityUX struct {
	OverwhelmMessage []string
	OverwhelmLink    string
}

SecurityUX controls the >OverwhelmThreshold message/link. Caller is responsible for defaulting and env override behavior.

type SkippedGroup

type SkippedGroup struct {
	Reason string
	Count  int
}

SkippedGroup is a pre-aggregated skip summary entry.

type SkippedItem added in v0.3.2

type SkippedItem struct {
	Name      string
	Version   string
	Ecosystem string
}

SkippedItem is the view model for a single skipped dependency.

type SkippedItemGroup added in v0.3.2

type SkippedItemGroup struct {
	Reason string
	Count  int
	Items  []SkippedItem
}

SkippedItemGroup is a skip summary with itemized dependency details.

type VulnRow

type VulnRow struct {
	ID        string // "CVE-2024-45337", "GHSA-xxxx-yyyy"
	Severity  string // "CRITICAL", "HIGH", "MEDIUM", "LOW"
	Package   string // "golang.org/x/crypto"
	Installed string // "0.28.0"
	FixedIn   string // "0.31.0" (empty = no fix)
	Title     string // one-line description
}

VulnRow is the view model for a single vulnerability in CLI output.

Jump to

Keyboard shortcuts

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