Skip to content

Commit d515036

Browse files
authored
Merge pull request #2773 from softsense/issue-2637-allow-license-rules-to-require-the-presence-of-certain-defining-keywords
Allow license rules to require the presence of certain defining keywords
2 parents 1dfd73a + 83840df commit d515036

File tree

83 files changed

+4993
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+4993
-89
lines changed

AUTHORS.rst

+2

CHANGELOG.rst

+3

docs/source/how-to-guides/add_new_license_detection_rule.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
license_expression: apache-2.0
2+
is_license_notice: yes
3+
relevance: 100

src/licensedcode/data/rules/apache-2.0_571.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<licenses>
22
<license>
3-
<name>Apache License 2.0</name>
3+
<name>{{Apache License 2.0}}</name>
44
<url>http://repository.jboss.org/licenses/apache-2.0.txt</url>
55
<distribution>repo</distribution>
66
</license>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Code is released under the [Apache 2.0 license](LICENSE). This `README.md` file and the [`CONTRIBUTING.md`](CONTRIBUTING.md) file are licensed under the Creative Commons Attribution 4.0 International License under the terms and conditions set forth in the file [`LICENSE.docs`](LICENSE.docs). You may obtain a duplicate copy of the same license, titled CC BY-SA 4.0, at http://creativecommons.org/licenses/by-sa/4.0/.
1+
Code is released under the [{{Apache 2.0}} license](LICENSE). This `README.md` file and the [`CONTRIBUTING.md`](CONTRIBUTING.md) file are licensed under the {{Creative Commons Attribution 4.0 International License}} under the terms and conditions set forth in the file [`LICENSE.docs`](LICENSE.docs). You may obtain a duplicate copy of the same license, titled CC BY-SA 4.0, at http://creativecommons.org/licenses/by-sa/4.0/.

src/licensedcode/data/rules/apache-2.0_or_epl-2.0_1.RULE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<licenses>
22
<license>
3-
<name>The Apache Software License, Version 2.0</name>
3+
<name>{{The Apache Software License}}, Version 2.0</name>
44
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
55
<distribution>repo</distribution>
66
</license>
77
<license>
8-
<name>Eclipse Public License - v 2.0</name>
8+
<name>{{Eclipse Public License}} - v 2.0</name>
99
<url>http://www.eclipse.org/legal/epl-v20.html</url>
1010
<distribution>repo</distribution>
1111
</license>

src/licensedcode/data/rules/apache-2.0_or_epl-2.0_2.RULE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<licenses>
22
<license>
3-
<name>The Apache Software License, Version 2.0</name>
3+
<name>The {{Apache Software License, Version 2.0}}</name>
44
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
55
<distribution>repo</distribution>
66
</license>
77
<license>
8-
<name>Eclipse Public License - v 2.0</name>
8+
<name>{{Eclipse Public License - v 2.0}}</name>
99
<url>http://www.eclipse.org/legal/epl-v20.html</url>
1010
<distribution>repo</distribution>
1111
</license>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<licenses><license><name>The Apache Software License, Version 2.0</name><url>http://www.apache.org/licenses/LICENSE-2.0.txt</url><distribution>repo</distribution></license><license><name>GNU Lesser General Public License (LGPL), Version 2.1</name><url>http://www.fsf.org/licensing/licenses/lgpl.txt</url><distribution>repo</distribution></license></licenses>
1+
<licenses><license><name>The {{Apache Software License}}, Version 2.0</name><url>http://www.apache.org/licenses/LICENSE-2.0.txt</url><distribution>repo</distribution></license><license><name>{{GNU Lesser General Public License}} (LGPL), Version 2.1</name><url>http://www.fsf.org/licensing/licenses/lgpl.txt</url><distribution>repo</distribution></license></licenses>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<licenses><license><name>The Apache Software License, Version 2.0</name><url>https://www.apache.org/licenses/LICENSE-2.0.txt</url><distribution>repo</distribution></license><license><name>GNU Lesser General Public License (LGPL), Version 2.1</name><url>http://www.fsf.org/licensing/licenses/lgpl.txt</url><distribution>repo</distribution></license></licenses>
1+
<licenses><license><name>The {{Apache Software License}}, Version 2.0</name><url>https://www.apache.org/licenses/LICENSE-2.0.txt</url><distribution>repo</distribution></license><license><name>{{GNU Lesser General Public License}} (LGPL), Version 2.1</name><url>http://www.fsf.org/licensing/licenses/lgpl.txt</url><distribution>repo</distribution></license></licenses>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<!-- Licensing: ASL or GPL -->
2-
<licenses><license><name>The Apache Software License, Version 2.0</name><url>https://www.apache.org/licenses/LICENSE-2.0.txt</url><distribution>repo</distribution></license><license><name>GNU Lesser General Public License (LGPL), Version 2.1</name><url>http://www.fsf.org/licensing/licenses/lgpl.txt</url><distribution>repo</distribution></license></licenses>
2+
<licenses><license><name>The {{Apache Software License}}, Version 2.0</name><url>https://www.apache.org/licenses/LICENSE-2.0.txt</url><distribution>repo</distribution></license><license><name>{{GNU Lesser General Public License}} (LGPL), Version 2.1</name><url>http://www.fsf.org/licensing/licenses/lgpl.txt</url><distribution>repo</distribution></license></licenses>

src/licensedcode/data/rules/apache-2.0_or_gpl-2.0-plus_with_classpath-exception-2.0_10.RULE

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<licenses>
22
<license>
3-
<name>Apache License, Version 2.0</name>
3+
<name>{{Apache License, Version 2.0}}</name>
44
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
55
<distribution>repo</distribution>
66
</license>
77
<license>
8-
<name>GNU General Public License (GPL) version 2, or any later version</name>
8+
<name>{{GNU General Public License (GPL) version 2}}, or any later version</name>
99
<url>https://www.gnu.org/licenses/</url>
1010
<distribution>repo</distribution>
1111
</license>
1212
<license>
13-
<name>GPLv2 with Classpath exception</name>
13+
<name>{{GPLv2 with Classpath exception}}</name>
1414
<url>https://www.gnu.org/software/classpath/license.html</url>
1515
<distribution>repo</distribution>
1616
</license>

src/licensedcode/data/rules/apache-2.0_or_gpl-2.0-plus_with_classpath-exception-2.0_7.RULE

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<licenses>
22
<license>
3-
<name>Apache License, Version 2.0</name>
3+
<name>{{Apache License}}, Version 2.0</name>
44
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
55
<distribution>repo</distribution>
66
</license>
77
<license>
8-
<name>GNU General Public License (GPL) version 2, or any later version</name>
8+
<name>{{GNU General Public License}} (GPL) version 2, or any later version</name>
99
<url>https://www.gnu.org/licenses/</url>
1010
<distribution>repo</distribution>
1111
</license>
1212
<license>
13-
<name>GPLv2 with Classpath exception</name>
13+
<name>{{GPLv2}} with {{Classpath exception}}</name>
1414
<url>https://www.gnu.org/software/classpath/license.html</url>
1515
<distribution>repo</distribution>
1616
</license>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<licenses> <license> <name>Apache License, Version 2.0</name> <url>https://www.apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses>
1+
<licenses> <license> <name>{{Apache License}}, Version 2.0</name> <url>https://www.apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<licenses> <license> <name>Apache License, Version 2.0</name> <url>https://apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses>
1+
<licenses> <license> <name>{{Apache License}}, Version 2.0</name> <url>https://apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<licenses> <license> <name>Apache License, Version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses>
1+
<licenses> <license> <name>{{Apache License, Version 2.0}}</name> <url>http://www.apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<licenses> <license> <name>Apache License, Version 2.0</name> <url>http://apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses>
1+
<licenses> <license> <name>{{Apache License}}, Version 2.0</name> <url>http://apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses>

src/licensedcode/data/rules/bsd-new_531.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<licenses>
22
<license>
3-
<name>Berkeley Software Distribution (BSD) License</name>
3+
<name>{{Berkeley Software Distribution}} (BSD) License</name>
44
<url>http://www.opensource.org/licenses/bsd-license.html</url>
55
<distribution>repo</distribution>
66
</license>
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<licenses>
22
<license>
3-
<name>Berkeley Software Distribution (BSD) License</name>
3+
<name>{{Berkeley Software Distribution (BSD) License}}</name>
44
<url>http://www.opensource.org/licenses/bsd-license.html</url>
55
</license>
66
</licenses>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This repository uses 2 different licenses :
2-
- all files in the `lib` directory use a BSD 2-Clause license
3-
- all other files use a GPLv2 license, unless explicitly stated otherwise
2+
- all files in the `lib` directory use a {{BSD 2-Clause}} license
3+
- all other files use a {{GPLv2}} license, unless explicitly stated otherwise
44

55
Relevant license is reminded at the top of each source file,
66
and with presence of COPYING or LICENSE file in associated directories.

src/licensedcode/data/rules/cc-by-4.0_16.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
under the Creative Commons Attribution 4.0 International License (the "License");
1+
under the {{Creative Commons Attribution 4.0 International License}} (the "License");
22
you may not use this file except in compliance with the License.
33
You may obtain a copy of the License at
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This work is licensed under a {{Creative Commons Attribution-NonCommercial-ShareAlike 4.0}}
2+
International License (the "License"). You may not use this file except in compliance with the
3+
License. A copy of the License is located at http://creativecommons.org/licenses/by-nc-sa/4.0/.
4+
5+
This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
6+
either express or implied. See the License for the specific language governing permissions and
7+
limitations under the License.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
license_expression: cc-by-nc-sa-4.0
2+
is_license_notice: yes
3+
relevance: 100
4+
ignorable_urls:
5+
- http://creativecommons.org/licenses/by-nc-sa/4.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{Creative Commons Attribution-NonCommercial-ShareAlike 4.0}} International License
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
license_expression: cc-by-nc-sa-4.0
2+
is_license_reference: yes
3+
relevance: 100

src/licensedcode/data/rules/cddl-1.0_27.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<licenses>
22
<license>
3-
<name>CDDL 1</name>
3+
<name>{{CDDL 1}}</name>
44
<url>http://opensource.org/licenses/CDDL-1.0</url>
55
<distribution>repo</distribution>
66
</license>

src/licensedcode/data/rules/epl-1.0_or_lgpl-2.1-plus_4.RULE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<licenses>
22
<license>
3-
<name>Eclipse Public License 1.0</name>
3+
<name>{{Eclipse Public License 1.0}}</name>
44
<url>http://www.eclipse.org/org/documents/epl-v10.php</url>
55
<distribution>Manual</distribution>
66
</license>
77
<license>
8-
<name>GNU Lesser GPL 2.1</name>
8+
<name>{{GNU Lesser GPL 2.1}}</name>
99
<url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</url>
1010
<distribution>manual</distribution>
1111
</license>

src/licensedcode/data/rules/epl-1.0_or_lgpl-2.1-plus_5.RULE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<licenses>
22
<license>
3-
<name>Eclipse Public License 1.0</name>
3+
<name>{{Eclipse Public License 1.0}}</name>
44
<url>http://www.eclipse.org/org/documents/epl-v10.php</url>
55
<distribution>Manual</distribution>
66
</license>
77
<license>
8-
<name>GNU Lesser GPL 2.1</name>
8+
<name>{{GNU Lesser GPL 2.1}}</name>
99
<url>https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</url>
1010
<distribution>manual</distribution>
1111
</license>

src/licensedcode/data/rules/false-positive_ansible_2.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# - GPLv3
66
# - Apache
77
# - CC-BY
8-
license: {{ license }}
8+
license: license
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Distributed under the terms of the GNU General Public License (version 2
2-
# or later) with exception for distributing the bootloader.
1+
Distributed under the terms of the {{GNU General Public License}} (version 2
2+
# or later) with exception for distributing the {{bootloader}}.
33
#
4-
# The full license is in the file COPYING.txt, distributed with this software.
4+
# The full license is in the file COPYING.txt, distributed with this software.

src/licensedcode/data/rules/gpl-2.0-plus_and_bootloader-exception_1.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ is_license_notice: yes
33
relevance: 100
44
referenced_filenames:
55
- COPYING.txt
6+
minimum_coverage: 70
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Licensed under the GNU General Public License v2 (the "License");
1+
Licensed under the {{GNU General Public License v2}} (the "License");
22
you may not use this file except in compliance with the License. The terms
33
of the License are located in the COPYING file of this distribution.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#{{IS_RIGHT
1+
#IS_RIGHT
22
# This program is distributed under GPL Version 2.0 in the hope that
33
# it will be useful, but WITHOUT ANY WARRANTY.
4-
#}}IS_RIGHT
4+
#IS_RIGHT
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{IS_RIGHT
2+
IS_RIGHT
33
This program is distributed under GPL Version 3.0 in the hope that
44
it will be useful, but WITHOUT ANY WARRANTY.
5-
}}IS_RIGHT
5+
IS_RIGHT

src/licensedcode/data/rules/imagemagick_19.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ You may add Your own copyright statement to Your modifications and may provide a
4545

4646
How to Apply the License to your Work
4747

48-
To apply the ImageMagick License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information (don't include the brackets). The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
48+
To apply the {{ImageMagick}} License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information (don't include the brackets). The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
4949

5050
Copyright [yyyy] [name of copyright owner]
5151

src/licensedcode/data/rules/lgpl-3.0-plus_216.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GNU Lesser General Public License, Version 3 {{{ */
1+
GNU Lesser General Public License, Version 3 */
22

33
is free software: you can redistribute it and/or modify it under
44
the terms of the GNU Lesser General Public License as published by the

src/licensedcode/data/rules/lgpl-3.0-plus_27.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GNU Lesser General Public License, Version 3 {{{ */
1+
GNU Lesser General Public License, Version 3 */
22

33
is free software: you can redistribute it and/or modify it under
44
the terms of the GNU Lesser General Public License as published by the
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
License
2-
Distributed under the MIT License. See LICENSE for more information.
2+
Distributed under the {{MIT}} License. See LICENSE for more information.

src/licensedcode/data/rules/mpl-1.0_14.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MPL:
22

3-
"The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
3+
"The contents of this file are subject to the {{Mozilla Public License}} Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
44

55
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
66

src/licensedcode/data/rules/mpl-1.0_8.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* The contents of this file are subject to the Mozilla Public License
1+
* The contents of this file are subject to the {{Mozilla Public License}}
22
* Version 1.0 (the "License"); you may not use this file except in
33
* compliance with the License. You may obtain a copy of the License at
44
* http://www.mozilla.org/MPL/

src/licensedcode/data/rules/mpl-1.1_36.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MPL v1.1:
22

3-
The contents of this file are subject to the Mozilla Public License
3+
The contents of this file are subject to the {{Mozilla Public License}}
44
Version 1.1 (the "License"); you may not use this file except in
55
compliance with the License. You may obtain a copy of the License at
66
http://www..com/mpl.html

src/licensedcode/data/rules/mpl-1.1_40.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The contents of this file are subject to the Mozilla Public License Version 1.1
1+
The contents of this file are subject to the {{Mozilla Public License}} Version 1.1
22
(the License); you may not use this file except in compliance with the License.
33
You may obtain a copy of the License at http://www.mozilla.org/MPL/
44
Software distributed under the License is distributed on an AS IS basis,

src/licensedcode/data/rules/mpl-1.1_6.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%% The contents of this file are subject to the Mozilla Public License
1+
%% The contents of this file are subject to the {{Mozilla Public License}}
22
%% Version 1.1 (the "License"); you may not use this file except in
33
%% compliance with the License. You may obtain a copy of the License at
44
%% http://www.mozilla.org/MPL/

src/licensedcode/data/rules/npl-1.1_1.RULE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
* The contents of this file are subject to the Netscape Public
2-
* License Version 1.1 (the "License"); you may not use this file
1+
* The contents of this file are subject to the {{Netscape Public
2+
* License}} Version 1.1 (the "License"); you may not use this file
33
* except in compliance with the License. You may obtain a copy of
44
* the License at http://www.mozilla.org/NPL/
55
*

src/licensedcode/data/rules/proprietary_133.RULE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* The contents of this file are subject to the KnowledgeTree Public
1+
* The contents of this file are subject to the {{KnowledgeTree}} Public
22
* License Version 1.1 ("License"); You may not use this file except in
33
* compliance with the License. You may obtain a copy of the License at
44
* http://www.ktdms.com/KPL
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This library is distributed under the terms of the Ruby license.
1+
This library is distributed under the terms of the {{Ruby}} license.

src/licensedcode/index.py

+3
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ def _add_rules(self, rules, _legalese=common_license_words, _spdx_tokens=frozens
330330
# "weak" rules can only be matched with an automaton.
331331
is_weak = True
332332

333+
# note down any key phrase spans that must be present for the rule to pass through refinement
334+
rule.key_phrase_spans = list(rule.key_phrases())
335+
333336
for rts in rule.tokens():
334337
rtid = dictionary_get(rts)
335338
if rtid is None:

0 commit comments

Comments
 (0)