Skip to content

Canonical form of composite license expressions #1462

Description

@bact

From https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/:

The license expression

LGPL-2.1-only OR MIT

is identical to

MIT OR LGPL-2.1-only

but it does not say what is canonical form of the expression.

LGPL-2.1-only OR MIT or MIT OR LGPL-2.1-only ?

Should we need to specify that?

The use cases are

  1. license matching by naive string matching, without license expression normalization (normalized by a smart producer, consumers can be relatively dumb)
  2. deterministic hash of an SBOM with a license information that contain composite license expressions

Or should we explicitly say that, don't reorder it since the order of licenses may indicate the author's preference (which the license expression is not captured), and leave the order as-is?

--

Follow up question if we think license expression canonicalization is useful:

How to order it?

  1. By straightforward alphabetical order (using codepoint values of ALPHA, DIGIT, etc in the ABNF).
  2. By presence in the SPDX License List then by alphabetical order.

Given a license expression:

MIT AND LicenseRef-My-License AND Apache-2.0

(1) will give:

Apache-2.0 AND LicenseRef-My-License AND MIT

(L comes before M)

while (2) will give:

Apache-2.0 AND MIT AND LicenseRef-My-License

(any LicenseRef-* will come after the listed licenses)

Which ordering is preferred?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions