diff --git a/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_10.RULE b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_10.RULE new file mode 100644 index 00000000000..e414b0c191c --- /dev/null +++ b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_10.RULE @@ -0,0 +1,6 @@ +--- +license_expression: lgpl-2.1 OR mpl-1.1 +is_license_tag: yes +--- + +license: LGPL/MPL \ No newline at end of file diff --git a/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_11.RULE b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_11.RULE new file mode 100644 index 00000000000..a16bceb8d62 --- /dev/null +++ b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_11.RULE @@ -0,0 +1,6 @@ +--- +license_expression: lgpl-2.1 OR mpl-1.1 +is_license_notice: yes +--- + +dual-licensed under the LGPL and the MPL. \ No newline at end of file diff --git a/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_12.RULE b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_12.RULE new file mode 100644 index 00000000000..e59f3365bd4 --- /dev/null +++ b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_12.RULE @@ -0,0 +1,9 @@ +--- +license_expression: lgpl-2.1 OR mpl-1.1 +is_license_notice: yes +--- + +Cairo is free software and is available to be redistributed and/or +modified under the terms of either the GNU Lesser General Public +License (LGPL) version 2.1 or the Mozilla Public License (MPL) version +1.1. \ No newline at end of file diff --git a/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_13.RULE b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_13.RULE new file mode 100644 index 00000000000..f0892a08e04 --- /dev/null +++ b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_13.RULE @@ -0,0 +1,25 @@ +--- +license_expression: lgpl-2.1 OR mpl-1.1 +is_license_notice: yes +referenced_filenames: + - COPYING-LGPL-2.1 + - COPYING-MPL-1.1 +--- + +is free software. + +Every source file in the implementation of is available to be +redistributed and/or modified under the terms of either the GNU Lesser +General Public License (LGPL) version 2.1 or the Mozilla Public +License (MPL) version 1.1. Some files are available under more +liberal terms, but we believe that in all cases, each file may be used +under either the LGPL or the MPL. + +See the following files in this directory for the precise terms and +conditions of either license: + + COPYING-LGPL-2.1 + COPYING-MPL-1.1 + +Please see each file in the implementation for copyright and licensing +information, (in the opening comment of each file). \ No newline at end of file diff --git a/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_14.RULE b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_14.RULE new file mode 100644 index 00000000000..ff2c9252545 --- /dev/null +++ b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_14.RULE @@ -0,0 +1,10 @@ +--- +license_expression: lgpl-2.1 OR mpl-1.1 +is_license_reference: yes +referenced_filenames: + - COPYING +--- + +* The code in the patch is copyright under the LGPL, but + * has been relicensed under the LGPL/MPL dual license for inclusion + * into (see COPYING). \ No newline at end of file diff --git a/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_7.RULE b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_7.RULE new file mode 100644 index 00000000000..19e418b33a2 --- /dev/null +++ b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_7.RULE @@ -0,0 +1,11 @@ +--- +license_expression: lgpl-2.1 OR mpl-1.1 +is_license_notice: yes +referenced_filenames: + - COPYING +--- + +Cairo is released under the terms of either the {{GNU Lesser General Public +License version 2.1}}, or the terms of the {{Mozilla Public License version 1.1}}. + +See the [`COPYING`](./COPYING) document for more information. \ No newline at end of file diff --git a/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_8.RULE b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_8.RULE new file mode 100644 index 00000000000..a980bc0b1b7 --- /dev/null +++ b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_8.RULE @@ -0,0 +1,7 @@ +--- +license_expression: lgpl-2.1 OR mpl-1.1 +is_license_notice: yes +--- + +Cairo is released under the terms of either the {{GNU Lesser General Public +License version 2.1}}, or the terms of the {{Mozilla Public License version 1.1}} \ No newline at end of file diff --git a/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_9.RULE b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_9.RULE new file mode 100644 index 00000000000..26f336a734e --- /dev/null +++ b/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_9.RULE @@ -0,0 +1,11 @@ +--- +license_expression: lgpl-2.1 OR mpl-1.1 +is_license_reference: yes +--- + +New license: LGPL/MPL + +The most significant news with this release is that the license of +cairo has changed. It is now dual-licensed under the LGPL and the +MPL. For details see the COPYING file as well as COPYING-LGPL-2.1 and +COPYING-MPL-1.1. \ No newline at end of file diff --git a/src/licensedcode/detection.py b/src/licensedcode/detection.py index 34cbe582e63..1def5f9e526 100644 --- a/src/licensedcode/detection.py +++ b/src/licensedcode/detection.py @@ -60,19 +60,19 @@ def logger_debug(*args): logger = logging.getLogger(__name__) -if TRACE: +if ( + TRACE + or TRACE_ANALYSIS + or TRACE_REFERENCE + or TRACE_IS_FUNCTIONS +): - if ( - TRACE - or TRACE_ANALYSIS - or TRACE_IS_FUNCTIONS - ): + logging.basicConfig(stream=sys.stdout) + logger.setLevel(logging.DEBUG) - logging.basicConfig(stream=sys.stdout) - logger.setLevel(logging.DEBUG) + def logger_debug(*args): + return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args)) - def logger_debug(*args): - return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args)) MATCHER_UNDETECTED = '5-undetected' MATCHER_UNDETECTED_ORDER = 4 @@ -1455,6 +1455,12 @@ def use_referenced_license_expression(referenced_license_expression, license_det if same_license_keys and not same_expression: return False + # If all the license keys of the referenced license expression already + # present in the actual license expression + # note that this preserves AND/OR expressions in the original license + if referenced_license_keys.issubset(license_keys): + return False + # when there are many license keys in an expression, and there are no # unknown or other cases, we cannot safely conclude that we should # follow the license in the referenced filenames. This is likely @@ -2072,6 +2078,10 @@ def update_detection_from_referenced_files( relation='AND', licensing=get_cache().licensing, )) + if TRACE_REFERENCE: + logger_debug( + f'update_detection_from_referenced_files: referenced_license_expression: {referenced_license_expression}', + ) if not use_referenced_license_expression( referenced_license_expression=referenced_license_expression, @@ -2080,24 +2090,26 @@ def update_detection_from_referenced_files( if TRACE_REFERENCE and referenced_resources: paths = [ resource.path - for resource in referenced_resource + for resource in referenced_resources ] logger_debug( f'use_referenced_license_expression: False for ' f'resources: {paths} and ' - f'license_expression: {referenced_license_expression}', + f'referenced_license_expression: {referenced_license_expression}', + f'license_detection.expression: {license_detection.license_expression}', ) return False if TRACE_REFERENCE and referenced_resources: paths = [ resource.path - for resource in referenced_resource + for resource in referenced_resources ] logger_debug( f'use_referenced_license_expression: True for ' f'resources: {paths} and ' - f'license_expression: {referenced_license_expression}', + f'referenced_license_expression: {referenced_license_expression}', + f'license_detection.expression: {license_detection.license_expression}', ) matches_to_extend = get_matches_from_detection_mappings( diff --git a/src/licensedcode/plugin_license.py b/src/licensedcode/plugin_license.py index 717253c4baa..7f638fc396a 100644 --- a/src/licensedcode/plugin_license.py +++ b/src/licensedcode/plugin_license.py @@ -210,7 +210,7 @@ def process_codebase(self, codebase, license_text=False, license_diagnostics=Fal modified = False for resource in codebase.walk(topdown=False): # follow license references to other files - if TRACE: + if TRACE_REFERENCE: license_expressions_before = resource.detected_license_expression try: @@ -218,7 +218,7 @@ def process_codebase(self, codebase, license_text=False, license_diagnostics=Fal except Exception as e: raise Exception(f"Failed to process resource: {resource!r}") from e - if TRACE and modified: + if TRACE_REFERENCE and modified: license_expressions_after = resource.detected_license_expression logger_debug( f'add_referenced_filenames_license_matches: Modified:', @@ -291,6 +291,11 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase): ) continue + if TRACE_REFERENCE: + logger_debug( + f'add_referenced_license_matches: referenced_filenames: {referenced_filenames}', + ) + is_modified = update_detection_from_referenced_files( referenced_filenames=referenced_filenames, license_detection_mapping=license_detection_mapping, diff --git a/tests/licensedcode/data/plugin_license/license_reference/scan-unknown-reference-generic.expected.json b/tests/licensedcode/data/plugin_license/license_reference/scan-unknown-reference-generic.expected.json new file mode 100644 index 00000000000..5f528cb8945 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/license_reference/scan-unknown-reference-generic.expected.json @@ -0,0 +1,276 @@ +{ + "license_detections": [ + { + "identifier": "lgpl_2_1_or_mpl_1_1__and_other_permissive-1ee33085-e414-376f-d358-b08f23c2584e", + "license_expression": "(lgpl-2.1 OR mpl-1.1) AND other-permissive", + "license_expression_spdx": "(LGPL-2.1-only OR MPL-1.1) AND LicenseRef-scancode-other-permissive", + "detection_count": 1, + "detection_log": [], + "reference_matches": [ + { + "license_expression": "(lgpl-2.1 OR mpl-1.1) AND other-permissive", + "license_expression_spdx": "(LGPL-2.1-only OR MPL-1.1) AND LicenseRef-scancode-other-permissive", + "from_file": "cairo-1.18.4/util/cairo-script/COPYING", + "start_line": 3, + "end_line": 17, + "matcher": "3-seq", + "score": 93.58, + "matched_length": 102, + "match_coverage": 93.58, + "rule_relevance": 100, + "rule_identifier": "lgpl-2.1_or_mpl-1.1_and_other-permissive_1.RULE", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_and_other-permissive_1.RULE", + "matched_text": "Every source file in the implementation of cairo is available to be\nredistributed and/or modified under the terms of either the GNU Lesser\nGeneral Public License (LGPL) version 2.1 or the Mozilla Public\nLicense (MPL) version 1.1. Some files are available under more\nliberal terms, but we believe that in all cases, each file may be used\nunder either the LGPL or the MPL.\n\nSee the following files in this directory for the precise terms and\nconditions of either license:\n\n\tCOPYING-LGPL-2.1\n\tCOPYING-MPL-1.1\n\nPlease see each file in the implementation for copyright and licensing\ninformation, (in the opening comment of each file).", + "matched_text_diagnostics": "is available to be\nredistributed and/or modified under the terms of either the GNU Lesser\nGeneral Public License (LGPL) version 2.1 or the Mozilla Public\nLicense (MPL) version 1.1. Some files are available under more\nliberal terms, but we believe that in all cases, each file may be used\nunder either the LGPL or the MPL.\n\nSee the following files in this directory for the precise terms and\nconditions of either license:\n\n\tCOPYING-LGPL-2.1\n\tCOPYING-MPL-1.1\n\nPlease see each file in the implementation for copyright and licensing\ninformation, (in the opening comment of each file)." + } + ] + }, + { + "identifier": "lgpl_2_1-be3f3949-802d-9c3e-b5f0-b2466a0bd98b", + "license_expression": "lgpl-2.1", + "license_expression_spdx": "LGPL-2.1-only", + "detection_count": 1, + "detection_log": [], + "reference_matches": [ + { + "license_expression": "lgpl-2.1", + "license_expression_spdx": "LGPL-2.1-only", + "from_file": "cairo-1.18.4/COPYING-LGPL-2.1", + "start_line": 2, + "end_line": 3, + "matcher": "2-aho", + "score": 100.0, + "matched_length": 8, + "match_coverage": 100.0, + "rule_relevance": 100, + "rule_identifier": "lgpl-2.1_36.RULE", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-2.1_36.RULE", + "matched_text": " GNU LESSER GENERAL PUBLIC LICENSE\n Version 2.1, February 1999", + "matched_text_diagnostics": "GNU LESSER GENERAL PUBLIC LICENSE\n Version 2.1," + } + ] + }, + { + "identifier": "lgpl_2_1_or_mpl_1_1-5bba2e46-ab42-c51a-524c-b2a67454e599", + "license_expression": "lgpl-2.1 OR mpl-1.1", + "license_expression_spdx": "LGPL-2.1-only OR MPL-1.1", + "detection_count": 1, + "detection_log": [], + "reference_matches": [ + { + "license_expression": "lgpl-2.1 OR mpl-1.1", + "license_expression_spdx": "LGPL-2.1-only OR MPL-1.1", + "from_file": "cairo-1.18.4/COPYING", + "start_line": 1, + "end_line": 33, + "matcher": "1-hash", + "score": 100.0, + "matched_length": 261, + "match_coverage": 100.0, + "rule_relevance": 100, + "rule_identifier": "lgpl-2.1_or_mpl-1.1_5.RULE", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_5.RULE", + "matched_text": "Cairo is free software.\n\nEvery source file in the implementation[*] of cairo is available to be\nredistributed and/or modified under the terms of either the GNU Lesser\nGeneral Public License (LGPL) version 2.1 or the Mozilla Public\nLicense (MPL) version 1.1. Some files are available under more\nliberal terms, but we believe that in all cases, each file may be used\nunder either the LGPL or the MPL.\n\nSee the following files in this directory for the precise terms and\nconditions of either license:\n\n\tCOPYING-LGPL-2.1\n\tCOPYING-MPL-1.1\n\nPlease see each file in the implementation for copyright and licensing\ninformation, (in the opening comment of each file).\n\n[*] The implementation of cairo is contained entirely within the \"src\"\ndirectory of the cairo source distribution. There are other components\nof the cairo source distribution (such as the \"test\", \"util\", and \"perf\")\nthat are auxiliary to the library itself. None of the source code in these\ndirectories contributes to a build of the cairo library itself, (libcairo.so\nor cairo.dll or similar).\n\nThese auxiliary components are also free software, but may be under\ndifferent license terms than cairo itself. For example, most of the\ntest cases in the perf and test directories are made available under\nan MIT license to simplify any use of this code for reference purposes\nin using cairo itself. Other files might be available under the GNU\nGeneral Public License (GPL), for example. Again, please see the COPYING\nfile under each directory and the opening comment of each file for copyright\nand licensing information.", + "matched_text_diagnostics": "Cairo is free software.\n\nEvery source file in the implementation[*] of cairo is available to be\nredistributed and/or modified under the terms of either the GNU Lesser\nGeneral Public License (LGPL) version 2.1 or the Mozilla Public\nLicense (MPL) version 1.1. Some files are available under more\nliberal terms, but we believe that in all cases, each file may be used\nunder either the LGPL or the MPL.\n\nSee the following files in this directory for the precise terms and\nconditions of either license:\n\n\tCOPYING-LGPL-2.1\n\tCOPYING-MPL-1.1\n\nPlease see each file in the implementation for copyright and licensing\ninformation, (in the opening comment of each file).\n\n[*] The implementation of cairo is contained entirely within the \"src\"\ndirectory of the cairo source distribution. There are other components\nof the cairo source distribution (such as the \"test\", \"util\", and \"perf\")\nthat are auxiliary to the library itself. None of the source code in these\ndirectories contributes to a build of the cairo library itself, (libcairo.so\nor cairo.dll or similar).\n\nThese auxiliary components are also free software, but may be under\ndifferent license terms than cairo itself. For example, most of the\ntest cases in the perf and test directories are made available under\nan MIT license to simplify any use of this code for reference purposes\nin using cairo itself. Other files might be available under the GNU\nGeneral Public License (GPL), for example. Again, please see the COPYING\nfile under each directory and the opening comment of each file for copyright\nand licensing information." + } + ] + }, + { + "identifier": "mpl_1_1-bda94646-bce9-7c88-28d3-e530599274c6", + "license_expression": "mpl-1.1", + "license_expression_spdx": "MPL-1.1", + "detection_count": 1, + "detection_log": [], + "reference_matches": [ + { + "license_expression": "mpl-1.1", + "license_expression_spdx": "MPL-1.1", + "from_file": "cairo-1.18.4/COPYING-MPL-1.1", + "start_line": 1, + "end_line": 2, + "matcher": "1-hash", + "score": 100.0, + "matched_length": 6, + "match_coverage": 100.0, + "rule_relevance": 100, + "rule_identifier": "mpl-1.1_16.RULE", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mpl-1.1_16.RULE", + "matched_text": " MOZILLA PUBLIC LICENSE\n Version 1.1", + "matched_text_diagnostics": "MOZILLA PUBLIC LICENSE\n Version 1.1" + } + ] + } + ], + "files": [ + { + "path": "COPYING", + "type": "file", + "detected_license_expression": "lgpl-2.1 OR mpl-1.1", + "detected_license_expression_spdx": "LGPL-2.1-only OR MPL-1.1", + "license_detections": [ + { + "license_expression": "lgpl-2.1 OR mpl-1.1", + "license_expression_spdx": "LGPL-2.1-only OR MPL-1.1", + "matches": [ + { + "license_expression": "lgpl-2.1 OR mpl-1.1", + "license_expression_spdx": "LGPL-2.1-only OR MPL-1.1", + "from_file": "cairo-1.18.4/COPYING", + "start_line": 1, + "end_line": 33, + "matcher": "1-hash", + "score": 100.0, + "matched_length": 261, + "match_coverage": 100.0, + "rule_relevance": 100, + "rule_identifier": "lgpl-2.1_or_mpl-1.1_5.RULE", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_5.RULE", + "matched_text": "Cairo is free software.\n\nEvery source file in the implementation[*] of cairo is available to be\nredistributed and/or modified under the terms of either the GNU Lesser\nGeneral Public License (LGPL) version 2.1 or the Mozilla Public\nLicense (MPL) version 1.1. Some files are available under more\nliberal terms, but we believe that in all cases, each file may be used\nunder either the LGPL or the MPL.\n\nSee the following files in this directory for the precise terms and\nconditions of either license:\n\n\tCOPYING-LGPL-2.1\n\tCOPYING-MPL-1.1\n\nPlease see each file in the implementation for copyright and licensing\ninformation, (in the opening comment of each file).\n\n[*] The implementation of cairo is contained entirely within the \"src\"\ndirectory of the cairo source distribution. There are other components\nof the cairo source distribution (such as the \"test\", \"util\", and \"perf\")\nthat are auxiliary to the library itself. None of the source code in these\ndirectories contributes to a build of the cairo library itself, (libcairo.so\nor cairo.dll or similar).\n\nThese auxiliary components are also free software, but may be under\ndifferent license terms than cairo itself. For example, most of the\ntest cases in the perf and test directories are made available under\nan MIT license to simplify any use of this code for reference purposes\nin using cairo itself. Other files might be available under the GNU\nGeneral Public License (GPL), for example. Again, please see the COPYING\nfile under each directory and the opening comment of each file for copyright\nand licensing information.", + "matched_text_diagnostics": "Cairo is free software.\n\nEvery source file in the implementation[*] of cairo is available to be\nredistributed and/or modified under the terms of either the GNU Lesser\nGeneral Public License (LGPL) version 2.1 or the Mozilla Public\nLicense (MPL) version 1.1. Some files are available under more\nliberal terms, but we believe that in all cases, each file may be used\nunder either the LGPL or the MPL.\n\nSee the following files in this directory for the precise terms and\nconditions of either license:\n\n\tCOPYING-LGPL-2.1\n\tCOPYING-MPL-1.1\n\nPlease see each file in the implementation for copyright and licensing\ninformation, (in the opening comment of each file).\n\n[*] The implementation of cairo is contained entirely within the \"src\"\ndirectory of the cairo source distribution. There are other components\nof the cairo source distribution (such as the \"test\", \"util\", and \"perf\")\nthat are auxiliary to the library itself. None of the source code in these\ndirectories contributes to a build of the cairo library itself, (libcairo.so\nor cairo.dll or similar).\n\nThese auxiliary components are also free software, but may be under\ndifferent license terms than cairo itself. For example, most of the\ntest cases in the perf and test directories are made available under\nan MIT license to simplify any use of this code for reference purposes\nin using cairo itself. Other files might be available under the GNU\nGeneral Public License (GPL), for example. Again, please see the COPYING\nfile under each directory and the opening comment of each file for copyright\nand licensing information." + } + ], + "detection_log": [], + "identifier": "lgpl_2_1_or_mpl_1_1-5bba2e46-ab42-c51a-524c-b2a67454e599" + } + ], + "license_clues": [], + "percentage_of_license_text": 100.0, + "scan_errors": [] + }, + { + "path": "COPYING-LGPL-2.1", + "type": "file", + "detected_license_expression": "lgpl-2.1", + "detected_license_expression_spdx": "LGPL-2.1-only", + "license_detections": [ + { + "license_expression": "lgpl-2.1", + "license_expression_spdx": "LGPL-2.1-only", + "matches": [ + { + "license_expression": "lgpl-2.1", + "license_expression_spdx": "LGPL-2.1-only", + "from_file": "cairo-1.18.4/COPYING-LGPL-2.1", + "start_line": 2, + "end_line": 3, + "matcher": "2-aho", + "score": 100.0, + "matched_length": 8, + "match_coverage": 100.0, + "rule_relevance": 100, + "rule_identifier": "lgpl-2.1_36.RULE", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-2.1_36.RULE", + "matched_text": " GNU LESSER GENERAL PUBLIC LICENSE\n Version 2.1, February 1999", + "matched_text_diagnostics": "GNU LESSER GENERAL PUBLIC LICENSE\n Version 2.1," + } + ], + "detection_log": [], + "identifier": "lgpl_2_1-be3f3949-802d-9c3e-b5f0-b2466a0bd98b" + } + ], + "license_clues": [], + "percentage_of_license_text": 80.0, + "scan_errors": [] + }, + { + "path": "COPYING-MPL-1.1", + "type": "file", + "detected_license_expression": "mpl-1.1", + "detected_license_expression_spdx": "MPL-1.1", + "license_detections": [ + { + "license_expression": "mpl-1.1", + "license_expression_spdx": "MPL-1.1", + "matches": [ + { + "license_expression": "mpl-1.1", + "license_expression_spdx": "MPL-1.1", + "from_file": "cairo-1.18.4/COPYING-MPL-1.1", + "start_line": 1, + "end_line": 2, + "matcher": "1-hash", + "score": 100.0, + "matched_length": 6, + "match_coverage": 100.0, + "rule_relevance": 100, + "rule_identifier": "mpl-1.1_16.RULE", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mpl-1.1_16.RULE", + "matched_text": " MOZILLA PUBLIC LICENSE\n Version 1.1", + "matched_text_diagnostics": "MOZILLA PUBLIC LICENSE\n Version 1.1" + } + ], + "detection_log": [], + "identifier": "mpl_1_1-bda94646-bce9-7c88-28d3-e530599274c6" + } + ], + "license_clues": [], + "percentage_of_license_text": 100.0, + "scan_errors": [] + }, + { + "path": "util", + "type": "directory", + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "util/COPYING", + "type": "file", + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "util/cairo-script", + "type": "directory", + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "util/cairo-script/COPYING", + "type": "file", + "detected_license_expression": "(lgpl-2.1 OR mpl-1.1) AND other-permissive", + "detected_license_expression_spdx": "(LGPL-2.1-only OR MPL-1.1) AND LicenseRef-scancode-other-permissive", + "license_detections": [ + { + "license_expression": "(lgpl-2.1 OR mpl-1.1) AND other-permissive", + "license_expression_spdx": "(LGPL-2.1-only OR MPL-1.1) AND LicenseRef-scancode-other-permissive", + "matches": [ + { + "license_expression": "(lgpl-2.1 OR mpl-1.1) AND other-permissive", + "license_expression_spdx": "(LGPL-2.1-only OR MPL-1.1) AND LicenseRef-scancode-other-permissive", + "from_file": "cairo-1.18.4/util/cairo-script/COPYING", + "start_line": 3, + "end_line": 17, + "matcher": "3-seq", + "score": 93.58, + "matched_length": 102, + "match_coverage": 93.58, + "rule_relevance": 100, + "rule_identifier": "lgpl-2.1_or_mpl-1.1_and_other-permissive_1.RULE", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-2.1_or_mpl-1.1_and_other-permissive_1.RULE", + "matched_text": "Every source file in the implementation of cairo is available to be\nredistributed and/or modified under the terms of either the GNU Lesser\nGeneral Public License (LGPL) version 2.1 or the Mozilla Public\nLicense (MPL) version 1.1. Some files are available under more\nliberal terms, but we believe that in all cases, each file may be used\nunder either the LGPL or the MPL.\n\nSee the following files in this directory for the precise terms and\nconditions of either license:\n\n\tCOPYING-LGPL-2.1\n\tCOPYING-MPL-1.1\n\nPlease see each file in the implementation for copyright and licensing\ninformation, (in the opening comment of each file).", + "matched_text_diagnostics": "is available to be\nredistributed and/or modified under the terms of either the GNU Lesser\nGeneral Public License (LGPL) version 2.1 or the Mozilla Public\nLicense (MPL) version 1.1. Some files are available under more\nliberal terms, but we believe that in all cases, each file may be used\nunder either the LGPL or the MPL.\n\nSee the following files in this directory for the precise terms and\nconditions of either license:\n\n\tCOPYING-LGPL-2.1\n\tCOPYING-MPL-1.1\n\nPlease see each file in the implementation for copyright and licensing\ninformation, (in the opening comment of each file)." + } + ], + "detection_log": [], + "identifier": "lgpl_2_1_or_mpl_1_1__and_other_permissive-1ee33085-e414-376f-d358-b08f23c2584e" + } + ], + "license_clues": [], + "percentage_of_license_text": 89.47, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING new file mode 100644 index 00000000000..f54969f1c94 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING @@ -0,0 +1,33 @@ +Cairo is free software. + +Every source file in the implementation[*] of cairo is available to be +redistributed and/or modified under the terms of either the GNU Lesser +General Public License (LGPL) version 2.1 or the Mozilla Public +License (MPL) version 1.1. Some files are available under more +liberal terms, but we believe that in all cases, each file may be used +under either the LGPL or the MPL. + +See the following files in this directory for the precise terms and +conditions of either license: + + COPYING-LGPL-2.1 + COPYING-MPL-1.1 + +Please see each file in the implementation for copyright and licensing +information, (in the opening comment of each file). + +[*] The implementation of cairo is contained entirely within the "src" +directory of the cairo source distribution. There are other components +of the cairo source distribution (such as the "test", "util", and "perf") +that are auxiliary to the library itself. None of the source code in these +directories contributes to a build of the cairo library itself, (libcairo.so +or cairo.dll or similar). + +These auxiliary components are also free software, but may be under +different license terms than cairo itself. For example, most of the +test cases in the perf and test directories are made available under +an MIT license to simplify any use of this code for reference purposes +in using cairo itself. Other files might be available under the GNU +General Public License (GPL), for example. Again, please see the COPYING +file under each directory and the opening comment of each file for copyright +and licensing information. diff --git a/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING-LGPL-2.1 b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING-LGPL-2.1 new file mode 100644 index 00000000000..68d084cf618 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING-LGPL-2.1 @@ -0,0 +1,5 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + diff --git a/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING-MPL-1.1 b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING-MPL-1.1 new file mode 100644 index 00000000000..73e22674b90 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/COPYING-MPL-1.1 @@ -0,0 +1,4 @@ + MOZILLA PUBLIC LICENSE + Version 1.1 + + --------------- diff --git a/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/util/COPYING b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/util/COPYING new file mode 100644 index 00000000000..ea44bb6f5c8 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/util/COPYING @@ -0,0 +1,4 @@ +Cairo is free software. + +These utilities are all free software, please see the licensing conditions +in the opening comments of each file. diff --git a/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/util/cairo-script/COPYING b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/util/cairo-script/COPYING new file mode 100644 index 00000000000..66ad7840fb5 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/license_reference/scan/cairo-1.18.4/util/cairo-script/COPYING @@ -0,0 +1,17 @@ +Cairo is free software. + +Every source file in the implementation of cairo is available to be +redistributed and/or modified under the terms of either the GNU Lesser +General Public License (LGPL) version 2.1 or the Mozilla Public +License (MPL) version 1.1. Some files are available under more +liberal terms, but we believe that in all cases, each file may be used +under either the LGPL or the MPL. + +See the following files in this directory for the precise terms and +conditions of either license: + + COPYING-LGPL-2.1 + COPYING-MPL-1.1 + +Please see each file in the implementation for copyright and licensing +information, (in the opening comment of each file). diff --git a/tests/licensedcode/test_licenses_reference.py b/tests/licensedcode/test_licenses_reference.py index 3625aad9a5a..356015079df 100644 --- a/tests/licensedcode/test_licenses_reference.py +++ b/tests/licensedcode/test_licenses_reference.py @@ -21,7 +21,7 @@ def test_licenses_reference_works(): - test_dir = test_env.get_test_loc('licenses_reference_reporting/scan', copy=True) + test_dir = test_env.get_test_loc('licenses_reference_reporting/scan') result_file = test_env.get_temp_file('json') args = [ '--license', '--package', '--license-references', @@ -34,7 +34,7 @@ def test_licenses_reference_works(): ) def test_licenses_reference_works_with_matched_text(): - test_dir = test_env.get_test_loc('licenses_reference_reporting/scan', copy=True) + test_dir = test_env.get_test_loc('licenses_reference_reporting/scan') result_file = test_env.get_temp_file('json') args = [ '--license', '--package', '--license-text', '--license-text-diagnostics', '--license-diagnostics', @@ -47,7 +47,7 @@ def test_licenses_reference_works_with_matched_text(): ) def test_licenses_reference_works_with_license_clues(): - test_dir = test_env.get_test_loc('licenses_reference_reporting/python.LICENSE', copy=True) + test_dir = test_env.get_test_loc('licenses_reference_reporting/python.LICENSE') result_file = test_env.get_temp_file('json') args = [ '--license', '--license-text', '--license-text-diagnostics', '--license-diagnostics', diff --git a/tests/licensedcode/test_plugin_license_detection.py b/tests/licensedcode/test_plugin_license_detection.py index ff249bc9c58..e18db47ccd3 100644 --- a/tests/licensedcode/test_plugin_license_detection.py +++ b/tests/licensedcode/test_plugin_license_detection.py @@ -310,6 +310,24 @@ def test_license_match_referenced_filename_unknown_ref(): check_json_scan(test_loc, result_file, regen=REGEN_TEST_FIXTURES) +def test_license_match_referenced_filename_generic(): + test_dir = test_env.get_test_loc('plugin_license/license_reference/scan/cairo-1.18.4/') + result_file = test_env.get_temp_file('json') + args = [ + '--license', + '--license-text', + '--license-text-diagnostics', + '--license-diagnostics', + '--strip-root', + '--verbose', + '--json', result_file, + test_dir, + ] + run_scan_click(args) + test_loc = test_env.get_test_loc('plugin_license/license_reference/scan-unknown-reference-generic.expected.json') + check_json_scan(test_loc, result_file, regen=REGEN_TEST_FIXTURES) + + def test_find_referenced_resource(): # Setup: Create a new scan to use for a virtual codebase test_dir = test_env.get_test_loc('plugin_license/license_reference/scan/scan-ref') diff --git a/tests/scancode/test_cli.py b/tests/scancode/test_cli.py index 9d038f71e62..0caeefa5f46 100644 --- a/tests/scancode/test_cli.py +++ b/tests/scancode/test_cli.py @@ -167,8 +167,7 @@ def test_scan_info_returns_full_root(): result_data = json.loads(open(result_file).read()) file_paths = [f['path'] for f in result_data['files']] assert len(file_paths) == 12 - # note that we strip paths from leading and trailing slashes - root = fileutils.as_posixpath(test_dir).strip('/') + root = fileutils.as_posixpath(test_dir) assert all(p.startswith(root) for p in file_paths) @@ -182,9 +181,8 @@ def test_scan_info_returns_correct_full_root_with_single_file(): # we have a single file assert len(files) == 1 scanned_file = files[0] - # and we check that the path is the full path without repeating the file name - # note that the path never contain leading and trailing slashes - assert scanned_file['path'] == fileutils.as_posixpath(test_file).strip('/') + # and we check that the path is the full absolute path without repeating the file name + assert scanned_file['path'] == fileutils.as_posixpath(test_file) def test_scan_info_returns_does_not_strip_root_with_single_file():