Documentation
¶
Index ¶
- Variables
- func IsProjectRootComponent(c Component) bool
- func MarshalDepGraphJSON(g *sdk.Graph, target Target, buildOpts BuildOptions, encodeOpts EncodeOptions) ([]byte, error)
- func MarshalJSON(doc *Document, target Target, opts EncodeOptions) ([]byte, error)
- func ToGraph(doc *Document) (*sdk.Graph, error)
- func UnmarshalAutoJSON(data []byte) (*Document, Target, error)
- type BuildOptions
- type Component
- type Dependency
- type Digest
- type Document
- type EOL
- type EncodeOptions
- type License
- type ProjectRoot
- type Provenance
- type Target
- type Vulnerability
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilDocument = errors.New("sbom document is nil") ErrUnsupportedTarget = errors.New("unsupported sbom target") ErrUnsupportedFormat = errors.New("unsupported sbom format") ErrMalformedJSON = errors.New("malformed sbom json") )
var ErrNilGraph = errors.New("dependency graph is nil")
Functions ¶
func IsProjectRootComponent ¶ added in v0.24.0
IsProjectRootComponent reports whether a component is a synthesized pseudo root that stands in for the scanned project rather than a resolved package.
func MarshalDepGraphJSON ¶
func MarshalDepGraphJSON(g *sdk.Graph, target Target, buildOpts BuildOptions, encodeOpts EncodeOptions) ([]byte, error)
MarshalDepGraphJSON converts a dependency graph directly into a target JSON SBOM.
func MarshalJSON ¶
func MarshalJSON(doc *Document, target Target, opts EncodeOptions) ([]byte, error)
MarshalJSON renders the intermediate SBOM document to a target JSON format.
Types ¶
type BuildOptions ¶
type BuildOptions struct {
DocumentName string
DocumentNS string
ToolName string
ToolNames []string
ToolVersion string
Created time.Time
RootComponentID string
SerialNumber string
// ProjectRoot, when non-nil, lets the projection synthesize a primary
// component for the scanned project when the graph has no single root.
ProjectRoot *ProjectRoot
Provenance Provenance
// Lifecycle is the CycloneDX lifecycle phase the document describes
// (for example "pre-build" for source scans, "post-build" for container
// images). Empty omits lifecycle metadata.
Lifecycle string
// Aggregate is the CycloneDX composition completeness declaration
// ("complete", "incomplete", ...). Empty omits the declaration; callers
// must only claim "complete" when nothing filtered or degraded the graph.
Aggregate string
// Registry, when non-nil, supplies matching-stage enrichment (licenses,
// vulnerabilities, CPEs, digests, EOL) resolved by PURL and folded onto
// each component during projection.
Registry *sdk.PackageRegistry
}
BuildOptions controls how a depgraph is projected into the intermediate SBOM model.
type Component ¶
type Component struct {
ID string
Name string
Version string
Scope string
PURL string
Ecosystem string
PackageManager string
Type string
Copyright string
Licenses []License
// Matching-stage enrichment (populated when BuildOptions.Registry is set).
CPEs []string
Digests []Digest
Vulnerabilities []Vulnerability
EOL *EOL
// Where the package came from. A detector asserts at most one of
// ArtifactURL and VCSURL; registry enrichment may then fill VCSURL from a
// resolved source repository when it is empty, so a component enriched
// under --enrich can carry both. VCSRevision only accompanies VCSURL.
// Both are plain absolute http(s) URLs; composing them into a format's
// locator grammar is the encoder's job.
ArtifactURL string
VCSURL string
VCSRevision string
}
Component describes one package surfaced in the intermediate SBOM model.
type Dependency ¶
Dependency describes one package relationship list in the intermediate SBOM model.
type Document ¶
type Document struct {
Name string
Namespace string
Tool string
Tools []string
ToolVersion string
Created time.Time
SerialNumber string
Provenance Provenance
Lifecycle string
Aggregate string
Components []Component
Dependencies []Dependency
Roots []string
}
Document is an intermediate, format-agnostic SBOM representation.
func FromDepGraph ¶
func FromDepGraph(g *sdk.Graph, opts BuildOptions) (*Document, error)
FromDepGraph builds a neutral SBOM document from a dependency DAG.
func UnmarshalJSON ¶
UnmarshalJSON parses a target JSON SBOM into the intermediate document model.
func (*Document) CreatedOrNow ¶
CreatedOrNow returns the document timestamp in UTC, defaulting to the current time.
func (*Document) NameOrDefault ¶
NameOrDefault returns the document name or Bomly's default document name.
func (*Document) NamespaceOrDefault ¶
NamespaceOrDefault returns the document namespace or a generated Bomly namespace.
func (*Document) ToolNamesOrDefault ¶
ToolNamesOrDefault returns all producing tool labels, defaulting to Bomly's tool label.
func (*Document) ToolOrDefault ¶
ToolOrDefault returns the producing tool name or Bomly's default tool label.
type EncodeOptions ¶
type EncodeOptions struct {
Pretty bool
}
EncodeOptions controls JSON output formatting.
type ProjectRoot ¶ added in v0.24.0
ProjectRoot describes the scanned project so the projection can synthesize a primary component when the graph itself has no single root (multiple manifests, multiple ecosystems). Name is required; Version is optional.
type Provenance ¶ added in v0.24.0
type Provenance struct {
Manufacturer string
SecurityContact string
VulnerabilityDisclosureURL string
SupportEnd string
}
Provenance carries optional producer metadata emitted into SBOM documents. The fields map onto EU CRA transparency expectations (manufacturer identification, security contact, coordinated disclosure, support period) but are format-agnostic and always optional.
func (Provenance) Empty ¶ added in v0.24.0
func (p Provenance) Empty() bool
Empty reports whether no provenance field is set.
type Target ¶
type Target string
Target identifies an SBOM wire format target.
func DetectJSONTarget ¶
DetectJSONTarget identifies the supported SBOM JSON format represented by data.
type Vulnerability ¶
type Vulnerability struct {
ID string
Source string
Severity string
Score *float64
Vector string
Method string
CWEs []int
FixedVersions []string
Advisories []string
Description string
// Recommendation is remediation guidance derived from known fixed
// versions (CycloneDX `recommendation`; SPDX 2.3 has no equivalent).
Recommendation string
}
Vulnerability is a format-agnostic projection of one matching-stage advisory affecting a component. Encoders map it to the format's native representation (CycloneDX vulnerabilities, SPDX SECURITY external references).