-
Notifications
You must be signed in to change notification settings - Fork 688
fix: [WIP]introduce Component Type Unknown in Cyclone DX for better conversion #3833
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
base: main
Are you sure you want to change the base?
Conversation
along with 'application' and 'library' Signed-off-by: Yuntao Hu <[email protected]>
Signed-off-by: Yuntao Hu <[email protected]>
Signed-off-by: Yuntao Hu <[email protected]>
Signed-off-by: Yuntao Hu <[email protected]>
8b66984
to
9d1fa05
Compare
Signed-off-by: Yuntao Hu <[email protected]>
Signed-off-by: Yuntao Hu <[email protected]>
Troubleshoot: The so-called error line 193 and the test case FOLLOW UP: This is because some implicit test case for the empty string here: line. So I have to compromise a bit, but I think crashing for an SBOM with source type being empty is reasonable. |
Signed-off-by: Yuntao Hu <[email protected]>
syft/source/unknown_metadata.go
Outdated
Description string `json:"description,omitempty" yaml:"description,omitempty"` | ||
PackageURL string `json:"purl" yaml:"purl"` | ||
Licenses *cyclonedx.Licenses `json:"licenses,omitempty" xml:"licenses,omitempty"` | ||
ExternalRef *[]cyclonedx.ExternalReference `json:"externalRef,omitempty" yaml:"externalRef,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't be able to use CycloneDX data structures directly in public Syft APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll take it carefully. So these data structures needs to be tailored to store as much important infos as it can.
What about the following scheme?
type UnknownMetadata struct {
......
Licenses *[]LicenseChoice `json:"licenses,omitempty" xml:"licenses,omitempty"`
ExternalRef *[]ExternalReference `json:"externalRef,omitempty" yaml:"externalRef,omitempty"`
Authors *[]OrganizationalContact `json:"authors,omitempty" xml:"authors>author,omitempty"`
}
type OrganizationalContact struct {
Name string `json:"name,omitempty" xml:"name,omitempty"`
}
type ExternalReference struct {
URL string `json:"url" xml:"url"`
Hashes *[]Hash `json:"hashes,omitempty" xml:"hashes>hash,omitempty"`
Type string `json:"type" xml:"type,attr"`
}
type Hash struct {
Algorithm string `json:"alg" xml:"alg,attr"`
Value string `json:"content" xml:",chardata"`
}
type LicenseChoice struct {
License *License `json:"license,omitempty" xml:"-"`
}
type License struct {
ID string `json:"id,omitempty" xml:"id,omitempty"`
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VictorHuu @kzantow sorry to push this but could you take a look into this as it would help us with the syft convert issue a lot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just took some time and had a look and the initial concern that the cyclonedx types would have been used directly should be fixed. @kzantow could you take a look at this again? we currently use some workarounds to fix the linked issues and I would love to get rid of them 😅
Signed-off-by: Yuntao Hu <[email protected]>
Signed-off-by: Yuntao Hu <[email protected]>
Description
ComponentType
,Unknown
is used to prevent crash during conversion between Cyclone DX and other formats.ComponentType
like container and file, other types defined in Cyclone DX Spec should also be included. Since most of these types share almost the same structure, a 'Unknown' type is enough to handle these types that Syft doesn't support now.I'm not sure whether the solution is good or not,but I think a bit lossy information like 'application/library' to 'unknown' is acceptable.Otherwise,if we add types for every Component Type, quite a lot of even overwhelming test cases have to be updated.
Follow up: It seems that there are lots of issues related to the conversion, so this PR attempts to make the minimum changes in order not to introduce catastrophic results.
Type of change
Checklist: