-
Notifications
You must be signed in to change notification settings - Fork 126
Support SPDX expressions with operators in allow/deny license lists #916
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
Conversation
This change updates license validation to support full SPDX expressions (such as 'EPL-1.0 AND LGPL-2.1') in both allow-lists and deny-lists. This enables the action to correctly validate packages that declare multiple licenses using SPDX conjunctions like AND/OR, which are common in complex open-source projects. Previously, only simple license identifiers were supported, which caused multi-licensed packages to be improperly flagged as invalid even when they matched the intent of the allow-list. The new logic uses `spdx.satisfies()` to evaluate whether a package’s declared license satisfies any expression in the allow/deny list, and comprehensive tests have been added to verify behavior for various SPDX combinations. This improves compatibility with projects using compound SPDX license expressions and ensures more accurate license policy enforcement.
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.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
I added a small repository to highlight my problem https://github.com/jebeaudet/dep-review-bug-example. You'll find there one PR that has the 3 licenses of logback-core individually so you can see the failure jebeaudet/dep-review-bug-example#1. The other PR has the proper SPDX expression in the allow-list so you can see that the dependency-review-action does not allow SPDX expressions in the allow-list jebeaudet/dep-review-bug-example#2. Remember that we don't see the error because exceptions are swallowed by the action here. The exception message that would be printed can be found here. |
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.
From what I understand, this change brings us back to a working implementation and fixes the issues introduced in v4.3.4.
Thanks!!!
@jebeaudet Hi, thank you so much for contributing this change! I'm working on validating it to see if we can make a new release that will hopefully address the problem for everyone. To make sure I understand correctly: the goal is that an I am still seeing a failure though, when using your test repo and running the workflow @ main to get the most recent code - check out: |
@ahpook Thanks for reviewing this. It was not super clear in my description, but You can see how my patches allow this here : jebeaudet/dep-review-bug-example#4 GPT answer on dual MIT AND Apache-2.0 licensed projectFrom a license compliance perspective in a company, is accepting the licenses MIT and Apache-2.0 separately the same as allowing a dual licensed project that would have a spdx MIT AND Apache-2.0?From a license compliance perspective, there is an important distinction between accepting projects licensed under MIT or Apache-2.0 individually, and accepting a project that is dual-licensed under MIT AND Apache-2.0. Here’s the breakdown:
This means:
This means: This is different from: ⸻ Compliance Implications: ⸻ Summary: No, accepting MIT and Apache-2.0 separately is not the same as accepting a dual-licensed project with MIT AND Apache-2.0. You need to review and explicitly allow the combination. |
@jebeaudet i see, thanks for the explanation. i was basing my expectations on the comments from @jcasner in #263:
But your (and ChatGPT's 😄 ) reasoning makes sense. I'll get back and do more testing on this. |
Yea, supporting |
I've confirmed with my legal team internally that my answer, and chatgpt's, is correct. |
This change updates license validation to support full SPDX expressions (such as 'EPL-1.0 AND LGPL-2.1') in both allow-lists and deny-lists. This enables the action to correctly validate packages that declare multiple licenses using SPDX conjunctions like AND/OR, which are common in the field.
One concrete example is
logback-core
which is licensed asEPL-1.0 AND LGPL-2.1 AND LGPL-2.1-only
source. With the latest version of this action, it is not possible to have a SPDX expression in the allow list which makes this license impossible to accept. Also, declaring the 3 licenses as allowed individually (allow: ['EPL-1.0', 'LGPL-2.1', 'LGPL-2.1-only']
) does not work either because satisfiesAny does not consider it as valid.The new logic uses
spdx.satisfies()
to evaluate whether a package’s declared license satisfies any expression in the allow/deny list, and comprehensive tests have been added to verify behavior for various SPDXcombinations.
This is a follow up of #915 after we upgraded our internal license check pipeline to the latest version which made me realize this bug/limitation.
fixes #897 #907