cmd

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Color ColorOutput
	// UsePager enables pager for long output
	UsePager bool
)
View Source
var NewEnrichmentClient = enrichment.NewClient

NewEnrichmentClient is the constructor for the enrichment client. Tests can replace this to avoid external API calls.

Functions

func Bold

func Bold(text string) string

Bold returns text in bold

func BuildCommands added in v0.9.1

func BuildCommands(managerName, operation string, input managers.CommandInput) ([][]string, error)

BuildCommands builds package manager commands without executing them

func CleanupOutput added in v0.10.7

func CleanupOutput()

CleanupOutput tears down the pager if one is active

func Colorize

func Colorize(text, color string) string

Colorize wraps text with color codes if color is enabled

func Cyan

func Cyan(text string) string

Cyan returns text in cyan

func Dim

func Dim(text string) string

Dim returns text in dim/faded style

func Execute

func Execute() error

func GetPager

func GetPager() string

GetPager returns the pager command to use

func Green

func Green(text string) string

Green returns text in green

func IsColorEnabled

func IsColorEnabled() bool

IsColorEnabled returns true if color output should be used

precedence: - current command config `--color=always` / `--color=never` - `$NO_COLOR` https://no-color.org/ - `$FORCE_COLOR` https://force-color.org/ - `$TERM` / stdout detection

func IsPURL added in v0.14.0

func IsPURL(s string) bool

func NewRootCmd

func NewRootCmd() *cobra.Command

func ParsePackageArg added in v0.14.0

func ParsePackageArg(arg, ecosystemFlag string) (ecosystem, name, version string, err error)

func Red

func Red(text string) string

Red returns text in red

func RunManagerCommands added in v0.9.1

func RunManagerCommands(ctx context.Context, dir, managerName, operation string, input managers.CommandInput, stdout, stderr io.Writer) error

RunManagerCommands builds and executes multiple package manager commands (for chained operations)

func Sanitize added in v0.15.4

func Sanitize(s string) string

Sanitize strips control characters (other than tab and newline) from externally sourced strings before they reach a TTY, so registry changelogs, OSV records, manifest entries, and commit metadata can't inject ANSI/OSC escape sequences into the operator's terminal.

func SetupOutput added in v0.10.7

func SetupOutput(cmd *cobra.Command)

SetupOutput configures colour and pager for a command

func SetupPager

func SetupPager(cmd *cobra.Command) func()

SetupPager configures output to go through a pager if available

func Yellow

func Yellow(text string) string

Yellow returns text in yellow

Types

type ColorOutput added in v0.10.6

type ColorOutput int
const (
	Auto ColorOutput = iota
	Always
	Never
)

type ColumnSchema

type ColumnSchema struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Nullable bool   `json:"nullable"`
	PK       bool   `json:"pk,omitempty"`
}

type DeprecatedPackage added in v0.17.0

type DeprecatedPackage struct {
	Name         string `json:"name"`
	Ecosystem    string `json:"ecosystem"`
	Version      string `json:"version"`
	Status       string `json:"status"`
	Message      string `json:"message,omitempty"`
	ManifestPath string `json:"manifest_path"`
	PURL         string `json:"purl,omitempty"`
}

type DetectedManager added in v0.9.1

type DetectedManager struct {
	Name      string
	Ecosystem string
	Lockfile  string
}

DetectedManager holds info about a detected package manager

func DetectManagers added in v0.9.1

func DetectManagers(dir string) ([]DetectedManager, error)

DetectManagers finds all package managers in the given directory. For each ecosystem, checks lockfiles first (in priority order), then falls back to the default manager if only a manifest file exists.

func FilterByEcosystem added in v0.9.1

func FilterByEcosystem(detected []DetectedManager, ecosystem string) []DetectedManager

FilterByEcosystem filters detected managers to those matching the ecosystem

func PromptForManager added in v0.9.1

func PromptForManager(detected []DetectedManager, out io.Writer, in io.Reader) (*DetectedManager, error)

PromptForManager asks the user to select a package manager when multiple are detected. Returns the selected manager, or an error if not running interactively or user cancels.

type DiffEntry

type DiffEntry struct {
	Name            string `json:"name"`
	Ecosystem       string `json:"ecosystem,omitempty"`
	ManifestPath    string `json:"manifest_path"`
	DependencyType  string `json:"dependency_type,omitempty"`
	FromRequirement string `json:"from_requirement,omitempty"`
	ToRequirement   string `json:"to_requirement,omitempty"`
}

type DiffResult

type DiffResult struct {
	Added    []DiffEntry `json:"added,omitempty"`
	Modified []DiffEntry `json:"modified,omitempty"`
	Removed  []DiffEntry `json:"removed,omitempty"`
}

type DiffStat added in v0.17.0

type DiffStat struct {
	Added        int `json:"added"`
	Removed      int `json:"removed"`
	Updated      int `json:"updated"`
	MajorUpdates int `json:"major_updates"`
	MinorUpdates int `json:"minor_updates"`
	PatchUpdates int `json:"patch_updates"`
	OtherUpdates int `json:"other_updates"`
}

type EcosystemDetail added in v0.10.7

type EcosystemDetail struct {
	Name      string   `json:"name"`
	Manifest  string   `json:"manifest,omitempty"`
	Lockfiles []string `json:"lockfiles,omitempty"`
	Managers  []string `json:"managers,omitempty"`
	Registry  bool     `json:"registry"`
}

type ExposureSummary

type ExposureSummary struct {
	TotalVulnerabilities int            `json:"total_vulnerabilities"`
	TotalExposureDays    int            `json:"total_exposure_days"`
	AverageExposureDays  float64        `json:"average_exposure_days"`
	MaxExposureDays      int            `json:"max_exposure_days"`
	BySeverity           map[string]int `json:"by_severity"`
	OldestExposure       string         `json:"oldest_exposure,omitempty"`
}

type FreshnessEntry added in v0.17.0

type FreshnessEntry struct {
	Name               string `json:"name"`
	Ecosystem          string `json:"ecosystem"`
	CurrentVersion     string `json:"current_version"`
	LatestVersion      string `json:"latest_version"`
	DaysBehindLatest   int    `json:"days_behind_latest"`
	CurrentPublishedAt string `json:"current_published_at"`
	LatestPublishedAt  string `json:"latest_published_at"`
	ManifestPath       string `json:"manifest_path"`
	PURL               string `json:"purl,omitempty"`
}

type FreshnessResult added in v0.17.0

type FreshnessResult struct {
	Summary      FreshnessSummary `json:"summary"`
	Dependencies []FreshnessEntry `json:"dependencies"`
}

type FreshnessSummary added in v0.17.0

type FreshnessSummary struct {
	TotalDependencies          int `json:"total_dependencies"`
	MeasuredDependencies       int `json:"measured_dependencies"`
	LaggingDependencies        int `json:"lagging_dependencies"`
	AverageDaysBehindLatest    int `json:"average_days_behind_latest"`
	MaximumDaysBehindLatest    int `json:"maximum_days_behind_latest"`
	UnmeasuredDependencies     int `json:"unmeasured_dependencies"`
	UniquePackagesWithMetadata int `json:"unique_packages_with_metadata"`
}

type FundingEntry added in v0.17.0

type FundingEntry struct {
	Name         string   `json:"name"`
	Ecosystem    string   `json:"ecosystem"`
	Version      string   `json:"version,omitempty"`
	FundingLinks []string `json:"funding_links,omitempty"`
	ManifestPath string   `json:"manifest_path"`
	PURL         string   `json:"purl,omitempty"`
}

type FundingResult added in v0.17.0

type FundingResult struct {
	Summary      FundingSummary `json:"summary"`
	Dependencies []FundingEntry `json:"dependencies"`
}

type FundingSummary added in v0.17.0

type FundingSummary struct {
	TotalDependencies     int `json:"total_dependencies"`
	CheckedDependencies   int `json:"checked_dependencies"`
	WithFunding           int `json:"with_funding"`
	WithoutFunding        int `json:"without_funding"`
	UnresolvedPackageData int `json:"unresolved_package_data"`
}

type HealthEntry added in v0.17.0

type HealthEntry struct {
	Name                   string   `json:"name"`
	Ecosystem              string   `json:"ecosystem"`
	Version                string   `json:"version,omitempty"`
	Score                  int      `json:"score"`
	Risk                   string   `json:"risk"`
	MaintainerCount        int      `json:"maintainer_count"`
	Downloads              int      `json:"downloads"`
	DownloadsPeriod        string   `json:"downloads_period,omitempty"`
	DependentPackagesCount int      `json:"dependent_packages_count"`
	DependentReposCount    int      `json:"dependent_repos_count"`
	Signals                []string `json:"signals"`
	ManifestPath           string   `json:"manifest_path"`
	PURL                   string   `json:"purl,omitempty"`
}

type HealthResult added in v0.17.0

type HealthResult struct {
	Summary      HealthSummary `json:"summary"`
	Dependencies []HealthEntry `json:"dependencies"`
}

type HealthSummary added in v0.17.0

type HealthSummary struct {
	TotalDependencies     int `json:"total_dependencies"`
	CheckedDependencies   int `json:"checked_dependencies"`
	AtRiskDependencies    int `json:"at_risk_dependencies"`
	UnresolvedPackageData int `json:"unresolved_package_data"`
	AverageScore          int `json:"average_score"`
	DisplayedDependencies int `json:"displayed_dependencies"`
	HealthScoreThreshold  int `json:"health_score_threshold"`
}

type IntegrityDrift

type IntegrityDrift struct {
	Name      string            `json:"name"`
	Ecosystem string            `json:"ecosystem"`
	Version   string            `json:"version"`
	Hashes    map[string]string `json:"hashes"` // manifest_path -> integrity
}

type IntegrityEntry

type IntegrityEntry struct {
	Name             string   `json:"name"`
	Ecosystem        string   `json:"ecosystem"`
	Version          string   `json:"version"`
	Integrity        string   `json:"integrity"`
	ManifestPath     string   `json:"manifest_path"`
	HasDrift         bool     `json:"has_drift,omitempty"`
	OtherHashes      []string `json:"other_hashes,omitempty"`
	RegistryMismatch bool     `json:"registry_mismatch,omitempty"`
	RegistryHash     string   `json:"registry_hash,omitempty"`
}

type LicenseDriftEntry added in v0.17.0

type LicenseDriftEntry struct {
	Name           string `json:"name"`
	Ecosystem      string `json:"ecosystem"`
	CurrentVersion string `json:"current_version"`
	LatestVersion  string `json:"latest_version,omitempty"`
	CurrentLicense string `json:"current_license"`
	LatestLicense  string `json:"latest_license"`
	ManifestPath   string `json:"manifest_path"`
	PURL           string `json:"purl,omitempty"`
}

type LicenseDriftResult added in v0.17.0

type LicenseDriftResult struct {
	Summary      LicenseDriftSummary `json:"summary"`
	Dependencies []LicenseDriftEntry `json:"dependencies"`
}

type LicenseDriftSummary added in v0.17.0

type LicenseDriftSummary struct {
	TotalDependencies      int `json:"total_dependencies"`
	CheckedDependencies    int `json:"checked_dependencies"`
	DriftedDependencies    int `json:"drifted_dependencies"`
	UnresolvedDependencies int `json:"unresolved_dependencies"`
}

type LicenseInfo

type LicenseInfo struct {
	Name          string   `json:"name"`
	Ecosystem     string   `json:"ecosystem"`
	Version       string   `json:"version,omitempty"`
	Licenses      []string `json:"licenses"`
	LicenseText   string   `json:"license_text,omitempty"`
	ManifestPath  string   `json:"manifest_path"`
	PURL          string   `json:"purl,omitempty"`
	LicenseSource string   `json:"license_source,omitempty"`
	Flagged       bool     `json:"flagged,omitempty"`
	FlagReason    string   `json:"flag_reason,omitempty"`
}

type MaintainerInfo added in v0.17.0

type MaintainerInfo struct {
	Login string `json:"login,omitempty"`
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
	URL   string `json:"url,omitempty"`
	Role  string `json:"role,omitempty"`
}

type MaintainersEntry added in v0.17.0

type MaintainersEntry struct {
	Name             string           `json:"name"`
	Ecosystem        string           `json:"ecosystem"`
	Version          string           `json:"version,omitempty"`
	ManifestPath     string           `json:"manifest_path"`
	PURL             string           `json:"purl,omitempty"`
	MaintainerCount  int              `json:"maintainer_count"`
	SingleMaintainer bool             `json:"single_maintainer"`
	Maintainers      []MaintainerInfo `json:"maintainers"`
	Error            string           `json:"error,omitempty"`
}

type MaintainersResult added in v0.17.0

type MaintainersResult struct {
	Summary      MaintainersSummary `json:"summary"`
	Dependencies []MaintainersEntry `json:"dependencies"`
}

type MaintainersSummary added in v0.17.0

type MaintainersSummary struct {
	TotalDependencies   int `json:"total_dependencies"`
	QueriedDependencies int `json:"queried_dependencies"`
	WithMaintainers     int `json:"with_maintainers"`
	WithoutMaintainers  int `json:"without_maintainers"`
	SingleMaintainer    int `json:"single_maintainer"`
	LookupErrors        int `json:"lookup_errors"`
}

type OutdatedPackage

type OutdatedPackage struct {
	Name           string `json:"name"`
	Ecosystem      string `json:"ecosystem"`
	CurrentVersion string `json:"current_version"`
	LatestVersion  string `json:"latest_version"`
	UpdateType     string `json:"update_type"` // major, minor, patch
	ManifestPath   string `json:"manifest_path"`
	PURL           string `json:"purl,omitempty"`
}

type PathNotSupportedError added in v0.10.0

type PathNotSupportedError struct {
	Manager string
}

func (*PathNotSupportedError) Error added in v0.10.0

func (e *PathNotSupportedError) Error() string

func (*PathNotSupportedError) ExitCode added in v0.10.0

func (e *PathNotSupportedError) ExitCode() int

type PraiseAuthorSummary

type PraiseAuthorSummary struct {
	Author         string         `json:"author"`
	TotalFixes     int            `json:"total_fixes"`
	BySeverity     map[string]int `json:"by_severity"`
	UniquePackages int            `json:"unique_packages"`
}

type PraiseSummary

type PraiseSummary struct {
	TotalFixes int                   `json:"total_fixes"`
	Authors    []PraiseAuthorSummary `json:"authors"`
}

type ProvenanceEntry added in v0.18.0

type ProvenanceEntry struct {
	Name               string   `json:"name"`
	Ecosystem          string   `json:"ecosystem"`
	Version            string   `json:"version"`
	ManifestPath       string   `json:"manifest_path"`
	PURL               string   `json:"purl,omitempty"`
	Status             string   `json:"status"`
	TrustedPublishing  bool     `json:"trusted_publishing"`
	RegistrySignatures int      `json:"registry_signatures,omitempty"`
	Evidence           []string `json:"evidence,omitempty"`
	Error              string   `json:"error,omitempty"`
}

type ProvenanceResult added in v0.18.0

type ProvenanceResult struct {
	Summary      ProvenanceSummary `json:"summary"`
	Dependencies []ProvenanceEntry `json:"dependencies"`
}

type ProvenanceSummary added in v0.18.0

type ProvenanceSummary struct {
	TotalDependencies      int `json:"total_dependencies"`
	CheckedDependencies    int `json:"checked_dependencies"`
	TrustedPublishing      int `json:"trusted_publishing"`
	AttestedDependencies   int `json:"attested_dependencies"`
	RegistrySignatures     int `json:"registry_signatures"`
	WithoutProvenance      int `json:"without_provenance"`
	UnsupportedEcosystems  int `json:"unsupported_ecosystems"`
	LookupErrors           int `json:"lookup_errors"`
	UnresolvedDependencies int `json:"unresolved_dependencies"`
}

type RegistryCheckResult

type RegistryCheckResult struct {
	Mismatches []RegistryMismatch `json:"mismatches"`
	Checked    int                `json:"checked"`
	Skipped    int                `json:"skipped"`
}

type RegistryMismatch

type RegistryMismatch struct {
	Name         string `json:"name"`
	Ecosystem    string `json:"ecosystem"`
	Version      string `json:"version"`
	LocalHash    string `json:"local_hash"`
	RegistryHash string `json:"registry_hash"`
	ManifestPath string `json:"manifest_path"`
}

type TableSchema

type TableSchema struct {
	Name     string         `json:"name"`
	Columns  []ColumnSchema `json:"columns"`
	Indexes  []string       `json:"indexes,omitempty"`
	IndexSQL []string       `json:"-"`
}

type TreeNode

type TreeNode struct {
	Name     string      `json:"name"`
	Type     string      `json:"type,omitempty"`
	Children []*TreeNode `json:"children,omitempty"`
}

type VulnBlameEntry

type VulnBlameEntry struct {
	VulnID      string `json:"vuln_id"`
	Severity    string `json:"severity"`
	Package     string `json:"package"`
	Version     string `json:"version"`
	FixedIn     string `json:"fixed_in,omitempty"`
	AddedBy     string `json:"added_by"`
	AddedEmail  string `json:"added_email"`
	AddedCommit string `json:"added_commit"`
	AddedDate   string `json:"added_date"`
}

type VulnExposureEntry

type VulnExposureEntry struct {
	VulnID       string `json:"vuln_id"`
	Severity     string `json:"severity"`
	Package      string `json:"package"`
	Version      string `json:"version"`
	IntroducedAt string `json:"introduced_at"`
	IntroducedBy string `json:"introduced_by"`
	ExposureDays int    `json:"exposure_days"`
}

type VulnHistoryEntry

type VulnHistoryEntry struct {
	SHA             string       `json:"sha"`
	Date            string       `json:"date"`
	Version         string       `json:"version"`
	Vulnerabilities []VulnResult `json:"vulnerabilities,omitempty"`
}

type VulnLogEntry

type VulnLogEntry struct {
	SHA        string       `json:"sha"`
	Message    string       `json:"message"`
	Author     string       `json:"author"`
	Date       string       `json:"date"`
	Introduced []VulnResult `json:"introduced,omitempty"`
	Fixed      []VulnResult `json:"fixed,omitempty"`
}

type VulnPraiseEntry

type VulnPraiseEntry struct {
	VulnID    string `json:"vuln_id"`
	Severity  string `json:"severity"`
	Package   string `json:"package"`
	FixedBy   string `json:"fixed_by"`
	FixedIn   string `json:"fixed_in"`
	FixedDate string `json:"fixed_date"`
}

type VulnResult

type VulnResult struct {
	ID           string   `json:"id"`
	Aliases      []string `json:"aliases,omitempty"`
	Summary      string   `json:"summary"`
	Severity     string   `json:"severity"`
	Package      string   `json:"package"`
	Ecosystem    string   `json:"ecosystem"`
	Version      string   `json:"version"`
	FixedVersion string   `json:"fixed_version,omitempty"`
	ManifestPath string   `json:"manifest_path"`
	References   []string `json:"references,omitempty"`
}

VulnResult represents a vulnerability found in a dependency.

type VulnShowExposure

type VulnShowExposure struct {
	Affected        bool   `json:"affected"`
	AffectedPackage string `json:"affected_package,omitempty"`
	CurrentVersion  string `json:"current_version,omitempty"`
	FixedVersion    string `json:"fixed_version,omitempty"`
	Commit          string `json:"commit,omitempty"`
}

type VulnShowResult

type VulnShowResult struct {
	Vulnerability *vulns.Vulnerability `json:"vulnerability"`
	Exposure      *VulnShowExposure    `json:"exposure,omitempty"`
}

type VulnsDiffResult

type VulnsDiffResult struct {
	Added []VulnResult `json:"added"`
	Fixed []VulnResult `json:"fixed"`
}

type WhereMatch

type WhereMatch struct {
	FilePath         string   `json:"file_path"`
	LineNumber       int      `json:"line_number"`
	Content          string   `json:"content"`
	Context          []string `json:"context,omitempty"`
	ContextStartLine int      `json:"-"`
	Ecosystem        string   `json:"ecosystem"`
}

Jump to

Keyboard shortcuts

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