From ec23ea2c79cea23d75807f1bf1324e8f352a685b Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 8 Jan 2025 23:25:42 -0800 Subject: [PATCH] EXTENDED_LICENSE_CLASSIFIERS for non-SPDX license validation Add support for validating licenses that aren't in the official SPDX license list but are commonly used in our codebase. These are the values output by the license classifier. This introduces a new EXTENDED_LICENSE_CLASSIFIERS set that contains these custom license identifiers, organized by restrictiveness level similar to ALLOWED_SPDX_LICENSES. Bug: 379977497 Change-Id: I18e0b38572ee4df783573ea338b55ac237d8134d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6107859 Reviewed-by: Rachael Newitt Commit-Queue: Jordan Brown --- metadata/fields/custom/license.py | 4 +- metadata/fields/custom/license_allowlist.py | 45 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/metadata/fields/custom/license.py b/metadata/fields/custom/license.py index bd3e2d131..bf1e161fd 100644 --- a/metadata/fields/custom/license.py +++ b/metadata/fields/custom/license.py @@ -18,7 +18,7 @@ sys.path.insert(0, _ROOT_DIR) import metadata.fields.field_types as field_types import metadata.fields.util as util import metadata.validation_result as vr -from metadata.fields.custom.license_allowlist import ALLOWED_SPDX_LICENSES +from metadata.fields.custom.license_allowlist import ALLOWED_LICENSES def process_license_value(value: str, @@ -57,7 +57,7 @@ def is_license_allowlisted(value: str) -> bool: """Returns whether the value is in the allowlist for license types. """ - return value in ALLOWED_SPDX_LICENSES + return value in ALLOWED_LICENSES class LicenseField(field_types.SingleLineTextField): diff --git a/metadata/fields/custom/license_allowlist.py b/metadata/fields/custom/license_allowlist.py index 0a43995ed..4fb6e1a1e 100644 --- a/metadata/fields/custom/license_allowlist.py +++ b/metadata/fields/custom/license_allowlist.py @@ -65,3 +65,48 @@ ALLOWED_SPDX_LICENSES = frozenset([ "MPL-1.1", "MPL-2.0", ]) + +# These are licenses that are not in the SPDX license list, but are identified +# by the license classifier. +EXTENDED_LICENSE_CLASSIFIERS = frozenset([ + # unencumbered. + "AhemFont", + "Android-SDK", + "LZMA", + "SPL-SQRT-FLOOR", + "public-domain-md5", + # permissive. + "LicenseRef-AMSFonts-2.2", + "test_fonts", + # notice. + "Apache-with-LLVM-Exception", + "Apache-with-Runtime-Exception", + "BSD-2-Clause-Flex", + "BSD-3-Clause-OpenMPI", + "BSD-4-Clause-Wasabi", + "Bitstream", + "CERN", + "Caffe", + "Entenssa", + "FFT2D", + "GIF-Encoder", + "GNU-All-permissive-Copying-License", + "IBM-DHCP", + "JsonCPP", + "Khronos", + "Libpng-2.0", + "LicenseRef-OpenGLUT", + "LicenseRef-base64", + "LicenseRef-takuya-ooura", + "Punycode", + "SSLeay", + "WebM-Project-Patent", + "X11-Lucent", + "cURL", + "dso", + "getopt", + "pffft", + "zxing", +]) + +ALLOWED_LICENSES = ALLOWED_SPDX_LICENSES | EXTENDED_LICENSE_CLASSIFIERS