Documentation
¶
Index ¶
- Constants
- Variables
- func Banner(w io.Writer, info BannerInfo, color bool)
- func CIHeader(w io.Writer)
- func ContextBlock(w io.Writer, kv []KV)
- func Dimmed(text string, color bool) string
- func FindingsSummaryLine(total, critical, warning, info, filesScanned int, color bool) string
- func IsCI() bool
- func IsGitLabCI() bool
- func LintTable(w io.Writer, stats []lint.ModuleStats, _ bool)
- func PhaseResult(w io.Writer, name, status, detail string, elapsed time.Duration)
- func RowStatus(sec *Section, label, detail, status string, color bool)
- func ScanAuditRows(sec *Section, audit ScanAudit)
- func SectionApplied(sec *Section, header string, updates []AppliedDep, color bool)
- func SectionCVEs(sec *Section, cves []CVEFixed, color bool)
- func SectionEnd(w io.Writer, id string)
- func SectionFindings(sec *Section, findings []lint.Finding, color bool)
- func SectionSkipped(sec *Section, header string, groups []SkippedGroup, color bool)
- func SectionSkippedItemized(sec *Section, header string, groups []SkippedItemGroup, color bool)
- func SectionStart(w io.Writer, id, name string)
- func SectionStartCollapsed(w io.Writer, id, name string)
- func SectionVulns(sec *Section, vulns []VulnRow, color bool, budget int, ux SecurityUX)
- func StatusIcon(status string, color bool) string
- func SummaryRow(w io.Writer, name, status, detail string, color bool)
- func SummaryTotal(w io.Writer, elapsed time.Duration, status string, color bool)
- func UseColor() bool
- func VulnSeverityTag(severity string, color bool) string
- func VulnURL(id string) string
- func WriteLintJUnit(dir string, findings []lint.Finding, files []lint.FileInfo, modules []string, ...) error
- type AppliedDep
- type BannerInfo
- type CVEFixed
- type JUnitFailure
- type JUnitTestCase
- type JUnitTestSuite
- type JUnitTestSuites
- type KV
- type Printer
- type ScanAudit
- type Section
- type SecurityUX
- type SkippedGroup
- type SkippedItem
- type SkippedItemGroup
- type VulnRow
Constants ¶
const ( MaxApplied = 20 MaxCVEs = 12 MaxSkippedPerGroup = 5 )
const ( SoftBudget = 15 HardBudget = 30 AbsoluteMax = 200 OverwhelmThreshold = 1000 DefaultOverwhelmLink = "https://www.psychologytoday.com/us/basics/anxiety" )
const BannerArtANSI = ""
BannerArtANSI is empty unless built with -tags banner_art. The generated constant lives in banner_art_gen.go (gitignored).
Variables ¶
var DefaultOverwhelmMessage = []string{"…maybe start here:"}
Functions ¶
func Banner ¶
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 ContextBlock ¶
ContextBlock prints the pipeline context header. Replaces the old CIHeader with an aligned key-value layout.
func FindingsSummaryLine ¶
FindingsSummaryLine returns a one-line findings summary, optionally colored.
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 ¶
PhaseResult prints a compact single-line phase summary.
func ScanAuditRows ¶
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 ¶
SectionCVEs renders the "CVEs Fixed (N)" table (truncates at MaxCVEs).
func SectionEnd ¶
func SectionFindings ¶
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 SectionStartCollapsed ¶
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 ¶
StatusIcon returns a colored status icon.
func SummaryRow ¶
SummaryRow writes a summary line with status icon.
func SummaryTotal ¶
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 ¶
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 ¶
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 ¶
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 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 Printer ¶
Printer formats and writes lint findings.
func NewPrinter ¶
func NewPrinter() *Printer
NewPrinter creates a printer writing to stdout with color auto-detection.
type Section ¶
type Section struct {
// contains filtered or unexported fields
}
Section renders a box-drawing framed output section.
func NewSection ¶
NewSection creates a section and writes its header. If elapsed is non-zero, it appears right-aligned in the header.
type SecurityUX ¶
SecurityUX controls the >OverwhelmThreshold message/link. Caller is responsible for defaulting and env override behavior.
type SkippedGroup ¶
SkippedGroup is a pre-aggregated skip summary entry.
type SkippedItem ¶ added in v0.3.2
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.