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: return ecosyste.ms license based on package version #88

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

paulrosca-snyk
Copy link
Contributor

When enriching with ecosyste.ms, fetch the license based on the package version.

Closes #87

Comment on lines 56 to 59
// Ecosyste.ms has a purl based API, but unfortunately slower
// so we break the purl down to registry and name values locally
// params := packages.LookupPackageParams{Purl: &p}
// resp, err := client.LookupPackageWithResponse(context.Background(), &params)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we remove this? including the comment about the purl api? i don't find it particularly useful 😄

expression := data.NormalizedLicenses[0]
func enrichCDXLicense(comp *cdx.Component, data *packages.Version) {
if data.Licenses != nil {
if *data.Licenses != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks a bit like a red flag. don't we have data.NormalizedLicenses on the package version response? this change would mean that we are potentially enriching with unsanitized data. e.g. MIT,Apache-2.0 is not a valid SPDX license expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like the ecosyste.ms response for a specific package version doesn't have a normalised licenses field, no

Copy link
Collaborator

Choose a reason for hiding this comment

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

I raised an issue with ecosyste.ms about this here: ecosyste-ms/packages#960

Copy link
Collaborator

Choose a reason for hiding this comment

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

@paulrosca-snyk could we move forward with this approach, but strings.Split() the value and build an SPDX license expression with strings.Join()? The current behaviour is to concatenate with an OR, but we have an open issue on this and should switch to AND.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mcombuechen definitely, but are we sure we want to proceed with the AND change, it doesn't seem like it will fix the issue, just change it in the other direction (i.e we'll be reporting OR clauses incorrectly as AND, but maybe that's better than the current behaviour?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

i.e we'll be reporting OR clauses incorrectly as AND

How so? Are the (unnormalized) license lists from ecosyste.ms OR or AND?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my understanding they can be either and we just don't get this information back from ecosyste.ms (assuming they even have it stored)

@paulrosca-snyk paulrosca-snyk force-pushed the fix/ecosyste.ms-licenses branch from a3816fb to 9006bf8 Compare December 17, 2024 14:39
@paulrosca-snyk paulrosca-snyk force-pushed the fix/ecosyste.ms-licenses branch from 9006bf8 to e6b1d52 Compare December 17, 2024 14:41
@paulrosca-snyk paulrosca-snyk marked this pull request as ready for review December 18, 2024 09:00
@paulrosca-snyk paulrosca-snyk requested review from garethr and a team as code owners December 18, 2024 09:00
@paulrosca-snyk paulrosca-snyk merged commit bc55e4d into main Dec 18, 2024
8 checks passed
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.

Parlay doesn't seem to respect version number when determining license
2 participants