CycloneDX / sbom-utility

Utility that provides an API platform for validating, querying and managing BOM data
Apache License 2.0
93 stars 13 forks source link

TODO: Change Formulation and ModelCard schemas to use pointers #79

Open mrutkows opened 6 months ago

mrutkows commented 6 months ago

The CycloneDX schema file:

/Users/Matt_1/Projects/CycloneDX/sbom-utility/schema/cyclonedx_formulation.go

defines all the structures used for "formulation" which was added in v1.5; however, these structs should be updated to use pointers to structs in all cases to improve performance during JSON Marshal (decoding).

The same should be done for the added ModelCard data (as part of the Component type):

/Users/Matt_1/Projects/CycloneDX/sbom-utility/schema/cyclonedx_modelcard.go

mohitsethia commented 2 months ago

Hi, I would like to contribute to this issue. Just to confirm that we need to move to using pointer to struct in all the places in cyclonedx_formulation.go, right? And in cyclonedx_modelcard.go there is only 1 place where pointer to struct is not used, otherwise all the places uses pointer, should I change CDXComponentData to *CDXComponentData?

type CDXDataset struct {
    CDXComponentData
    Ref *CDXRefLinkType `json:"ref,omitempty" cdx:"+1.5"` // v1.5
}
mrutkows commented 2 months ago

@mohitsethia Hi! Sorry that it took me so long to respond, but July was a very busy month inside my company with a shift in my job role to support AI GPU software stack which has a steep learning curve as well as being on vacation. Would very much like to replace all structure (bindings) to use pointers as the utility now supports "write" (output) for some new commands. I tried very hard to do so for the latest release, but you found a struct member I missed under the model card structs):

https://github.com/CycloneDX/sbom-utility/blob/b538cf9e4c2e498f77b5856892ccb9891300f2e1/schema/cyclonedx_modelcard.go#L64

Please do submit a PR with the fix (and believe it should pass existing functional tests as we do not have any specific to testing "update"/change of that field)