core

package
v0.76.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 18

Documentation

Index

Constants

View Source
const (
	TypeFilesystem     ComponentType = "filesystem"
	TypeRepository     ComponentType = "repository"
	TypeContainerImage ComponentType = "container_image"
	TypeVM             ComponentType = "vm"
	TypeApplication    ComponentType = "application"
	TypeLibrary        ComponentType = "library"
	TypeOS             ComponentType = "os"
	TypePlatform       ComponentType = "platform"

	// Metadata properties
	PropertySchemaVersion = "SchemaVersion"
	PropertyType          = "Type"
	PropertyClass         = "Class"

	// Image properties
	PropertySize         = "Size"
	PropertyImageID      = "ImageID"
	PropertyRepoDigest   = "RepoDigest"
	PropertyDiffID       = "DiffID"
	PropertyRepoTag      = "RepoTag"
	PropertyReference    = "Reference"
	PropertyLabelsPrefix = "Labels"

	// Package properties
	PropertyPkgID           = "PkgID"
	PropertyPkgType         = "PkgType"
	PropertySrcName         = "SrcName"
	PropertySrcVersion      = "SrcVersion"
	PropertySrcRelease      = "SrcRelease"
	PropertySrcEpoch        = "SrcEpoch"
	PropertyModularitylabel = "Modularitylabel"
	PropertyFilePath        = "FilePath"
	PropertyLayerDigest     = "LayerDigest"
	PropertyLayerDiffID     = "LayerDiffID"

	// Red Hat packages only.
	// A package can use multiple NVR + Arch content sets or fields.
	PropertyContentSet = "ContentSet"
	PropertyNVR        = "NVR"
	PropertyArch       = "Arch"

	// Relationships
	RelationshipDescribes RelationshipType = "describes"
	RelationshipContains  RelationshipType = "contains"
	RelationshipDependsOn RelationshipType = "depends_on"

	ExternalReferenceVEX ExternalReferenceType = "external_reference_vex"
)

Variables

This section is empty.

Functions

func CryptoBOMRef added in v0.75.0

func CryptoBOMRef(descriptor ftypes.CryptoDescriptor) string

CryptoBOMRef returns the BOM reference of the component describing an asset.

The prefix scopes cryptographic assets in a namespace shared with package components, whose reference is a package URL.

Types

type BOM

type BOM struct {
	SerialNumber string
	Version      int
	// contains filtered or unexported fields
}

BOM represents an intermediate representation of a component for SBOM.

func NewBOM

func NewBOM(opts Options) *BOM

func (*BOM) AddComponent

func (b *BOM) AddComponent(c *Component)

func (*BOM) AddCryptoComponent added in v0.75.0

func (b *BOM) AddCryptoComponent(c *CryptoComponent)

func (*BOM) AddExternalReferences added in v0.60.0

func (b *BOM) AddExternalReferences(refs []ExternalReference)

func (*BOM) AddRelationship

func (b *BOM) AddRelationship(parent, child *Component, relationshipType RelationshipType)

func (*BOM) AddVulnerabilities

func (b *BOM) AddVulnerabilities(c *Component, vulns []Vulnerability)

func (*BOM) Clone added in v0.67.0

func (b *BOM) Clone() *BOM

Clone creates a deep copy of the BOM, including all components, relationships, and vulnerabilities. This ensures that modifications to the cloned BOM do not affect the original BOM.

func (*BOM) Components

func (b *BOM) Components() map[uuid.UUID]*Component

func (*BOM) CryptoComponents added in v0.75.0

func (b *BOM) CryptoComponents() []*CryptoComponent

func (*BOM) ExternalReferences added in v0.60.0

func (b *BOM) ExternalReferences() []ExternalReference

func (*BOM) Parents added in v0.52.0

func (b *BOM) Parents() map[uuid.UUID][]uuid.UUID

func (*BOM) Relationships

func (b *BOM) Relationships() map[uuid.UUID][]Relationship

func (*BOM) Root

func (b *BOM) Root() *Component

func (*BOM) Vulnerabilities

func (b *BOM) Vulnerabilities() map[uuid.UUID][]Vulnerability

type Component

type Component struct {

	// Type is the type of the component
	// CycloneDX: component.type
	Type ComponentType

	// Root represents the root of the BOM
	// Only one root is allowed in a BOM.
	// CycloneDX: metadata.component
	Root bool

	// Name is the name of the component
	// CycloneDX: component.name
	// SPDX: package.name
	Name string

	// Group is the group of the component
	// CycloneDX: component.group
	// SPDX: N/A
	Group string

	// Version is the version of the component
	// CycloneDX: component.version
	// SPDX: package.versionInfo
	Version string

	// SrcName is the name of the source component
	// CycloneDX: N/A
	// SPDX: package.sourceInfo
	SrcName string

	// SrcVersion is the version of the source component
	// CycloneDX: N/A
	// SPDX: package.sourceInfo
	SrcVersion string

	// SrcFile is the file path where the component is found.
	// CycloneDX: N/A
	// SPDX: package.sourceInfo
	SrcFile string

	// Licenses is a list of licenses that apply to the component
	// CycloneDX: component.licenses
	// SPDX: package.licenseConcluded, package.licenseDeclared
	Licenses []string

	// PkgIdentifier has PURL and BOMRef for the component
	// PURL:
	//   CycloneDX: component.purl
	//   SPDX: package.externalRefs.referenceLocator
	// BOMRef:
	//   CycloneDX: component.bom-ref
	//   SPDX: N/A
	PkgIdentifier ftypes.PkgIdentifier

	// Supplier is the name of the supplier of the component
	// CycloneDX: component.supplier
	// SPDX: package.supplier
	Supplier string

	// Files is a list of files that are part of the component.
	// CycloneDX: component.properties
	// SPDX: files
	Files []File

	// Properties is a list of key-value pairs that provide additional information about the component
	// CycloneDX: component.properties
	// SPDX: package.attributionTexts
	Properties Properties `hash:"set"`
	// contains filtered or unexported fields
}

func (*Component) Clone added in v0.67.0

func (c *Component) Clone() *Component

Clone creates a deep copy of the Component

func (*Component) ID

func (c *Component) ID() uuid.UUID

type ComponentType

type ComponentType string

type CryptoComponent added in v0.75.0

type CryptoComponent struct {
	// Asset is what the component describes. Its identity is derived from content and does
	// not depend on where the asset was found.
	// CycloneDX: component.cryptoProperties
	// SPDX: N/A
	Asset ftypes.CryptoAssetInfo

	// Occurrences are the places the asset was found at. One component is merged from the
	// assets of several files and layers, and each of them becomes an occurrence.
	// CycloneDX: component.evidence.occurrences
	// SPDX: N/A
	Occurrences []Occurrence
}

CryptoComponent describes a cryptographic asset: a certificate, a key or an algorithm. It is kept apart from Component, which describes software.

func (*CryptoComponent) BOMRef added in v0.75.0

func (c *CryptoComponent) BOMRef() string

BOMRef returns the reference of the component, derived from the asset identity.

func (*CryptoComponent) Clone added in v0.75.0

func (c *CryptoComponent) Clone() *CryptoComponent

Clone creates a deep copy of the CryptoComponent

type ExternalReference added in v0.60.0

type ExternalReference struct {
	URL  string
	Type ExternalReferenceType
}

type ExternalReferenceType added in v0.60.0

type ExternalReferenceType string

type File

type File struct {
	// Path is a path of the file.
	// CycloneDX: N/A
	// SPDX: package.files[].fileName
	Path string

	// Hash is a hash that uniquely identify the component.
	// A file can have several digests with different algorithms, like SHA1, SHA256, etc.
	// CycloneDX: component.hashes
	// SPDX: package.files[].checksums
	Digests []digest.Digest
}

func (File) IsEmpty added in v0.71.0

func (f File) IsEmpty() bool

type Occurrence added in v0.75.0

type Occurrence struct {
	// Location is the path of the file the component was found in.
	// CycloneDX: component.evidence.occurrences[].location
	Location string

	// LayerDiffID is the layer the file was found in. It is empty for a target that has no
	// layers.
	// CycloneDX: component.evidence.occurrences[].additionalContext
	LayerDiffID string
}

Occurrence is a place a component was found at.

type Options

type Options struct {
	GenerateBOMRef bool // Generate BOMRef for CycloneDX
	Parents        bool // Hold parent maps
}

type Properties

type Properties []Property

func (Properties) Len

func (p Properties) Len() int

func (Properties) Less

func (p Properties) Less(i, j int) bool

func (Properties) Swap

func (p Properties) Swap(i, j int)

type Property

type Property struct {
	Name      string
	Value     string
	Namespace string
	// External indicates if this property came from external source (not generated by Trivy)
	// When false (default), Trivy namespace prefix will be applied during marshaling
	External bool
}

type Relationship

type Relationship struct {
	Dependency uuid.UUID
	Type       RelationshipType
}

type RelationshipType

type RelationshipType string

type Vulnerability

type Vulnerability struct {
	dtypes.Vulnerability
	ID               string
	PkgName          string
	InstalledVersion string
	FixedVersion     string
	PrimaryURL       string
	DataSource       *dtypes.DataSource
}

Jump to

Keyboard shortcuts

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