scainternal

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scainternal holds helpers shared by `krci sca` verbs (validation, enum sets, Dependency-Track error hint, table cells, paging footer).

Index

Constants

View Source
const (
	SeverityCritical   = "CRITICAL"
	SeverityHigh       = "HIGH"
	SeverityMedium     = "MEDIUM"
	SeverityLow        = "LOW"
	SeverityInfo       = "INFO"
	SeverityUnassigned = "UNASSIGNED"
)

Canonical Dep-Track severity values.

View Source
const BranchFlagUsage = "branch name (maps to the Dep-Track project 'version' field). " +
	"Defaults to the project's spec.defaultBranch. " +
	"Run 'krci sca list --search=<project>' to discover all recorded versions."

BranchFlagUsage is the verbatim help text for `--branch` across every per-codebase sca verb. Spec Requirement "Codebase + Branch Addressing" mandates this exact string so users always see the same Dep-Track `version` field explanation.

View Source
const EmptyPlaceholder = "—"

EmptyPlaceholder is the em-dash shown in sca table cells for a missing value.

View Source
const FindingsServerCap = 1000

FindingsServerCap is the maximum number of rows the portal returns from the unpaginated `sca findings` endpoint. Mirrors the server-side ceiling documented in the OpenAPI spec; the help text and truncation footer must stay in sync with it.

View Source
const MaxPageSize = 500

MaxPageSize is the upper bound on `--page-size` for every paginated sca verb. Matches the OpenAPI ceiling.

View Source
const SeverityFlagUsage = "minimum severity to include (inclusive). " +
	"One of: critical, high, medium, low, info. Case-insensitive. " +
	"'high' returns high+critical; 'medium' returns medium+high+critical; etc. " +
	"INFO includes UNASSIGNED."

SeverityFlagUsage is the verbatim help text for `--severity` across the verbs that expose it. Spec design §D4 mandates this exact string: it enumerates the allowed values and explains the inclusive semantics.

Variables

This section is empty.

Functions

func BoolYesNo

func BoolYesNo(b bool) string

BoolYesNo renders a bool as the lowercase "yes" / "no" used by every sca table column.

func ExpandSeverityFlag

func ExpandSeverityFlag(raw []string) []string

ExpandSeverityFlag is the composite helper for run functions: it validates the raw `--severity` flag values (silently ignoring the error — callers are expected to run ValidateSeverityCSV in RunE first) and returns the inclusive "min and above" expansion. nil input returns nil so the caller can skip filtering without a branch on slice length.

func FormatRisk

func FormatRisk(r float32) string

FormatRisk renders a Dep-Track risk score, using EmptyPlaceholder for zero.

func FormatVulnCounts

func FormatVulnCounts(m *portal.SCAMetrics) output.Cell

FormatVulnCounts renders the C/H/M/L vulnerability counts column. The styled form is yellow when critical+high > 0.

func HandleError

func HandleError(ios *iostreams.IOStreams, outputFormat string, err error) error

HandleError is render.HandleError with portal.ErrUpstreamUnavailable prefixed by the Dependency-Track hint.

func InclusiveFromSet

func InclusiveFromSet(set []string) []string

InclusiveFromSet returns the inclusive severity set derived from an already-validated `--severity` value list. When several thresholds are supplied, it takes the least-severe one ("medium" when "critical,medium" is supplied) so the expansion pulls everything at or above medium — matching the intent of "include all of these severities plus higher ones".

func InclusiveSeverities

func InclusiveSeverities(min string) []string

InclusiveSeverities returns the severities that should be included when the user supplies `--severity=<min>`. The return set is "min and above": e.g. `HIGH` → `{CRITICAL, HIGH}`; `INFO` → `{CRITICAL, HIGH, MEDIUM, LOW, INFO, UNASSIGNED}`. An unknown min returns nil so callers can treat that as "no filter" (already validated upstream).

severityOrder is in descending severity (CRITICAL first); we walk from the start through `min` inclusive.

func OrDash

func OrDash(s string) string

OrDash returns s when non-empty, otherwise EmptyPlaceholder. sca cells use this, not output.OrDash, which returns output.EmptyCell.

func PageFooter(noun string, total, pageIndex, pageSize int) string

PageFooter formats the paging summary printed below a paginated sca table.

func SeverityColor added in v0.20.0

func SeverityColor(severity string) output.Cell

SeverityColor colors a Dep-Track vulnerability severity, matched case-insensitively. An unknown severity is made printable on one row and left unstyled.

func ValidateCodebaseCommand

func ValidateCodebaseCommand(cmd *cobra.Command, outputFormat, codebase, branch string) error

ValidateCodebaseCommand validates a per-codebase sca verb's inputs in order: output format, Kubernetes-name codebase, non-empty --branch when supplied. sca verbs take no --pr, so there is no scope-mutex step.

func ValidateNonEmptyFlag

func ValidateNonEmptyFlag(name string, changed bool, value string) error

ValidateNonEmptyFlag rejects a flag that was explicitly supplied with an empty value. changed is true when the flag was set on the command line.

func ValidatePageBounds

func ValidatePageBounds(page, pageSize int) error

ValidatePageBounds rejects out-of-range --page / --page-size values. Shared between every paginated sca verb so the ceiling is enforced uniformly.

func ValidateSeverityCSV

func ValidateSeverityCSV(values []string) ([]string, error)

ValidateSeverityCSV canonicalises the comma-separated / repeatable values in values to upper-case Dep-Track severities. Empty input returns nil. An unknown value returns an error listing the accepted values.

The function returns validated values in input order with duplicates collapsed — this makes the test expectations stable.

Types

This section is empty.

Directories

Path Synopsis
Package scatestutil holds helpers shared by the krci sca verb tests.
Package scatestutil holds helpers shared by the krci sca verb tests.

Jump to

Keyboard shortcuts

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