Documentation
¶
Index ¶
- Constants
- func Execute() error
- func ExitCode(err error) int
- func LSPActive() bool
- func LoadFromMemory(rootPath string, freshExploits, freshAdvisories, freshVulns bool) error
- type AIBOMPassOptions
- type AIBOMPassResult
- type CBOMPassOptions
- type CBOMPassResult
- type CommandManifest
- type EcoGroups
- type EcoStatus
- type ExitCodeError
- type GateBreach
- type JailRunOptions
- type JailRunResult
- type JailUsageError
- type JailVerdictError
- type LicensePolicyFlags
- type LicenseRunOptions
- type LicenseRunResult
- type ManifestCommand
- type MultiPolicyBreachError
- type PolicyBreachError
- type SeverityBreachError
Constants ¶
const ( // ExitOK — the command succeeded. ExitOK = 0 // ExitFailure — the command failed, or a policy gate breached. Every error // that does not name its own code lands here, which is what the CLI did // before this file existed. ExitFailure = 1 // ExitUsage — a local argument or configuration error, before any // meaningful work was attempted. ExitUsage = 2 // ExitIndeterminate — the gate ran but could not reach a verdict, because // the backend state it needs is stale or absent. NOT a pass and NOT a // breach. ExitIndeterminate = 3 )
Process exit codes. These are a contract with every pipeline in the field; changing what one means is a breaking change to somebody's CI.
Variables ¶
This section is empty.
Functions ¶
func ExitCode ¶ added in v3.93.0
ExitCode resolves the process exit code for an error returned by Execute.
errors.As, not a bare type assertion. A future `fmt.Errorf("...: %w", err)` wrapper anywhere in a call chain would make an assertion miss, silently demoting a 3 to a 1 — and a demoted 3 reads to a pipeline as an ordinary build failure rather than "the gate could not tell". That is the whole distinction this file exists to preserve, so it is asserted in exit_codes_test.go.
func LSPActive ¶ added in v3.89.0
func LSPActive() bool
LSPActive reports whether the process is serving LSP. Read by startupHooks.
func LoadFromMemory ¶
LoadFromMemory reconstructs the scan pretty output from .vulnetix/sbom.cdx.json. When fresh* flags are true, selective API calls are made to refresh that data.
Types ¶
type AIBOMPassOptions ¶ added in v3.79.0
type AIBOMPassOptions struct {
RootPath string
Depth int
Ignore []string
CatalogPath string
NoBuiltinCatalog bool
// Passes selects which detection passes run; the zero value runs none, so
// callers must be explicit.
Passes aibomPasses
IncludeHome bool
CommitMax int
RespectGitignore bool
// SpecVersion defaults to 1.7.
SpecVersion string
// Upload submits the AIBOM to the backend when authenticated.
Upload bool
GitCtx *gitctx.GitContext
}
AIBOMPassOptions is the AIBOM owner's entry contract. The `aibom` command builds it from its flags; `scan` builds it with the pass defaults. Both go through runAIBOMPass, so there is one definition of "detect AI usage".
type AIBOMPassResult ¶ added in v3.79.0
type AIBOMPassResult struct {
Detections cyclonedx.AIDetections
BOM []byte
SpecVersion string
}
AIBOMPassResult carries what the caller renders or writes.
type CBOMPassOptions ¶ added in v3.79.0
type CBOMPassOptions struct {
RootPath string
Depth int
Ignore []string
CatalogPath string
NoBuiltinCatalog bool
// Passes selects which detection passes run; the zero value runs none.
Passes cbomPasses
RespectGitignore bool
// SpecVersion defaults to 1.7.
SpecVersion string
// Upload submits the CBOM to the backend when authenticated.
Upload bool
GitCtx *gitctx.GitContext
}
CBOMPassOptions is the CBOM owner's entry contract, mirroring AIBOMPassOptions: the `cbom` command builds it from its flags, `scan` builds it with the pass defaults, and runCBOMPass is the only implementation.
type CBOMPassResult ¶ added in v3.79.0
type CBOMPassResult struct {
Detections cyclonedx.CryptoDetections
BOM []byte
SpecVersion string
}
CBOMPassResult carries what the caller renders, writes or gates on.
type CommandManifest ¶ added in v3.56.0
type CommandManifest struct {
Commands map[string]ManifestCommand `json:"commands"`
}
CommandManifest is the serialized shape of the Cobra tree.
func BuildCommandManifest ¶ added in v3.56.0
func BuildCommandManifest() CommandManifest
BuildCommandManifest walks the live root command and records every command path with its flags. Persistent flags are attributed to the command that declares them and to every descendant, because that is how a user sees them.
type ExitCodeError ¶ added in v3.93.0
ExitCodeError is an error that names the process exit code it should produce.
Absent this interface an error still exits 1, which is what every command in the tree did before jail existed and must keep doing.
type GateBreach ¶
type GateBreach struct {
Gate string // "malware" | "exploits" | "severity" | "eol"
Count int
Message string // pre-formatted, ready to print
}
GateBreach captures one quality gate's failure details.
type JailRunOptions ¶ added in v3.93.0
type JailRunOptions struct {
Mode string
RootPath string
Repo string
Branch string
RuleUuids []string
// KnownSnapshotUuids names scanner runs the caller just created, so a
// scan-then-gate in one invocation is not defeated by read-replica lag.
KnownSnapshotUuids []string
// Artefacts
VexPath string
VexFormat string
SarifPath string
WriteVex bool
WriteSarif bool
// Gate behaviour
NoFail bool
StalenessDays int
OnStale string
MaxLookbackDays int
// Exempt mode
ExemptRuleUuid string
ExemptReason string
ExemptExpires time.Duration
ExemptDeactivate string
ExemptDeactivateReason string
BaseURL string
Output string
Timeout time.Duration
Stdout io.Writer
Stderr io.Writer
}
JailRunOptions is the single input to the jail capability.
type JailRunResult ¶ added in v3.93.0
type JailRunResult struct {
Response *vdb.CliJailResponse
Exemption *vdb.CliJailExemptResponse
Artefacts []string
ExitCode int
}
JailRunResult is what the caller needs to render and to decide an exit code.
type JailUsageError ¶ added in v3.93.0
type JailUsageError struct {
// contains filtered or unexported fields
}
JailUsageError is a local argument or configuration failure: an unparseable duration, a scope override on an assess run, an unwritable artefact path, no credentials.
Its exit code 2 is deliberately scoped to this command. Cobra's own usage errors across the rest of the tree keep exiting 1; promoting them globally would change the contract of every pipeline in the field.
func (*JailUsageError) Error ¶ added in v3.93.0
func (e *JailUsageError) Error() string
func (*JailUsageError) ExitCode ¶ added in v3.93.0
func (e *JailUsageError) ExitCode() int
func (*JailUsageError) Unwrap ¶ added in v3.93.0
func (e *JailUsageError) Unwrap() error
type JailVerdictError ¶ added in v3.93.0
type JailVerdictError struct {
Verdict string
Code int
Summary vdb.CliJailSummary
}
JailVerdictError is returned when the gate reports jailed or indeterminate.
The command has already rendered the full verdict block, so Execute() suppresses the generic "Error:" line for it the same way it does for a quality-gate breach.
func (*JailVerdictError) Error ¶ added in v3.93.0
func (e *JailVerdictError) Error() string
func (*JailVerdictError) ExitCode ¶ added in v3.93.0
func (e *JailVerdictError) ExitCode() int
ExitCode reports 1 for a breach and 3 for an indeterminate verdict.
type LicensePolicyFlags ¶ added in v3.79.0
LicensePolicyFlags is the license policy as the scan-family flags express it (`--license-mode`, `--allow`, `--allow-file`). It travels through the scan pipeline to the license owner so a scan and a standalone `license` run apply the same policy.
type LicenseRunOptions ¶ added in v3.79.0
type LicenseRunOptions struct {
RootPath string
// Mode is the license.EvalConfig mode ("inclusive" or "individual"). Empty
// defaults to inclusive.
Mode string
// AllowCSV / AllowFile are the two spellings of the allow list; AllowFile
// wins when both are set.
AllowCSV string
AllowFile string
// SeverityThreshold filters findings below the given severity.
SeverityThreshold string
// Packages are the parsed manifest packages to analyse.
Packages []scan.ScopedPackage
// ManifestGroups carries the dependency graph used for introduced-via chains.
ManifestGroups []scan.ManifestGroup
// LicensedPackages lets a caller reuse an earlier license.DetectLicenses
// result (the scan pipeline resolves licenses before its SCA round-trip so
// the payload can carry them). Empty means "detect now".
LicensedPackages []license.PackageLicense
// Memory, when non-nil, receives this run's findings and the resolution of
// findings that have disappeared. The caller owns saving it.
Memory *memory.Memory
GitCtx *gitctx.GitContext
// Stderr receives warnings; nil means os.Stderr.
Stderr io.Writer
}
LicenseRunOptions is everything the license pipeline needs from a caller. The `license` command builds it from its own flags; `scan --evaluate-licenses` builds it from the scan-family license flags and passes the packages it has already parsed. Both go through runLicensePipeline so there is exactly one implementation of "what does a license finding mean".
type LicenseRunResult ¶ added in v3.79.0
type LicenseRunResult struct {
Result *license.AnalysisResult
LicensedPackages []license.PackageLicense
// FindingVulnerabilities are this run's open license findings as CycloneDX
// vulnerability entries.
FindingVulnerabilities []cdx.Vulnerability
// VEXVulnerabilities are the resolution attestations read back from memory.
// They are kept separate from the findings because the scan pipeline feeds
// them through cdx.ApplyVEXAnalysis (which annotates an existing entry rather
// than appending a twin), while the license command merges both into the BOM
// in one call.
VEXVulnerabilities []cdx.Vulnerability
// StateChanges are the memory transitions this run produced (new findings,
// resolutions). Empty when Options.Memory was nil.
StateChanges []memory.StateChange
}
LicenseRunResult is the pipeline's output. Callers decide what to do with it: the `license` command merges the CycloneDX entries into the on-disk BOM, the scan pipeline appends them to the BOM it is already building in memory.
func (*LicenseRunResult) CDXVulnerabilities ¶ added in v3.79.0
func (r *LicenseRunResult) CDXVulnerabilities() []cdx.Vulnerability
CDXVulnerabilities is the findings and their VEX attestations in one slice, for callers that merge everything into the BOM at once.
func (*LicenseRunResult) LicenseSpdxIDByPackage ¶ added in v3.79.0
func (r *LicenseRunResult) LicenseSpdxIDByPackage() map[string]string
LicenseSpdxIDByPackage maps "name@version" → resolved SPDX id for every package whose license was determined. It is what the CycloneDX component population and the /v2/cli.sca payload both consume.
type ManifestCommand ¶ added in v3.56.0
type ManifestCommand struct {
Short string `json:"short"`
Flags []string `json:"flags"`
Deprecated []string `json:"deprecatedFlags,omitempty"`
Subs []string `json:"subcommands,omitempty"`
}
ManifestCommand describes one command path (e.g. "auth login").
type MultiPolicyBreachError ¶
type MultiPolicyBreachError struct {
Breaches []GateBreach
}
MultiPolicyBreachError is returned when one or more quality gates are breached.
func (*MultiPolicyBreachError) Error ¶
func (e *MultiPolicyBreachError) Error() string
type PolicyBreachError ¶
type PolicyBreachError interface {
error
// contains filtered or unexported methods
}
PolicyBreachError is implemented by all quality-gate breach errors. Execute() uses this interface to suppress redundant error printing — the command itself has already printed the breach details.
type SeverityBreachError ¶
type SeverityBreachError struct {
// contains filtered or unexported fields
}
SeverityBreachError is returned when --severity threshold is breached. It signals main() to exit with code 1 without printing a redundant error message.
func (*SeverityBreachError) Error ¶
func (e *SeverityBreachError) Error() string
Source Files
¶
- ai_firewall.go
- ai_firewall_apply.go
- ai_firewall_inventory.go
- ai_firewall_policy.go
- aibom.go
- analyze.go
- auth.go
- banner.go
- binary_scan.go
- cbom.go
- cdx.go
- cli_helpers.go
- cli_sca.go
- completion.go
- config.go
- config_ai_firewall.go
- config_jail.go
- env.go
- exit_codes.go
- fix.go
- fix_autofix.go
- fix_prompt.go
- from_memory.go
- gh_dependabot.go
- gha.go
- gha_setup.go
- gha_submit.go
- insights_graph.go
- insights_upload.go
- jail.go
- jail_artifacts.go
- jail_render.go
- license.go
- lsp.go
- malscan.go
- malscan_curation.go
- malscan_engine.go
- malscan_render.go
- malscan_sarif.go
- manifest.go
- package_firewall.go
- progress.go
- quality_gate_enforce.go
- reconcile.go
- report.go
- root.go
- sarif_persist.go
- sast_rules.go
- scan.go
- scan_jail.go
- skills.go
- specialized_scans.go
- status_summary.go
- suppress.go
- suppress_filter.go
- suppress_sync.go
- tea.go
- tea_distribution.go
- tea_publish.go
- tea_release.go
- testsuite_scan.go
- update.go
- upload.go
- upload_publish.go
- vdb.go
- vdb_ai.go
- vdb_attack_techniques.go
- vdb_ecosystem.go
- vdb_eol.go
- vdb_exploits_poc.go
- vdb_iocs.go
- vdb_kev.go
- vdb_msrc.go
- vdb_nuclei.go
- vdb_raw.go
- vdb_reachability.go
- vdb_sightings.go
- vdb_snort_rules.go
- vdb_trends.go
- vdb_triage.go
- vdb_v2.go
- vdb_vex.go
- vdb_yara_rules.go
- version.go