Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for both the v1.5 component evidence identity and the v1.6 array of componentIdentityEvidence #92

Open
mrutkows opened this issue May 8, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed priority-high

Comments

@mrutkows
Copy link
Contributor

mrutkows commented May 8, 2024

TODO: figure out how to support both the v1.5 "Identity" type (a singleton of an anonymous type) vs. the v1.6 "identity" which is an array of named type (i.e., componentIdentityEvidence):

type CDXComponentEvidence struct {
	Licenses  *[]CDXLicense   `json:"licenses,omitempty" cdx:"added:1.3"`
	Copyright *[]CDXCopyright `json:"copyright,omitempty" cdx:"added:1.3"`
	Identity  interface{}     `json:"identity,omitempty" cdx:"added:1.5,changed:1.6"`
...
}

where these struct types would be referenced:

type CDXComponentIdentityEvidence struct {
	Field      string       `json:"field,omitempty" cdx:"added:1.5"`
	Confidence float64      `json:"confidence,omitempty" cdx:"added:1.5"`
	Methods    *[]CDXMethod `json:"methods,omitempty" cdx:"added:1.5"`
	Tools      *[]string    `json:"tools,omitempty" cdx:"added:1.5"`
}

// v1.5: added
type CDXMethod struct {
	Technique  string  `json:"technique,omitempty" cdx:"added:1.5"`
	Confidence float64 `json:"confidence,omitempty" cdx:"added:1.5"`
	Value      string  `json:"value,omitempty" cdx:"added:1.5"`
}
@mrutkows
Copy link
Contributor Author

mrutkows commented May 8, 2024

See issue #91

for a similar problem...

@mrutkows
Copy link
Contributor Author

mrutkows commented May 9, 2024

Note: we need to create a custom marshaler as had to done with "Tools" like below:

	// v1.5 allows tools to be either an array of (legacy) tool object or a new tool object
	// TODO: author test for legacy (array) object vs. new tool object
	if IsInterfaceASlice(value.Tools) {
		arrayTools, ok := value.Tools.([]CDXLegacyCreationTool)
		if ok && len(arrayTools) > 0 {
			temp["tools"] = arrayTools
		}
	} else {
		tools, ok := value.Tools.(CDXCreationTools)
		if ok {
			temp["tools"] = tools
		}
	}

@mrutkows mrutkows added enhancement New feature or request help wanted Extra attention is needed priority-high labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed priority-high
Projects
None yet
Development

No branches or pull requests

1 participant