Skip to content

Commit abd0f64

Browse files
Fix windows package license detection
* Do not include copyright statement in license detection * Handle cases of license/trademarks not being present correctly Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 02793b8 commit abd0f64

23 files changed

+77
-445
lines changed

src/packagedcode/win_pe.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,13 @@ def parse(cls, location, package_only=False):
311311

312312
License = get_first(infos, 'License')
313313

314-
extracted_license_statement = {}
315-
if LegalCopyright or LegalTrademarks or License:
316-
extracted_license_statement = dict(
317-
LegalCopyright=copyr,
318-
LegalTrademarks=LegalTrademarks,
319-
License=License
320-
)
314+
extracted_license_statement = None
315+
if LegalTrademarks or License:
316+
extracted_license_statement = {}
317+
if LegalTrademarks and LegalTrademarks != '':
318+
extracted_license_statement['LegalTrademarks'] = LegalTrademarks
319+
if License:
320+
extracted_license_statement['License'] = License
321321

322322
description = concat(infos, 'FileDescription', 'Comments')
323323

tests/packagedcode/data/plugin/com-package-expected.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,13 @@
3838
"vcs_url": null,
3939
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
4040
"holder": "Microsoft Corporation",
41-
"declared_license_expression": "unknown",
42-
"declared_license_expression_spdx": "LicenseRef-scancode-unknown",
43-
"license_detections": [
44-
{
45-
"license_expression": "unknown",
46-
"license_expression_spdx": "LicenseRef-scancode-unknown",
47-
"matches": [
48-
{
49-
"license_expression": "unknown",
50-
"license_expression_spdx": "LicenseRef-scancode-unknown",
51-
"from_file": "chcp.com",
52-
"start_line": 1,
53-
"end_line": 1,
54-
"matcher": "5-undetected",
55-
"score": 90.0,
56-
"matched_length": 9,
57-
"match_coverage": 100.0,
58-
"rule_relevance": 100,
59-
"rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
60-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
61-
"matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}"
62-
}
63-
],
64-
"identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7"
65-
}
66-
],
41+
"declared_license_expression": null,
42+
"declared_license_expression_spdx": null,
43+
"license_detections": [],
6744
"other_license_expression": null,
6845
"other_license_expression_spdx": null,
6946
"other_license_detections": [],
70-
"extracted_license_statement": "LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:\n",
47+
"extracted_license_statement": null,
7148
"notice_text": null,
7249
"source_packages": [],
7350
"file_references": [],

tests/packagedcode/data/plugin/mui-package-expected.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,13 @@
3838
"vcs_url": null,
3939
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
4040
"holder": "Microsoft Corporation",
41-
"declared_license_expression": "unknown",
42-
"declared_license_expression_spdx": "LicenseRef-scancode-unknown",
43-
"license_detections": [
44-
{
45-
"license_expression": "unknown",
46-
"license_expression_spdx": "LicenseRef-scancode-unknown",
47-
"matches": [
48-
{
49-
"license_expression": "unknown",
50-
"license_expression_spdx": "LicenseRef-scancode-unknown",
51-
"from_file": "clfs.sys.mui",
52-
"start_line": 1,
53-
"end_line": 1,
54-
"matcher": "5-undetected",
55-
"score": 90.0,
56-
"matched_length": 9,
57-
"match_coverage": 100.0,
58-
"rule_relevance": 100,
59-
"rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
60-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
61-
"matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}"
62-
}
63-
],
64-
"identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7"
65-
}
66-
],
41+
"declared_license_expression": null,
42+
"declared_license_expression_spdx": null,
43+
"license_detections": [],
6744
"other_license_expression": null,
6845
"other_license_expression_spdx": null,
6946
"other_license_detections": [],
70-
"extracted_license_statement": "LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:\n",
47+
"extracted_license_statement": null,
7148
"notice_text": null,
7249
"source_packages": [],
7350
"file_references": [],

tests/packagedcode/data/plugin/mun-package-expected.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,13 @@
3838
"vcs_url": null,
3939
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
4040
"holder": "Microsoft Corporation",
41-
"declared_license_expression": "unknown",
42-
"declared_license_expression_spdx": "LicenseRef-scancode-unknown",
43-
"license_detections": [
44-
{
45-
"license_expression": "unknown",
46-
"license_expression_spdx": "LicenseRef-scancode-unknown",
47-
"matches": [
48-
{
49-
"license_expression": "unknown",
50-
"license_expression_spdx": "LicenseRef-scancode-unknown",
51-
"from_file": "crypt32.dll.mun",
52-
"start_line": 1,
53-
"end_line": 1,
54-
"matcher": "5-undetected",
55-
"score": 90.0,
56-
"matched_length": 9,
57-
"match_coverage": 100.0,
58-
"rule_relevance": 100,
59-
"rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
60-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
61-
"matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}"
62-
}
63-
],
64-
"identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7"
65-
}
66-
],
41+
"declared_license_expression": null,
42+
"declared_license_expression_spdx": null,
43+
"license_detections": [],
6744
"other_license_expression": null,
6845
"other_license_expression_spdx": null,
6946
"other_license_detections": [],
70-
"extracted_license_statement": "LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:\n",
47+
"extracted_license_statement": null,
7148
"notice_text": null,
7249
"source_packages": [],
7350
"file_references": [],

tests/packagedcode/data/plugin/sys-package-expected.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,13 @@
3838
"vcs_url": null,
3939
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
4040
"holder": "Microsoft Corporation",
41-
"declared_license_expression": "unknown",
42-
"declared_license_expression_spdx": "LicenseRef-scancode-unknown",
43-
"license_detections": [
44-
{
45-
"license_expression": "unknown",
46-
"license_expression_spdx": "LicenseRef-scancode-unknown",
47-
"matches": [
48-
{
49-
"license_expression": "unknown",
50-
"license_expression_spdx": "LicenseRef-scancode-unknown",
51-
"from_file": "tbs.sys",
52-
"start_line": 1,
53-
"end_line": 1,
54-
"matcher": "5-undetected",
55-
"score": 90.0,
56-
"matched_length": 9,
57-
"match_coverage": 100.0,
58-
"rule_relevance": 100,
59-
"rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
60-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
61-
"matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}"
62-
}
63-
],
64-
"identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7"
65-
}
66-
],
41+
"declared_license_expression": null,
42+
"declared_license_expression_spdx": null,
43+
"license_detections": [],
6744
"other_license_expression": null,
6845
"other_license_expression_spdx": null,
6946
"other_license_detections": [],
70-
"extracted_license_statement": "LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:\n",
47+
"extracted_license_statement": null,
7148
"notice_text": null,
7249
"source_packages": [],
7350
"file_references": [],

tests/packagedcode/data/plugin/tlb-package-expected.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,13 @@
3838
"vcs_url": null,
3939
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
4040
"holder": "Microsoft Corporation",
41-
"declared_license_expression": "unknown",
42-
"declared_license_expression_spdx": "LicenseRef-scancode-unknown",
43-
"license_detections": [
44-
{
45-
"license_expression": "unknown",
46-
"license_expression_spdx": "LicenseRef-scancode-unknown",
47-
"matches": [
48-
{
49-
"license_expression": "unknown",
50-
"license_expression_spdx": "LicenseRef-scancode-unknown",
51-
"from_file": "stdole2.tlb",
52-
"start_line": 1,
53-
"end_line": 1,
54-
"matcher": "5-undetected",
55-
"score": 90.0,
56-
"matched_length": 9,
57-
"match_coverage": 100.0,
58-
"rule_relevance": 100,
59-
"rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
60-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
61-
"matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}"
62-
}
63-
],
64-
"identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7"
65-
}
66-
],
41+
"declared_license_expression": null,
42+
"declared_license_expression_spdx": null,
43+
"license_detections": [],
6744
"other_license_expression": null,
6845
"other_license_expression_spdx": null,
6946
"other_license_detections": [],
70-
"extracted_license_statement": "LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:\n",
47+
"extracted_license_statement": null,
7148
"notice_text": null,
7249
"source_packages": [],
7350
"file_references": [],

tests/packagedcode/data/plugin/win_pe-package-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"other_license_expression": null,
6868
"other_license_expression_spdx": null,
6969
"other_license_detections": [],
70-
"extracted_license_statement": "LegalCopyright: \u00a9 2009 Ian F. Darwin\nLegalTrademarks: GnuWin32\u00ae, File\u00ae, file\u00ae\nLicense: 'Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995. Software\n written by Ian F. Darwin and others; maintained 1994-2004 Christos Zoulas. This software is\n not subject to any export provision of the United States Department of Commerce, and may be\n exported to any country or planet. Redistribution and use in source and binary forms, with\n or without modification, are permitted provided that the following conditions are met: 1.\n Redistributions of source code must retain the above copyright notice immediately at the beginning\n of the file, without modification, this list of conditions, and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright notice, this list of\n conditions and the following disclaimer in the documentation and/or other materials provided\n with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''''\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\n THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY\n OF SUCH DAMAGE.'\n",
70+
"extracted_license_statement": "LegalTrademarks: GnuWin32\u00ae, File\u00ae, file\u00ae\nLicense: 'Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995. Software\n written by Ian F. Darwin and others; maintained 1994-2004 Christos Zoulas. This software is\n not subject to any export provision of the United States Department of Commerce, and may be\n exported to any country or planet. Redistribution and use in source and binary forms, with\n or without modification, are permitted provided that the following conditions are met: 1.\n Redistributions of source code must retain the above copyright notice immediately at the beginning\n of the file, without modification, this list of conditions, and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright notice, this list of\n conditions and the following disclaimer in the documentation and/or other materials provided\n with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''''\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\n THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY\n OF SUCH DAMAGE.'\n",
7171
"notice_text": null,
7272
"source_packages": [],
7373
"file_references": [],

tests/packagedcode/data/plugin/winmd-package-expected.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,13 @@
3838
"vcs_url": null,
3939
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
4040
"holder": "Microsoft Corporation",
41-
"declared_license_expression": "unknown",
42-
"declared_license_expression_spdx": "LicenseRef-scancode-unknown",
43-
"license_detections": [
44-
{
45-
"license_expression": "unknown",
46-
"license_expression_spdx": "LicenseRef-scancode-unknown",
47-
"matches": [
48-
{
49-
"license_expression": "unknown",
50-
"license_expression_spdx": "LicenseRef-scancode-unknown",
51-
"from_file": "Windows.AI.winmd",
52-
"start_line": 1,
53-
"end_line": 1,
54-
"matcher": "5-undetected",
55-
"score": 90.0,
56-
"matched_length": 9,
57-
"match_coverage": 100.0,
58-
"rule_relevance": 100,
59-
"rule_identifier": "package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
60-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-33f1f14c9c3aed427a1ebff42fd03640ebc75225",
61-
"matched_text": "license {'LegalCopyright': '\u00a9 Microsoft Corporation. All rights reserved.', 'LegalTrademarks': '', 'License': None}"
62-
}
63-
],
64-
"identifier": "unknown-7a4e31a4-3c62-cfda-29ff-b00424060fd7"
65-
}
66-
],
41+
"declared_license_expression": null,
42+
"declared_license_expression_spdx": null,
43+
"license_detections": [],
6744
"other_license_expression": null,
6845
"other_license_expression_spdx": null,
6946
"other_license_detections": [],
70-
"extracted_license_statement": "LegalCopyright: \u00a9 Microsoft Corporation. All rights reserved.\nLegalTrademarks:\nLicense:\n",
47+
"extracted_license_statement": null,
7148
"notice_text": null,
7249
"source_packages": [],
7350
"file_references": [],

tests/packagedcode/data/win_pe/Microsoft.Practices.EnterpriseLibrary.Caching.dll.package-expected.json

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,13 @@
3131
"vcs_url": null,
3232
"copyright": null,
3333
"holder": null,
34-
"declared_license_expression": "unknown",
35-
"declared_license_expression_spdx": "LicenseRef-scancode-unknown",
36-
"license_detections": [
37-
{
38-
"license_expression": "unknown",
39-
"license_expression_spdx": "LicenseRef-scancode-unknown",
40-
"matches": [
41-
{
42-
"license_expression": "unknown",
43-
"license_expression_spdx": "LicenseRef-scancode-unknown",
44-
"from_file": null,
45-
"start_line": 1,
46-
"end_line": 1,
47-
"matcher": "5-undetected",
48-
"score": 83.33,
49-
"matched_length": 5,
50-
"match_coverage": 100.0,
51-
"rule_relevance": 100,
52-
"rule_identifier": "package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce",
53-
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/package-manifest-unknown-679f097d28658555700ef170738adb0fd7151fce",
54-
"matched_text": "license {'LegalCopyright': None, 'LegalTrademarks': '', 'License': None}"
55-
}
56-
],
57-
"identifier": "unknown-3a74427e-26a2-7b3f-eb84-9b610c013417"
58-
}
59-
],
34+
"declared_license_expression": null,
35+
"declared_license_expression_spdx": null,
36+
"license_detections": [],
6037
"other_license_expression": null,
6138
"other_license_expression_spdx": null,
6239
"other_license_detections": [],
63-
"extracted_license_statement": "LegalCopyright:\nLegalTrademarks:\nLicense:\n",
40+
"extracted_license_statement": null,
6441
"notice_text": null,
6542
"source_packages": [],
6643
"file_references": [],

0 commit comments

Comments
 (0)