From 2d9f4ba9d8307c6e49146cb25eaf649b535023d8 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 19 Jul 2023 21:24:09 +0530 Subject: [PATCH 01/12] Also handle .jar archives which don't have a type Signed-off-by: Ayan Sinha Mahapatra --- src/summarycode/todo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/summarycode/todo.py b/src/summarycode/todo.py index 91c14971a74..750bd30debf 100644 --- a/src/summarycode/todo.py +++ b/src/summarycode/todo.py @@ -213,6 +213,8 @@ def get_package_identifier(package_data, file_path): def get_unknown_purl(package_type): + if not package_type: + package_type = "unknown" purl = PackageURL(type=package_type, name="unknown") return purl.to_string() From b1ad02fa5364b168185beba89e770cedb65f178c Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Thu, 20 Jul 2023 00:32:16 +0530 Subject: [PATCH 02/12] Add new epl-1.0 and other-copyleft rule Signed-off-by: Ayan Sinha Mahapatra --- .../rules/epl-1.0_and_other-copyleft_2.RULE | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/licensedcode/data/rules/epl-1.0_and_other-copyleft_2.RULE diff --git a/src/licensedcode/data/rules/epl-1.0_and_other-copyleft_2.RULE b/src/licensedcode/data/rules/epl-1.0_and_other-copyleft_2.RULE new file mode 100644 index 00000000000..12fb7acc3fb --- /dev/null +++ b/src/licensedcode/data/rules/epl-1.0_and_other-copyleft_2.RULE @@ -0,0 +1,21 @@ +--- +license_expression: epl-1.0 AND other-copyleft +is_license_notice: yes +relevance: 99 +ignorable_urls: + - https://network.pivotal.io/open-source + - https://spring.io/projects +--- + +To the extent any open source components are licensed under the EPL and/or +other similar licenses that require the source code and/or modifications to +source code to be made available (as would be noted above), you may obtain a +copy of the source code corresponding to the binaries for such open source +components and modifications thereto, if any, (the "Source Files"), by +downloading the Source Files from https://spring.io/projects, Pivotal's website +at https://network.pivotal.io/open-source, or by sending a request, with your +name and address to: Pivotal Software, Inc., 875 Howard Street, 5th floor, San +Francisco, CA 94103, Attention: General Counsel. All such requests should +clearly specify: OPEN SOURCE FILES REQUEST, Attention General Counsel. Pivotal +can mail a copy of the Source Files to you on a CD or equivalent physical +medium. \ No newline at end of file From 0988c724ef78de2b6b22687c3ff846ac0df380fe Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Thu, 20 Jul 2023 19:24:27 +0530 Subject: [PATCH 03/12] Add new license rule model attributes To the license Rule class: - Adds is_license_clue attribute - Adds is_deprecated attribute Also implements related processing. Signed-off-by: Ayan Sinha Mahapatra --- etc/scripts/licenses/buildrules-template.txt | 126 ++++++++++++------ etc/scripts/licenses/buildrules.py | 2 + etc/scripts/licenses/report_license_rules.py | 2 + src/licensedcode/models.py | 48 ++++++- src/packagedcode/jar_manifest.py | 2 +- src/summarycode/score.py | 2 + .../data/common/manifests-expected.yaml | 15 ++- .../yaml/package-and-licenses-expected.yaml | 11 +- ...tional_license_combined_test.expected.json | 5 + ...ional_license_directory_test.expected.json | 2 + ...ditional_license_plugin_test.expected.json | 1 + ...e-reference-works-with-clues.expected.json | 19 +++ ...-matched-text-with-reference.expected.json | 4 + .../scan-with-reference.expected.json | 4 + 14 files changed, 193 insertions(+), 50 deletions(-) diff --git a/etc/scripts/licenses/buildrules-template.txt b/etc/scripts/licenses/buildrules-template.txt index f6edea21012..f4f6565e088 100644 --- a/etc/scripts/licenses/buildrules-template.txt +++ b/etc/scripts/licenses/buildrules-template.txt @@ -7,7 +7,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -21,7 +22,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -35,7 +37,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -49,7 +52,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -63,7 +67,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -77,7 +82,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -91,7 +97,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -105,7 +112,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -119,7 +127,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -133,7 +142,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -147,7 +157,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -161,7 +172,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -175,7 +187,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -189,7 +202,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -203,7 +217,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -217,7 +232,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -231,7 +247,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -245,7 +262,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -259,7 +277,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -273,7 +292,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -287,7 +307,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -301,7 +322,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -315,7 +337,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -329,7 +352,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -343,7 +367,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -357,7 +382,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -371,7 +397,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -385,7 +412,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -399,7 +427,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -413,7 +442,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -427,7 +457,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -441,7 +472,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -455,7 +487,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -469,7 +502,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -483,7 +517,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -497,7 +532,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -511,7 +547,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -525,7 +562,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -539,7 +577,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -553,7 +592,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -567,7 +607,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- @@ -581,7 +622,8 @@ is_license_text: yes is_license_reference: yes is_license_tag: yes is_false_positive: yes -is_license_inro: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: notes: --- diff --git a/etc/scripts/licenses/buildrules.py b/etc/scripts/licenses/buildrules.py index 999fb770f12..3f2277a3964 100644 --- a/etc/scripts/licenses/buildrules.py +++ b/etc/scripts/licenses/buildrules.py @@ -222,6 +222,8 @@ def cli(licenses_file): base_name = "false-positive" elif rule.is_license_intro: base_name = "license-intro" + elif rule.is_license_clue: + base_name = "license-clue" else: base_name = rule.license_expression diff --git a/etc/scripts/licenses/report_license_rules.py b/etc/scripts/licenses/report_license_rules.py index a15d5d367f5..8e8ff04abfb 100644 --- a/etc/scripts/licenses/report_license_rules.py +++ b/etc/scripts/licenses/report_license_rules.py @@ -61,6 +61,8 @@ "is_license_tag", "is_license_reference", "is_license_intro", + "is_license_clue", + "is_deprecated", "has_unknown", "only_known_words", "notes", diff --git a/src/licensedcode/models.py b/src/licensedcode/models.py index 92a32a36287..5c522c65a35 100644 --- a/src/licensedcode/models.py +++ b/src/licensedcode/models.py @@ -1189,7 +1189,12 @@ def get_license_tokens(): yield 'licensed' -def load_rules(rules_data_dir=rules_data_dir, with_checks=True, is_builtin=True): +def load_rules( + rules_data_dir=rules_data_dir, + with_checks=True, + is_builtin=True, + ignore_deprecated=True, +): """ Return an iterable of rules loaded from rule files in ``rules_data_dir``. Optionally check for consistency if ``with_checks`` is True. @@ -1211,7 +1216,12 @@ def load_rules(rules_data_dir=rules_data_dir, with_checks=True, is_builtin=True) space_problems.append(rule_file) try: - yield Rule.from_file(rule_file=rule_file) + rule = Rule.from_file(rule_file=rule_file) + if rule.is_deprecated and ignore_deprecated: + continue + else: + yield rule + except Exception as re: if with_checks: model_errors.append(str(re)) @@ -1387,6 +1397,22 @@ class BasicRule: 'after. Mutually exclusive from any other is_license_* flag') ) + is_license_clue = attr.ib( + default=False, + repr=False, + metadata=dict( + help='True if this is rule text is a clue to a license ' + 'but cannot be considered in a proper license detection ' + 'as a license text/notice/reference/tag/intro as it is' + 'merely a clue and does not actually point to or refer to ' + 'the actual license directly. This is still valuable information ' + 'useful in determining the license/origin of a file, but this ' + 'should not be summarized/present in the license expression for ' + 'a package or a file, nor its list of license detections. ' + 'considered in the context of the detection that it precedes. ' + 'Mutually exclusive from any other is_license_* flag') + ) + is_false_positive = attr.ib( default=False, repr=False, @@ -1505,6 +1531,19 @@ class BasicRule: 'built at runtime, such as an SPDX license rule.') ) + is_deprecated = attr.ib( + default=False, + repr=False, + metadata=dict( + help='Flag set to True if this rule is deleted, ' + 'and not to be used anymore in license detection. ' + 'This happens usually when a rule is renamed/assigned ' + 'to a seperate license-expression, promoted to being a ' + 'license text or just plain retired. This is used to ' + 'preserve the link to the rule, and therefore make links ' + 'to rules as permanent.') + ) + ########################################################################### # lists of clues that can be ignored when detected in this license as they # are part of the license or rule text itself @@ -1769,6 +1808,7 @@ def validate(self, licensing=None, thorough=False): self.is_license_reference, self.is_license_tag, self.is_license_intro, + self.is_license_clue, ) has_license_flags = any(license_flags) @@ -1924,6 +1964,7 @@ def to_reference(self): data['is_license_reference'] = self.is_license_reference data['is_license_tag'] = self.is_license_tag data['is_license_intro'] = self.is_license_intro + data['is_license_clue'] = self.is_license_clue data['is_continuous'] = self.is_continuous data['is_builtin'] = self.is_builtin data['is_from_license'] = self.is_from_license @@ -1961,6 +2002,7 @@ def to_dict(self, include_text=False): 'is_license_reference', 'is_license_tag', 'is_license_intro', + 'is_license_clue', 'is_continuous', ) @@ -2253,7 +2295,9 @@ def load(self, rule_file, with_checks=True): self.is_license_tag = data.get('is_license_tag', False) self.is_license_reference = data.get('is_license_reference', False) self.is_license_intro = data.get('is_license_intro', False) + self.is_license_clue = data.get('is_license_clue', False) self.is_continuous = data.get('is_continuous', False) + self.is_deprecated = data.get('is_deprecated', False) self.referenced_filenames = data.get('referenced_filenames', []) or [] diff --git a/src/packagedcode/jar_manifest.py b/src/packagedcode/jar_manifest.py index adc2a6882f7..48df5373eb1 100644 --- a/src/packagedcode/jar_manifest.py +++ b/src/packagedcode/jar_manifest.py @@ -216,7 +216,7 @@ def dget(s): name = i_title or am_nm or ext_nm or nm descriptions = [s_title, i_title, nm] - datasource_id =get_datasource_id(package_type=package_type) + datasource_id = get_datasource_id(package_type=package_type) descriptions = unique(descriptions) descriptions = [d for d in descriptions if d and d.strip() and d != name] diff --git a/src/summarycode/score.py b/src/summarycode/score.py index 26b271e7dfd..b0fe826fa85 100644 --- a/src/summarycode/score.py +++ b/src/summarycode/score.py @@ -250,6 +250,7 @@ class LicenseFilter(object): is_license_tag=LicenseFilter(min_coverage=100), is_license_reference=LicenseFilter(min_score=50, min_coverage=100), is_license_intro=LicenseFilter(min_score=100, min_coverage=100), + is_license_clue=LicenseFilter(min_score=100, min_coverage=100), ) @@ -268,6 +269,7 @@ def is_good_license(license_match_object): ('is_license_reference', license_match_object.rule.is_license_reference), ('is_license_tag', license_match_object.rule.is_license_tag), ('is_license_intro', license_match_object.rule.is_license_intro), + ('is_license_clue', license_match_object.rule.is_license_clue), ] ) matched = False diff --git a/tests/formattedcode/data/common/manifests-expected.yaml b/tests/formattedcode/data/common/manifests-expected.yaml index 9c4c89b1714..f94594e279b 100644 --- a/tests/formattedcode/data/common/manifests-expected.yaml +++ b/tests/formattedcode/data/common/manifests-expected.yaml @@ -29,8 +29,8 @@ headers: system_environment: operating_system: linux cpu_architecture: 64 - platform: Linux-5.15.0-75-generic-x86_64-with-glibc2.29 - platform_version: '#82~20.04.1-Ubuntu SMP Wed Jun 7 19:37:37 UTC 2023' + platform: Linux-5.15.0-76-generic-x86_64-with-glibc2.29 + platform_version: '#83~20.04.1-Ubuntu SMP Wed Jun 21 20:23:31 UTC 2023' python_version: "3.8.10 (default, May 26 2023, 14:05:08) \n[GCC 9.4.0]" spdx_license_list_version: '3.21' files_count: 4 @@ -1126,6 +1126,7 @@ license_rule_references: is_license_reference: no is_license_tag: yes is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1150,6 +1151,7 @@ license_rule_references: is_license_reference: yes is_license_tag: no is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1174,6 +1176,7 @@ license_rule_references: is_license_reference: no is_license_tag: yes is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1199,6 +1202,7 @@ license_rule_references: is_license_reference: yes is_license_tag: no is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1224,6 +1228,7 @@ license_rule_references: is_license_reference: no is_license_tag: yes is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1248,6 +1253,7 @@ license_rule_references: is_license_reference: no is_license_tag: no is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1284,6 +1290,7 @@ license_rule_references: is_license_reference: no is_license_tag: no is_license_intro: yes + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1311,6 +1318,7 @@ license_rule_references: is_license_reference: no is_license_tag: yes is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1335,6 +1343,7 @@ license_rule_references: is_license_reference: no is_license_tag: yes is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1359,6 +1368,7 @@ license_rule_references: is_license_reference: no is_license_tag: yes is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -1383,6 +1393,7 @@ license_rule_references: is_license_reference: yes is_license_tag: no is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no diff --git a/tests/formattedcode/data/yaml/package-and-licenses-expected.yaml b/tests/formattedcode/data/yaml/package-and-licenses-expected.yaml index b2623e1cbc1..05c1c7afac0 100644 --- a/tests/formattedcode/data/yaml/package-and-licenses-expected.yaml +++ b/tests/formattedcode/data/yaml/package-and-licenses-expected.yaml @@ -29,10 +29,10 @@ headers: system_environment: operating_system: linux cpu_architecture: 64 - platform: Linux-5.15.0-73-generic-x86_64-with-glibc2.29 - platform_version: '#80~20.04.1-Ubuntu SMP Wed May 17 14:58:14 UTC 2023' + platform: Linux-5.15.0-76-generic-x86_64-with-glibc2.29 + platform_version: '#83~20.04.1-Ubuntu SMP Wed Jun 21 20:23:31 UTC 2023' python_version: "3.8.10 (default, May 26 2023, 14:05:08) \n[GCC 9.4.0]" - spdx_license_list_version: '3.20' + spdx_license_list_version: '3.21' files_count: 4 summary: declared_license_expression: apache-2.0 @@ -369,6 +369,7 @@ license_rule_references: is_license_reference: no is_license_tag: no is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: yes @@ -596,6 +597,7 @@ license_rule_references: is_license_reference: no is_license_tag: yes is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -620,6 +622,7 @@ license_rule_references: is_license_reference: yes is_license_tag: no is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: no @@ -644,6 +647,7 @@ license_rule_references: is_license_reference: yes is_license_tag: no is_license_intro: no + is_license_clue: no is_continuous: yes is_builtin: yes is_from_license: no @@ -668,6 +672,7 @@ license_rule_references: is_license_reference: no is_license_tag: no is_license_intro: no + is_license_clue: no is_continuous: no is_builtin: yes is_from_license: yes diff --git a/tests/licensedcode/data/additional_licenses/additional_license_combined_test.expected.json b/tests/licensedcode/data/additional_licenses/additional_license_combined_test.expected.json index 32d12044edf..190a7381c46 100644 --- a/tests/licensedcode/data/additional_licenses/additional_license_combined_test.expected.json +++ b/tests/licensedcode/data/additional_licenses/additional_license_combined_test.expected.json @@ -196,6 +196,7 @@ "is_license_reference": false, "is_license_tag": true, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -222,6 +223,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": false, "is_from_license": true, @@ -248,6 +250,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": false, "is_from_license": true, @@ -274,6 +277,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": false, "is_from_license": true, @@ -300,6 +304,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": false, "is_from_license": true, diff --git a/tests/licensedcode/data/additional_licenses/additional_license_directory_test.expected.json b/tests/licensedcode/data/additional_licenses/additional_license_directory_test.expected.json index d03a782383b..24e591bb1f6 100644 --- a/tests/licensedcode/data/additional_licenses/additional_license_directory_test.expected.json +++ b/tests/licensedcode/data/additional_licenses/additional_license_directory_test.expected.json @@ -85,6 +85,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": false, "is_from_license": true, @@ -111,6 +112,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": false, "is_from_license": true, diff --git a/tests/licensedcode/data/additional_licenses/additional_license_plugin_test.expected.json b/tests/licensedcode/data/additional_licenses/additional_license_plugin_test.expected.json index 485d939edee..18f31e4886b 100644 --- a/tests/licensedcode/data/additional_licenses/additional_license_plugin_test.expected.json +++ b/tests/licensedcode/data/additional_licenses/additional_license_plugin_test.expected.json @@ -52,6 +52,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": false, "is_from_license": true, diff --git a/tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json b/tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json index 559d7d3d47e..d2c8fd87484 100644 --- a/tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json +++ b/tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json @@ -643,6 +643,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -669,6 +670,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -695,6 +697,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -721,6 +724,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": true, @@ -747,6 +751,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -773,6 +778,7 @@ "is_license_reference": true, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -799,6 +805,7 @@ "is_license_reference": true, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -825,6 +832,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": true, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -851,6 +859,7 @@ "is_license_reference": true, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -877,6 +886,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -905,6 +915,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -941,6 +952,7 @@ "is_license_reference": true, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -967,6 +979,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": true, @@ -993,6 +1006,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -1030,6 +1044,7 @@ "is_license_reference": true, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -1058,6 +1073,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -1084,6 +1100,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": true, @@ -1120,6 +1137,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": true, @@ -1150,6 +1168,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, diff --git a/tests/licensedcode/data/licenses_reference_reporting/scan-matched-text-with-reference.expected.json b/tests/licensedcode/data/licenses_reference_reporting/scan-matched-text-with-reference.expected.json index 71be31b2270..8b5ef3c5d2b 100644 --- a/tests/licensedcode/data/licenses_reference_reporting/scan-matched-text-with-reference.expected.json +++ b/tests/licensedcode/data/licenses_reference_reporting/scan-matched-text-with-reference.expected.json @@ -287,6 +287,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -317,6 +318,7 @@ "is_license_reference": false, "is_license_tag": true, "is_license_intro": false, + "is_license_clue": false, "is_continuous": true, "is_builtin": true, "is_from_license": false, @@ -343,6 +345,7 @@ "is_license_reference": false, "is_license_tag": true, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -369,6 +372,7 @@ "is_license_reference": false, "is_license_tag": true, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, diff --git a/tests/licensedcode/data/licenses_reference_reporting/scan-with-reference.expected.json b/tests/licensedcode/data/licenses_reference_reporting/scan-with-reference.expected.json index d503931d0a8..b4947f047b8 100644 --- a/tests/licensedcode/data/licenses_reference_reporting/scan-with-reference.expected.json +++ b/tests/licensedcode/data/licenses_reference_reporting/scan-with-reference.expected.json @@ -284,6 +284,7 @@ "is_license_reference": false, "is_license_tag": false, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -314,6 +315,7 @@ "is_license_reference": false, "is_license_tag": true, "is_license_intro": false, + "is_license_clue": false, "is_continuous": true, "is_builtin": true, "is_from_license": false, @@ -340,6 +342,7 @@ "is_license_reference": false, "is_license_tag": true, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, @@ -366,6 +369,7 @@ "is_license_reference": false, "is_license_tag": true, "is_license_intro": false, + "is_license_clue": false, "is_continuous": false, "is_builtin": true, "is_from_license": false, From edd797449c051f2d3ed4722639bc8fcf6a806e31 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Thu, 20 Jul 2023 20:31:09 +0530 Subject: [PATCH 04/12] Fix unknown license clues bug Signed-off-by: Ayan Sinha Mahapatra --- etc/scripts/licenses/buildrules-template.txt | 24 +- .../data/rules/license-clue_1.RULE | 7 + .../rules/unknown-license-reference_354.RULE | 1 + src/licensedcode/detection.py | 28 +- .../clues/woodstox.expected.json | 293 ++++++++++++++++++ .../data/plugin_license/clues/woodstox/ASL2.0 | 6 + .../plugin_license/clues/woodstox/LICENSE | 12 + .../clues/woodstox/META-INF/MANIFEST.MF | 11 + .../data/plugin_license/clues/woodstox/NOTICE | 8 + .../test_plugin_license_detection.py | 19 ++ 10 files changed, 396 insertions(+), 13 deletions(-) create mode 100644 src/licensedcode/data/rules/license-clue_1.RULE create mode 100644 tests/licensedcode/data/plugin_license/clues/woodstox.expected.json create mode 100644 tests/licensedcode/data/plugin_license/clues/woodstox/ASL2.0 create mode 100644 tests/licensedcode/data/plugin_license/clues/woodstox/LICENSE create mode 100644 tests/licensedcode/data/plugin_license/clues/woodstox/META-INF/MANIFEST.MF create mode 100644 tests/licensedcode/data/plugin_license/clues/woodstox/NOTICE diff --git a/etc/scripts/licenses/buildrules-template.txt b/etc/scripts/licenses/buildrules-template.txt index f4f6565e088..240d96cbbf8 100644 --- a/etc/scripts/licenses/buildrules-template.txt +++ b/etc/scripts/licenses/buildrules-template.txt @@ -1,18 +1,22 @@ ---------------------------------------- -license_expression: -relevance: 100 -minimum_coverage: 90 +license_expression: apache-2.0 is_license_notice: yes -is_license_text: yes -is_license_reference: yes -is_license_tag: yes -is_false_positive: yes -is_license_intro: yes -is_license_clue: yes referenced_filenames: -notes: + - ASL2.0 +notes: seen in woodstox --- +This copy of is licensed under the +{{Apache (Software) License, version 2.0 ("the License")}}. +See the License for details about distribution rights, and the +specific rights regarding derivate works. + +You may obtain a copy of the License at: + +http://www.apache.org/licenses/ +A copy is also included in the downloadable source code package +containing , in file {{"ASL2.0"}}, under the same directory +as this file. ---------------------------------------- license_expression: relevance: 100 diff --git a/src/licensedcode/data/rules/license-clue_1.RULE b/src/licensedcode/data/rules/license-clue_1.RULE new file mode 100644 index 00000000000..24e54bc6450 --- /dev/null +++ b/src/licensedcode/data/rules/license-clue_1.RULE @@ -0,0 +1,7 @@ +--- +license_expression: unknown-license-reference +is_license_clue: yes +notes: Seen in woodstox +--- + +This product currently only contains code developed by authors of specific components, as identified by the source code files. \ No newline at end of file diff --git a/src/licensedcode/data/rules/unknown-license-reference_354.RULE b/src/licensedcode/data/rules/unknown-license-reference_354.RULE index 487b7daf2ff..21e3407b1d6 100644 --- a/src/licensedcode/data/rules/unknown-license-reference_354.RULE +++ b/src/licensedcode/data/rules/unknown-license-reference_354.RULE @@ -1,6 +1,7 @@ --- license_expression: unknown-license-reference is_license_reference: yes +is_deprecated: yes notes: Seen in woodstox --- diff --git a/src/licensedcode/detection.py b/src/licensedcode/detection.py index 7bee3330e18..6b049ba799a 100644 --- a/src/licensedcode/detection.py +++ b/src/licensedcode/detection.py @@ -927,10 +927,21 @@ def is_undetected_license_matches(license_matches): return True +def is_correct_detection_non_unknown(license_matches): + """ + Return True if all the matches in ``license_matches`` List of LicenseMatch + are correct/perfect license detections and also there aren't any unknowns. + """ + return ( + is_correct_detection(license_matches) + and not has_unknown_matches(license_matches) + ) + + def is_correct_detection(license_matches): """ Return True if all the matches in ``license_matches`` List of LicenseMatch - are correct license detections. + are perfect license detections. """ matchers = (license_match.matcher for license_match in license_matches) is_match_coverage_perfect = [ @@ -940,7 +951,7 @@ def is_correct_detection(license_matches): return ( all(matcher in ("1-hash", "1-spdx-id", "2-aho") for matcher in matchers) - and all(is_match_coverage_perfect) and not has_unknown_matches(license_matches) + and all(is_match_coverage_perfect) ) @@ -1088,6 +1099,14 @@ def is_unknown_intro(license_match): ) +def has_correct_license_clue_matches(license_matches): + """ + Return True if all the matches in ``license_matches`` List of LicenseMatch + has True for the `is_license_clue` rule attribute. + """ + return is_correct_detection(license_matches) and all(match.rule.is_license_clue for match in license_matches) + + def is_license_clues(license_matches): """ Return True if the license_matches are not part of a correct @@ -1480,9 +1499,12 @@ def analyze_detection(license_matches, package_license=False): return DetectionCategory.FALSE_POSITVE.value # Case where all matches have `matcher` as `1-hash` or `4-spdx-id` - elif is_correct_detection(license_matches=license_matches): + elif is_correct_detection_non_unknown(license_matches=license_matches): return DetectionCategory.PERFECT_DETECTION.value + elif has_correct_license_clue_matches(license_matches=license_matches): + return DetectionCategory.LICENSE_CLUES.value + # Case where even though the matches have perfect coverage, they have # matches with `unknown` rule identifiers elif has_unknown_matches(license_matches=license_matches): diff --git a/tests/licensedcode/data/plugin_license/clues/woodstox.expected.json b/tests/licensedcode/data/plugin_license/clues/woodstox.expected.json new file mode 100644 index 00000000000..753015ff0a7 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/clues/woodstox.expected.json @@ -0,0 +1,293 @@ +{ + "license_detections": [ + { + "identifier": "apache_2_0-aef5c472-cdfd-dc5f-c152-40e3d96f140e", + "license_expression": "apache-2.0", + "detection_count": 1, + "detection_log": [] + }, + { + "identifier": "apache_2_0-e6c6a798-7f38-0f45-701a-6f3304caf1ee", + "license_expression": "apache-2.0", + "detection_count": 1, + "detection_log": [] + } + ], + "license_references": [ + { + "key": "apache-2.0", + "language": "en", + "short_name": "Apache 2.0", + "name": "Apache License 2.0", + "category": "Permissive", + "owner": "Apache Software Foundation", + "homepage_url": "http://www.apache.org/licenses/", + "notes": "Per SPDX.org, this version was released January 2004 This license is OSI\ncertified\n", + "is_builtin": true, + "is_exception": false, + "is_unknown": false, + "is_generic": false, + "spdx_license_key": "Apache-2.0", + "other_spdx_license_keys": [ + "LicenseRef-Apache", + "LicenseRef-Apache-2.0" + ], + "osi_license_key": "Apache-2.0", + "text_urls": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "osi_url": "http://opensource.org/licenses/apache2.0.php", + "faq_url": "http://www.apache.org/foundation/licence-FAQ.html", + "other_urls": [ + "http://www.opensource.org/licenses/Apache-2.0", + "https://opensource.org/licenses/Apache-2.0", + "https://www.apache.org/licenses/LICENSE-2.0" + ], + "key_aliases": [], + "minimum_coverage": 0, + "standard_notice": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [ + "http://www.apache.org/licenses/", + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "ignorable_emails": [], + "text": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n \n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n \n 1. Definitions.\n \n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n \n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n \n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n \n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n \n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n \n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n \n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n \n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n \n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n \n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n \n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n \n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n \n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n \n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n \n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n \n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n \n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n \n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n \n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n \n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n \n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n \n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n \n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n \n END OF TERMS AND CONDITIONS\n \n APPENDIX: How to apply the Apache License to your work.\n \n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n \n Copyright [yyyy] [name of copyright owner]\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.", + "scancode_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/apache-2.0.LICENSE", + "licensedb_url": "https://scancode-licensedb.aboutcode.org/apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0" + }, + { + "key": "unknown-license-reference", + "language": "en", + "short_name": "Unknown License reference", + "name": "Unknown License file reference", + "category": "Unstated License", + "owner": "Unspecified", + "homepage_url": null, + "notes": "This applies to the case of a file with no clear license, which may be referenced via URL or text such as \"See license in...\" or \"This file is licensed under...\", but where the reference cannot be resolved to a specific named, public license.", + "is_builtin": true, + "is_exception": false, + "is_unknown": true, + "is_generic": false, + "spdx_license_key": "LicenseRef-scancode-unknown-license-reference", + "other_spdx_license_keys": [], + "osi_license_key": null, + "text_urls": [], + "osi_url": null, + "faq_url": null, + "other_urls": [], + "key_aliases": [], + "minimum_coverage": 0, + "standard_notice": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [], + "ignorable_emails": [], + "text": "", + "scancode_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE", + "licensedb_url": "https://scancode-licensedb.aboutcode.org/unknown-license-reference", + "spdx_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE" + } + ], + "license_rule_references": [ + { + "license_expression": "apache-2.0", + "identifier": "apache-2.0_791.RULE", + "language": "en", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_791.RULE", + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "is_license_clue": false, + "is_continuous": false, + "is_builtin": true, + "is_from_license": false, + "is_synthetic": false, + "length": 12, + "relevance": 100, + "minimum_coverage": 50, + "referenced_filenames": [], + "notes": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [ + "http://www.apache.org/licenses/" + ], + "ignorable_emails": [], + "text": "Apache License\nVersion 2.0, January 2004\nhttp://www.apache.org/licenses/" + }, + { + "license_expression": "apache-2.0", + "identifier": "apache-2.0_jna1.RULE", + "language": "en", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_jna1.RULE", + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "is_license_clue": false, + "is_continuous": false, + "is_builtin": true, + "is_from_license": false, + "is_synthetic": false, + "length": 65, + "relevance": 100, + "minimum_coverage": 0, + "referenced_filenames": [ + "AL2.0" + ], + "notes": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [ + "http://www.apache.org/licenses/" + ], + "ignorable_emails": [], + "text": "This copy of is licensed under the\nApache (Software) License, version 2.0 (\"the License\").\nSee the License for details about distribution rights, and the\nspecific rights regarding derivate works.\n\nYou may obtain a copy of the License at:\n\nhttp://www.apache.org/licenses/\n\nA copy is also included in the downloadable source code package\ncontaining , in file \"AL2.0\", under the same directory\nas this file." + }, + { + "license_expression": "unknown-license-reference", + "identifier": "license-clue_1.RULE", + "language": "en", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/license-clue_1.RULE", + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "is_license_clue": true, + "is_continuous": false, + "is_builtin": true, + "is_from_license": false, + "is_synthetic": false, + "length": 19, + "relevance": 100, + "minimum_coverage": 50, + "referenced_filenames": [], + "notes": "Seen in woodstox", + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [], + "ignorable_emails": [], + "text": "This product currently only contains code developed by authors of specific components, as identified by the source code files." + } + ], + "files": [ + { + "path": "ASL2.0", + "type": "file", + "detected_license_expression": "apache-2.0", + "detected_license_expression_spdx": "Apache-2.0", + "license_detections": [ + { + "license_expression": "apache-2.0", + "matches": [ + { + "score": 100.0, + "start_line": 2, + "end_line": 4, + "matched_length": 12, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "apache-2.0", + "rule_identifier": "apache-2.0_791.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_791.RULE", + "matched_text": "Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/" + } + ], + "detection_log": [], + "identifier": "apache_2_0-aef5c472-cdfd-dc5f-c152-40e3d96f140e" + } + ], + "license_clues": [], + "percentage_of_license_text": 100.0, + "scan_errors": [] + }, + { + "path": "LICENSE", + "type": "file", + "detected_license_expression": "apache-2.0", + "detected_license_expression_spdx": "Apache-2.0", + "license_detections": [ + { + "license_expression": "apache-2.0", + "matches": [ + { + "score": 78.46, + "start_line": 1, + "end_line": 11, + "matched_length": 51, + "match_coverage": 78.46, + "matcher": "3-seq", + "license_expression": "apache-2.0", + "rule_identifier": "apache-2.0_jna1.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_jna1.RULE", + "matched_text": "is licensed under the\nApache (Software) License, version 2.0 (\"the License\").\nSee the License for details about distribution rights, and the\nspecific rights regarding derivate works.\n\nYou may obtain a copy of the License at:\n\nhttp://www.apache.org/licenses/\n\nA copy is also included in the downloadable source code package\ncontaining" + } + ], + "detection_log": [], + "identifier": "apache_2_0-e6c6a798-7f38-0f45-701a-6f3304caf1ee" + } + ], + "license_clues": [], + "percentage_of_license_text": 73.91, + "scan_errors": [] + }, + { + "path": "META-INF", + "type": "directory", + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "META-INF/MANIFEST.MF", + "type": "file", + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "NOTICE", + "type": "file", + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 2, + "matched_length": 19, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "unknown-license-reference", + "rule_identifier": "license-clue_1.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/license-clue_1.RULE", + "matched_text": "This product currently only contains code developed by authors\nof specific components, as identified by the source code files." + } + ], + "percentage_of_license_text": 44.19, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/licensedcode/data/plugin_license/clues/woodstox/ASL2.0 b/tests/licensedcode/data/plugin_license/clues/woodstox/ASL2.0 new file mode 100644 index 00000000000..41f4ab268a7 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/clues/woodstox/ASL2.0 @@ -0,0 +1,6 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + \ No newline at end of file diff --git a/tests/licensedcode/data/plugin_license/clues/woodstox/LICENSE b/tests/licensedcode/data/plugin_license/clues/woodstox/LICENSE new file mode 100644 index 00000000000..0cb4fe3817c --- /dev/null +++ b/tests/licensedcode/data/plugin_license/clues/woodstox/LICENSE @@ -0,0 +1,12 @@ +This copy of Woodstox XML processor is licensed under the +Apache (Software) License, version 2.0 ("the License"). +See the License for details about distribution rights, and the +specific rights regarding derivate works. + +You may obtain a copy of the License at: + +http://www.apache.org/licenses/ + +A copy is also included in the downloadable source code package +containing Woodstox, in file "ASL2.0", under the same directory +as this file. diff --git a/tests/licensedcode/data/plugin_license/clues/woodstox/META-INF/MANIFEST.MF b/tests/licensedcode/data/plugin_license/clues/woodstox/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..359f858ff34 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/clues/woodstox/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.6.5 +Created-By: 1.5.0_14-b03 (Sun Microsystems Inc.) +Built-By: tatu +Specification-Title: StAX 1.0 API +Specification-Version: 1.0 +Specification-Vendor: http://jcp.org/en/jsr/detail?id=173 +Implementation-Title: WoodSToX XML-processor +Implementation-Version: 3.2.8 +Implementation-Vendor: woodstox.codehaus.org + diff --git a/tests/licensedcode/data/plugin_license/clues/woodstox/NOTICE b/tests/licensedcode/data/plugin_license/clues/woodstox/NOTICE new file mode 100644 index 00000000000..53890124fd8 --- /dev/null +++ b/tests/licensedcode/data/plugin_license/clues/woodstox/NOTICE @@ -0,0 +1,8 @@ +This product currently only contains code developed by authors +of specific components, as identified by the source code files. + +Since product implements StAX API, it has dependencies to StAX API +classes. + +For additional credits (generally to people who reported problems) +see CREDITS file. diff --git a/tests/licensedcode/test_plugin_license_detection.py b/tests/licensedcode/test_plugin_license_detection.py index 4b915e10fd0..945c00e1169 100644 --- a/tests/licensedcode/test_plugin_license_detection.py +++ b/tests/licensedcode/test_plugin_license_detection.py @@ -74,6 +74,25 @@ def test_license_match_unknown_license_intro_with_dual_license(): check_json_scan(test_loc, result_file, regen=REGEN_TEST_FIXTURES) +def test_license_match_unknown_clues_is_not_in_expression(): + test_dir = test_env.get_test_loc('plugin_license/clues/woodstox/', copy=True) + result_file = test_env.get_temp_file('json') + args = [ + '--license', + '--license-text', + '--license-text-diagnostics', + '--license-diagnostics', + '--license-references', + '--strip-root', + '--verbose', + '--json', result_file, + test_dir, + ] + run_scan_click(args) + test_loc = test_env.get_test_loc('plugin_license/clues/woodstox.expected.json') + check_json_scan(test_loc, result_file, regen=REGEN_TEST_FIXTURES) + + def test_license_match_unknown_license_intro_eclipse_foundation(): test_dir = test_env.get_test_loc('plugin_license/unknown_intro/scan-unknown-intro-eclipse-foundation/', copy=True) result_file = test_env.get_temp_file('json') From 951b155387edecce7b1dcc4017ad3b0964b2c886 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Fri, 21 Jul 2023 16:40:35 +0530 Subject: [PATCH 05/12] Update rules to be license clues Signed-off-by: Ayan Sinha Mahapatra --- etc/scripts/licenses/buildrules-template.txt | 24 ++++++++----------- .../data/rules/agpl-3.0-plus_152.RULE | 2 +- ...agpl-3.0-plus_or_commercial-license_7.RULE | 2 +- .../data/rules/free-unknown_55.RULE | 2 +- .../data/rules/free-unknown_85.RULE | 2 +- .../data/rules/free-unknown_88.RULE | 2 +- .../data/rules/license-clue_2.RULE | 6 +++++ .../data/rules/proprietary_greensock_8.RULE | 2 +- src/licensedcode/data/rules/python_10.RULE | 2 +- .../rules/unknown-license-reference_131.RULE | 2 +- .../rules/unknown-license-reference_82.RULE | 2 +- 11 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 src/licensedcode/data/rules/license-clue_2.RULE diff --git a/etc/scripts/licenses/buildrules-template.txt b/etc/scripts/licenses/buildrules-template.txt index 240d96cbbf8..f4f6565e088 100644 --- a/etc/scripts/licenses/buildrules-template.txt +++ b/etc/scripts/licenses/buildrules-template.txt @@ -1,22 +1,18 @@ ---------------------------------------- -license_expression: apache-2.0 +license_expression: +relevance: 100 +minimum_coverage: 90 is_license_notice: yes +is_license_text: yes +is_license_reference: yes +is_license_tag: yes +is_false_positive: yes +is_license_intro: yes +is_license_clue: yes referenced_filenames: - - ASL2.0 -notes: seen in woodstox +notes: --- -This copy of is licensed under the -{{Apache (Software) License, version 2.0 ("the License")}}. -See the License for details about distribution rights, and the -specific rights regarding derivate works. - -You may obtain a copy of the License at: - -http://www.apache.org/licenses/ -A copy is also included in the downloadable source code package -containing , in file {{"ASL2.0"}}, under the same directory -as this file. ---------------------------------------- license_expression: relevance: 100 diff --git a/src/licensedcode/data/rules/agpl-3.0-plus_152.RULE b/src/licensedcode/data/rules/agpl-3.0-plus_152.RULE index 312d3bea842..5db20313bd0 100644 --- a/src/licensedcode/data/rules/agpl-3.0-plus_152.RULE +++ b/src/licensedcode/data/rules/agpl-3.0-plus_152.RULE @@ -1,6 +1,6 @@ --- license_expression: agpl-3.0-plus -is_license_reference: yes +is_license_clue: yes relevance: 90 ignorable_urls: - http://www.ghostscript.com/ diff --git a/src/licensedcode/data/rules/agpl-3.0-plus_or_commercial-license_7.RULE b/src/licensedcode/data/rules/agpl-3.0-plus_or_commercial-license_7.RULE index 6230eae92d5..186350d8bbe 100644 --- a/src/licensedcode/data/rules/agpl-3.0-plus_or_commercial-license_7.RULE +++ b/src/licensedcode/data/rules/agpl-3.0-plus_or_commercial-license_7.RULE @@ -1,6 +1,6 @@ --- license_expression: agpl-3.0-plus OR commercial-license -is_license_reference: yes +is_license_clue: yes relevance: 90 --- diff --git a/src/licensedcode/data/rules/free-unknown_55.RULE b/src/licensedcode/data/rules/free-unknown_55.RULE index 98df9cf4694..819673e72f7 100644 --- a/src/licensedcode/data/rules/free-unknown_55.RULE +++ b/src/licensedcode/data/rules/free-unknown_55.RULE @@ -1,6 +1,6 @@ --- license_expression: free-unknown -is_license_reference: yes +is_license_clue: yes relevance: 99 --- diff --git a/src/licensedcode/data/rules/free-unknown_85.RULE b/src/licensedcode/data/rules/free-unknown_85.RULE index 4210b7da1d4..e5e1d98d813 100644 --- a/src/licensedcode/data/rules/free-unknown_85.RULE +++ b/src/licensedcode/data/rules/free-unknown_85.RULE @@ -1,6 +1,6 @@ --- license_expression: free-unknown -is_license_reference: yes +is_license_clue: yes relevance: 100 --- diff --git a/src/licensedcode/data/rules/free-unknown_88.RULE b/src/licensedcode/data/rules/free-unknown_88.RULE index 5b0bd2fbca7..421c8ecb7e6 100644 --- a/src/licensedcode/data/rules/free-unknown_88.RULE +++ b/src/licensedcode/data/rules/free-unknown_88.RULE @@ -1,6 +1,6 @@ --- license_expression: free-unknown -is_license_reference: yes +is_license_clue: yes relevance: 50 --- diff --git a/src/licensedcode/data/rules/license-clue_2.RULE b/src/licensedcode/data/rules/license-clue_2.RULE new file mode 100644 index 00000000000..3169e429153 --- /dev/null +++ b/src/licensedcode/data/rules/license-clue_2.RULE @@ -0,0 +1,6 @@ +--- +license_expression: free-unknown +is_license_clue: yes +--- + +licensed under an open source license \ No newline at end of file diff --git a/src/licensedcode/data/rules/proprietary_greensock_8.RULE b/src/licensedcode/data/rules/proprietary_greensock_8.RULE index 0fdca4ef004..41218448640 100644 --- a/src/licensedcode/data/rules/proprietary_greensock_8.RULE +++ b/src/licensedcode/data/rules/proprietary_greensock_8.RULE @@ -1,6 +1,6 @@ --- license_expression: proprietary-license -is_license_reference: yes +is_license_clue: yes relevance: 90 ignorable_urls: - http://www.greensock.com/ diff --git a/src/licensedcode/data/rules/python_10.RULE b/src/licensedcode/data/rules/python_10.RULE index 558e916f1f5..5835fda1bd3 100644 --- a/src/licensedcode/data/rules/python_10.RULE +++ b/src/licensedcode/data/rules/python_10.RULE @@ -1,6 +1,6 @@ --- license_expression: python -is_license_reference: yes +is_license_clue: yes relevance: 80 notes: seen in FreeBSD. Alone this is not super discriminant --- diff --git a/src/licensedcode/data/rules/unknown-license-reference_131.RULE b/src/licensedcode/data/rules/unknown-license-reference_131.RULE index 1c9b8b422f1..36aab88ae38 100644 --- a/src/licensedcode/data/rules/unknown-license-reference_131.RULE +++ b/src/licensedcode/data/rules/unknown-license-reference_131.RULE @@ -1,6 +1,6 @@ --- license_expression: unknown-license-reference -is_license_reference: yes +is_license_clue: yes notes: https://raw.githubusercontent.com/finalburnneo/FBNeo/master/src/license.txt --- diff --git a/src/licensedcode/data/rules/unknown-license-reference_82.RULE b/src/licensedcode/data/rules/unknown-license-reference_82.RULE index f6706a458e1..1c0f9f3cd50 100644 --- a/src/licensedcode/data/rules/unknown-license-reference_82.RULE +++ b/src/licensedcode/data/rules/unknown-license-reference_82.RULE @@ -1,6 +1,6 @@ --- license_expression: unknown-license-reference -is_license_reference: yes +is_license_clue: yes relevance: 90 ignorable_urls: - https://newen.visualstudio.com/_git/NewenNetworks From 79871d3fec1c0faa500d0dabc85da47c3a94ec42 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Fri, 21 Jul 2023 19:46:38 +0530 Subject: [PATCH 06/12] Fix setup.cfg license detection bug Signed-off-by: Ayan Sinha Mahapatra --- src/licensedcode/data/rules/bsd-new_1302.RULE | 10 + src/licensedcode/data/rules/bsd-new_1303.RULE | 9 + src/packagedcode/pypi.py | 7 + .../data/instance/pypi/LICENSE.rst | 1 + ...n-package-instance-expected-with-uuid.json | 65 ++++- .../python-package-instance-expected.json | 65 ++++- ...ackage-instance-with-license-expected.json | 246 +++++++++++------- .../wheel-0.34.2/setup.cfg-expected.json | 91 ++++++- tests/packagedcode/test_package_instance.py | 2 +- tests/packagedcode/test_pypi.py | 10 + 10 files changed, 378 insertions(+), 128 deletions(-) create mode 100644 src/licensedcode/data/rules/bsd-new_1302.RULE create mode 100644 src/licensedcode/data/rules/bsd-new_1303.RULE create mode 100644 tests/packagedcode/data/instance/pypi/LICENSE.rst diff --git a/src/licensedcode/data/rules/bsd-new_1302.RULE b/src/licensedcode/data/rules/bsd-new_1302.RULE new file mode 100644 index 00000000000..d0db2df64e4 --- /dev/null +++ b/src/licensedcode/data/rules/bsd-new_1302.RULE @@ -0,0 +1,10 @@ +--- +license_expression: bsd-new +is_license_tag: yes +relevance: 100 +referenced_filenames: + - LICENSE.rst +--- + +license = BSD-3-Clause +license_files = LICENSE.rst \ No newline at end of file diff --git a/src/licensedcode/data/rules/bsd-new_1303.RULE b/src/licensedcode/data/rules/bsd-new_1303.RULE new file mode 100644 index 00000000000..c15c25560e4 --- /dev/null +++ b/src/licensedcode/data/rules/bsd-new_1303.RULE @@ -0,0 +1,9 @@ +--- +license_expression: bsd-new +is_license_tag: yes +relevance: 100 +referenced_filenames: + - LICENSE.rst +--- + +BSD-3-Clause LICENSE.rst \ No newline at end of file diff --git a/src/packagedcode/pypi.py b/src/packagedcode/pypi.py index 04ebebae1f5..cde769d4de1 100644 --- a/src/packagedcode/pypi.py +++ b/src/packagedcode/pypi.py @@ -771,6 +771,7 @@ def parse(cls, location): 'name', 'version', 'license', + 'license_files', 'url', 'author', 'author_email', @@ -793,6 +794,11 @@ def parse(cls, location): ) ] + extracted_license_statement = metadata.get('license') + license_file_references = metadata.get('license_files') + if license_file_references: + extracted_license_statement = f"{extracted_license_statement} {license_file_references}" + yield models.PackageData( datasource_id=cls.datasource_id, type=cls.default_package_type, @@ -802,6 +808,7 @@ def parse(cls, location): homepage_url=metadata.get('url'), primary_language=cls.default_primary_language, dependencies=dependent_packages, + extracted_license_statement=extracted_license_statement, ) @classmethod diff --git a/tests/packagedcode/data/instance/pypi/LICENSE.rst b/tests/packagedcode/data/instance/pypi/LICENSE.rst new file mode 100644 index 00000000000..bcbe412d3f6 --- /dev/null +++ b/tests/packagedcode/data/instance/pypi/LICENSE.rst @@ -0,0 +1 @@ +license bsd-new \ No newline at end of file diff --git a/tests/packagedcode/data/instance/python-package-instance-expected-with-uuid.json b/tests/packagedcode/data/instance/python-package-instance-expected-with-uuid.json index 16d915a6d44..5c0ad489500 100644 --- a/tests/packagedcode/data/instance/python-package-instance-expected-with-uuid.json +++ b/tests/packagedcode/data/instance/python-package-instance-expected-with-uuid.json @@ -32,13 +32,33 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": null, - "declared_license_expression_spdx": null, - "license_detections": [], + "declared_license_expression": "bsd-new", + "declared_license_expression_spdx": "BSD-3-Clause", + "license_detections": [ + { + "license_expression": "bsd-new", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "bsd-new", + "rule_identifier": "bsd-new_1303.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_1303.RULE", + "matched_text": "BSD-3-Clause LICENSE.rst" + } + ], + "identifier": "bsd_new-93f27a43-68fa-0573-8609-f6d624f3ac9a" + } + ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": null, + "extracted_license_statement": "BSD-3-Clause LICENSE.rst", "notice_text": null, "source_packages": [], "extra_data": {}, @@ -100,6 +120,15 @@ } ], "files": [ + { + "path": "LICENSE.rst", + "type": "file", + "package_data": [], + "for_packages": [ + "pkg:pypi/click@attr:%20click.__version__?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "scan_errors": [] + }, { "path": "MANIFEST.in", "type": "file", @@ -145,13 +174,33 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": null, - "declared_license_expression_spdx": null, - "license_detections": [], + "declared_license_expression": "bsd-new", + "declared_license_expression_spdx": "BSD-3-Clause", + "license_detections": [ + { + "license_expression": "bsd-new", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "bsd-new", + "rule_identifier": "bsd-new_1303.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_1303.RULE", + "matched_text": "BSD-3-Clause LICENSE.rst" + } + ], + "identifier": "bsd_new-93f27a43-68fa-0573-8609-f6d624f3ac9a" + } + ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": null, + "extracted_license_statement": "BSD-3-Clause LICENSE.rst", "notice_text": null, "source_packages": [], "file_references": [], diff --git a/tests/packagedcode/data/instance/python-package-instance-expected.json b/tests/packagedcode/data/instance/python-package-instance-expected.json index 16d915a6d44..5c0ad489500 100644 --- a/tests/packagedcode/data/instance/python-package-instance-expected.json +++ b/tests/packagedcode/data/instance/python-package-instance-expected.json @@ -32,13 +32,33 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": null, - "declared_license_expression_spdx": null, - "license_detections": [], + "declared_license_expression": "bsd-new", + "declared_license_expression_spdx": "BSD-3-Clause", + "license_detections": [ + { + "license_expression": "bsd-new", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "bsd-new", + "rule_identifier": "bsd-new_1303.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_1303.RULE", + "matched_text": "BSD-3-Clause LICENSE.rst" + } + ], + "identifier": "bsd_new-93f27a43-68fa-0573-8609-f6d624f3ac9a" + } + ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": null, + "extracted_license_statement": "BSD-3-Clause LICENSE.rst", "notice_text": null, "source_packages": [], "extra_data": {}, @@ -100,6 +120,15 @@ } ], "files": [ + { + "path": "LICENSE.rst", + "type": "file", + "package_data": [], + "for_packages": [ + "pkg:pypi/click@attr:%20click.__version__?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "scan_errors": [] + }, { "path": "MANIFEST.in", "type": "file", @@ -145,13 +174,33 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": null, - "declared_license_expression_spdx": null, - "license_detections": [], + "declared_license_expression": "bsd-new", + "declared_license_expression_spdx": "BSD-3-Clause", + "license_detections": [ + { + "license_expression": "bsd-new", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 5, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "bsd-new", + "rule_identifier": "bsd-new_1303.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_1303.RULE", + "matched_text": "BSD-3-Clause LICENSE.rst" + } + ], + "identifier": "bsd_new-93f27a43-68fa-0573-8609-f6d624f3ac9a" + } + ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": null, + "extracted_license_statement": "BSD-3-Clause LICENSE.rst", "notice_text": null, "source_packages": [], "file_references": [], diff --git a/tests/packagedcode/data/instance/python-package-instance-with-license-expected.json b/tests/packagedcode/data/instance/python-package-instance-with-license-expected.json index dc092551438..cc1cfe51bc3 100644 --- a/tests/packagedcode/data/instance/python-package-instance-with-license-expected.json +++ b/tests/packagedcode/data/instance/python-package-instance-with-license-expected.json @@ -32,62 +32,48 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": "(bsd-new AND (bsd-new AND bsd-simplified)) AND bsd-new", - "declared_license_expression_spdx": "(BSD-3-Clause AND (BSD-3-Clause AND BSD-2-Clause)) AND BSD-3-Clause", + "declared_license_expression": "bsd-new", + "declared_license_expression_spdx": "BSD-3-Clause", "license_detections": [ { - "license_expression": "bsd-new AND (bsd-new AND bsd-simplified)", + "license_expression": "bsd-new", "matches": [ { - "score": 11.36, - "start_line": 13, - "end_line": 14, + "score": 100.0, + "start_line": 1, + "end_line": 1, "matched_length": 5, - "match_coverage": 11.36, - "matcher": "3-seq", + "match_coverage": 100.0, + "matcher": "1-hash", "license_expression": "bsd-new", - "rule_identifier": "bsd-new_537.RULE", + "rule_identifier": "bsd-new_1303.RULE", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_537.RULE" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_1303.RULE", + "matched_text": "BSD-3-Clause LICENSE.rst" }, - { - "score": 13.16, - "start_line": 13, - "end_line": 15, - "matched_length": 5, - "match_coverage": 13.16, - "matcher": "3-seq", - "license_expression": "bsd-new AND bsd-simplified", - "rule_identifier": "bsd-new_and_bsd-simplified_1.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_and_bsd-simplified_1.RULE" - } - ], - "identifier": "bsd_new_and__bsd_new_and_bsd_simplified-6feee5ac-439e-c60c-2478-86ff52373283" - }, - { - "license_expression": "bsd-new", - "matches": [ { "score": 99.0, - "start_line": 25, - "end_line": 25, - "matched_length": 5, + "start_line": 1, + "end_line": 1, + "matched_length": 2, "match_coverage": 100.0, "matcher": "2-aho", "license_expression": "bsd-new", - "rule_identifier": "pypi_bsd_license.RULE", + "rule_identifier": "bsd-new_89.RULE", "rule_relevance": 99, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/pypi_bsd_license.RULE" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE" } ], - "identifier": "bsd_new-f4e99f86-00ab-18d9-a65d-a3a12767dcf5" + "identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf", + "detection_log": [ + "package-unknown-reference-to-local-file" + ] } ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": null, + "extracted_license_statement": "BSD-3-Clause LICENSE.rst", "notice_text": null, "source_packages": [], "extra_data": {}, @@ -150,17 +136,69 @@ ], "license_detections": [ { - "identifier": "bsd_new-f4e99f86-00ab-18d9-a65d-a3a12767dcf5", + "identifier": "bsd_new-261898a0-0118-87c4-7092-14e4ff134882", + "license_expression": "bsd-new", + "detection_count": 2, + "detection_log": [] + }, + { + "identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf", + "license_expression": "bsd-new", + "detection_count": 1, + "detection_log": [ + "package-unknown-reference-to-local-file" + ] + }, + { + "identifier": "bsd-new-68720980-08c9-ffb1-f28e-24c2e067385b", "license_expression": "bsd-new", - "detection_count": 2 + "detection_count": 1, + "detection_log": [ + "unknown-reference-to-local-file" + ] }, { - "identifier": "bsd_new_and__bsd_new_and_bsd_simplified-6feee5ac-439e-c60c-2478-86ff52373283", - "license_expression": "bsd-new AND (bsd-new AND bsd-simplified)", - "detection_count": 2 + "identifier": "bsd_new-f4e99f86-00ab-18d9-a65d-a3a12767dcf5", + "license_expression": "bsd-new", + "detection_count": 1, + "detection_log": [] } ], "files": [ + { + "path": "LICENSE.rst", + "type": "file", + "package_data": [], + "for_packages": [ + "pkg:pypi/click@attr:%20click.__version__?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "detected_license_expression": "bsd-new", + "detected_license_expression_spdx": "BSD-3-Clause", + "license_detections": [ + { + "license_expression": "bsd-new", + "matches": [ + { + "score": 99.0, + "start_line": 1, + "end_line": 1, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "bsd-new", + "rule_identifier": "bsd-new_89.RULE", + "rule_relevance": 99, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE" + } + ], + "detection_log": [], + "identifier": "bsd_new-261898a0-0118-87c4-7092-14e4ff134882" + } + ], + "license_clues": [], + "percentage_of_license_text": 66.67, + "scan_errors": [] + }, { "path": "MANIFEST.in", "type": "file", @@ -211,62 +249,48 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": "(bsd-new AND (bsd-new AND bsd-simplified)) AND bsd-new", - "declared_license_expression_spdx": "(BSD-3-Clause AND (BSD-3-Clause AND BSD-2-Clause)) AND BSD-3-Clause", + "declared_license_expression": "bsd-new", + "declared_license_expression_spdx": "BSD-3-Clause", "license_detections": [ { - "license_expression": "bsd-new AND (bsd-new AND bsd-simplified)", + "license_expression": "bsd-new", "matches": [ { - "score": 11.36, - "start_line": 13, - "end_line": 14, + "score": 100.0, + "start_line": 1, + "end_line": 1, "matched_length": 5, - "match_coverage": 11.36, - "matcher": "3-seq", + "match_coverage": 100.0, + "matcher": "1-hash", "license_expression": "bsd-new", - "rule_identifier": "bsd-new_537.RULE", + "rule_identifier": "bsd-new_1303.RULE", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_537.RULE" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_1303.RULE", + "matched_text": "BSD-3-Clause LICENSE.rst" }, - { - "score": 13.16, - "start_line": 13, - "end_line": 15, - "matched_length": 5, - "match_coverage": 13.16, - "matcher": "3-seq", - "license_expression": "bsd-new AND bsd-simplified", - "rule_identifier": "bsd-new_and_bsd-simplified_1.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_and_bsd-simplified_1.RULE" - } - ], - "identifier": "bsd_new_and__bsd_new_and_bsd_simplified-6feee5ac-439e-c60c-2478-86ff52373283" - }, - { - "license_expression": "bsd-new", - "matches": [ { "score": 99.0, - "start_line": 25, - "end_line": 25, - "matched_length": 5, + "start_line": 1, + "end_line": 1, + "matched_length": 2, "match_coverage": 100.0, "matcher": "2-aho", "license_expression": "bsd-new", - "rule_identifier": "pypi_bsd_license.RULE", + "rule_identifier": "bsd-new_89.RULE", "rule_relevance": 99, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/pypi_bsd_license.RULE" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE" } ], - "identifier": "bsd_new-f4e99f86-00ab-18d9-a65d-a3a12767dcf5" + "identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf", + "detection_log": [ + "package-unknown-reference-to-local-file" + ] } ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], - "extracted_license_statement": null, + "extracted_license_statement": "BSD-3-Clause LICENSE.rst", "notice_text": null, "source_packages": [], "file_references": [], @@ -293,38 +317,41 @@ "for_packages": [ "pkg:pypi/click@attr:%20click.__version__?uuid=fixed-uid-done-for-testing-5642512d1758" ], - "detected_license_expression": "(bsd-new AND (bsd-new AND bsd-simplified)) AND bsd-new", - "detected_license_expression_spdx": "(BSD-3-Clause AND (BSD-3-Clause AND BSD-2-Clause)) AND BSD-3-Clause", + "detected_license_expression": "bsd-new", + "detected_license_expression_spdx": "BSD-3-Clause", "license_detections": [ { - "license_expression": "bsd-new AND (bsd-new AND bsd-simplified)", + "license_expression": "bsd-new", "matches": [ { - "score": 11.36, + "score": 100.0, "start_line": 13, "end_line": 14, - "matched_length": 5, - "match_coverage": 11.36, - "matcher": "3-seq", + "matched_length": 8, + "match_coverage": 100.0, + "matcher": "2-aho", "license_expression": "bsd-new", - "rule_identifier": "bsd-new_537.RULE", + "rule_identifier": "bsd-new_1302.RULE", "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_537.RULE" + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_1302.RULE" }, { - "score": 13.16, - "start_line": 13, - "end_line": 15, - "matched_length": 5, - "match_coverage": 13.16, - "matcher": "3-seq", - "license_expression": "bsd-new AND bsd-simplified", - "rule_identifier": "bsd-new_and_bsd-simplified_1.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_and_bsd-simplified_1.RULE" + "score": 99.0, + "start_line": 1, + "end_line": 1, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "bsd-new", + "rule_identifier": "bsd-new_89.RULE", + "rule_relevance": 99, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE" } ], - "identifier": "bsd_new_and__bsd_new_and_bsd_simplified-6feee5ac-439e-c60c-2478-86ff52373283" + "detection_log": [ + "unknown-reference-to-local-file" + ], + "identifier": "bsd-new-68720980-08c9-ffb1-f28e-24c2e067385b" }, { "license_expression": "bsd-new", @@ -342,11 +369,12 @@ "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/pypi_bsd_license.RULE" } ], + "detection_log": [], "identifier": "bsd_new-f4e99f86-00ab-18d9-a65d-a3a12767dcf5" } ], "license_clues": [], - "percentage_of_license_text": 3.81, + "percentage_of_license_text": 4.13, "scan_errors": [] }, { @@ -377,9 +405,29 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": null, - "declared_license_expression_spdx": null, - "license_detections": [], + "declared_license_expression": "bsd-new", + "declared_license_expression_spdx": "BSD-3-Clause", + "license_detections": [ + { + "license_expression": "bsd-new", + "matches": [ + { + "score": 99.0, + "start_line": 1, + "end_line": 1, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "bsd-new", + "rule_identifier": "bsd-new_89.RULE", + "rule_relevance": 99, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE" + } + ], + "detection_log": [], + "identifier": "bsd_new-261898a0-0118-87c4-7092-14e4ff134882" + } + ], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], diff --git a/tests/packagedcode/data/pypi/setup.cfg/wheel-0.34.2/setup.cfg-expected.json b/tests/packagedcode/data/pypi/setup.cfg/wheel-0.34.2/setup.cfg-expected.json index aaf05585743..6e5c7c4c2b9 100644 --- a/tests/packagedcode/data/pypi/setup.cfg/wheel-0.34.2/setup.cfg-expected.json +++ b/tests/packagedcode/data/pypi/setup.cfg/wheel-0.34.2/setup.cfg-expected.json @@ -2,24 +2,24 @@ { "type": "pypi", "namespace": null, - "name": null, - "version": "0.34.2", + "name": "wheel", + "version": "attr: wheel.__version__", "qualifiers": {}, "subpath": null, "primary_language": "Python", - "description": "", + "description": null, "release_date": null, "parties": [ { "type": "person", - "role": "maintainer", - "name": "Alex Gr\u00f6nholm", - "email": null, + "role": "author", + "name": "Daniel Holth", + "email": "dholth@fastmail.fm", "url": null } ], "keywords": [], - "homepage_url": null, + "homepage_url": "https://github.com/pypa/wheel", "download_url": null, "size": null, "sha1": null, @@ -30,17 +30,84 @@ "code_view_url": null, "vcs_url": null, "copyright": null, - "license_expression": null, - "declared_license": {}, + "holder": null, + "declared_license_expression": "mit", + "declared_license_expression_spdx": "MIT", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "1-spdx-id", + "license_expression": "mit", + "rule_identifier": "spdx-license-identifier-mit-5da48780aba670b0860c46d899ed42a0f243ff06", + "rule_relevance": 100, + "rule_url": null, + "matched_text": "MIT" + } + ], + "identifier": "mit-a822f434-d61f-f2b1-c792-8b8cb9e7b9bf" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "MIT", "notice_text": null, "source_packages": [], "file_references": [], "extra_data": {}, - "dependencies": [], + "dependencies": [ + { + "purl": "pkg:pypi/setuptools", + "extracted_requirement": "setuptools>=40.9.0", + "scope": "setup", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:generic/python", + "extracted_requirement": "python_requires>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", + "scope": "python", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/pytest", + "extracted_requirement": "pytest>=3.0.0", + "scope": "test", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/pytest-cov", + "extracted_requirement": "pytest-cov", + "scope": "test", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], "repository_homepage_url": null, "repository_download_url": null, "api_data_url": null, - "datasource_id": "pypi_setup_py", - "purl": null + "datasource_id": "pypi_setup_cfg", + "purl": "pkg:pypi/wheel@attr:%20wheel.__version__" } ] \ No newline at end of file diff --git a/tests/packagedcode/test_package_instance.py b/tests/packagedcode/test_package_instance.py index 20b771d5c0e..56d017721b4 100644 --- a/tests/packagedcode/test_package_instance.py +++ b/tests/packagedcode/test_package_instance.py @@ -29,7 +29,7 @@ def test_package_instance_scan_python_with_license(self): test_dir = self.get_test_loc('instance/pypi') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('instance/python-package-instance-with-license-expected.json') - run_scan_click(['--package', '--license', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) + run_scan_click(['--package', '--license', '--license-diagnostics', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES, remove_uuid=True) # Note that this will fail even at regen True. diff --git a/tests/packagedcode/test_pypi.py b/tests/packagedcode/test_pypi.py index 7ecac8c8397..ba55474fd17 100644 --- a/tests/packagedcode/test_pypi.py +++ b/tests/packagedcode/test_pypi.py @@ -547,6 +547,16 @@ def test_parse_setup_py_arpy(self): self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES) +class TestPyPiSetupCfg(PackageTester): + test_data_dir = os.path.join(os.path.dirname(__file__), 'data') + + def test_parse_setup_cfg(self): + test_file = self.get_test_loc('pypi/setup.cfg/wheel-0.34.2/setup.cfg') + package = pypi.SetupCfgHandler.parse(test_file) + expected_loc = self.get_test_loc('pypi/setup.cfg/wheel-0.34.2/setup.cfg-expected.json') + self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES) + + class TestPyPiSetupPyNames(PackageTester): test_data_dir = os.path.join(os.path.dirname(__file__), 'data') From cfa072b34e573be350f673c86dffb61d3a2eabe8 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Fri, 21 Jul 2023 20:47:18 +0530 Subject: [PATCH 07/12] Fix license detection bugs * Top level packages were inconsistant because of license plugin post processing running after the package plugin post processing. * Adjust license clues/false-postives/bad matches heuristics. Signed-off-by: Ayan Sinha Mahapatra --- src/licensedcode/detection.py | 65 +++- .../yaml/package-and-licenses-expected.yaml | 70 ++-- ...e-reference-works-with-clues.expected.json | 52 +-- .../stable_copyright-detailed.expected.yml | 2 +- .../p/perl/copyright-detailed.expected.yml | 2 +- .../fusiondirectory.expected.json | 324 +++++------------- .../reference-to-package/samba.expected.json | 314 +++-------------- ...ackson-dataformat-xml-2.13.5-expected.json | 105 ++---- 8 files changed, 283 insertions(+), 651 deletions(-) diff --git a/src/licensedcode/detection.py b/src/licensedcode/detection.py index 6b049ba799a..d85fff91e02 100644 --- a/src/licensedcode/detection.py +++ b/src/licensedcode/detection.py @@ -25,6 +25,7 @@ from commoncode.text import python_safe_name from licensedcode.cache import get_index from licensedcode.cache import get_cache +from licensedcode.cache import build_spdx_license_expression from licensedcode.match import LicenseMatch from licensedcode.match import set_matched_lines from licensedcode.models import UnDetectedRule @@ -105,6 +106,7 @@ class DetectionCategory(Enum): EXTRA_WORDS = 'extra-words' UNKNOWN_MATCH = 'unknown-match' LICENSE_CLUES = 'license-clues' + LOW_QUALITY_MATCHES = 'license-clues' IMPERFECT_COVERAGE = 'imperfect-match-coverage' FALSE_POSITVE = 'possible-false-positive' UNDETECTED_LICENSE = 'undetected-license' @@ -730,6 +732,10 @@ def collect_license_detections(codebase, include_license_clues=True): ) if not detection_is_same: package["declared_license_expression"] = license_expression + package["declared_license_expression_spdx"] = str(build_spdx_license_expression( + license_expression=license_expression, + licensing=get_cache().licensing, + )) modified = True other_license_detections = package["other_license_detections"] @@ -741,6 +747,10 @@ def collect_license_detections(codebase, include_license_clues=True): ) if not detection_is_same: package["other_license_expression"] = license_expression + package["other_license_expression_spdx"] = str(build_spdx_license_expression( + license_expression=license_expression, + licensing=get_cache().licensing, + )) modified = True if modified: @@ -753,6 +763,30 @@ def collect_license_detections(codebase, include_license_clues=True): ) all_license_detections.extend(package_license_detection_objects) + if has_packages and has_licenses: + for package in getattr(codebase.attributes, 'packages', []): + license_expression_package = package["declared_license_expression"] + if not license_expression_package: + continue + + resource_paths = package["datafile_paths"] + if len(resource_paths) == 1: + resource_path = resource_paths[0] + else: + #TODO: implement the correct consistency check + # based on which datafile path the license came from + resource_path = resource_paths[0] + resource = codebase.get_resource(path=resource_path) + resource_packages = getattr(resource, 'package_data', None) + if not resource_packages or len(resource_packages) > 1: + continue + + resource_package = resource_packages[0] + if license_expression_package != resource_package["declared_license_expression"]: + package["license_detections"] = resource_package["license_detections"] + package["declared_license_expression"] = resource_package["declared_license_expression"] + package["declared_license_expression_spdx"] = resource_package["declared_license_expression_spdx"] + return all_license_detections @@ -1107,7 +1141,7 @@ def has_correct_license_clue_matches(license_matches): return is_correct_detection(license_matches) and all(match.rule.is_license_clue for match in license_matches) -def is_license_clues(license_matches): +def is_low_quality_matches(license_matches): """ Return True if the license_matches are not part of a correct license detection and are mere license clues. @@ -1329,6 +1363,14 @@ def get_detected_license_expression( detection_log.append(DetectionRule.LICENSE_CLUES.value) return detection_log, combined_expression + elif analysis == DetectionCategory.LOW_QUALITY_MATCHES.value: + if TRACE_ANALYSIS: + logger_debug(f'analysis {DetectionCategory.LICENSE_CLUES.value}') + # TODO: we are temporarily returning these as license clues, and not + # in detections but ideally we should return synthetic unknowns for these + detection_log.append(DetectionRule.LOW_QUALITY_MATCHES.value) + return detection_log, combined_expression + else: if TRACE_ANALYSIS: logger_debug(f'analysis not-combined') @@ -1510,8 +1552,8 @@ def analyze_detection(license_matches, package_license=False): elif has_unknown_matches(license_matches=license_matches): return DetectionCategory.UNKNOWN_MATCH.value - elif is_license_clues(license_matches=license_matches): - return DetectionCategory.LICENSE_CLUES.value + elif not package_license and is_low_quality_matches(license_matches=license_matches): + return DetectionCategory.LOW_QUALITY_MATCHES.value # Case where at least one of the matches have `match_coverage` # below IMPERFECT_MATCH_COVERAGE_THR @@ -1644,12 +1686,10 @@ def process_detections(detections, licensing=Licensing()): for detection in detections: if detection.license_expression == None: - license_keys = licensing.license_keys(expression=detection.license_expression) - if all( - key in detected_license_keys - for key in license_keys - ): - detection.license_expression = str(combine_expressions( + if has_correct_license_clue_matches(detection.matches): + continue + + license_expression = str(combine_expressions( expressions=[ match.rule.license_expression for match in detection.matches @@ -1657,6 +1697,13 @@ def process_detections(detections, licensing=Licensing()): unique=True, licensing=licensing, )) + license_keys = licensing.license_keys(expression=license_expression) + + if all( + key in detected_license_keys + for key in license_keys + ): + detection.license_expression = license_expression detection.detection_log.append(DetectionRule.NOT_LICENSE_CLUES.value) detection.identifier = detection.identifier_with_expression diff --git a/tests/formattedcode/data/yaml/package-and-licenses-expected.yaml b/tests/formattedcode/data/yaml/package-and-licenses-expected.yaml index 05c1c7afac0..da4f8a8a0c7 100644 --- a/tests/formattedcode/data/yaml/package-and-licenses-expected.yaml +++ b/tests/formattedcode/data/yaml/package-and-licenses-expected.yaml @@ -90,21 +90,21 @@ packages: - license_expression: apache-2.0 matches: - score: '100.0' - start_line: 4 - end_line: 4 - matched_length: 4 + start_line: 1 + end_line: 1 + matched_length: 3 match_coverage: '100.0' - matcher: 2-aho + matcher: 1-hash license_expression: apache-2.0 - rule_identifier: apache-2.0_65.RULE + rule_identifier: spdx_license_id_apache-2.0_for_apache-2.0.RULE rule_relevance: 100 - rule_url: https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_65.RULE - matched_text: license = Apache-2.0 - identifier: apache_2_0-ec759ae0-ea5a-f138-793e-388520e080c0 + rule_url: https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_apache-2.0_for_apache-2.0.RULE + matched_text: Apache-2.0 + identifier: apache_2_0-d66ab77d-a5cc-7104-e702-dc7df61fe9e8 other_license_expression: other_license_expression_spdx: other_license_detections: [] - extracted_license_statement: + extracted_license_statement: Apache-2.0 notice_text: source_packages: [] extra_data: {} @@ -119,12 +119,15 @@ packages: purl: pkg:pypi/codebase dependencies: [] license_detections: - - identifier: apache_2_0-ec759ae0-ea5a-f138-793e-388520e080c0 - license_expression: apache-2.0 - detection_count: 2 - identifier: apache_2_0-ab23f79b-ec38-9a8a-9b23-85059407f34d license_expression: apache-2.0 detection_count: 1 + - identifier: apache_2_0-d66ab77d-a5cc-7104-e702-dc7df61fe9e8 + license_expression: apache-2.0 + detection_count: 1 + - identifier: apache_2_0-ec759ae0-ea5a-f138-793e-388520e080c0 + license_expression: apache-2.0 + detection_count: 1 - identifier: apache_2_0_and__apache_2_0_or_mit-9b638e72-e872-a67f-3447-eec297ef7b39 license_expression: apache-2.0 AND (apache-2.0 OR mit) detection_count: 1 @@ -706,6 +709,31 @@ license_rule_references: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + - license_expression: apache-2.0 + identifier: spdx_license_id_apache-2.0_for_apache-2.0.RULE + language: en + rule_url: https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_apache-2.0_for_apache-2.0.RULE + is_license_text: no + is_license_notice: no + is_license_reference: yes + is_license_tag: no + is_license_intro: no + is_license_clue: no + is_continuous: no + is_builtin: yes + is_from_license: no + is_synthetic: no + length: 3 + relevance: 100 + minimum_coverage: 100 + referenced_filenames: [] + notes: Used to detect a bare SPDX license id + ignorable_copyrights: [] + ignorable_holders: [] + ignorable_authors: [] + ignorable_urls: [] + ignorable_emails: [] + text: apache-2.0 files: - path: package-and-licenses type: directory @@ -1148,21 +1176,21 @@ files: - license_expression: apache-2.0 matches: - score: '100.0' - start_line: 4 - end_line: 4 - matched_length: 4 + start_line: 1 + end_line: 1 + matched_length: 3 match_coverage: '100.0' - matcher: 2-aho + matcher: 1-hash license_expression: apache-2.0 - rule_identifier: apache-2.0_65.RULE + rule_identifier: spdx_license_id_apache-2.0_for_apache-2.0.RULE rule_relevance: 100 - rule_url: https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_65.RULE - matched_text: license = Apache-2.0 - identifier: apache_2_0-ec759ae0-ea5a-f138-793e-388520e080c0 + rule_url: https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_apache-2.0_for_apache-2.0.RULE + matched_text: Apache-2.0 + identifier: apache_2_0-d66ab77d-a5cc-7104-e702-dc7df61fe9e8 other_license_expression: other_license_expression_spdx: other_license_detections: [] - extracted_license_statement: + extracted_license_statement: Apache-2.0 notice_text: source_packages: [] file_references: [] diff --git a/tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json b/tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json index d2c8fd87484..83fbe8c3cef 100644 --- a/tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json +++ b/tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json @@ -12,15 +12,6 @@ "detection_count": 1, "detection_log": [] }, - { - "identifier": "bsd_simplified-7517fbd6-3fa4-e9f9-2167-c65251d77656", - "license_expression": "bsd-simplified", - "detection_count": 1, - "detection_log": [ - "license-clues", - "not-license-clues-as-more-detections-present" - ] - }, { "identifier": "bzip2_libbzip_2010-7158bcb2-a4d7-9815-17d2-1b1d0a6d5de2", "license_expression": "bzip2-libbzip-2010", @@ -1194,8 +1185,8 @@ { "path": "python.LICENSE", "type": "file", - "detected_license_expression": "python AND (other-copyleft AND gpl-1.0-plus) AND (python AND python-cwi) AND bzip2-libbzip-2010 AND sleepycat AND bsd-simplified AND bsd-new AND openssl-ssleay AND openssl AND ssleay-windows AND tcl", - "detected_license_expression_spdx": "Python-2.0 AND (LicenseRef-scancode-other-copyleft AND GPL-1.0-or-later) AND (Python-2.0 AND LicenseRef-scancode-python-cwi) AND bzip2-1.0.6 AND Sleepycat AND BSD-2-Clause AND BSD-3-Clause AND OpenSSL AND LicenseRef-scancode-openssl AND LicenseRef-scancode-ssleay-windows AND TCL", + "detected_license_expression": "python AND (other-copyleft AND gpl-1.0-plus) AND (python AND python-cwi) AND bzip2-libbzip-2010 AND sleepycat AND bsd-new AND openssl-ssleay AND openssl AND ssleay-windows AND tcl", + "detected_license_expression_spdx": "Python-2.0 AND (LicenseRef-scancode-other-copyleft AND GPL-1.0-or-later) AND (Python-2.0 AND LicenseRef-scancode-python-cwi) AND bzip2-1.0.6 AND Sleepycat AND BSD-3-Clause AND OpenSSL AND LicenseRef-scancode-openssl AND LicenseRef-scancode-ssleay-windows AND TCL", "license_detections": [ { "license_expression": "python", @@ -1431,29 +1422,6 @@ ], "identifier": "sleepycat-a7cd8833-ecc2-8ade-54d7-392befcce801" }, - { - "license_expression": "bsd-simplified", - "matches": [ - { - "score": 33.71, - "start_line": 358, - "end_line": 363, - "matched_length": 59, - "match_coverage": 33.71, - "matcher": "3-seq", - "license_expression": "bsd-simplified", - "rule_identifier": "bsd-simplified_242.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-simplified_242.RULE", - "matched_text": "INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE." - } - ], - "detection_log": [ - "license-clues", - "not-license-clues-as-more-detections-present" - ], - "identifier": "bsd_simplified-7517fbd6-3fa4-e9f9-2167-c65251d77656" - }, { "license_expression": "bsd-new", "matches": [ @@ -1653,7 +1621,21 @@ "identifier": "tcl-75d8de8c-9cf0-d604-4b99-e03436ebfcd3" } ], - "license_clues": [], + "license_clues": [ + { + "score": 33.71, + "start_line": 358, + "end_line": 363, + "matched_length": 59, + "match_coverage": 33.71, + "matcher": "3-seq", + "license_expression": "bsd-simplified", + "rule_identifier": "bsd-simplified_242.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-simplified_242.RULE", + "matched_text": "INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE." + } + ], "percentage_of_license_text": 83.64, "scan_errors": [] } diff --git a/tests/packagedcode/data/debian/copyright/debian-2019-11-15/main/m/mariadb-10.3/stable_copyright-detailed.expected.yml b/tests/packagedcode/data/debian/copyright/debian-2019-11-15/main/m/mariadb-10.3/stable_copyright-detailed.expected.yml index 3083ad07ef7..1084cf20376 100644 --- a/tests/packagedcode/data/debian/copyright/debian-2019-11-15/main/m/mariadb-10.3/stable_copyright-detailed.expected.yml +++ b/tests/packagedcode/data/debian/copyright/debian-2019-11-15/main/m/mariadb-10.3/stable_copyright-detailed.expected.yml @@ -545,7 +545,7 @@ other_license_detections: 2. Redistributions in binary form must the following disclaimer in the documentation and/or other materials provided with the distribution. - identifier: + identifier: bsd_new-7c8321ea-5f82-974c-692b-936bcaabf520 - license_expression: bsd-new matches: - score: '100.0' diff --git a/tests/packagedcode/data/debian/copyright/debian-2019-11-15/main/p/perl/copyright-detailed.expected.yml b/tests/packagedcode/data/debian/copyright/debian-2019-11-15/main/p/perl/copyright-detailed.expected.yml index 0b3025240f4..90b89f0ee81 100644 --- a/tests/packagedcode/data/debian/copyright/debian-2019-11-15/main/p/perl/copyright-detailed.expected.yml +++ b/tests/packagedcode/data/debian/copyright/debian-2019-11-15/main/p/perl/copyright-detailed.expected.yml @@ -3337,7 +3337,7 @@ other_license_detections: matched_text: | license notice, but it is assumed that it is licensed under the same terms as - identifier: + identifier: artistic_perl_1_0_or_gpl_1_0_plus-f8a67153-d3ca-59da-be8b-68b1535b0862 - license_expression: artistic-perl-1.0 OR gpl-1.0-plus matches: - score: '100.0' diff --git a/tests/packagedcode/data/license_detection/reference-to-package/fusiondirectory.expected.json b/tests/packagedcode/data/license_detection/reference-to-package/fusiondirectory.expected.json index ff09971d7e3..4139cefc08b 100644 --- a/tests/packagedcode/data/license_detection/reference-to-package/fusiondirectory.expected.json +++ b/tests/packagedcode/data/license_detection/reference-to-package/fusiondirectory.expected.json @@ -4824,15 +4824,6 @@ "detection_count": 2, "detection_log": [] }, - { - "identifier": "lgpl_3_0-6b4a45da-85cc-8eb0-5613-be81d4efd6a5", - "license_expression": "lgpl-3.0", - "detection_count": 2, - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ] - }, { "identifier": "lgpl_3_0_plus-4c8d95b2-1acf-7a81-473c-d8e70962288c", "license_expression": "lgpl-3.0-plus", @@ -4848,15 +4839,6 @@ "not-license-clues-as-more-detections-present" ] }, - { - "identifier": "mit_and_other_permissive-907b56d6-95b9-e85c-83c0-efd967c7e30a", - "license_expression": "mit AND other-permissive", - "detection_count": 2, - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ] - }, { "identifier": "public_domain-1a6a4f2c-bd92-9942-920f-be3d0c2bbda6", "license_expression": "public-domain", @@ -4865,15 +4847,6 @@ "possible-false-positive", "not-license-clues-as-more-detections-present" ] - }, - { - "identifier": "public_domain_and_bsd_original_and_gpl_1_0_plus-ccb73883-974d-42eb-d572-39fa7bf22f4c", - "license_expression": "public-domain AND bsd-original AND gpl-1.0-plus", - "detection_count": 2, - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ] } ], "files": [ @@ -5377,8 +5350,8 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": "gpl-2.0-plus AND (gpl-2.0-plus AND free-unknown) AND bsd-new AND lgpl-3.0-plus AND public-domain AND mit AND bsd-original AND (gpl-2.0-plus AND gpl-3.0-plus AND lgpl-2.1-plus AND lgpl-3.0-plus AND bsd-new AND bsd-original AND mit AND public-domain AND other-permissive) AND bsd-simplified AND lgpl-3.0 AND (mit AND other-permissive) AND (public-domain AND bsd-original AND gpl-1.0-plus)", - "declared_license_expression_spdx": "GPL-2.0-or-later AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown) AND BSD-3-Clause AND LGPL-3.0-or-later AND LicenseRef-scancode-public-domain AND MIT AND BSD-4-Clause AND (GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later AND BSD-3-Clause AND BSD-4-Clause AND MIT AND LicenseRef-scancode-public-domain AND LicenseRef-scancode-other-permissive) AND BSD-2-Clause AND LGPL-3.0-only AND (MIT AND LicenseRef-scancode-other-permissive) AND (LicenseRef-scancode-public-domain AND BSD-4-Clause AND GPL-1.0-or-later)", + "declared_license_expression": "gpl-2.0-plus AND (gpl-2.0-plus AND free-unknown) AND bsd-new AND lgpl-3.0-plus AND public-domain AND mit AND bsd-original AND (gpl-2.0-plus AND gpl-3.0-plus AND lgpl-2.1-plus AND lgpl-3.0-plus AND bsd-new AND bsd-original AND mit AND public-domain AND other-permissive) AND bsd-simplified", + "declared_license_expression_spdx": "GPL-2.0-or-later AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown) AND BSD-3-Clause AND LGPL-3.0-or-later AND LicenseRef-scancode-public-domain AND MIT AND BSD-4-Clause AND (GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later AND BSD-3-Clause AND BSD-4-Clause AND MIT AND LicenseRef-scancode-public-domain AND LicenseRef-scancode-other-permissive) AND BSD-2-Clause", "license_detections": [ { "license_expression": "gpl-2.0-plus", @@ -6590,29 +6563,6 @@ "detection_log": [], "identifier": "gpl_2_0_plus-227f50b1-f05e-5b3b-b107-ae1e2f56448b" }, - { - "license_expression": "lgpl-3.0", - "matches": [ - { - "score": 100.0, - "start_line": 2925, - "end_line": 2925, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "lgpl-3.0", - "rule_identifier": "lgpl-3.0_37.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_37.RULE", - "matched_text": "License: LGPL (v3" - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "lgpl_3_0-6b4a45da-85cc-8eb0-5613-be81d4efd6a5" - }, { "license_expression": "gpl-2.0-plus", "matches": [ @@ -6852,91 +6802,6 @@ ], "detection_log": [], "identifier": "gpl_2_0_plus-227f50b1-f05e-5b3b-b107-ae1e2f56448b" - }, - { - "license_expression": "mit AND other-permissive", - "matches": [ - { - "score": 90.0, - "start_line": 3010, - "end_line": 3010, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "mit", - "rule_identifier": "mit_221.RULE", - "rule_relevance": 90, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_221.RULE", - "matched_text": "License: MIT/X11 (" - }, - { - "score": 100.0, - "start_line": 3010, - "end_line": 3010, - "matched_length": 2, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "other-permissive", - "rule_identifier": "other-permissive_16.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/other-permissive_16.RULE", - "matched_text": "BSD like)" - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "mit_and_other_permissive-907b56d6-95b9-e85c-83c0-efd967c7e30a" - }, - { - "license_expression": "public-domain AND bsd-original AND gpl-1.0-plus", - "matches": [ - { - "score": 99.0, - "start_line": 3016, - "end_line": 3016, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "public-domain", - "rule_identifier": "pypi_public_domain.RULE", - "rule_relevance": 99, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/pypi_public_domain.RULE", - "matched_text": "License: Public domain" - }, - { - "score": 100.0, - "start_line": 3016, - "end_line": 3016, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "bsd-original", - "rule_identifier": "spdx_license_id_bsd-4-clause_for_bsd-original.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_bsd-4-clause_for_bsd-original.RULE", - "matched_text": "BSD (4 clause)" - }, - { - "score": 50.0, - "start_line": 3016, - "end_line": 3016, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-1.0-plus", - "rule_identifier": "gpl_bare_word_only.RULE", - "rule_relevance": 50, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl_bare_word_only.RULE", - "matched_text": "GPL" - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "public_domain_and_bsd_original_and_gpl_1_0_plus-ccb73883-974d-42eb-d572-39fa7bf22f4c" } ], "other_license_expression": null, @@ -12629,8 +12494,8 @@ "pkg:deb/fusiondirectory-theme-oxygen?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758", "pkg:deb/fusiondirectory-webservice-shell?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758" ], - "detected_license_expression": "gpl-2.0-plus AND bsd-simplified AND lgpl-3.0 AND (mit AND other-permissive) AND (public-domain AND bsd-original AND gpl-1.0-plus)", - "detected_license_expression_spdx": "GPL-2.0-or-later AND BSD-2-Clause AND LGPL-3.0-only AND (MIT AND LicenseRef-scancode-other-permissive) AND (LicenseRef-scancode-public-domain AND BSD-4-Clause AND GPL-1.0-or-later)", + "detected_license_expression": "gpl-2.0-plus AND bsd-simplified", + "detected_license_expression_spdx": "GPL-2.0-or-later AND BSD-2-Clause", "license_detections": [ { "license_expression": "gpl-2.0-plus", @@ -12852,29 +12717,6 @@ "detection_log": [], "identifier": "gpl_2_0_plus-227f50b1-f05e-5b3b-b107-ae1e2f56448b" }, - { - "license_expression": "lgpl-3.0", - "matches": [ - { - "score": 100.0, - "start_line": 2925, - "end_line": 2925, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "lgpl-3.0", - "rule_identifier": "lgpl-3.0_37.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_37.RULE", - "matched_text": "License: LGPL (v3" - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "lgpl_3_0-6b4a45da-85cc-8eb0-5613-be81d4efd6a5" - }, { "license_expression": "gpl-2.0-plus", "matches": [ @@ -13114,94 +12956,88 @@ ], "detection_log": [], "identifier": "gpl_2_0_plus-227f50b1-f05e-5b3b-b107-ae1e2f56448b" + } + ], + "license_clues": [ + { + "score": 100.0, + "start_line": 2925, + "end_line": 2925, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "lgpl-3.0", + "rule_identifier": "lgpl-3.0_37.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_37.RULE", + "matched_text": "License: LGPL (v3" }, { - "license_expression": "mit AND other-permissive", - "matches": [ - { - "score": 90.0, - "start_line": 3010, - "end_line": 3010, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "mit", - "rule_identifier": "mit_221.RULE", - "rule_relevance": 90, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_221.RULE", - "matched_text": "License: MIT/X11 (" - }, - { - "score": 100.0, - "start_line": 3010, - "end_line": 3010, - "matched_length": 2, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "other-permissive", - "rule_identifier": "other-permissive_16.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/other-permissive_16.RULE", - "matched_text": "BSD like)" - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "mit_and_other_permissive-907b56d6-95b9-e85c-83c0-efd967c7e30a" + "score": 90.0, + "start_line": 3010, + "end_line": 3010, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit_221.RULE", + "rule_relevance": 90, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_221.RULE", + "matched_text": "License: MIT/X11 (" + }, + { + "score": 100.0, + "start_line": 3010, + "end_line": 3010, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "other-permissive", + "rule_identifier": "other-permissive_16.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/other-permissive_16.RULE", + "matched_text": "BSD like)" }, { - "license_expression": "public-domain AND bsd-original AND gpl-1.0-plus", - "matches": [ - { - "score": 99.0, - "start_line": 3016, - "end_line": 3016, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "public-domain", - "rule_identifier": "pypi_public_domain.RULE", - "rule_relevance": 99, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/pypi_public_domain.RULE", - "matched_text": "License: Public domain" - }, - { - "score": 100.0, - "start_line": 3016, - "end_line": 3016, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "bsd-original", - "rule_identifier": "spdx_license_id_bsd-4-clause_for_bsd-original.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_bsd-4-clause_for_bsd-original.RULE", - "matched_text": "BSD (4 clause)" - }, - { - "score": 50.0, - "start_line": 3016, - "end_line": 3016, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-1.0-plus", - "rule_identifier": "gpl_bare_word_only.RULE", - "rule_relevance": 50, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl_bare_word_only.RULE", - "matched_text": "GPL" - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "public_domain_and_bsd_original_and_gpl_1_0_plus-ccb73883-974d-42eb-d572-39fa7bf22f4c" + "score": 99.0, + "start_line": 3016, + "end_line": 3016, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "public-domain", + "rule_identifier": "pypi_public_domain.RULE", + "rule_relevance": 99, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/pypi_public_domain.RULE", + "matched_text": "License: Public domain" + }, + { + "score": 100.0, + "start_line": 3016, + "end_line": 3016, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "bsd-original", + "rule_identifier": "spdx_license_id_bsd-4-clause_for_bsd-original.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_bsd-4-clause_for_bsd-original.RULE", + "matched_text": "BSD (4 clause)" + }, + { + "score": 50.0, + "start_line": 3016, + "end_line": 3016, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "gpl-1.0-plus", + "rule_identifier": "gpl_bare_word_only.RULE", + "rule_relevance": 50, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl_bare_word_only.RULE", + "matched_text": "GPL" } ], - "license_clues": [], "percentage_of_license_text": 0.66, "scan_errors": [] }, diff --git a/tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json b/tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json index 84e7e2eaa17..951516181fc 100644 --- a/tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json +++ b/tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json @@ -24,8 +24,8 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": "gpl-3.0 AND (gpl-3.0 AND lgpl-3.0 AND gpl-2.0) AND (gpl-2.0-plus AND free-unknown AND gpl-1.0-plus) AND (gpl-1.0-plus AND lgpl-3.0-plus AND gpl-3.0 AND lgpl-3.0) AND (cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1) AND gpl-2.0 AND gpl-1.0-plus", - "declared_license_expression_spdx": "GPL-3.0-only AND (GPL-3.0-only AND LGPL-3.0-only AND GPL-2.0-only) AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later) AND (GPL-1.0-or-later AND LGPL-3.0-or-later AND GPL-3.0-only AND LGPL-3.0-only) AND (CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1) AND GPL-2.0-only AND GPL-1.0-or-later", + "declared_license_expression": "gpl-3.0 AND (gpl-2.0-plus AND free-unknown AND gpl-1.0-plus) AND (gpl-1.0-plus AND lgpl-3.0-plus AND gpl-3.0 AND lgpl-3.0) AND (cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1) AND gpl-2.0 AND gpl-1.0-plus", + "declared_license_expression_spdx": "GPL-3.0-only AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later) AND (GPL-1.0-or-later AND LGPL-3.0-or-later AND GPL-3.0-only AND LGPL-3.0-only) AND (CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1) AND GPL-2.0-only AND GPL-1.0-or-later", "license_detections": [ { "license_expression": "gpl-3.0", @@ -47,55 +47,6 @@ "detection_log": [], "identifier": "gpl_3_0-ab79e5a8-e510-cbf4-5302-ef968484bcdf" }, - { - "license_expression": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0", - "matches": [ - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-3.0", - "rule_identifier": "gpl-3.0_32.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-3.0_32.RULE", - "matched_text": "GPLv3" - }, - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "lgpl-3.0", - "rule_identifier": "lgpl-3.0_29.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_29.RULE", - "matched_text": "LGPLv3 (" - }, - { - "score": 100.0, - "start_line": 39, - "end_line": 39, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-2.0", - "rule_identifier": "gpl-2.0_bare_single_word.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE", - "matched_text": "GPLv2." - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "gpl_3_0_and_lgpl_3_0_and_gpl_2_0-ee9a67a8-9de9-86d0-077b-8e6f7f285b72" - }, { "license_expression": "gpl-2.0-plus AND free-unknown AND gpl-1.0-plus", "matches": [ @@ -366,17 +317,8 @@ "detection_log": [] }, { - "identifier": "gpl_3_0_and_lgpl_3_0_and_gpl_2_0-ee9a67a8-9de9-86d0-077b-8e6f7f285b72", - "license_expression": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0", - "detection_count": 3, - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ] - }, - { - "identifier": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1-dd15dba8-74ee-829f-46c7-4b6aba4b5a8a", - "license_expression": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1", + "identifier": "gpl-3.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND lgpl-3.0 AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1 AND gpl-2.0-da1317f5-da7a-5367-fc96-9a084eb2ac00", + "license_expression": "gpl-3.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND lgpl-3.0 AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1 AND gpl-2.0", "detection_count": 1, "detection_log": [ "unknown-reference-to-local-file" @@ -474,58 +416,9 @@ "for_packages": [ "pkg:autotools/samba?uuid=fixed-uid-done-for-testing-5642512d1758" ], - "detected_license_expression": "(gpl-3.0 AND lgpl-3.0 AND gpl-2.0) AND (gpl-2.0-plus AND free-unknown AND gpl-1.0-plus) AND (gpl-1.0-plus AND lgpl-3.0-plus AND gpl-3.0 AND lgpl-3.0) AND (cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1)", - "detected_license_expression_spdx": "(GPL-3.0-only AND LGPL-3.0-only AND GPL-2.0-only) AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later) AND (GPL-1.0-or-later AND LGPL-3.0-or-later AND GPL-3.0-only AND LGPL-3.0-only) AND (CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1)", + "detected_license_expression": "(gpl-2.0-plus AND free-unknown AND gpl-1.0-plus) AND (gpl-1.0-plus AND lgpl-3.0-plus AND gpl-3.0 AND lgpl-3.0) AND (cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1)", + "detected_license_expression_spdx": "(GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later) AND (GPL-1.0-or-later AND LGPL-3.0-or-later AND GPL-3.0-only AND LGPL-3.0-only) AND (CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1)", "license_detections": [ - { - "license_expression": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0", - "matches": [ - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-3.0", - "rule_identifier": "gpl-3.0_32.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-3.0_32.RULE", - "matched_text": "GPLv3" - }, - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "lgpl-3.0", - "rule_identifier": "lgpl-3.0_29.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_29.RULE", - "matched_text": "LGPLv3 (" - }, - { - "score": 100.0, - "start_line": 39, - "end_line": 39, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-2.0", - "rule_identifier": "gpl-2.0_bare_single_word.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE", - "matched_text": "GPLv2." - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "gpl_3_0_and_lgpl_3_0_and_gpl_2_0-ee9a67a8-9de9-86d0-077b-8e6f7f285b72" - }, { "license_expression": "gpl-2.0-plus AND free-unknown AND gpl-1.0-plus", "matches": [ @@ -693,7 +586,47 @@ "identifier": "cc_by_sa_3_0_and_cc_by_sa_4_0_and_dco_1_1-4fb8e409-441a-1243-5a0d-d6af2acc0c62" } ], - "license_clues": [], + "license_clues": [ + { + "score": 100.0, + "start_line": 38, + "end_line": 38, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "gpl-3.0", + "rule_identifier": "gpl-3.0_32.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-3.0_32.RULE", + "matched_text": "GPLv3" + }, + { + "score": 100.0, + "start_line": 38, + "end_line": 38, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "lgpl-3.0", + "rule_identifier": "lgpl-3.0_29.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_29.RULE", + "matched_text": "LGPLv3 (" + }, + { + "score": 100.0, + "start_line": 39, + "end_line": 39, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "gpl-2.0", + "rule_identifier": "gpl-2.0_bare_single_word.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE", + "matched_text": "GPLv2." + } + ], "percentage_of_license_text": 9.84, "scan_errors": [] }, @@ -795,8 +728,8 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": "gpl-3.0 AND (gpl-3.0 AND lgpl-3.0 AND gpl-2.0) AND (gpl-2.0-plus AND free-unknown AND gpl-1.0-plus) AND (gpl-1.0-plus AND lgpl-3.0-plus AND gpl-3.0 AND lgpl-3.0) AND (cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1) AND gpl-2.0", - "declared_license_expression_spdx": "GPL-3.0-only AND (GPL-3.0-only AND LGPL-3.0-only AND GPL-2.0-only) AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later) AND (GPL-1.0-or-later AND LGPL-3.0-or-later AND GPL-3.0-only AND LGPL-3.0-only) AND (CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1) AND GPL-2.0-only AND GPL-1.0-or-later", + "declared_license_expression": "gpl-3.0 AND (gpl-2.0-plus AND free-unknown AND gpl-1.0-plus) AND (gpl-1.0-plus AND lgpl-3.0-plus AND gpl-3.0 AND lgpl-3.0) AND (cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1) AND gpl-2.0", + "declared_license_expression_spdx": "GPL-3.0-only AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later) AND (GPL-1.0-or-later AND LGPL-3.0-or-later AND GPL-3.0-only AND LGPL-3.0-only) AND (CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1) AND GPL-2.0-only", "license_detections": [ { "license_expression": "gpl-3.0", @@ -818,55 +751,6 @@ "detection_log": [], "identifier": "gpl_3_0-ab79e5a8-e510-cbf4-5302-ef968484bcdf" }, - { - "license_expression": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0", - "matches": [ - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-3.0", - "rule_identifier": "gpl-3.0_32.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-3.0_32.RULE", - "matched_text": "GPLv3" - }, - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "lgpl-3.0", - "rule_identifier": "lgpl-3.0_29.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_29.RULE", - "matched_text": "LGPLv3 (" - }, - { - "score": 100.0, - "start_line": 39, - "end_line": 39, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-2.0", - "rule_identifier": "gpl-2.0_bare_single_word.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE", - "matched_text": "GPLv2." - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "gpl_3_0_and_lgpl_3_0_and_gpl_2_0-ee9a67a8-9de9-86d0-077b-8e6f7f285b72" - }, { "license_expression": "gpl-2.0-plus AND free-unknown AND gpl-1.0-plus", "matches": [ @@ -1157,8 +1041,8 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": "gpl-3.0 AND (gpl-3.0 AND lgpl-3.0 AND gpl-2.0) AND (gpl-2.0-plus AND free-unknown AND gpl-1.0-plus) AND (gpl-1.0-plus AND lgpl-3.0-plus AND gpl-3.0 AND lgpl-3.0) AND (cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1) AND gpl-2.0", - "declared_license_expression_spdx": "GPL-3.0-only AND (GPL-3.0-only AND LGPL-3.0-only AND GPL-2.0-only) AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later) AND (GPL-1.0-or-later AND LGPL-3.0-or-later AND GPL-3.0-only AND LGPL-3.0-only) AND (CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1) AND GPL-2.0-only AND GPL-1.0-or-later", + "declared_license_expression": "gpl-3.0 AND (gpl-2.0-plus AND free-unknown AND gpl-1.0-plus) AND (gpl-1.0-plus AND lgpl-3.0-plus AND gpl-3.0 AND lgpl-3.0) AND (cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1) AND gpl-2.0", + "declared_license_expression_spdx": "GPL-3.0-only AND (GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later) AND (GPL-1.0-or-later AND LGPL-3.0-or-later AND GPL-3.0-only AND LGPL-3.0-only) AND (CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1) AND GPL-2.0-only", "license_detections": [ { "license_expression": "gpl-3.0", @@ -1180,55 +1064,6 @@ "detection_log": [], "identifier": "gpl_3_0-ab79e5a8-e510-cbf4-5302-ef968484bcdf" }, - { - "license_expression": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0", - "matches": [ - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-3.0", - "rule_identifier": "gpl-3.0_32.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-3.0_32.RULE", - "matched_text": "GPLv3" - }, - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "lgpl-3.0", - "rule_identifier": "lgpl-3.0_29.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_29.RULE", - "matched_text": "LGPLv3 (" - }, - { - "score": 100.0, - "start_line": 39, - "end_line": 39, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-2.0", - "rule_identifier": "gpl-2.0_bare_single_word.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE", - "matched_text": "GPLv2." - } - ], - "detection_log": [ - "possible-false-positive", - "not-license-clues-as-more-detections-present" - ], - "identifier": "gpl_3_0_and_lgpl_3_0_and_gpl_2_0-ee9a67a8-9de9-86d0-077b-8e6f7f285b72" - }, { "license_expression": "gpl-2.0-plus AND free-unknown AND gpl-1.0-plus", "matches": [ @@ -1526,11 +1361,11 @@ "for_packages": [ "pkg:autotools/samba?uuid=fixed-uid-done-for-testing-5642512d1758" ], - "detected_license_expression": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1", - "detected_license_expression_spdx": "GPL-3.0-only AND LGPL-3.0-only AND GPL-2.0-only AND GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later AND LGPL-3.0-or-later AND CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1", + "detected_license_expression": "gpl-3.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND lgpl-3.0 AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1 AND gpl-2.0", + "detected_license_expression_spdx": "GPL-3.0-only AND GPL-2.0-or-later AND LicenseRef-scancode-free-unknown AND GPL-1.0-or-later AND LGPL-3.0-or-later AND LGPL-3.0-only AND CC-BY-SA-3.0 AND CC-BY-SA-4.0 AND LicenseRef-scancode-dco-1.1 AND GPL-2.0-only", "license_detections": [ { - "license_expression": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1", + "license_expression": "gpl-3.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND lgpl-3.0 AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1 AND gpl-2.0", "matches": [ { "score": 100.0, @@ -1558,45 +1393,6 @@ "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-3.0_204.RULE", "matched_text": "GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. \n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n Preamble\n\n The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works. By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users. We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors. You can apply it to\nyour programs, too.\n\n When we speak of free software, we are referring to freedom, not\nprice. Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights. Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received. You must make sure that they, too, receive\nor can get the source code. And you must show them these terms so they\nknow their rights.\n\n Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software. For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so. This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software. The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable. Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts. If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary. To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n The precise terms and conditions for copying, distribution and\nmodification follow.\n\n TERMS AND CONDITIONS\n\n 0. Definitions.\n\n \"This License\" refers to version 3 of the GNU General Public License.\n\n \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n \"The Program\" refers to any copyrightable work licensed under this\nLicense. Each licensee is addressed as \"you\". \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy. The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy. Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies. Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License. If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n 1. Source Code.\n\n The \"source code\" for a work means the preferred form of the work\nfor making modifications to it. \"Object code\" means any non-source\nform of a work.\n\n A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form. A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities. However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work. For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n The Corresponding Source for a work in source code form is that\nsame work.\n\n 2. Basic Permissions.\n\n All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met. This License explicitly affirms your unlimited\npermission to run the unmodified Program. The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work. This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force. You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright. Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n Conveying under any other circumstances is permitted solely under\nthe conditions stated below. Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n 4. Conveying Verbatim Copies.\n\n You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n 5. Conveying Modified Source Versions.\n\n You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n a) The work must carry prominent notices stating that you modified\n it, and giving a relevant date.\n\n b) The work must carry prominent notices stating that it is\n released under this License and any conditions added under section\n 7. This requirement modifies the requirement in section 4 to\n \"keep intact all notices\".\n\n c) You must license the entire work, as a whole, under this\n License to anyone who comes into possession of a copy. This\n License will therefore apply, along with any applicable section 7\n additional terms, to the whole of the work, and all its parts,\n regardless of how they are packaged. This License gives no\n permission to license the work in any other way, but it does not\n invalidate such permission if you have separately received it.\n\n d) If the work has interactive user interfaces, each must display\n Appropriate Legal Notices; however, if the Program has interactive\n interfaces that do not display Appropriate Legal Notices, your\n work need not make them do so.\n\n A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit. Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n 6. Conveying Non-Source Forms.\n\n You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n a) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by the\n Corresponding Source fixed on a durable physical medium\n customarily used for software interchange.\n\n b) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by a\n written offer, valid for at least three years and valid for as\n long as you offer spare parts or customer support for that product\n model, to give anyone who possesses the object code either (1) a\n copy of the Corresponding Source for all the software in the\n product that is covered by this License, on a durable physical\n medium customarily used for software interchange, for a price no\n more than your reasonable cost of physically performing this\n conveying of source, or (2) access to copy the\n Corresponding Source from a network server at no charge.\n\n c) Convey individual copies of the object code with a copy of the\n written offer to provide the Corresponding Source. This\n alternative is allowed only occasionally and noncommercially, and\n only if you received the object code with such an offer, in accord\n with subsection 6b.\n\n d) Convey the object code by offering access from a designated\n place (gratis or for a charge), and offer equivalent access to the\n Corresponding Source in the same way through the same place at no\n further charge. You need not require recipients to copy the\n Corresponding Source along with the object code. If the place to\n copy the object code is a network server, the Corresponding Source\n may be on a different server (operated by you or a third party)\n that supports equivalent copying facilities, provided you maintain\n clear directions next to the object code saying where to find the\n Corresponding Source. Regardless of what server hosts the\n Corresponding Source, you remain obligated to ensure that it is\n available for as long as needed to satisfy these requirements.\n\n e) Convey the object code using peer-to-peer transmission, provided\n you inform other peers where the object code and Corresponding\n Source of the work are being offered to the general public at no\n charge under subsection 6d.\n\n A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling. In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage. For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product. A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source. The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information. But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed. Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n 7. Additional Terms.\n\n \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law. If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit. (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.) You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n a) Disclaiming warranty or limiting liability differently from the\n terms of sections 15 and 16 of this License; or\n\n b) Requiring preservation of specified reasonable legal notices or\n author attributions in that material or in the Appropriate Legal\n Notices displayed by works containing it; or\n\n c) Prohibiting misrepresentation of the origin of that material, or\n requiring that modified versions of such material be marked in\n reasonable ways as different from the original version; or\n\n d) Limiting the use for publicity purposes of names of licensors or\n authors of the material; or\n\n e) Declining to grant rights under trademark law for use of some\n trade names, trademarks, or service marks; or\n\n f) Requiring indemnification of licensors and authors of that\n material by anyone who conveys the material (or modified versions of\n it) with contractual assumptions of liability to the recipient, for\n any liability that these contractual assumptions directly impose on\n those licensors and authors.\n\n All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10. If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term. If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n 8. Termination.\n\n You may not propagate or modify a covered work except as expressly\nprovided under this License. Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License. If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n 9. Acceptance Not Required for Having Copies.\n\n You are not required to accept this License in order to receive or\nrun a copy of the Program. Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance. However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work. These actions infringe copyright if you do\nnot accept this License. Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n 10. Automatic Licensing of Downstream Recipients.\n\n Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License. You are not responsible\nfor enforcing compliance by third parties with this License.\n\n An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations. If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License. For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n 11. Patents.\n\n A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based. The\nwork thus licensed is called the contributor's \"contributor version\".\n\n A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version. For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement). To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients. \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License. You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n 12. No Surrender of Others' Freedom.\n\n If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License. If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all. For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n 13. Use with the GNU Affero General Public License.\n\n Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work. The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n 14. Revised Versions of this License.\n\n The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time. Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n Each version is given a distinguishing version number. If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation. If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n Later license versions may give you additional or different\npermissions. However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n 15. Disclaimer of Warranty.\n\n THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n 16. Limitation of Liability.\n\n IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n 17. Interpretation of Sections 15 and 16.\n\n If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n END OF TERMS AND CONDITIONS\n\n How to Apply These Terms to Your New Programs\n\n If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n To do so, attach the following notices to the program. It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n \n Copyright (C) \n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .\n\nAlso add information on how to contact you by electronic and paper mail.\n\n If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n Copyright (C) \n This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n This is free software, and you are welcome to redistribute it\n under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License. Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n.\n\n The GNU General Public License does not permit incorporating your program\ninto proprietary programs. If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library. If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License. But first, please read\n." }, - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-3.0", - "rule_identifier": "gpl-3.0_32.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-3.0_32.RULE", - "matched_text": "GPLv3" - }, - { - "score": 100.0, - "start_line": 38, - "end_line": 38, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "lgpl-3.0", - "rule_identifier": "lgpl-3.0_29.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-3.0_29.RULE", - "matched_text": "LGPLv3 (" - }, - { - "score": 100.0, - "start_line": 39, - "end_line": 39, - "matched_length": 1, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "gpl-2.0", - "rule_identifier": "gpl-2.0_bare_single_word.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_bare_single_word.RULE", - "matched_text": "GPLv2." - }, { "score": 20.0, "start_line": 57, @@ -1783,7 +1579,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "gpl-3.0 AND lgpl-3.0 AND gpl-2.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1-dd15dba8-74ee-829f-46c7-4b6aba4b5a8a" + "identifier": "gpl-3.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND lgpl-3.0 AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1 AND gpl-2.0-da1317f5-da7a-5367-fc96-9a084eb2ac00" } ], "license_clues": [], diff --git a/tests/packagedcode/data/maven_misc/assemble/jackson-dataformat-xml-2.13.5-expected.json b/tests/packagedcode/data/maven_misc/assemble/jackson-dataformat-xml-2.13.5-expected.json index 54952553efa..e784f3cf71c 100644 --- a/tests/packagedcode/data/maven_misc/assemble/jackson-dataformat-xml-2.13.5-expected.json +++ b/tests/packagedcode/data/maven_misc/assemble/jackson-dataformat-xml-2.13.5-expected.json @@ -32,8 +32,8 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": "apache-2.0 AND free-unknown AND unknown-license-reference", - "declared_license_expression_spdx": "Apache-2.0 AND LicenseRef-scancode-free-unknown AND LicenseRef-scancode-unknown-license-reference", + "declared_license_expression": "apache-2.0", + "declared_license_expression_spdx": "Apache-2.0", "license_detections": [ { "license_expression": "apache-2.0", @@ -55,28 +55,7 @@ "identifier": "apache_2_0-8607fc22-7931-3e71-b7d5-bd208970dc6f" }, { - "license_expression": "free-unknown", - "matches": [ - { - "score": 100.0, - "start_line": 3, - "end_line": 3, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "free-unknown", - "rule_identifier": "free-unknown_85.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/free-unknown_85.RULE" - } - ], - "detection_log": [ - "unknown-match" - ], - "identifier": "free_unknown-998e0fe1-3b73-fcf9-a86b-09f04f518687" - }, - { - "license_expression": "unknown-license-reference", + "license_expression": "apache-2.0", "matches": [ { "score": 100.0, @@ -89,10 +68,24 @@ "rule_identifier": "unknown-license-reference_375.RULE", "rule_relevance": 100, "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/unknown-license-reference_375.RULE" + }, + { + "score": 100.0, + "start_line": 1, + "end_line": 8, + "matched_length": 43, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "apache-2.0", + "rule_identifier": "apache-2.0_394.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_394.RULE" } ], - "detection_log": [], - "identifier": "unknown_license_reference-2fec5f0c-deef-fe36-7c0d-527b4552d10c" + "detection_log": [ + "unknown-reference-to-local-file" + ], + "identifier": "apache-2.0-31344ceb-eee7-3f95-45bb-cc86209f76f8" } ], "other_license_expression": null, @@ -130,14 +123,6 @@ "license_expression": "apache-2.0", "detection_count": 2, "detection_log": [] - }, - { - "identifier": "free_unknown-998e0fe1-3b73-fcf9-a86b-09f04f518687", - "license_expression": "free-unknown", - "detection_count": 2, - "detection_log": [ - "unknown-match" - ] } ], "files": [ @@ -234,8 +219,8 @@ "vcs_url": null, "copyright": null, "holder": null, - "declared_license_expression": "apache-2.0 AND free-unknown", - "declared_license_expression_spdx": "Apache-2.0 AND LicenseRef-scancode-free-unknown AND LicenseRef-scancode-unknown-license-reference", + "declared_license_expression": "apache-2.0", + "declared_license_expression_spdx": "Apache-2.0", "license_detections": [ { "license_expression": "apache-2.0", @@ -256,27 +241,6 @@ "detection_log": [], "identifier": "apache_2_0-8607fc22-7931-3e71-b7d5-bd208970dc6f" }, - { - "license_expression": "free-unknown", - "matches": [ - { - "score": 100.0, - "start_line": 3, - "end_line": 3, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "free-unknown", - "rule_identifier": "free-unknown_85.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/free-unknown_85.RULE" - } - ], - "detection_log": [ - "unknown-match" - ], - "identifier": "free_unknown-998e0fe1-3b73-fcf9-a86b-09f04f518687" - }, { "license_expression": "apache-2.0", "matches": [ @@ -344,30 +308,9 @@ "for_packages": [ "pkg:jar/Jackson-dataformat-XML@2.13.5?uuid=fixed-uid-done-for-testing-5642512d1758" ], - "detected_license_expression": "free-unknown AND apache-2.0", - "detected_license_expression_spdx": "LicenseRef-scancode-free-unknown AND Apache-2.0", + "detected_license_expression": "apache-2.0", + "detected_license_expression_spdx": "Apache-2.0", "license_detections": [ - { - "license_expression": "free-unknown", - "matches": [ - { - "score": 100.0, - "start_line": 3, - "end_line": 3, - "matched_length": 3, - "match_coverage": 100.0, - "matcher": "2-aho", - "license_expression": "free-unknown", - "rule_identifier": "free-unknown_85.RULE", - "rule_relevance": 100, - "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/free-unknown_85.RULE" - } - ], - "detection_log": [ - "unknown-match" - ], - "identifier": "free_unknown-998e0fe1-3b73-fcf9-a86b-09f04f518687" - }, { "license_expression": "apache-2.0", "matches": [ @@ -403,7 +346,7 @@ } ], "license_clues": [], - "percentage_of_license_text": 24.37, + "percentage_of_license_text": 21.85, "scan_errors": [] } ] From 03963fec10df1aba7e472178352a11630694e682 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Sat, 22 Jul 2023 00:35:13 +0530 Subject: [PATCH 08/12] Make license identifiers python-safe Signed-off-by: Ayan Sinha Mahapatra --- src/licensedcode/detection.py | 3 +- .../license-ref-see-copying.expected.json | 4 +-- ...-unknown-reference-copyright.expected.json | 10 +++---- ...ackage-instance-with-license-expected.json | 10 +++---- .../fizzler.expected.json | 20 ++++++------- .../reference-to-package/base.expected.json | 4 +-- .../google_appengine_sdk.expected.json | 28 +++++++++---------- .../paddlenlp.expected.json | 22 +++++++-------- .../physics.expected.json | 8 +++--- .../reference-to-package/samba.expected.json | 22 +++++++-------- ...ackson-dataformat-xml-2.13.5-expected.json | 8 +++--- 11 files changed, 70 insertions(+), 69 deletions(-) diff --git a/src/licensedcode/detection.py b/src/licensedcode/detection.py index d85fff91e02..43c20acf0d4 100644 --- a/src/licensedcode/detection.py +++ b/src/licensedcode/detection.py @@ -554,7 +554,8 @@ def get_new_identifier_from_detections(initial_detection, detections_added, lice ] identifiers.append(initial_detection["identifier"]) uuid = get_uuid_on_content(content=sorted(identifiers)) - return f"{license_expression}-{uuid}" + expression = python_safe_name(s=str(license_expression)) + return f"{expression}-{uuid}" @attr.s diff --git a/tests/licensedcode/data/plugin_license/license_reference/license-ref-see-copying.expected.json b/tests/licensedcode/data/plugin_license/license_reference/license-ref-see-copying.expected.json index 82eb8a15005..394c06b5d66 100644 --- a/tests/licensedcode/data/plugin_license/license_reference/license-ref-see-copying.expected.json +++ b/tests/licensedcode/data/plugin_license/license_reference/license-ref-see-copying.expected.json @@ -1,7 +1,7 @@ { "license_detections": [ { - "identifier": "apache-2.0-1c807a43-2040-70af-75aa-c343d5f2b90c", + "identifier": "apache_2_0-1c807a43-2040-70af-75aa-c343d5f2b90c", "license_expression": "apache-2.0", "detection_count": 1, "detection_log": [ @@ -86,7 +86,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "apache-2.0-1c807a43-2040-70af-75aa-c343d5f2b90c" + "identifier": "apache_2_0-1c807a43-2040-70af-75aa-c343d5f2b90c" } ], "license_clues": [], diff --git a/tests/licensedcode/data/plugin_license/license_reference/scan-unknown-reference-copyright.expected.json b/tests/licensedcode/data/plugin_license/license_reference/scan-unknown-reference-copyright.expected.json index 6caf1308106..171ce100093 100644 --- a/tests/licensedcode/data/plugin_license/license_reference/scan-unknown-reference-copyright.expected.json +++ b/tests/licensedcode/data/plugin_license/license_reference/scan-unknown-reference-copyright.expected.json @@ -1,7 +1,7 @@ { "license_detections": [ { - "identifier": "x11-xconsortium-veillard-61f804f6-d484-92ca-09b5-26be51ac974e", + "identifier": "x11_xconsortium_veillard-61f804f6-d484-92ca-09b5-26be51ac974e", "license_expression": "x11-xconsortium-veillard", "detection_count": 2, "detection_log": [ @@ -9,7 +9,7 @@ ] }, { - "identifier": "x11-xconsortium-veillard-50c015bd-e4e1-c6fe-eb82-9551473dd8e1", + "identifier": "x11_xconsortium_veillard-50c015bd-e4e1-c6fe-eb82-9551473dd8e1", "license_expression": "x11-xconsortium-veillard", "detection_count": 1, "detection_log": [ @@ -94,7 +94,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "x11-xconsortium-veillard-61f804f6-d484-92ca-09b5-26be51ac974e" + "identifier": "x11_xconsortium_veillard-61f804f6-d484-92ca-09b5-26be51ac974e" } ], "license_clues": [], @@ -140,7 +140,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "x11-xconsortium-veillard-61f804f6-d484-92ca-09b5-26be51ac974e" + "identifier": "x11_xconsortium_veillard-61f804f6-d484-92ca-09b5-26be51ac974e" } ], "license_clues": [], @@ -206,7 +206,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "x11-xconsortium-veillard-50c015bd-e4e1-c6fe-eb82-9551473dd8e1" + "identifier": "x11_xconsortium_veillard-50c015bd-e4e1-c6fe-eb82-9551473dd8e1" } ], "license_clues": [], diff --git a/tests/packagedcode/data/instance/python-package-instance-with-license-expected.json b/tests/packagedcode/data/instance/python-package-instance-with-license-expected.json index cc1cfe51bc3..42eb51c6e41 100644 --- a/tests/packagedcode/data/instance/python-package-instance-with-license-expected.json +++ b/tests/packagedcode/data/instance/python-package-instance-with-license-expected.json @@ -64,7 +64,7 @@ "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE" } ], - "identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf", + "identifier": "bsd_new-56110dee-5dcd-3acb-7774-ab2491cc76bf", "detection_log": [ "package-unknown-reference-to-local-file" ] @@ -142,7 +142,7 @@ "detection_log": [] }, { - "identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf", + "identifier": "bsd_new-56110dee-5dcd-3acb-7774-ab2491cc76bf", "license_expression": "bsd-new", "detection_count": 1, "detection_log": [ @@ -150,7 +150,7 @@ ] }, { - "identifier": "bsd-new-68720980-08c9-ffb1-f28e-24c2e067385b", + "identifier": "bsd_new-68720980-08c9-ffb1-f28e-24c2e067385b", "license_expression": "bsd-new", "detection_count": 1, "detection_log": [ @@ -281,7 +281,7 @@ "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE" } ], - "identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf", + "identifier": "bsd_new-56110dee-5dcd-3acb-7774-ab2491cc76bf", "detection_log": [ "package-unknown-reference-to-local-file" ] @@ -351,7 +351,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "bsd-new-68720980-08c9-ffb1-f28e-24c2e067385b" + "identifier": "bsd_new-68720980-08c9-ffb1-f28e-24c2e067385b" }, { "license_expression": "bsd-new", diff --git a/tests/packagedcode/data/license_detection/reference-at-manifest/fizzler.expected.json b/tests/packagedcode/data/license_detection/reference-at-manifest/fizzler.expected.json index 8b76cbf4859..0b89a2b0498 100644 --- a/tests/packagedcode/data/license_detection/reference-at-manifest/fizzler.expected.json +++ b/tests/packagedcode/data/license_detection/reference-at-manifest/fizzler.expected.json @@ -78,7 +78,7 @@ "matched_text": "GNU GENERAL PUBLIC LICENSE" } ], - "identifier": "lgpl-2.0-plus AND gpl-1.0-plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945", + "identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945", "detection_log": [ "package-unknown-reference-to-local-file" ] @@ -142,7 +142,7 @@ ], "license_detections": [ { - "identifier": "lgpl-2.0-plus AND gpl-1.0-plus-17115808-8fc8-9c98-b64d-c5013bcbde1b", + "identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-17115808-8fc8-9c98-b64d-c5013bcbde1b", "license_expression": "lgpl-2.0-plus AND gpl-1.0-plus", "detection_count": 1, "detection_log": [ @@ -150,18 +150,18 @@ ] }, { - "identifier": "lgpl-2.0-plus AND gpl-1.0-plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945", + "identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-2a11c930-7038-736e-5e48-b35f872691cc", "license_expression": "lgpl-2.0-plus AND gpl-1.0-plus", "detection_count": 1, - "detection_log": [ - "package-unknown-reference-to-local-file" - ] + "detection_log": [] }, { - "identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-2a11c930-7038-736e-5e48-b35f872691cc", + "identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945", "license_expression": "lgpl-2.0-plus AND gpl-1.0-plus", "detection_count": 1, - "detection_log": [] + "detection_log": [ + "package-unknown-reference-to-local-file" + ] } ], "files": [ @@ -293,7 +293,7 @@ "matched_text": "GNU GENERAL PUBLIC LICENSE" } ], - "identifier": "lgpl-2.0-plus AND gpl-1.0-plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945", + "identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945", "detection_log": [ "package-unknown-reference-to-local-file" ] @@ -394,7 +394,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "lgpl-2.0-plus AND gpl-1.0-plus-17115808-8fc8-9c98-b64d-c5013bcbde1b" + "identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-17115808-8fc8-9c98-b64d-c5013bcbde1b" } ], "license_clues": [], diff --git a/tests/packagedcode/data/license_detection/reference-to-package/base.expected.json b/tests/packagedcode/data/license_detection/reference-to-package/base.expected.json index 6db7c6e57e8..f5cd867791d 100644 --- a/tests/packagedcode/data/license_detection/reference-to-package/base.expected.json +++ b/tests/packagedcode/data/license_detection/reference-to-package/base.expected.json @@ -98,7 +98,7 @@ "detection_log": [] }, { - "identifier": "bsd-new-af493d9f-0c66-d9f8-4538-579134812514", + "identifier": "bsd_new-af493d9f-0c66-d9f8-4538-579134812514", "license_expression": "bsd-new", "detection_count": 1, "detection_log": [ @@ -270,7 +270,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "bsd-new-af493d9f-0c66-d9f8-4538-579134812514" + "identifier": "bsd_new-af493d9f-0c66-d9f8-4538-579134812514" } ], "license_clues": [], diff --git a/tests/packagedcode/data/license_detection/reference-to-package/google_appengine_sdk.expected.json b/tests/packagedcode/data/license_detection/reference-to-package/google_appengine_sdk.expected.json index 5419c027cd3..5d3b0b3968e 100644 --- a/tests/packagedcode/data/license_detection/reference-to-package/google_appengine_sdk.expected.json +++ b/tests/packagedcode/data/license_detection/reference-to-package/google_appengine_sdk.expected.json @@ -196,7 +196,7 @@ "detection_log": [] }, { - "identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653", + "identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653", "license_expression": "bsd-new", "detection_count": 5, "detection_log": [ @@ -204,18 +204,18 @@ ] }, { - "identifier": "bsd-new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7", + "identifier": "bsd_new-72cae3bc-4423-3a9e-be84-ee8bb5120a4d", "license_expression": "bsd-new", "detection_count": 2, - "detection_log": [ - "unknown-reference-in-file-to-package" - ] + "detection_log": [] }, { - "identifier": "bsd_new-72cae3bc-4423-3a9e-be84-ee8bb5120a4d", + "identifier": "bsd_new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7", "license_expression": "bsd-new", "detection_count": 2, - "detection_log": [] + "detection_log": [ + "unknown-reference-in-file-to-package" + ] } ], "files": [ @@ -425,7 +425,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653" + "identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653" } ], "license_clues": [], @@ -475,7 +475,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653" + "identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653" } ], "license_clues": [], @@ -549,7 +549,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "bsd-new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7" + "identifier": "bsd_new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7" } ], "license_clues": [], @@ -599,7 +599,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "bsd-new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7" + "identifier": "bsd_new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7" } ], "license_clues": [], @@ -649,7 +649,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653" + "identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653" } ], "license_clues": [], @@ -1210,7 +1210,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653" + "identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653" } ], "license_clues": [], @@ -1284,7 +1284,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653" + "identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653" } ], "license_clues": [], diff --git a/tests/packagedcode/data/license_detection/reference-to-package/paddlenlp.expected.json b/tests/packagedcode/data/license_detection/reference-to-package/paddlenlp.expected.json index c118925a7e5..9cc1a844a19 100644 --- a/tests/packagedcode/data/license_detection/reference-to-package/paddlenlp.expected.json +++ b/tests/packagedcode/data/license_detection/reference-to-package/paddlenlp.expected.json @@ -384,7 +384,7 @@ ], "license_detections": [ { - "identifier": "apache-2.0-35de6d3f-8962-0454-2270-33aac504c123", + "identifier": "apache_2_0-35de6d3f-8962-0454-2270-33aac504c123", "license_expression": "apache-2.0", "detection_count": 2, "detection_log": [ @@ -392,18 +392,18 @@ ] }, { - "identifier": "apache-2.0-abb5bcc3-dac9-a935-3392-31a86beb482a", + "identifier": "apache_2_0-999670be-3d5e-ebf8-ae18-b555c26c5e80", "license_expression": "apache-2.0", "detection_count": 2, - "detection_log": [ - "unknown-reference-to-local-file" - ] + "detection_log": [] }, { - "identifier": "apache_2_0-999670be-3d5e-ebf8-ae18-b555c26c5e80", + "identifier": "apache_2_0-abb5bcc3-dac9-a935-3392-31a86beb482a", "license_expression": "apache-2.0", "detection_count": 2, - "detection_log": [] + "detection_log": [ + "unknown-reference-to-local-file" + ] }, { "identifier": "apache_2_0-c4e30bcd-ccfd-bbc3-d2f1-196ab911e47d", @@ -550,7 +550,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "apache-2.0-abb5bcc3-dac9-a935-3392-31a86beb482a" + "identifier": "apache_2_0-abb5bcc3-dac9-a935-3392-31a86beb482a" } ], "license_clues": [], @@ -661,7 +661,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "apache-2.0-35de6d3f-8962-0454-2270-33aac504c123" + "identifier": "apache_2_0-35de6d3f-8962-0454-2270-33aac504c123" } ], "license_clues": [], @@ -724,7 +724,7 @@ "detection_log": [ "unknown-reference-in-file-to-package" ], - "identifier": "apache-2.0-35de6d3f-8962-0454-2270-33aac504c123" + "identifier": "apache_2_0-35de6d3f-8962-0454-2270-33aac504c123" } ], "license_clues": [], @@ -1075,7 +1075,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "apache-2.0-abb5bcc3-dac9-a935-3392-31a86beb482a" + "identifier": "apache_2_0-abb5bcc3-dac9-a935-3392-31a86beb482a" } ], "other_license_expression": null, diff --git a/tests/packagedcode/data/license_detection/reference-to-package/physics.expected.json b/tests/packagedcode/data/license_detection/reference-to-package/physics.expected.json index e04a56752cb..03f666de93c 100644 --- a/tests/packagedcode/data/license_detection/reference-to-package/physics.expected.json +++ b/tests/packagedcode/data/license_detection/reference-to-package/physics.expected.json @@ -9,7 +9,7 @@ "detection_log": [] }, { - "identifier": "gpl-3.0-76e8f741-ece2-d587-493c-92b0b1e4bdfe", + "identifier": "gpl_3_0-76e8f741-ece2-d587-493c-92b0b1e4bdfe", "license_expression": "gpl-3.0", "detection_count": 1, "detection_log": [ @@ -17,7 +17,7 @@ ] }, { - "identifier": "gpl-3.0-e907b820-6f8c-81c4-38c5-75006ae093a4", + "identifier": "gpl_3_0-e907b820-6f8c-81c4-38c5-75006ae093a4", "license_expression": "gpl-3.0", "detection_count": 1, "detection_log": [ @@ -318,7 +318,7 @@ "detection_log": [ "unknown-reference-in-file-to-nonexistent-package" ], - "identifier": "gpl-3.0-e907b820-6f8c-81c4-38c5-75006ae093a4" + "identifier": "gpl_3_0-e907b820-6f8c-81c4-38c5-75006ae093a4" } ], "license_clues": [], @@ -431,7 +431,7 @@ "detection_log": [ "unknown-reference-in-file-to-nonexistent-package" ], - "identifier": "gpl-3.0-76e8f741-ece2-d587-493c-92b0b1e4bdfe" + "identifier": "gpl_3_0-76e8f741-ece2-d587-493c-92b0b1e4bdfe" } ], "license_clues": [], diff --git a/tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json b/tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json index 951516181fc..40dc5e8851b 100644 --- a/tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json +++ b/tests/packagedcode/data/license_detection/reference-to-package/samba.expected.json @@ -303,21 +303,21 @@ ] }, { - "identifier": "gpl-3.0-db305a6e-7013-4ffa-0ad4-09f113582e67", + "identifier": "gpl_3_0-ab79e5a8-e510-cbf4-5302-ef968484bcdf", "license_expression": "gpl-3.0", "detection_count": 3, - "detection_log": [ - "unknown-reference-to-local-file" - ] + "detection_log": [] }, { - "identifier": "gpl_3_0-ab79e5a8-e510-cbf4-5302-ef968484bcdf", + "identifier": "gpl_3_0-db305a6e-7013-4ffa-0ad4-09f113582e67", "license_expression": "gpl-3.0", "detection_count": 3, - "detection_log": [] + "detection_log": [ + "unknown-reference-to-local-file" + ] }, { - "identifier": "gpl-3.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND lgpl-3.0 AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1 AND gpl-2.0-da1317f5-da7a-5367-fc96-9a084eb2ac00", + "identifier": "gpl_3_0_and_gpl_2_0_plus_and_free_unknown_and_gpl_1_0_plus_and_lgpl_3_0_plus_and_lgpl_3_0_and_cc_by_sa_3_0_and_cc_by_sa_4_0_and_dco_1_1_and_gpl_2_0-7f4f0ff2-4f58-b290-f00d-9b2ef6eafd63", "license_expression": "gpl-3.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND lgpl-3.0 AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1 AND gpl-2.0", "detection_count": 1, "detection_log": [ @@ -693,7 +693,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "gpl-3.0-db305a6e-7013-4ffa-0ad4-09f113582e67" + "identifier": "gpl_3_0-db305a6e-7013-4ffa-0ad4-09f113582e67" } ], "license_clues": [], @@ -970,7 +970,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "gpl-3.0-db305a6e-7013-4ffa-0ad4-09f113582e67" + "identifier": "gpl_3_0-db305a6e-7013-4ffa-0ad4-09f113582e67" } ], "other_license_expression": null, @@ -1283,7 +1283,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "gpl-3.0-db305a6e-7013-4ffa-0ad4-09f113582e67" + "identifier": "gpl_3_0-db305a6e-7013-4ffa-0ad4-09f113582e67" } ], "other_license_expression": null, @@ -1579,7 +1579,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "gpl-3.0 AND gpl-2.0-plus AND free-unknown AND gpl-1.0-plus AND lgpl-3.0-plus AND lgpl-3.0 AND cc-by-sa-3.0 AND cc-by-sa-4.0 AND dco-1.1 AND gpl-2.0-da1317f5-da7a-5367-fc96-9a084eb2ac00" + "identifier": "gpl_3_0_and_gpl_2_0_plus_and_free_unknown_and_gpl_1_0_plus_and_lgpl_3_0_plus_and_lgpl_3_0_and_cc_by_sa_3_0_and_cc_by_sa_4_0_and_dco_1_1_and_gpl_2_0-7f4f0ff2-4f58-b290-f00d-9b2ef6eafd63" } ], "license_clues": [], diff --git a/tests/packagedcode/data/maven_misc/assemble/jackson-dataformat-xml-2.13.5-expected.json b/tests/packagedcode/data/maven_misc/assemble/jackson-dataformat-xml-2.13.5-expected.json index e784f3cf71c..ee211af3f63 100644 --- a/tests/packagedcode/data/maven_misc/assemble/jackson-dataformat-xml-2.13.5-expected.json +++ b/tests/packagedcode/data/maven_misc/assemble/jackson-dataformat-xml-2.13.5-expected.json @@ -85,7 +85,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "apache-2.0-31344ceb-eee7-3f95-45bb-cc86209f76f8" + "identifier": "apache_2_0-31344ceb-eee7-3f95-45bb-cc86209f76f8" } ], "other_license_expression": null, @@ -111,7 +111,7 @@ "dependencies": [], "license_detections": [ { - "identifier": "apache-2.0-31344ceb-eee7-3f95-45bb-cc86209f76f8", + "identifier": "apache_2_0-31344ceb-eee7-3f95-45bb-cc86209f76f8", "license_expression": "apache-2.0", "detection_count": 2, "detection_log": [ @@ -272,7 +272,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "apache-2.0-31344ceb-eee7-3f95-45bb-cc86209f76f8" + "identifier": "apache_2_0-31344ceb-eee7-3f95-45bb-cc86209f76f8" } ], "other_license_expression": null, @@ -342,7 +342,7 @@ "detection_log": [ "unknown-reference-to-local-file" ], - "identifier": "apache-2.0-31344ceb-eee7-3f95-45bb-cc86209f76f8" + "identifier": "apache_2_0-31344ceb-eee7-3f95-45bb-cc86209f76f8" } ], "license_clues": [], From fb7cedcbb1bef44b439231b65c2b9a374d4afe57 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Sat, 22 Jul 2023 01:26:16 +0530 Subject: [PATCH 09/12] Filter license intros from dereferenced matches Signed-off-by: Ayan Sinha Mahapatra --- src/licensedcode/detection.py | 25 +++++++++++++++++++------ src/summarycode/todo.py | 8 ++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/licensedcode/detection.py b/src/licensedcode/detection.py index 43c20acf0d4..7a589dc51bd 100644 --- a/src/licensedcode/detection.py +++ b/src/licensedcode/detection.py @@ -1256,6 +1256,16 @@ def filter_license_references(license_match_objects): return filtered_matches +def filter_license_intros_and_references(license_match_objects): + """ + Return a filtered ``license_matches`` list of LicenseMatch objects removing + matches which had references to local files with licenses and spurious matches + to license introduction statements. + """ + filtered_license_match_objects = filter_license_intros(license_match_objects) + return filter_license_references(filtered_license_match_objects) + + def has_references_to_local_files(license_matches): """ Return True if any of the matched Rule for the ``license_matches`` has a @@ -1319,37 +1329,37 @@ def get_detected_license_expression( if analysis == DetectionCategory.UNKNOWN_REFERENCE_IN_FILE_TO_PACKAGE.value: if TRACE_ANALYSIS: logger_debug(f'analysis {DetectionCategory.UNKNOWN_REFERENCE_IN_FILE_TO_PACKAGE.value}') - matches_for_expression = filter_license_references(license_matches) + matches_for_expression = filter_license_intros_and_references(license_matches) detection_log.append(DetectionRule.UNKNOWN_REFERENCE_IN_FILE_TO_PACKAGE.value) elif analysis == DetectionCategory.UNKNOWN_REFERENCE_IN_FILE_TO_NONEXISTENT_PACKAGE.value: if TRACE_ANALYSIS: logger_debug(f'analysis {DetectionCategory.UNKNOWN_REFERENCE_IN_FILE_TO_NONEXISTENT_PACKAGE.value}') - matches_for_expression = filter_license_references(license_matches) + matches_for_expression = filter_license_intros_and_references(license_matches) detection_log.append(DetectionRule.UNKNOWN_REFERENCE_IN_FILE_TO_NONEXISTENT_PACKAGE.value) elif analysis == DetectionCategory.UNKNOWN_FILE_REFERENCE_LOCAL.value: if TRACE_ANALYSIS: logger_debug(f'analysis {DetectionCategory.UNKNOWN_FILE_REFERENCE_LOCAL.value}') - matches_for_expression = filter_license_references(license_matches) + matches_for_expression = filter_license_intros_and_references(license_matches) detection_log.append(DetectionRule.UNKNOWN_REFERENCE_TO_LOCAL_FILE.value) elif analysis == DetectionCategory.PACKAGE_UNKNOWN_FILE_REFERENCE_LOCAL.value: if TRACE_ANALYSIS: logger_debug(f'analysis {DetectionCategory.PACKAGE_UNKNOWN_FILE_REFERENCE_LOCAL.value}') - matches_for_expression = filter_license_references(license_matches) + matches_for_expression = filter_license_intros_and_references(license_matches) detection_log.append(DetectionRule.PACKAGE_UNKNOWN_REFERENCE_TO_LOCAL_FILE.value) elif analysis == DetectionCategory.PACKAGE_ADD_FROM_SIBLING_FILE.value: if TRACE_ANALYSIS: logger_debug(f'analysis {DetectionCategory.PACKAGE_ADD_FROM_SIBLING_FILE.value}') - matches_for_expression = filter_license_references(license_matches) + matches_for_expression = filter_license_intros_and_references(license_matches) detection_log.append(DetectionRule.PACKAGE_ADD_FROM_SIBLING_FILE.value) elif analysis == DetectionCategory.PACKAGE_ADD_FROM_FILE.value: if TRACE_ANALYSIS: logger_debug(f'analysis {DetectionCategory.PACKAGE_ADD_FROM_FILE.value}') - matches_for_expression = filter_license_references(license_matches) + matches_for_expression = filter_license_intros_and_references(license_matches) detection_log.append(DetectionRule.PACKAGE_ADD_FROM_FILE.value) elif analysis == DetectionCategory.UNKNOWN_MATCH.value: @@ -1495,6 +1505,9 @@ def get_ambiguous_license_detections_by_type(unique_license_detections): elif is_undetected_license_matches(license_matches=detection.matches): ambi_license_detections[DetectionCategory.UNDETECTED_LICENSE.value] = detection + + elif has_correct_license_clue_matches(license_matches=detection.matches): + ambi_license_detections[DetectionCategory.LICENSE_CLUES.value] = detection elif "unknown" in detection.license_expression: if has_unknown_matches(license_matches=detection.matches): diff --git a/src/summarycode/todo.py b/src/summarycode/todo.py index 750bd30debf..c9c881f6a0b 100644 --- a/src/summarycode/todo.py +++ b/src/summarycode/todo.py @@ -327,6 +327,11 @@ class ReviewComments(Enum): "rule text is matched, but some unknown extra words have been inserted in " "the text, which needs to be reviewed. " ) + LICENSE_CLUES = ( + "Text which might contain useful clues about license detections, but cannot " + "be considered as a proper license detection. Additional review is needed " + "to determine if this license clue is useful." + ) UNKNOWN_MATCH = ( "The license detection is inconclusive, as the license matches have " "been matched to rules having unknown as their license key, and these " @@ -380,6 +385,9 @@ def get_review_comments(detection_log): if LicenseDetectionCategory.EXTRA_WORDS.value in detection_log: review_comments[LicenseDetectionCategory.EXTRA_WORDS.value] = ReviewComments.EXTRA_WORDS.value + if LicenseDetectionCategory.LICENSE_CLUES.value in detection_log: + review_comments[LicenseDetectionCategory.LICENSE_CLUES.value] = ReviewComments.LICENSE_CLUES.value + if LicenseDetectionCategory.UNKNOWN_MATCH.value in detection_log: review_comments[LicenseDetectionCategory.UNKNOWN_MATCH.value] = ReviewComments.UNKNOWN_MATCH.value From 35d8f6b828aef16c1712e07558c98d1d5a0685d8 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Sat, 22 Jul 2023 02:10:38 +0530 Subject: [PATCH 10/12] Add rules and tests from jquery-form Signed-off-by: Ayan Sinha Mahapatra --- .../data/rules/mit_or_gpl-2.0_68.RULE | 28 + .../data/rules/mit_or_gpl-2.0_69.RULE | 12 + .../jquery-form-3.51.0.expected.json | 1028 +++++++++++++++++ .../multi-flavor/jquery-form-3.51.0/README.md | 26 + .../jquery-form-3.51.0/bower.json | 15 + .../jquery-form-3.51.0/composer.json | 40 + .../jquery-form-3.51.0/package.json | 50 + tests/packagedcode/test_license_detection.py | 21 + 8 files changed, 1220 insertions(+) create mode 100644 src/licensedcode/data/rules/mit_or_gpl-2.0_68.RULE create mode 100644 src/licensedcode/data/rules/mit_or_gpl-2.0_69.RULE create mode 100644 tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0.expected.json create mode 100644 tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/README.md create mode 100644 tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/bower.json create mode 100644 tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/composer.json create mode 100644 tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/package.json diff --git a/src/licensedcode/data/rules/mit_or_gpl-2.0_68.RULE b/src/licensedcode/data/rules/mit_or_gpl-2.0_68.RULE new file mode 100644 index 00000000000..9afc31b9ebe --- /dev/null +++ b/src/licensedcode/data/rules/mit_or_gpl-2.0_68.RULE @@ -0,0 +1,28 @@ +--- +license_expression: mit OR gpl-2.0 +is_license_notice: yes +ignorable_urls: + - http://malsup.github.com/gpl-license-v2.txt + - http://malsup.github.com/mit-license.txt +--- + +All versions, present and past, of the +are {{dual licensed under the MIT and GPL licenses}}: + +* [MIT](http://malsup.github.com/mit-license.txt) +* [GPL](http://malsup.github.com/gpl-license-v2.txt) + +You may use either license. +The MIT License is recommended for most projects because +it is simple and easy to understand and it places almost +no restrictions on what you can do with the plugin. + +If the GPL suits your project better you are also +free to use the plugin under that license. + +You don't have to do anything special to choose +one license or the other and you don't have to notify +anyone which license you are using. +You are free to use the jQuery Form Plugin in +commercial projects as long as the copyright header +is left intact. \ No newline at end of file diff --git a/src/licensedcode/data/rules/mit_or_gpl-2.0_69.RULE b/src/licensedcode/data/rules/mit_or_gpl-2.0_69.RULE new file mode 100644 index 00000000000..9a4cb14613a --- /dev/null +++ b/src/licensedcode/data/rules/mit_or_gpl-2.0_69.RULE @@ -0,0 +1,12 @@ +--- +license_expression: mit OR gpl-2.0 +is_license_notice: yes +ignorable_urls: + - http://malsup.github.com/gpl-license-v2.txt + - http://malsup.github.com/mit-license.txt +--- + +type: MIT +url: http://malsup.github.com/mit-license.txt +type: GPL +url: http://malsup.github.com/gpl-license-v2.txt \ No newline at end of file diff --git a/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0.expected.json b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0.expected.json new file mode 100644 index 00000000000..caeb24426fe --- /dev/null +++ b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0.expected.json @@ -0,0 +1,1028 @@ +{ + "summary": { + "declared_license_expression": "mit OR gpl-2.0", + "license_clarity_score": { + "score": 90, + "declared_license": true, + "identification_precision": true, + "has_license_text": true, + "declared_copyrights": false, + "conflicting_license_categories": false, + "ambiguous_compound_licensing": false + }, + "declared_holder": "", + "primary_language": null, + "other_license_expressions": [ + { + "value": null, + "count": 1 + }, + { + "value": "(mit OR gpl-2.0-plus) AND gpl-2.0", + "count": 1 + } + ], + "other_holders": [], + "other_languages": [] + }, + "packages": [ + { + "type": "bower", + "namespace": null, + "name": "jquery-form", + "version": "3.51.0", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "mit OR gpl-2.0", + "declared_license_expression_spdx": "MIT OR GPL-2.0-only", + "license_detections": [ + { + "license_expression": "mit OR gpl-2.0", + "matches": [ + { + "score": 94.81, + "start_line": 12, + "end_line": 21, + "matched_length": 128, + "match_coverage": 94.81, + "matcher": "3-seq", + "license_expression": "mit OR gpl-2.0", + "rule_identifier": "mit_or_gpl-2.0_68.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_or_gpl-2.0_68.RULE", + "matched_text": "are dual licensed under the MIT and GPL licenses:\n\n* [MIT](http://malsup.github.com/mit-license.txt)\n* [GPL](http://malsup.github.com/gpl-license-v2.txt)\n\nYou may use either license. The MIT License is recommended for most projects because it is simple and easy to understand and it places almost no restrictions on what you can do with the plugin.\n\nIf the GPL suits your project better you are also free to use the plugin under that license.\n\nYou don't have to do anything special to choose one license or the other and you don't have to notify anyone which license you are using. You are free to use the jQuery Form Plugin in commercial projects as long as the copyright header is left intact." + } + ], + "detection_log": [], + "identifier": "mit_or_gpl_2_0-562fb174-abc9-da75-d29f-5bc4f1d9c56f" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": null, + "notice_text": null, + "source_packages": [], + "extra_data": {}, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:bower/jquery-form@3.51.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_paths": [ + "bower.json" + ], + "datasource_ids": [ + "bower_json" + ], + "purl": "pkg:bower/jquery-form@3.51.0" + }, + { + "type": "composer", + "namespace": "malsup", + "name": "form", + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "PHP", + "description": null, + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "M. Alsup", + "email": null, + "url": "http://jquery.malsup.com" + }, + { + "type": "person", + "role": "vendor", + "name": "malsup", + "email": null, + "url": null + } + ], + "keywords": [], + "homepage_url": "http://jquery.malsup.com/form/", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": "https://github.com/malsup/form/issues", + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "mit OR gpl-2.0", + "declared_license_expression_spdx": "MIT OR GPL-2.0-only", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "1-spdx-id", + "license_expression": "mit", + "rule_identifier": "spdx-license-identifier-mit-5da48780aba670b0860c46d899ed42a0f243ff06", + "rule_relevance": 100, + "rule_url": null, + "matched_text": "MIT" + } + ], + "identifier": "mit-a822f434-d61f-f2b1-c792-8b8cb9e7b9bf" + }, + { + "license_expression": "gpl-2.0", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "gpl-2.0", + "rule_identifier": "gpl-2.0_52.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_52.RULE", + "matched_text": "GPL-2.0" + } + ], + "identifier": "gpl_2_0-d7f02717-086e-f71b-962e-b18cc23b1827" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "- MIT\n- GPL-2.0\n", + "notice_text": null, + "source_packages": [], + "extra_data": {}, + "repository_homepage_url": "https://packagist.org/packages/malsup/form", + "repository_download_url": null, + "api_data_url": "https://packagist.org/p/packages/malsup/form.json", + "package_uid": "pkg:composer/malsup/form?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_paths": [ + "composer.json" + ], + "datasource_ids": [ + "php_composer_json" + ], + "purl": "pkg:composer/malsup/form" + }, + { + "type": "npm", + "namespace": "@liferay", + "name": "jquery-form", + "version": "3.51.0-liferay.1", + "qualifiers": {}, + "subpath": null, + "primary_language": "JavaScript", + "description": "A simple way to AJAX-ify any form on your page; with file upload and progress support.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "M. Alsup", + "email": null, + "url": "http://jquery.malsup.com" + } + ], + "keywords": [ + "form", + "upload", + "ajax" + ], + "homepage_url": "http://jquery.malsup.com/form/", + "download_url": "https://registry.npmjs.org/@liferay/jquery-form/-/jquery-form-3.51.0-liferay.1.tgz", + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": "https://github.com/malsup/form/issues", + "code_view_url": null, + "vcs_url": "git+https://github.com/liferay/liferay-frontend-projects.git", + "copyright": null, + "holder": null, + "declared_license_expression": "mit AND gpl-1.0-plus", + "declared_license_expression_spdx": "MIT AND GPL-1.0-or-later", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "1-spdx-id", + "license_expression": "mit", + "rule_identifier": "spdx-license-identifier-mit-5da48780aba670b0860c46d899ed42a0f243ff06", + "rule_relevance": 100, + "rule_url": null, + "matched_text": "MIT" + } + ], + "identifier": "mit-a822f434-d61f-f2b1-c792-8b8cb9e7b9bf" + }, + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit_14.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_14.RULE", + "matched_text": "http://malsup.github.com/mit-license.txt" + } + ], + "identifier": "mit-9967e727-165e-9bb5-f090-7de5e47a3929" + }, + { + "license_expression": "gpl-1.0-plus", + "matches": [ + { + "score": 50.0, + "start_line": 1, + "end_line": 1, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "gpl-1.0-plus", + "rule_identifier": "gpl_bare_word_only.RULE", + "rule_relevance": 50, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl_bare_word_only.RULE", + "matched_text": "GPL" + } + ], + "identifier": "gpl_1_0_plus-473308ff-72ce-7e72-b3a9-5b1cc6680abb" + }, + { + "license_expression": "gpl-1.0-plus", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "gpl-1.0-plus", + "rule_identifier": "gpl_200.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl_200.RULE", + "matched_text": "http://malsup.github.com/gpl-license-v2.txt" + } + ], + "identifier": "gpl_1_0_plus-b6a20479-06f3-d753-878b-d3193c879108" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "- type: MIT\n url: http://malsup.github.com/mit-license.txt\n- type: GPL\n url: http://malsup.github.com/gpl-license-v2.txt\n", + "notice_text": null, + "source_packages": [], + "extra_data": {}, + "repository_homepage_url": "https://www.npmjs.com/package/@liferay/jquery-form", + "repository_download_url": "https://registry.npmjs.org/@liferay/jquery-form/-/jquery-form-3.51.0-liferay.1.tgz", + "api_data_url": "https://registry.npmjs.org/@liferay%2fjquery-form/3.51.0-liferay.1", + "package_uid": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_paths": [ + "package.json" + ], + "datasource_ids": [ + "npm_package_json" + ], + "purl": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1" + } + ], + "dependencies": [ + { + "purl": "pkg:bower/jquery", + "extracted_requirement": ">=1.5", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:bower/jquery?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:bower/jquery-form@3.51.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "bower.json", + "datasource_id": "bower_json" + }, + { + "purl": "pkg:composer/components/jquery", + "extracted_requirement": ">=1.5", + "scope": "require", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:composer/components/jquery?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:composer/malsup/form?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "composer.json", + "datasource_id": "php_composer_json" + }, + { + "purl": "pkg:npm/jquery", + "extracted_requirement": ">=1.5", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/jquery?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "package.json", + "datasource_id": "npm_package_json" + }, + { + "purl": "pkg:npm/gulp", + "extracted_requirement": "~3.5.2", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/gulp?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "package.json", + "datasource_id": "npm_package_json" + }, + { + "purl": "pkg:npm/gulp-concat", + "extracted_requirement": "~2.1.7", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/gulp-concat?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "package.json", + "datasource_id": "npm_package_json" + }, + { + "purl": "pkg:npm/gulp-jshint", + "extracted_requirement": "~1.4.2", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/gulp-jshint?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "package.json", + "datasource_id": "npm_package_json" + }, + { + "purl": "pkg:npm/gulp-uglify", + "extracted_requirement": "~0.2.1", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/gulp-uglify?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "package.json", + "datasource_id": "npm_package_json" + }, + { + "purl": "pkg:npm/gulp-util", + "extracted_requirement": "~2.2.14", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:npm/gulp-util?uuid=fixed-uid-done-for-testing-5642512d1758", + "for_package_uid": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758", + "datafile_path": "package.json", + "datasource_id": "npm_package_json" + } + ], + "license_detections": [ + { + "identifier": "mit_or_gpl_2_0_plus__and_gpl_2_0-876682c2-38c1-1236-75ea-c46243d9c414", + "license_expression": "(mit OR gpl-2.0-plus) AND gpl-2.0", + "detection_count": 1, + "detection_log": [] + }, + { + "identifier": "gpl_1_0_plus-473308ff-72ce-7e72-b3a9-5b1cc6680abb", + "license_expression": "gpl-1.0-plus", + "detection_count": 1, + "detection_log": [] + }, + { + "identifier": "gpl_1_0_plus-b6a20479-06f3-d753-878b-d3193c879108", + "license_expression": "gpl-1.0-plus", + "detection_count": 1, + "detection_log": [] + }, + { + "identifier": "gpl_2_0-d7f02717-086e-f71b-962e-b18cc23b1827", + "license_expression": "gpl-2.0", + "detection_count": 1, + "detection_log": [] + }, + { + "identifier": "mit-a822f434-d61f-f2b1-c792-8b8cb9e7b9bf", + "license_expression": "mit", + "detection_count": 2, + "detection_log": [] + }, + { + "identifier": "mit-9967e727-165e-9bb5-f090-7de5e47a3929", + "license_expression": "mit", + "detection_count": 1, + "detection_log": [] + }, + { + "identifier": "mit_or_gpl_2_0-562fb174-abc9-da75-d29f-5bc4f1d9c56f", + "license_expression": "mit OR gpl-2.0", + "detection_count": 2, + "detection_log": [] + }, + { + "identifier": "mit_or_gpl_2_0-7f34a90b-f7b4-e345-2cc0-2de55fdcc1bd", + "license_expression": "mit OR gpl-2.0", + "detection_count": 1, + "detection_log": [] + } + ], + "files": [ + { + "path": "README.md", + "type": "file", + "package_data": [], + "for_packages": [ + "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": true, + "is_key_file": true, + "detected_license_expression": "mit OR gpl-2.0", + "detected_license_expression_spdx": "MIT OR GPL-2.0-only", + "license_detections": [ + { + "license_expression": "mit OR gpl-2.0", + "matches": [ + { + "score": 94.81, + "start_line": 12, + "end_line": 21, + "matched_length": 128, + "match_coverage": 94.81, + "matcher": "3-seq", + "license_expression": "mit OR gpl-2.0", + "rule_identifier": "mit_or_gpl-2.0_68.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_or_gpl-2.0_68.RULE", + "matched_text": "are dual licensed under the MIT and GPL licenses:\n\n* [MIT](http://malsup.github.com/mit-license.txt)\n* [GPL](http://malsup.github.com/gpl-license-v2.txt)\n\nYou may use either license. The MIT License is recommended for most projects because it is simple and easy to understand and it places almost no restrictions on what you can do with the plugin.\n\nIf the GPL suits your project better you are also free to use the plugin under that license.\n\nYou don't have to do anything special to choose one license or the other and you don't have to notify anyone which license you are using. You are free to use the jQuery Form Plugin in commercial projects as long as the copyright header is left intact." + } + ], + "detection_log": [], + "identifier": "mit_or_gpl_2_0-562fb174-abc9-da75-d29f-5bc4f1d9c56f" + } + ], + "license_clues": [], + "percentage_of_license_text": 53.11, + "scan_errors": [] + }, + { + "path": "bower.json", + "type": "file", + "package_data": [ + { + "type": "bower", + "namespace": null, + "name": "jquery-form", + "version": "3.51.0", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "mit OR gpl-2.0", + "declared_license_expression_spdx": "MIT OR GPL-2.0-only", + "license_detections": [ + { + "license_expression": "mit OR gpl-2.0", + "matches": [ + { + "score": 94.81, + "start_line": 12, + "end_line": 21, + "matched_length": 128, + "match_coverage": 94.81, + "matcher": "3-seq", + "license_expression": "mit OR gpl-2.0", + "rule_identifier": "mit_or_gpl-2.0_68.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_or_gpl-2.0_68.RULE", + "matched_text": "are dual licensed under the MIT and GPL licenses:\n\n* [MIT](http://malsup.github.com/mit-license.txt)\n* [GPL](http://malsup.github.com/gpl-license-v2.txt)\n\nYou may use either license. The MIT License is recommended for most projects because it is simple and easy to understand and it places almost no restrictions on what you can do with the plugin.\n\nIf the GPL suits your project better you are also free to use the plugin under that license.\n\nYou don't have to do anything special to choose one license or the other and you don't have to notify anyone which license you are using. You are free to use the jQuery Form Plugin in commercial projects as long as the copyright header is left intact." + } + ], + "detection_log": [], + "identifier": "mit_or_gpl_2_0-562fb174-abc9-da75-d29f-5bc4f1d9c56f" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:bower/jquery", + "extracted_requirement": ">=1.5", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "bower_json", + "purl": "pkg:bower/jquery-form@3.51.0" + } + ], + "for_packages": [ + "pkg:bower/jquery-form@3.51.0?uuid=fixed-uid-done-for-testing-5642512d1758", + "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "scan_errors": [] + }, + { + "path": "composer.json", + "type": "file", + "package_data": [ + { + "type": "composer", + "namespace": "malsup", + "name": "form", + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "PHP", + "description": null, + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "M. Alsup", + "email": null, + "url": "http://jquery.malsup.com" + }, + { + "type": "person", + "role": "vendor", + "name": "malsup", + "email": null, + "url": null + } + ], + "keywords": [], + "homepage_url": "http://jquery.malsup.com/form/", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": "https://github.com/malsup/form/issues", + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "mit AND gpl-2.0", + "declared_license_expression_spdx": "MIT AND GPL-2.0-only", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "1-spdx-id", + "license_expression": "mit", + "rule_identifier": "spdx-license-identifier-mit-5da48780aba670b0860c46d899ed42a0f243ff06", + "rule_relevance": 100, + "rule_url": null, + "matched_text": "MIT" + } + ], + "identifier": "mit-a822f434-d61f-f2b1-c792-8b8cb9e7b9bf" + }, + { + "license_expression": "gpl-2.0", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "gpl-2.0", + "rule_identifier": "gpl-2.0_52.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_52.RULE", + "matched_text": "GPL-2.0" + } + ], + "identifier": "gpl_2_0-d7f02717-086e-f71b-962e-b18cc23b1827" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "- MIT\n- GPL-2.0\n", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:composer/components/jquery", + "extracted_requirement": ">=1.5", + "scope": "require", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": "https://packagist.org/packages/malsup/form", + "repository_download_url": null, + "api_data_url": "https://packagist.org/p/packages/malsup/form.json", + "datasource_id": "php_composer_json", + "purl": "pkg:composer/malsup/form" + } + ], + "for_packages": [ + "pkg:composer/malsup/form?uuid=fixed-uid-done-for-testing-5642512d1758", + "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "detected_license_expression": "(mit OR gpl-2.0-plus) AND gpl-2.0", + "detected_license_expression_spdx": "(MIT OR GPL-2.0-or-later) AND GPL-2.0-only", + "license_detections": [ + { + "license_expression": "(mit OR gpl-2.0-plus) AND gpl-2.0", + "matches": [ + { + "score": 100.0, + "start_line": 21, + "end_line": 23, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit OR gpl-2.0-plus", + "rule_identifier": "mit_or_gpl-2.0-plus_1.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_or_gpl-2.0-plus_1.RULE", + "matched_text": "license\": [\n \"MIT\",\n \"GPL-" + }, + { + "score": 100.0, + "start_line": 23, + "end_line": 23, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "gpl-2.0", + "rule_identifier": "gpl-2.0_52.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl-2.0_52.RULE", + "matched_text": "GPL-2.0\"" + } + ], + "detection_log": [], + "identifier": "mit_or_gpl_2_0_plus__and_gpl_2_0-876682c2-38c1-1236-75ea-c46243d9c414" + } + ], + "license_clues": [], + "percentage_of_license_text": 6.76, + "scan_errors": [] + }, + { + "path": "package.json", + "type": "file", + "package_data": [ + { + "type": "npm", + "namespace": "@liferay", + "name": "jquery-form", + "version": "3.51.0-liferay.1", + "qualifiers": {}, + "subpath": null, + "primary_language": "JavaScript", + "description": "A simple way to AJAX-ify any form on your page; with file upload and progress support.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "M. Alsup", + "email": null, + "url": "http://jquery.malsup.com" + } + ], + "keywords": [ + "form", + "upload", + "ajax" + ], + "homepage_url": "http://jquery.malsup.com/form/", + "download_url": "https://registry.npmjs.org/@liferay/jquery-form/-/jquery-form-3.51.0-liferay.1.tgz", + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": "https://github.com/malsup/form/issues", + "code_view_url": null, + "vcs_url": "git+https://github.com/liferay/liferay-frontend-projects.git", + "copyright": null, + "holder": null, + "declared_license_expression": "mit AND gpl-1.0-plus", + "declared_license_expression_spdx": "MIT AND GPL-1.0-or-later", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "1-spdx-id", + "license_expression": "mit", + "rule_identifier": "spdx-license-identifier-mit-5da48780aba670b0860c46d899ed42a0f243ff06", + "rule_relevance": 100, + "rule_url": null, + "matched_text": "MIT" + } + ], + "identifier": "mit-a822f434-d61f-f2b1-c792-8b8cb9e7b9bf" + }, + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit_14.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_14.RULE", + "matched_text": "http://malsup.github.com/mit-license.txt" + } + ], + "identifier": "mit-9967e727-165e-9bb5-f090-7de5e47a3929" + }, + { + "license_expression": "gpl-1.0-plus", + "matches": [ + { + "score": 50.0, + "start_line": 1, + "end_line": 1, + "matched_length": 1, + "match_coverage": 100.0, + "matcher": "1-hash", + "license_expression": "gpl-1.0-plus", + "rule_identifier": "gpl_bare_word_only.RULE", + "rule_relevance": 50, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl_bare_word_only.RULE", + "matched_text": "GPL" + } + ], + "identifier": "gpl_1_0_plus-473308ff-72ce-7e72-b3a9-5b1cc6680abb" + }, + { + "license_expression": "gpl-1.0-plus", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "gpl-1.0-plus", + "rule_identifier": "gpl_200.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/gpl_200.RULE", + "matched_text": "http://malsup.github.com/gpl-license-v2.txt" + } + ], + "identifier": "gpl_1_0_plus-b6a20479-06f3-d753-878b-d3193c879108" + } + ], + "other_license_expression": null, + "other_license_expression_spdx": null, + "other_license_detections": [], + "extracted_license_statement": "- type: MIT\n url: http://malsup.github.com/mit-license.txt\n- type: GPL\n url: http://malsup.github.com/gpl-license-v2.txt\n", + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:npm/jquery", + "extracted_requirement": ">=1.5", + "scope": "dependencies", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/gulp", + "extracted_requirement": "~3.5.2", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/gulp-concat", + "extracted_requirement": "~2.1.7", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/gulp-jshint", + "extracted_requirement": "~1.4.2", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/gulp-uglify", + "extracted_requirement": "~0.2.1", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:npm/gulp-util", + "extracted_requirement": "~2.2.14", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": "https://www.npmjs.com/package/@liferay/jquery-form", + "repository_download_url": "https://registry.npmjs.org/@liferay/jquery-form/-/jquery-form-3.51.0-liferay.1.tgz", + "api_data_url": "https://registry.npmjs.org/@liferay%2fjquery-form/3.51.0-liferay.1", + "datasource_id": "npm_package_json", + "purl": "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1" + } + ], + "for_packages": [ + "pkg:npm/%40liferay/jquery-form@3.51.0-liferay.1?uuid=fixed-uid-done-for-testing-5642512d1758" + ], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "detected_license_expression": "mit OR gpl-2.0", + "detected_license_expression_spdx": "MIT OR GPL-2.0-only", + "license_detections": [ + { + "license_expression": "mit OR gpl-2.0", + "matches": [ + { + "score": 100.0, + "start_line": 17, + "end_line": 22, + "matched_length": 21, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit OR gpl-2.0", + "rule_identifier": "mit_or_gpl-2.0_69.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_or_gpl-2.0_69.RULE", + "matched_text": "type\": \"MIT\",\n \"url\": \"http://malsup.github.com/mit-license.txt\"\n },\n {\n \"type\": \"GPL\",\n \"url\": \"http://malsup.github.com/gpl-license-v2.txt\"" + } + ], + "detection_log": [], + "identifier": "mit_or_gpl_2_0-7f34a90b-f7b4-e345-2cc0-2de55fdcc1bd" + } + ], + "license_clues": [], + "percentage_of_license_text": 14.0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/README.md b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/README.md new file mode 100644 index 00000000000..81fb018a59a --- /dev/null +++ b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/README.md @@ -0,0 +1,26 @@ +#[jQuery Form Plugin](http://jquery.malsup.com/form/) + +##Overview +The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted. + +No special markup is needed, just a normal form. Submitting a form with AJAX doesn't get any easier than this! + + +##Copyright and License +Copyright 2006-2013 (c) M. Alsup + +All versions, present and past, of the jQuery Form plugin are dual licensed under the MIT and GPL licenses: + +* [MIT](http://malsup.github.com/mit-license.txt) +* [GPL](http://malsup.github.com/gpl-license-v2.txt) + +You may use either license. The MIT License is recommended for most projects because it is simple and easy to understand and it places almost no restrictions on what you can do with the plugin. + +If the GPL suits your project better you are also free to use the plugin under that license. + +You don't have to do anything special to choose one license or the other and you don't have to notify anyone which license you are using. You are free to use the jQuery Form Plugin in commercial projects as long as the copyright header is left intact. + + +--- + +Additional documentation and examples at: http://malsup.com/jquery/form/ diff --git a/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/bower.json b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/bower.json new file mode 100644 index 00000000000..5e487e4cf6f --- /dev/null +++ b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/bower.json @@ -0,0 +1,15 @@ +{ + "name": "jquery-form", + "version": "3.51.0", + "main": "jquery.form.js", + "author": "M. Alsup", + "dependencies": { + "jquery": ">=1.5" + }, + "ignore": [ + "README.md", + "composer.json", + "form.jquery.json", + "package.json" + ] +} diff --git a/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/composer.json b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/composer.json new file mode 100644 index 00000000000..2137c1bd15b --- /dev/null +++ b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/composer.json @@ -0,0 +1,40 @@ +{ + "name": "malsup/form", + "description": "A simple way to AJAX-ify any form on your page; with file upload and progress support.", + "type": "component", + "homepage": "http://jquery.malsup.com/form/", + "keywords": [ + "form", + "upload", + "ajax" + ], + "support": { + "issues": "https://github.com/malsup/form/issues", + "wiki": "http://jquery.malsup.com/form/" + }, + "authors": [ + { + "name": "M. Alsup", + "homepage": "http://jquery.malsup.com" + } + ], + "license": [ + "MIT", + "GPL-2.0" + ], + "require": { + "components/jquery": ">=1.5" + }, + "extra": { + "component": { + "scripts": [ + "jquery.form.js" + ], + "shim": { + "deps": [ + "jquery" + ] + } + } + } +} diff --git a/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/package.json b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/package.json new file mode 100644 index 00000000000..b28a5e39f15 --- /dev/null +++ b/tests/packagedcode/data/license_detection/multi-flavor/jquery-form-3.51.0/package.json @@ -0,0 +1,50 @@ +{ + "name": "@liferay/jquery-form", + "title": "jQuery Form Plugin", + "description": "A simple way to AJAX-ify any form on your page; with file upload and progress support.", + "keywords": [ + "form", + "upload", + "ajax" + ], + "version": "3.51.0-liferay.1", + "author": { + "name": "M. Alsup", + "url": "http://jquery.malsup.com" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://malsup.github.com/mit-license.txt" + }, + { + "type": "GPL", + "url": "http://malsup.github.com/gpl-license-v2.txt" + } + ], + "bugs": "https://github.com/malsup/form/issues", + "homepage": "http://jquery.malsup.com/form/", + "docs": "http://jquery.malsup.com/form/", + "download": "http://malsup.github.com/jquery.form.js", + "dependencies": { + "jquery": ">=1.5" + }, + "jam": { + "main": "jquery.form.js", + "dependencies": { + "jquery": ">=1.5.0" + } + }, + "devDependencies": { + "gulp": "~3.5.2", + "gulp-concat": "~2.1.7", + "gulp-jshint": "~1.4.2", + "gulp-uglify": "~0.2.1", + "gulp-util": "~2.2.14" + }, + "repository": { + "directory": "third-party/projects/jquery-form", + "type": "git", + "url": "https://github.com/liferay/liferay-frontend-projects.git" + } +} diff --git a/tests/packagedcode/test_license_detection.py b/tests/packagedcode/test_license_detection.py index 6aa491075c3..ccb2ac62273 100644 --- a/tests/packagedcode/test_license_detection.py +++ b/tests/packagedcode/test_license_detection.py @@ -283,3 +283,24 @@ def test_license_reference_to_unknown_package_special_case_debian(): run_scan_click(args) test_loc = test_env.get_test_loc('license_detection/reference-to-package/fusiondirectory.expected.json') check_json_scan(test_loc, result_file, regen=REGEN_TEST_FIXTURES) + + +def test_license_package_multi_flavored(): + test_dir = test_env.get_test_loc('license_detection/multi-flavor/jquery-form-3.51.0/') + result_file = test_env.get_temp_file('json') + args = [ + '--license', + '--license-text', + '--license-text-diagnostics', + '--license-diagnostics', + '--package', + '--strip-root', + '--verbose', + '--summary', + '--classify', + '--json', result_file, + test_dir, + ] + run_scan_click(args) + test_loc = test_env.get_test_loc('license_detection/multi-flavor/jquery-form-3.51.0.expected.json') + check_json_scan(test_loc, result_file, regen=REGEN_TEST_FIXTURES) From 5f458b966e02c906a4e22c80a6ba47e8d7cf5b56 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Mon, 24 Jul 2023 19:14:32 +0530 Subject: [PATCH 11/12] Address feedback on #3462 Signed-off-by: Ayan Sinha Mahapatra --- .../reference/available_package_parsers.rst | 22 ++++++++++++------- etc/scripts/licenses/buildrules.py | 2 +- src/licensedcode/detection.py | 12 +++++----- src/licensedcode/models.py | 4 ++-- src/packagedcode/misc.py | 8 +++---- src/packagedcode/readme.py | 3 +++ src/summarycode/todo.py | 8 +++---- tests/packagedcode/data/plugin/help.txt | 22 +++++++++---------- tests/packagedcode/test_package_models.py | 10 +++++++++ ...ti-orig-tarball-package-expected-diag.json | 2 +- 10 files changed, 55 insertions(+), 38 deletions(-) diff --git a/docs/source/reference/available_package_parsers.rst b/docs/source/reference/available_package_parsers.rst index 4e39b11b9c2..86954ef68a0 100644 --- a/docs/source/reference/available_package_parsers.rst +++ b/docs/source/reference/available_package_parsers.rst @@ -23,12 +23,6 @@ parsers in scancode-toolkit during documentation builds. - Datasource ID - Primary Language - Documentation URL - * - JAR Java Archive - - ``*.jar`` - - None - - ``java_jar`` - - None - - https://en.wikipedia.org/wiki/JAR_(file_format) * - AboutCode ABOUT file - ``*.ABOUT`` - ``about`` @@ -306,13 +300,13 @@ parsers in scancode-toolkit during documentation builds. - ``debian_source_metadata_tarball`` - None - https://manpages.debian.org/unstable/dpkg-dev/deb.5.en.html - * - None + * - macOS disk image file - ``*.dmg`` ``*.sparseimage`` - ``dmg`` - ``apple_dmg`` - None - - None + - https://en.wikipedia.org/wiki/Apple_Disk_Image * - Java EAR application.xml - ``*/META-INF/application.xml`` - ``ear`` @@ -437,6 +431,12 @@ parsers in scancode-toolkit during documentation builds. - ``ant_ivy_xml`` - Java - https://ant.apache.org/ivy/history/latest-milestone/ivyfile.html + * - JAR Java Archive + - ``*.jar`` + - ``jar`` + - ``java_jar`` + - None + - https://en.wikipedia.org/wiki/JAR_(file_format) * - Java JAR MANIFEST.MF - ``*/META-INF/MANIFEST.MF`` - ``jar`` @@ -555,6 +555,12 @@ parsers in scancode-toolkit during documentation builds. - ``opam_file`` - Ocaml - https://opam.ocaml.org/doc/Manual.html#Common-file-format + * - Java OSGi MANIFEST.MF + - None + - ``osgi`` + - ``java_osgi_manifest`` + - Java + - https://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html * - Dart pubspec lockfile - ``*pubspec.lock`` - ``pubspec`` diff --git a/etc/scripts/licenses/buildrules.py b/etc/scripts/licenses/buildrules.py index 3f2277a3964..f1d79171038 100644 --- a/etc/scripts/licenses/buildrules.py +++ b/etc/scripts/licenses/buildrules.py @@ -223,7 +223,7 @@ def cli(licenses_file): elif rule.is_license_intro: base_name = "license-intro" elif rule.is_license_clue: - base_name = "license-clue" + base_name = f"license-clue_{rule.license_expression}" else: base_name = rule.license_expression diff --git a/src/licensedcode/detection.py b/src/licensedcode/detection.py index 7a589dc51bd..3645fe304ad 100644 --- a/src/licensedcode/detection.py +++ b/src/licensedcode/detection.py @@ -106,11 +106,10 @@ class DetectionCategory(Enum): EXTRA_WORDS = 'extra-words' UNKNOWN_MATCH = 'unknown-match' LICENSE_CLUES = 'license-clues' - LOW_QUALITY_MATCHES = 'license-clues' + LOW_QUALITY_MATCH_FRAGMENTS = 'low-quality-matches' IMPERFECT_COVERAGE = 'imperfect-match-coverage' FALSE_POSITVE = 'possible-false-positive' UNDETECTED_LICENSE = 'undetected-license' - MATCH_FRAGMENTS = 'match-fragments' LOW_RELEVANCE = 'low-relevance' @@ -124,6 +123,7 @@ class DetectionRule(Enum): """ UNKNOWN_MATCH = 'unknown-match' LICENSE_CLUES = 'license-clues' + LOW_QUALITY_MATCH_FRAGMENTS = 'low-quality-matches' FALSE_POSITIVE = 'possible-false-positive' NOT_LICENSE_CLUES = 'not-license-clues-as-more-detections-present' UNKNOWN_REFERENCE_TO_LOCAL_FILE = 'unknown-reference-to-local-file' @@ -1374,12 +1374,12 @@ def get_detected_license_expression( detection_log.append(DetectionRule.LICENSE_CLUES.value) return detection_log, combined_expression - elif analysis == DetectionCategory.LOW_QUALITY_MATCHES.value: + elif analysis == DetectionCategory.LOW_QUALITY_MATCH_FRAGMENTS.value: if TRACE_ANALYSIS: logger_debug(f'analysis {DetectionCategory.LICENSE_CLUES.value}') # TODO: we are temporarily returning these as license clues, and not # in detections but ideally we should return synthetic unknowns for these - detection_log.append(DetectionRule.LOW_QUALITY_MATCHES.value) + detection_log.append(DetectionRule.LOW_QUALITY_MATCH_FRAGMENTS.value) return detection_log, combined_expression else: @@ -1501,7 +1501,7 @@ def get_ambiguous_license_detections_by_type(unique_license_detections): for detection in unique_license_detections: if not detection.license_expression: - ambi_license_detections[DetectionCategory.MATCH_FRAGMENTS.value] = detection + ambi_license_detections[DetectionCategory.LOW_QUALITY_MATCH_FRAGMENTS.value] = detection elif is_undetected_license_matches(license_matches=detection.matches): ambi_license_detections[DetectionCategory.UNDETECTED_LICENSE.value] = detection @@ -1567,7 +1567,7 @@ def analyze_detection(license_matches, package_license=False): return DetectionCategory.UNKNOWN_MATCH.value elif not package_license and is_low_quality_matches(license_matches=license_matches): - return DetectionCategory.LOW_QUALITY_MATCHES.value + return DetectionCategory.LOW_QUALITY_MATCH_FRAGMENTS.value # Case where at least one of the matches have `match_coverage` # below IMPERFECT_MATCH_COVERAGE_THR diff --git a/src/licensedcode/models.py b/src/licensedcode/models.py index 5c522c65a35..d81cae1126f 100644 --- a/src/licensedcode/models.py +++ b/src/licensedcode/models.py @@ -1193,7 +1193,7 @@ def load_rules( rules_data_dir=rules_data_dir, with_checks=True, is_builtin=True, - ignore_deprecated=True, + with_depreacted=False, ): """ Return an iterable of rules loaded from rule files in ``rules_data_dir``. @@ -1217,7 +1217,7 @@ def load_rules( try: rule = Rule.from_file(rule_file=rule_file) - if rule.is_deprecated and ignore_deprecated: + if not with_depreacted and rule.is_deprecated: continue else: yield rule diff --git a/src/packagedcode/misc.py b/src/packagedcode/misc.py index a3ba060258d..f4b7289d69f 100644 --- a/src/packagedcode/misc.py +++ b/src/packagedcode/misc.py @@ -18,13 +18,12 @@ # yet the purpose and semantics are rather different here # TODO: parse me!!! -# TODO: add missing URLs and descriptions - class JavaJarHandler(models.NonAssemblableDatafileHandler): datasource_id = 'java_jar' # NOTE: there are a few rare cases where a .zip can be a JAR. path_patterns = ('*.jar',) + default_package_type = 'jar' filetypes = ('zip archive', 'java archive',) description = 'JAR Java Archive' documentation_url = 'https://en.wikipedia.org/wiki/JAR_(file_format)' @@ -270,8 +269,9 @@ class AppleDmgHandler(models.NonAssemblableDatafileHandler): datasource_id = 'apple_dmg' default_package_type = 'dmg' path_patterns = ('*.dmg', '*.sparseimage',) - description = '' - documentation_url = '' + description = 'macOS disk image file' + # See also https://en.wikipedia.org/wiki/Sparse_image + documentation_url = 'https://en.wikipedia.org/wiki/Apple_Disk_Image' class IsoImageHandler(models.NonAssemblableDatafileHandler): diff --git a/src/packagedcode/readme.py b/src/packagedcode/readme.py index 5916f72cf7a..63741e86648 100644 --- a/src/packagedcode/readme.py +++ b/src/packagedcode/readme.py @@ -37,6 +37,7 @@ 'licence': 'extracted_license_statement', 'license': 'extracted_license_statement', + # This also has License File sometimes } @@ -50,6 +51,8 @@ class ReadmeHandler(models.NonAssemblableDatafileHandler): '*/README.google', '*/README.thirdparty', ) + description = '' + documentation_url = '' @classmethod def parse(cls, location): diff --git a/src/summarycode/todo.py b/src/summarycode/todo.py index c9c881f6a0b..e69b4d1b903 100644 --- a/src/summarycode/todo.py +++ b/src/summarycode/todo.py @@ -213,8 +213,6 @@ def get_package_identifier(package_data, file_path): def get_unknown_purl(package_type): - if not package_type: - package_type = "unknown" purl = PackageURL(type=package_type, name="unknown") return purl.to_string() @@ -337,7 +335,7 @@ class ReviewComments(Enum): "been matched to rules having unknown as their license key, and these " "needs to be reviewed." ) - MATCH_FRAGMENTS = ( + LOW_QUALITY_MATCH_FRAGMENTS = ( "Fragments of license text were detected which are not proper license detections " "and likely has misleading license expression, but this has some clues about licenses, " "which needs review." @@ -391,8 +389,8 @@ def get_review_comments(detection_log): if LicenseDetectionCategory.UNKNOWN_MATCH.value in detection_log: review_comments[LicenseDetectionCategory.UNKNOWN_MATCH.value] = ReviewComments.UNKNOWN_MATCH.value - if LicenseDetectionCategory.MATCH_FRAGMENTS.value in detection_log: - review_comments[LicenseDetectionCategory.MATCH_FRAGMENTS.value] = ReviewComments.MATCH_FRAGMENTS.value + if LicenseDetectionCategory.LOW_QUALITY_MATCH_FRAGMENTS.value in detection_log: + review_comments[LicenseDetectionCategory.LOW_QUALITY_MATCH_FRAGMENTS.value] = ReviewComments.LOW_QUALITY_MATCH_FRAGMENTS.value if LicenseDetectionCategory.LOW_RELEVANCE.value in detection_log: review_comments[LicenseDetectionCategory.LOW_RELEVANCE.value] = ReviewComments.LOW_RELEVANCE.value diff --git a/tests/packagedcode/data/plugin/help.txt b/tests/packagedcode/data/plugin/help.txt index f004d93ed63..1f0da6029b5 100755 --- a/tests/packagedcode/data/plugin/help.txt +++ b/tests/packagedcode/data/plugin/help.txt @@ -1,11 +1,4 @@ -------------------------------------------- -Package type: None - datasource_id: java_jar - documentation URL: https://en.wikipedia.org/wiki/JAR_(file_format) - primary language: None - description: JAR Java Archive - path_patterns: '*.jar' --------------------------------------------- Package type: about datasource_id: about_file documentation URL: https://aboutcode-toolkit.readthedocs.io/en/latest/specification.html @@ -323,9 +316,9 @@ Package type: deb -------------------------------------------- Package type: dmg datasource_id: apple_dmg - documentation URL: + documentation URL: https://en.wikipedia.org/wiki/Apple_Disk_Image primary language: None - description: + description: macOS disk image file path_patterns: '*.dmg', '*.sparseimage' -------------------------------------------- Package type: ear @@ -468,6 +461,13 @@ Package type: ivy description: Ant IVY dependency file path_patterns: '*/ivy.xml' -------------------------------------------- +Package type: jar + datasource_id: java_jar + documentation URL: https://en.wikipedia.org/wiki/JAR_(file_format) + primary language: None + description: JAR Java Archive + path_patterns: '*.jar' +-------------------------------------------- Package type: jar datasource_id: java_jar_manifest documentation URL: https://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html @@ -715,9 +715,9 @@ Package type: pypi -------------------------------------------- Package type: readme datasource_id: readme - documentation URL: None + documentation URL: primary language: None - description: None + description: path_patterns: '*/README.android', '*/README.chromium', '*/README.facebook', '*/README.google', '*/README.thirdparty' -------------------------------------------- Package type: rpm diff --git a/tests/packagedcode/test_package_models.py b/tests/packagedcode/test_package_models.py index e10966a027a..98a3606093d 100644 --- a/tests/packagedcode/test_package_models.py +++ b/tests/packagedcode/test_package_models.py @@ -153,6 +153,16 @@ def test_package_data_datasource_id_are_unique(self): ), f'Duplicated datasource_id: {pdh!r} with {seen[pdhid]!r}' seen[pdh.datasource_id] = pdh + def test_package_data_handlers_have_package_type(self): + """ + Check that we do not have two DataFileHandlers with the same + datasource_id and that all have one. + """ + for pdh in ALL_DATAFILE_HANDLERS: + pdh_type = pdh.default_package_type + assert pdh_type + + def test_package_data_file_patterns_are_tuples(self): """ Check that all file patterns are tuples, as if they are diff --git a/tests/summarycode/data/todo/todo_present/README.multi-orig-tarball-package-expected-diag.json b/tests/summarycode/data/todo/todo_present/README.multi-orig-tarball-package-expected-diag.json index 30a889fd1c2..ef137b36c97 100644 --- a/tests/summarycode/data/todo/todo_present/README.multi-orig-tarball-package-expected-diag.json +++ b/tests/summarycode/data/todo/todo_present/README.multi-orig-tarball-package-expected-diag.json @@ -24,7 +24,7 @@ } ], "detection_log": [ - "license-clues" + "low-quality-matches" ], "identifier": "borceux-3c39742c-edef-82b7-0cdd-fc4d9ff8b044" } From 06f20bdb8de82a0b3b26a38ea598123add718e49 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 2 Aug 2023 18:03:43 +0530 Subject: [PATCH 12/12] Make license rule a clue Reference: https://github.com/nexB/scancode-toolkit/issues/3480 Signed-off-by: Ayan Sinha Mahapatra --- src/licensedcode/data/rules/unknown-license-reference_332.RULE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/licensedcode/data/rules/unknown-license-reference_332.RULE b/src/licensedcode/data/rules/unknown-license-reference_332.RULE index b5ce54bc40d..e27c0801685 100644 --- a/src/licensedcode/data/rules/unknown-license-reference_332.RULE +++ b/src/licensedcode/data/rules/unknown-license-reference_332.RULE @@ -1,6 +1,6 @@ --- license_expression: unknown-license-reference -is_license_reference: yes +is_license_clue: yes relevance: 80 ---