opts

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package opts resolves +/- selector expressions used by the CLI to filter detectors, auditors, matchers, and ecosystems. The resolver is generic: callers build a catalog of available items (with optional aliases) and pass a default set plus a raw expression — the resolver returns the include and exclude lists.

Index

Constants

View Source
const (
	VulnerabilityAuditorName = "vulnerability"
)

Variables

View Source
var ErrNoSubprojects = errors.New("no subprojects discovered for execution target with the applied filters")

ErrNoSubprojects indicates that no compatible subprojects were discovered for the runtime.

Functions

func BindCommandFlagGroups

func BindCommandFlagGroups(cmd *cobra.Command, cfg *config.Resolved, groups ...FlagGroup) error

func BindJSONFormatFlag

func BindJSONFormatFlag(flags *pflag.FlagSet, format *string, usage string)

BindJSONFormatFlag binds --json as a no-argument shortcut for setting format to json.

func PlanSubprojects

func PlanSubprojects(registryValue *engine.Registry, req Request) ([]sdk.Subproject, error)

PlanSubprojects discovers subprojects for an execution target with the provided registry and filters.

func RegistryConfigsFromResolved

func RegistryConfigsFromResolved(cfg config.Resolved) engine.RegistryConfigs

RegistryConfigsFromResolved converts resolved CLI configuration into scan registry wiring. Validation of FailOn values happens earlier in the CLI pipeline; here we drop parse errors and keep only the valid constraints so secondary callers (tests, plugin adapters) stay functional.

func ResolveAnalyzerFilter

func ResolveAnalyzerFilter(raw string, reg *engine.Registry) (sdk.AnalyzerFilter, error)

ResolveAnalyzerFilter parses --analyzers and returns an AnalyzerFilter. Empty input yields an empty filter so the registry's default-enabled set applies.

func ResolveAuditorFilter

func ResolveAuditorFilter(raw string, reg *engine.Registry) (sdk.AuditorFilter, error)

func ResolveMatcherFilter

func ResolveMatcherFilter(raw string, reg *engine.Registry) (sdk.MatcherFilter, error)

func ToContext

func ToContext(ctx context.Context, options *Options) context.Context

ToContext returns a context that carries Bomly command options.

Types

type FlagGroup

type FlagGroup string
const (
	FlagGroupTarget    FlagGroup = "target"
	FlagGroupAnalysis  FlagGroup = "analysis"
	FlagGroupSelectors FlagGroup = "selectors"
	FlagGroupExecution FlagGroup = "execution"
)

type Options

type Options struct {
	ResolvedConfig config.Resolved

	Format output.Format
	// contains filtered or unexported fields
}

Options encapsulates the context for executing a CLI command, including configuration, registry, execution target, filters, output format, and cleanup logic.

func FromContext

func FromContext(ctx context.Context) (*Options, bool)

FromContext returns the Bomly command context stored on ctx.

func NewOptions

func NewOptions() *Options

func (*Options) AnalyzerFilter

func (o *Options) AnalyzerFilter() sdk.AnalyzerFilter

AnalyzerFilter returns the analyzer filter prepared for command execution.

func (*Options) AuditorFilter

func (o *Options) AuditorFilter() sdk.AuditorFilter

AuditorFilter returns the auditor filter prepared for command execution.

func (*Options) Bind

func (o *Options) Bind(root *cobra.Command) error

func (*Options) Close

func (o *Options) Close() error

Close performs any necessary cleanup for the command options.

func (*Options) DetectorFilter

func (o *Options) DetectorFilter() sdk.DetectorFilter

DetectorFilter returns the detector filter prepared for command execution.

func (*Options) ExecutionTarget

func (o *Options) ExecutionTarget() sdk.ExecutionTarget

ExecutionTarget returns the target prepared for command execution.

func (*Options) GetConfig

func (o *Options) GetConfig() config.Resolved

func (*Options) MatcherFilter

func (o *Options) MatcherFilter() sdk.MatcherFilter

MatcherFilter returns the matcher filter prepared for command execution.

func (*Options) OutputFormat

func (o *Options) OutputFormat() (output.Format, error)

func (*Options) PipelineRequest

func (o *Options) PipelineRequest(scope sdk.Scope, stderr io.Writer) engine.PipelineRequest

PipelineRequest builds the scan pipeline request for this prepared command context.

func (*Options) PluginLaunchContext

func (o *Options) PluginLaunchContext(ctx context.Context) context.Context

func (*Options) Prepare

func (o *Options) Prepare(ctx context.Context, logger *zap.Logger) (Options, error)

func (*Options) PrepareForExecutionTarget

func (o *Options) PrepareForExecutionTarget(ctx context.Context, logger *zap.Logger, executionTarget sdk.ExecutionTarget, cleanup func() error) (Options, error)

func (*Options) ProjectDescriptor

func (o *Options) ProjectDescriptor() output.ProjectDescriptor

ProjectDescriptor returns a descriptor for the main project being analyzed, summarizing its name, path, ecosystem, and package manager.

func (*Options) ProjectDescriptorForSubproject

func (o *Options) ProjectDescriptorForSubproject(subproject sdk.Subproject) output.ProjectDescriptor

ProjectDescriptorForSubproject returns a descriptor for a given subproject, summarizing its name, path, ecosystem, and package manager. If the subproject's relative path is ".", it uses the main execution target's name instead.

func (*Options) Registry

func (o *Options) Registry() *engine.Registry

Registry returns the filtered scan registry prepared for command execution.

func (*Options) ResolveConfig

func (o *Options) ResolveConfig(cmd *cobra.Command) error

func (*Options) ResolveExecutionTarget

func (o *Options) ResolveExecutionTarget(logger *zap.Logger) (sdk.ExecutionTarget, func() error, error)

ResolveExecutionTarget resolves where the scan should run: it clones a remote repository, materializes an SBOM file, or resolves a local path. The returned cleanup must be deferred by the caller. CLI commands call this directly when they want to surface a dedicated "Cloning repository" (or similar) progress step around just this phase, before calling PrepareForExecutionTarget for the subproject-indexing phase.

func (*Options) ResolveProjectPath

func (o *Options) ResolveProjectPath() (string, error)

func (*Options) SetConfig

func (o *Options) SetConfig(cfg config.Resolved)

func (*Options) Subprojects

func (o *Options) Subprojects() []sdk.Subproject

Subprojects returns the subprojects prepared for command execution.

func (*Options) Verbose

func (o *Options) Verbose() bool

Verbose reports whether verbose command output is enabled.

func (*Options) Writer

func (o *Options) Writer(stdout io.Writer) (io.Writer, func() error, error)

Writer returns an io.Writer for the command's output, which writes to the specified output path if provided, or to the given stdout otherwise.

type Request

type Request struct {
	Registry             *engine.Registry
	ExecutionTarget      sdk.ExecutionTarget
	ForcedPackageManager sdk.PackageManager
	DetectorFilter       sdk.DetectorFilter
	EcosystemFilter      sdk.EcosystemFilter
}

Request defines the inputs required to build one execution runtime.

Jump to

Keyboard shortcuts

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