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

fix(cyclonedx): fix unmarshal for licenses #5828

Conversation

DmitriyLewen
Copy link
Contributor

@DmitriyLewen DmitriyLewen commented Dec 27, 2023

Description

After #4941 we use Licenses.License.Name field for marshal licenses.
But we still check Licenses.Expression when unmarshalling.

Add unmarshalling support for all CycloneDX supported fields. - Licenses.License.ID, Licenses.License.Name and Licenses.Expression.

Also update the testdata (cyclonedx files created using Trivy).

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@DmitriyLewen DmitriyLewen self-assigned this Dec 27, 2023
@DmitriyLewen DmitriyLewen changed the title feat(cyclonedx): add support for all license fields fix(cyclonedx): fix unmarshal for licenses Dec 27, 2023
@DmitriyLewen DmitriyLewen marked this pull request as ready for review December 27, 2023 09:04

// getPackageLicenses checks all supported license fields and returns a list of licenses.
// https://cyclonedx.org/docs/1.5/json/#components_items_licenses
func getPackageLicenses(l *cdx.Licenses) []string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: A more detailed function name is preferred, as get does not contain much information in most cases.

Suggested change
func getPackageLicenses(l *cdx.Licenses) []string {
func parsePackageLicenses(l *cdx.Licenses) []string {

Even for getters, GetXXX is not common in Go.
https://go.dev/doc/effective_go#Getters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in a79bcd4

@knqyf263 knqyf263 added this pull request to the merge queue Dec 29, 2023
Merged via the queue into aquasecurity:main with commit b3d516e Dec 29, 2023
12 checks passed
@DmitriyLewen DmitriyLewen deleted the fix/cyclonedx-support-all-license-fields branch January 9, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants