format

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 4 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEncodingNotSupported   = errors.New("encoding not supported")
	ErrDecodingNotSupported   = errors.New("decoding not supported")
	ErrValidationNotSupported = errors.New("validation not supported")
)

Functions

This section is empty.

Types

type Decoder

type Decoder func(reader io.Reader) (*sbom.SBOM, error)

Decoder is a function that can convert an SBOM document of a specific format from a reader into Syft native objects.

type Encoder

type Encoder func(io.Writer, sbom.SBOM) error

Encoder is a function that can transform Syft native objects into an SBOM document of a specific format written to the given writer.

type Format

type Format struct {
	Option Option
	// contains filtered or unexported fields
}

func NewFormat

func NewFormat(option Option, encoder Encoder, decoder Decoder, validator Validator) Format

func (Format) Decode

func (f Format) Decode(reader io.Reader) (*sbom.SBOM, error)

func (Format) Encode

func (f Format) Encode(output io.Writer, s sbom.SBOM) error

func (Format) Presenter

func (f Format) Presenter(s sbom.SBOM) *Presenter

func (Format) Validate

func (f Format) Validate(reader io.Reader) error

type Option

type Option string
const (
	UnknownFormatOption Option = "UnknownFormatOption"
	JSONOption          Option = "json"
	TextOption          Option = "text"
	TableOption         Option = "table"
	CycloneDxXMLOption  Option = "cyclonedx"
	CycloneDxJSONOption Option = "cyclonedx-json"
	SPDXTagValueOption  Option = "spdx-tag-value"
	SPDXJSONOption      Option = "spdx-json"
)

func ParseOption

func ParseOption(userStr string) Option

type Presenter

type Presenter struct {
	// contains filtered or unexported fields
}

func NewPresenter

func NewPresenter(encoder Encoder, s sbom.SBOM) *Presenter

func (*Presenter) Present

func (pres *Presenter) Present(output io.Writer) error

type Validator

type Validator func(reader io.Reader) error

Validator reads the SBOM from the given reader and assesses whether the document conforms to the specific SBOM format. The validator should positively confirm if the SBOM is not only the format but also has the minimal set of values that the format requires. For example, all syftjson formatted documents have a schema section which should have "anchore/syft" within the version --if this isn't found then the validator should raise an error. These active assertions protect against "simple" format decoding validations that may lead to false positives (e.g. I decoded json successfully therefore this must be the target format, however, all values are their default zero-value and really represent a different format that also uses json)

Jump to

Keyboard shortcuts

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