-
Notifications
You must be signed in to change notification settings - Fork 9
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 bug where GPL-2.0 failed to match GPL-2.0-only #42
Conversation
// first, second | ||
return nodes.licensesExactlyEqual() | ||
// first, second requires both to be in same range group | ||
return nodes.rangesEqual() |
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.
This is the change that fixes the bug. It makes sure that if neither license hasPlus
, then the licenses must be in the same range (e.g. GPL-2.0
and GPL-2.0-only
are in the same range).
Previously, it checked that the licenses were exactly the same. (e.g. GPL-2.0
!= GPL-2.0-only
). Since these should be treated as equivalent, but aren't literally the same, it led to the bug.
add/refine function documentation
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.
LGTM! I asked if exceptions are handled elsewhere and it certainly looks to be the case from the test that appears at the very end of the PR view (satisfies_test.go
line 119). Great that you were able to spot this problem!
@@ -1,5 +1,13 @@ | |||
package spdxexp | |||
|
|||
// The compare methods determine if two ranges are greater than, less than or equal within the same license group. |
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.
very helpful comment!
@@ -238,7 +256,7 @@ func (nodes *nodePair) rangesAreCompatible() bool { | |||
// When both licenses allow later versions (i.e. hasPlus==true), being in the same license | |||
// group is sufficient for compatibility, as long as, any exception is also compatible | |||
// Example: All Apache licenses (e.g. Apache-1.0, Apache-2.0) are in the same license group | |||
return sameLicenseGroup(firstRange, secondRange) && nodes.exceptionsAreCompatible() | |||
return sameLicenseGroup(firstRange, secondRange) |
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 assume exception compatibility is still handled elsewhere?
if !nodes.firstNode.isLicense() || !nodes.secondNode.isLicense() { | ||
return false | ||
} | ||
if !nodes.exceptionsAreCompatible() { |
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.
@dangoor This is the check for exceptions. It is handled before checking ranges.
Description
Testing the policy service identified a bug where
GPL-2.0
was not allowed forGPL-2.0-only
. This PR does some cleanup onnode.go
to lay out the comparisons more clearly and fix the bug.Changes
Most of the changes are adding test-cases that would have caught the bug. The only substantive changes are in the range checks in
node.go
. There is one minor change tocompareEQ()
to short cut the comparison if the two licenses are the same.has_plus==true
has_plus