shell

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFormat = formats.SPDX23JSON
)

Variables

This section is empty.

Functions

func Library

func Library() cel.EnvOption

Types

type Bomshell

type Bomshell struct {
	Options Options
	// contains filtered or unexported fields
}

func New

func New() (*Bomshell, error)

func NewWithOptions

func NewWithOptions(opts Options) (*Bomshell, error)

func (*Bomshell) LoadSBOM

func (bs *Bomshell) LoadSBOM(path string) (*elements.Document, error)

func (*Bomshell) PrintResult

func (bs *Bomshell) PrintResult(result ref.Val, w io.WriteCloser) error

PrintResult writes result into writer w according to the format configured in the options

func (*Bomshell) Run

func (bs *Bomshell) Run(code string) (ref.Val, error)

func (*Bomshell) RunFile

func (bs *Bomshell) RunFile(path string) (ref.Val, error)

RunFile runs a bomshell recipe from a file

type BomshellImplementation

type BomshellImplementation interface {
	Compile(*Runner, string) (*cel.Ast, error)
	Evaluate(*Runner, *cel.Ast, map[string]interface{}) (ref.Val, error)
	LoadSBOM(io.ReadSeekCloser) (*elements.Document, error)
	OpenFile(path string) (*os.File, error)
	PrintDocumentResult(Options, ref.Val, io.WriteCloser) error
	ReadRecipeFile(io.Reader) (string, error)
}

type DefaultBomshellImplementation

type DefaultBomshellImplementation struct{}

func (*DefaultBomshellImplementation) Compile

func (di *DefaultBomshellImplementation) Compile(runner *Runner, code string) (*cel.Ast, error)

func (*DefaultBomshellImplementation) Evaluate

func (di *DefaultBomshellImplementation) Evaluate(runner *Runner, ast *cel.Ast, variables map[string]interface{}) (ref.Val, error)

func (*DefaultBomshellImplementation) LoadSBOM

func (*DefaultBomshellImplementation) OpenFile

func (di *DefaultBomshellImplementation) OpenFile(path string) (*os.File, error)

func (*DefaultBomshellImplementation) PrintDocumentResult

func (di *DefaultBomshellImplementation) PrintDocumentResult(opts Options, result ref.Val, w io.WriteCloser) error

PrintDocumentResult takes a document result from a bomshell query and outputs it as an SBOM in the format specified in the options

func (*DefaultBomshellImplementation) ReadRecipeFile

func (di *DefaultBomshellImplementation) ReadRecipeFile(f io.Reader) (string, error)

ReadRecipeFile reads a bomshell recipe file and returns it as a string. This function will look for a pind-bag line at the start of the file and strip it if needed.

type Options

type Options struct {
	SBOMs      []string
	Format     formats.Format
	EnvOptions []cel.EnvOption
}

type Runner

type Runner struct {
	Environment *cel.Env
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner() (*Runner, error)

func NewRunnerWithOptions

func NewRunnerWithOptions(opts *Options) (*Runner, error)

func (*Runner) Compile

func (r *Runner) Compile(code string) (*cel.Ast, error)

Compile reads CEL code from string, compiles it and returns the Abstract Syntax Tree (AST). The AST can then be evaluated in the environment. As compilation of the AST is expensive, it can be cached for better performance.

func (*Runner) EvaluateAST

func (r *Runner) EvaluateAST(ast *cel.Ast, variables map[string]interface{}) (ref.Val, error)

EvaluateAST evaluates a CEL syntax tree on an SBOM. Returns the program evaluation result or an error.

type RunnerImplementation

type RunnerImplementation interface {
	ReadStream(io.Reader) (string, error)
	Compile(*cel.Env, string) (*cel.Ast, error)
}

Jump to

Keyboard shortcuts

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