models

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package models contains any structs used throughout kissbom

Index

Constants

View Source
const (
	OptionJSON       = "json"       // OptionDefault represents the default output format (kissbom format, json encoding).
	OptionYAML       = "yaml"       // OptionYAML represents the YAML output format (kissbom format, json encoding).
	OptionMinimal    = "minimal"    // OptionMinimal represents a minimal output format (kissbom format, but only Purls).
	OptionCompatible = "compatible" // OptionCompatible represents a compatible output format (CycloneDX formatted output, but only Purls).
	OptionCSV        = "csv"        // OptionCSV represents a CSV (Comma-Separated Values) output format (all kissbom elements)
)

Enumeration of valid output formats for kissbom.

Variables

This section is empty.

Functions

This section is empty.

Types

type KissBOM

type KissBOM struct {
	Packages []Package `json:"packages"` // Packages is a slice of Package structs, serialized as "packages" in JSON.
}

KissBOM represents a collection of packages.

func NewKissBOMFromCycloneDX

func NewKissBOMFromCycloneDX(cdx *cyclonedx.BOM) (kissbom KissBOM)

NewKissBOMFromCycloneDX creates a new KissBOM (Keep It Simple Software Bill of Materials) from a CycloneDX Bill of Materials (BOM). It iterates over the components in the CycloneDX BOM and constructs a simplified representation in the KissBOM format, with essential information such as Package URL and Description.

Parameters:

  • cdx: A pointer to a CycloneDX BOM containing information about software components.

Returns:

  • kissbom: A KissBOM representation derived from the CycloneDX BOM.

NewKissBOMFromCycloneDX converts a CycloneDX BOM (Bill of Materials) to a KissBOM (KISS Build of Materials) by extracting relevant information from each component.

func (*KissBOM) CSV

func (k *KissBOM) CSV() ([]byte, error)

CSV converts the KissBOM struct to CSV format using gocsv

func (*KissBOM) Compatible

func (k *KissBOM) Compatible() ([]byte, error)

Compatible generates a CycloneDX Bill of Materials (BOM) based on the packages stored in the KissBOM instance. Each package's PackageURL is used to create corresponding CycloneDX components, and these components are added to the BOM. The resulting BOM is then encoded to a byte slice using the JSON format.

Returns:

  • The encoded BOM as a byte slice.
  • An error if there was any issue during encoding.

func (*KissBOM) JSON

func (k *KissBOM) JSON() ([]byte, error)

JSON converts the KissBOM struct to JSON format

func (*KissBOM) Minimal

func (k *KissBOM) Minimal() ([]byte, error)

Minimal converts the KissBOM struct to a JSON format with only the PURLs

func (*KissBOM) YAML

func (k *KissBOM) YAML() ([]byte, error)

YAML converts the KissBOM struct to YAML format

type Package

type Package struct {
	Purl      string `json:"purl" csv:"purl" yaml:"purl"`                                    // Purl is the Package URL, a unique identifier for the package.
	License   string `json:"license,omitempty" csv:"license" yaml:"license,omitempty"`       // License is the software license associated with the package, omitempty allows for optional serialization.
	Copyright string `json:"copyright,omitempty" csv:"copyright" yaml:"copyright,omitempty"` // Copyright is information about the package's copyright, omitempty allows for optional serialization.
	Notes     string `json:"notes,omitempty" csv:"notes" yaml:"notes,omitempty"`             // Notes is additional notes or comments about the package, omitempty allows for optional serialization.
}

Package represents information about a software package.

Jump to

Keyboard shortcuts

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