licenses: support compound SPDX expressions in the allow list#853
Open
MavenRain wants to merge 1 commit into
Open
licenses: support compound SPDX expressions in the allow list#853MavenRain wants to merge 1 commit into
MavenRain wants to merge 1 commit into
Conversation
Closes EmbarkStudios#827. Each entry of the `[licenses] allow` list may now be either a single SPDX licensee (the historical shape) or a compound SPDX expression with OR/AND operators. A compound entry covers a dependency only when the dep's expression remains satisfiable under every interpretation that satisfies the compound entry, i.e. for every licensing choice the project commits to offering its downstream. This is strictly stronger than the per-licensee semantics that the existing flat-list shape provides. Concretely, allow `GPL-2.0-only OR GPL-3.0-only` covers a dep licensed `GPL-2.0-only OR GPL-3.0-only` but rejects a dep licensed `GPL-2.0-only` alone, since incorporating the latter would force the project to drop the `GPL-3.0-only` option from the compound it commits to its users. Implementation: enumerate the 2^n subsets of the compound allow's requirements (n capped at 16), filter to subsets in which the allow expression evaluates true, and verify the dep expression also evaluates true in every such world. Limitation: `spdx::Licensee::satisfies` does not currently relate the canonical-form identifiers `GPL-2.0-only` and `GPL-2.0-or-later`, so a dep licensed `GPL-2.0-or-later` is not yet covered by an allow expression that only mentions the `-only` forms. Pinned as a regression guard in tests; lifting the limitation is upstream `spdx` work. Tests: six unit tests on the coverage helper covering the motivating compound match, lone-disjunct rejection, unrelated AND-dep rejection, AND covers OR-dep, single-licensee passthrough, and the or-later limitation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #827.
Each entry of the
[licenses] allowlist may now be either asingle SPDX licensee (the historical shape) or a compound SPDX
expression with OR/AND operators. A compound entry covers a
dependency only when the dep's expression remains satisfiable
under every interpretation that satisfies the compound entry,
i.e. for every licensing choice the project commits to offering
its downstream. This is strictly stronger than the per-licensee
semantics that the existing flat-list shape provides.
Concretely, allow
GPL-2.0-only OR GPL-3.0-onlycovers a deplicensed
GPL-2.0-only OR GPL-3.0-onlybut rejects a deplicensed
GPL-2.0-onlyalone, since incorporating the latterwould force the project to drop the
GPL-3.0-onlyoption fromthe compound it commits to its users.
Implementation: enumerate the 2^n subsets of the compound
allow's requirements (n capped at 16), filter to subsets in
which the allow expression evaluates true, and verify the dep
expression also evaluates true in every such world.
Limitation:
spdx::Licensee::satisfiesdoes not currentlyrelate the canonical-form identifiers
GPL-2.0-onlyandGPL-2.0-or-later, so a dep licensedGPL-2.0-or-laterisnot yet covered by an allow expression that only mentions the
-onlyforms. Pinned as a regression guard in tests; liftingthe limitation is upstream
spdxwork.Tests: six unit tests on the coverage helper covering the
motivating compound match, lone-disjunct rejection, unrelated
AND-dep rejection, AND covers OR-dep, single-licensee
passthrough, and the or-later limitation.