From 62b53429289d6cc6884b111256588150e3fed308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Comb=C3=BCchen?= Date: Tue, 14 May 2024 13:52:27 +0200 Subject: [PATCH] feat(1.6): add BOM.Definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #158. Signed-off-by: Maximilian Combüchen --- convert.go | 3 +++ cyclonedx.go | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/convert.go b/convert.go index 6acec2f..806f0d1 100644 --- a/convert.go +++ b/convert.go @@ -52,6 +52,9 @@ func (b *BOM) convert(specVersion SpecVersion) { b.Annotations = nil b.Formulation = nil } + if specVersion < SpecVersion1_6 { + b.Definitions = nil + } if b.Metadata != nil { if specVersion < SpecVersion1_3 { diff --git a/cyclonedx.go b/cyclonedx.go index 9afabe0..76fa1af 100644 --- a/cyclonedx.go +++ b/cyclonedx.go @@ -91,6 +91,7 @@ type BOM struct { Vulnerabilities *[]Vulnerability `json:"vulnerabilities,omitempty" xml:"vulnerabilities>vulnerability,omitempty"` Annotations *[]Annotation `json:"annotations,omitempty" xml:"annotations>annotation,omitempty"` Formulation *[]Formula `json:"formulation,omitempty" xml:"formulation>formula,omitempty"` + Definitions *Definitions `json:"definitions" xml:"definitions,omitempty"` } func NewBOM() *BOM { @@ -280,6 +281,10 @@ const ( DataFlowUnknown DataFlow = "unknown" ) +type Definitions struct { + Standards *[]StandardDefinition `json:"standards,omitempty" xml:"standards>standard,omitempty"` +} + type Dependency struct { Ref string `json:"ref"` Dependencies *[]string `json:"dependsOn,omitempty"` @@ -498,6 +503,33 @@ const ( IssueTypeSecurity IssueType = "security" ) +type JSFSignature struct { + *JSFSigner `json:"-" xml:"-"` + + Signers *[]JSFSigner `json:"signers,omitempty" xml:"-"` + Chain *[]JSFSigner `json:"chain,omitempty" xml:"-"` +} + +type JSFSigner struct { + Algorithm string `json:"algorithm" xml:"-"` + KeyID string `json:"keyId,omitempty" xml:"-"` + PublicKey JSFPublicKey `json:"publicKey,omitempty" xml:"-"` + CertificatePath *[]string `json:"certificatePath,omitempty" xml:"-"` + Excludes *[]string `json:"excludes,omitempty" xml:"-"` + Value string `json:"value" xml:"-"` +} + +type JSFPublicKey struct { + KTY string `json:"kty,omitempty" xml:"-"` + + CRV string `json:"crv,omitempty" xml:"-"` + X string `json:"x,omitempty" xml:"-"` + Y string `json:"y,omitempty" xml:"-"` + + N string `json:"n,omitempty" xml:"-"` + E string `json:"e,omitempty" xml:"-"` +} + type License struct { BOMRef string `json:"bom-ref,omitempty" xml:"bom-ref,attr,omitempty"` ID string `json:"id,omitempty" xml:"id,omitempty"` @@ -824,6 +856,39 @@ const ( SpecVersion1_6 // 1.6 ) +type StandardDefinition struct { + BOMRef string `json:"bom-ref,omitempty" xml:"bom-ref,attr,omitempty"` + Name string `json:"name,omitempty" xml:"name,omitempty"` + Version string `json:"version,omitempty" xml:"version,omitempty"` + Description string `json:"description,omitempty" xml:"description,omitempty"` + Owner string `json:"owner,omitempty" xml:"owner,omitempty"` + + Requirements *[]StandardRequirement `json:"requirements,omitempty" xml:"requirements>requirement,omitempty"` + Levels *[]StandardLevel `json:"levels,omitempty" xml:"levels>level,omitempty"` + ExternalReferences *[]ExternalReference `json:"externalReferences,omitempty" xml:"externalReferences,omitempty"` + Signature *JSFSignature `json:"signature,omitempty" xml:"-"` +} + +type StandardRequirement struct { + BOMRef string `json:"bom-ref,omitempty" xml:"bom-ref,attr,omitempty"` + Identifier string `json:"identifier,omitempty" xml:"identifier,omitempty"` + Title string `json:"title,omitempty" xml:"title,omitempty"` + Text string `json:"text,omitempty" xml:"text,omitempty"` + Descriptions *[]string `json:"descriptions,omitempty" xml:"descriptions>description,omitempty"` + OpenCRE *[]string `json:"openCre,omitempty" xml:"openCre,omitempty"` + Parent string `json:"parent,omitempty" xml:"parent,omitempty"` + Properties *[]Property `json:"properties,omitempty" xml:"properties>property,omitempty"` + ExternalReferences *[]ExternalReference `json:"externalReferences,omitempty" xml:"externalReferences>reference,omitempty"` +} + +type StandardLevel struct { + BOMRef string `json:"bom-ref,omitempty" xml:"bom-ref,attr,omitempty"` + Identifier string `json:"identifier,omitempty" xml:"identifier,omitempty"` + Title string `json:"title,omitempty" xml:"title,omitempty"` + Description string `json:"description,omitempty" xml:"description,omitempty"` + Requirements *[]string `json:"requirements,omitempty" xml:"requirements>requirement,omitempty"` +} + type SWID struct { Text *AttachedText `json:"text,omitempty" xml:"text,omitempty"` URL string `json:"url,omitempty" xml:"url,attr,omitempty"`