Skip to content

fix(validation): support '+' or-later operator on license references (#887) - #909

Open
ShivanshhhG wants to merge 1 commit into
spdx:mainfrom
ShivanshhhG:fix-887-or-later-license-operator
Open

ShivanshhhG wants to merge 1 commit into
spdx:mainfrom
ShivanshhhG:fix-887-or-later-license-operator

Conversation

@ShivanshhhG

Copy link
Copy Markdown

Description

Per the SPDX specification (Clause 8.1.3), an SPDX-listed license short-form identifier, user-defined license reference (LicenseRef-[idstring]), or external license reference can be followed by a + operator indicating "or any later version" (e.g. Apache-1.0+, Apache-2.0+, LicenseRef-custom+).

Currently, when spdx_licensing.validate validates a license expression containing a valid license with a + operator, the symbol is reported as an unknown license key (because the known license keys in the license list match base keys without the operator suffix). Consequently, validate_license_expression flags legitimate expressions like Apache-1.0+ as unrecognized license references.

Changes

  • Updated validate_license_expression in src/spdx_tools/spdx/validation/license_expression_validator.py to recognize when an invalid symbol ends with +. If the base symbol stripped of + is a known non-exception SPDX license or present in the document's extracted_licensing_info, it is accepted as valid.
  • Extended unit tests in tests/spdx/validation/test_license_expression_validator.py covering standard licenses with + (Apache-1.0+, Apache-2.0+, Apache-1.0+ or MIT), extracted licenses with + (LicenseRef-... and external references), while verifying invalid licenses (InvalidLicense+) and exception symbols with + (LLVM-exception+) remain correctly rejected.

Fixes #887

…pdx#887)

According to the SPDX specification, any SPDX-listed license short-form
identifier, user-defined license reference (LicenseRef-), or external
license reference can be followed by a '+' operator indicating 'or any later
version'.

Currently, when a license expression contains a license identifier with '+'
(such as 'Apache-1.0+'), spdx_licensing.validate reports the token as an
unknown license key because the underlying license list contains base keys
without the operator suffix. Consequently, validate_license_expression falsely
reports valid expressions as unrecognized license references.

Support the '+' operator in validate_license_expression by checking whether
the base token (stripped of '+') resolves to a known SPDX license (non-exception)
or a defined license reference.

Fixes spdx#887

Signed-off-by: SHIVANSH-ux-ys <[email protected]>

This branch has not been deployed

No deployments
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.

Apache-1.0+ not recognized as a valid license

1 participant