From 5a68d1f3c220e28935d62069bd3fa09a1b905e9e Mon Sep 17 00:00:00 2001 From: Qing Tomlinson Date: Mon, 17 Jul 2023 08:01:13 -0700 Subject: [PATCH] Fix license not detected for some maven packages In one of the workflow, scancode summarizer goes through the root files to look for license. The filtering for root files is based on case sensitive file path matching. In maven packaging, META/INF directory is used often. Add this to the license location to search. Test case: https://clearlydefined.io/definitions/maven/mavencentral/org.flywaydb/flyway-core/9.20.0 https://dev.clearlydefined.io/definitions/maven/mavencentral/org.flywaydb/flyway-core/7.7.2 Task: https://github.com/clearlydefined/service/issues/846 --- lib/utils.js | 7 +- .../30.1.0/maven-flywaydb-file-license.json | 1531 +++++++++++++++++ test/providers/summary/scancode.js | 9 +- 3 files changed, 1545 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/scancode/30.1.0/maven-flywaydb-file-license.json diff --git a/lib/utils.js b/lib/utils.js index 7c52be21..b142d9a7 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -338,7 +338,12 @@ function isDeclaredLicense(identifier) { } function getLicenseLocations(coordinates) { - const map = { npm: ['package/'], maven: ['meta-inf/'], pypi: [`${coordinates.name}-${coordinates.revision}/`], go: [goLicenseLocations(coordinates)] } + const map = { + npm: ['package/'], + maven: ['meta-inf/', 'META-INF/'], + pypi: [`${coordinates.name}-${coordinates.revision}/`], + go: [goLicenseLocations(coordinates)] + } return map[coordinates.type] } diff --git a/test/fixtures/scancode/30.1.0/maven-flywaydb-file-license.json b/test/fixtures/scancode/30.1.0/maven-flywaydb-file-license.json new file mode 100644 index 00000000..dde707b5 --- /dev/null +++ b/test/fixtures/scancode/30.1.0/maven-flywaydb-file-license.json @@ -0,0 +1,1531 @@ +{ + "_metadata": { + "type": "scancode", + "url": "cd:/maven/mavencentral/org.flywaydb/flyway-maven-plugin/5.0.6", + "fetchedAt": "2023-07-04T22:13:03.522Z", + "links": { + "self": { + "href": "urn:maven:mavencentral:org.flywaydb:flyway-maven-plugin:revision:5.0.6:tool:scancode:30.3.0", + "type": "resource" + }, + "siblings": { + "href": "urn:maven:mavencentral:org.flywaydb:flyway-maven-plugin:revision:5.0.6:tool:scancode", + "type": "collection" + } + }, + "schemaVersion": "30.3.0", + "toolVersion": "30.1.0", + "contentType": "application/json", + "releaseDate": "2018-01-16T13:54:17.000Z", + "processedAt": "2023-07-04T22:13:13.842Z" + }, + "content": { + "headers": [ + { + "tool_name": "scancode-toolkit", + "tool_version": "30.1.0", + "options": { + "input": [ + "/tempdir/cd-Tq1gTt" + ], + "--classify": true, + "--copyright": true, + "--email": true, + "--generated": true, + "--info": true, + "--is-license-text": true, + "--json-pp": "/tempdir/cd-LxElVP", + "--license": true, + "--license-clarity-score": true, + "--license-text": true, + "--license-text-diagnostics": true, + "--package": true, + "--processes": "2", + "--strip-root": true, + "--summary": true, + "--summary-key-files": true, + "--timeout": "1000.0", + "--url": true + }, + "notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "start_timestamp": "2023-07-04T221304.102545", + "end_timestamp": "2023-07-04T221313.153887", + "output_format_version": "1.0.0", + "duration": 9.051357507705688, + "message": null, + "errors": [], + "extra_data": { + "spdx_license_list_version": "3.14", + "OUTDATED": "WARNING: Outdated ScanCode Toolkit version! You are using an outdated version of ScanCode Toolkit: 30.1.0 released on: 2021-09-24. A new version is available with important improvements including bug and security fixes, updated license, copyright and package detection, and improved scanning accuracy. Please download and install the latest version of ScanCode. Visit https://github.com/nexB/scancode-toolkit/releases for details.", + "files_count": 17 + } + } + ], + "summary": { + "license_expressions": [ + { + "value": "apache-2.0", + "count": 3 + } + ], + "copyrights": [ + { + "value": null, + "count": 14 + }, + { + "value": "Copyright Boxfuse GmbH", + "count": 2 + }, + { + "value": "Copyright (c) Axel Fontaine", + "count": 1 + } + ], + "holders": [ + { + "value": null, + "count": 14 + }, + { + "value": "Boxfuse GmbH", + "count": 2 + }, + { + "value": "Axel Fontaine", + "count": 1 + } + ], + "authors": [ + { + "value": null, + "count": 17 + } + ], + "programming_language": [], + "packages": [ + { + "type": "maven", + "namespace": "org.flywaydb", + "name": "flyway-maven-plugin", + "version": "5.0.6", + "qualifiers": {}, + "subpath": null, + "primary_language": "Java", + "description": "flyway-maven-plugin", + "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, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:maven/org.apache.maven/maven-plugin-api", + "requirement": null, + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": null + }, + { + "purl": "pkg:maven/org.apache.maven/maven-artifact", + "requirement": null, + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": null + }, + { + "purl": "pkg:maven/org.apache.maven/maven-model", + "requirement": null, + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": null + }, + { + "purl": "pkg:maven/org.apache.maven/maven-core", + "requirement": null, + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": null + }, + { + "purl": "pkg:maven/org.sonatype.plexus/plexus-sec-dispatcher@1.4", + "requirement": "1.4", + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": true + }, + { + "purl": "pkg:maven/org.codehaus.plexus/plexus-utils@1.5.15", + "requirement": "1.5.15", + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": true + }, + { + "purl": "pkg:maven/org.flywaydb/flyway-core@5.0.6", + "requirement": "5.0.6", + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": true + }, + { + "purl": "pkg:maven/org.apache.maven.plugin-tools/maven-plugin-annotations@3.5", + "requirement": "3.5", + "scope": "provided", + "is_runtime": true, + "is_optional": false, + "is_resolved": true + } + ], + "contains_source_code": null, + "source_packages": [ + "pkg:maven/org.flywaydb/flyway-maven-plugin@5.0.6?classifier=sources" + ], + "extra_data": {}, + "purl": "pkg:maven/org.flywaydb/flyway-maven-plugin@5.0.6", + "repository_homepage_url": "https://repo1.maven.org/maven2/org/flywaydb/flyway-maven-plugin/5.0.6/", + "repository_download_url": "https://repo1.maven.org/maven2/org/flywaydb/flyway-maven-plugin/5.0.6/flyway-maven-plugin-5.0.6.jar", + "api_data_url": "https://repo1.maven.org/maven2/org/flywaydb/flyway-maven-plugin/5.0.6/flyway-maven-plugin-5.0.6.pom", + "files": [ + { + "path": "META-INF/maven/org.flywaydb/flyway-maven-plugin/pom.xml", + "type": "file" + } + ] + } + ] + }, + "license_clarity_score": { + "score": 4, + "declared": false, + "discovered": 0.18, + "consistency": false, + "spdx": false, + "license_texts": false + }, + "summary_of_key_files": { + "license_expressions": [], + "copyrights": [], + "holders": [], + "authors": [], + "programming_language": [] + }, + "files": [ + { + "path": "META-INF", + "type": "directory", + "name": "META-INF", + "base_name": "META-INF", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "sha256": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 7, + "dirs_count": 3, + "size_count": 409851, + "scan_errors": [] + }, + { + "path": "META-INF/LICENSE.txt", + "type": "file", + "name": "LICENSE.txt", + "base_name": "LICENSE", + "extension": ".txt", + "size": 561, + "date": "2018-01-16", + "sha1": "956959d6b1a80c27d1d697e0a1e79623417715f8", + "md5": "c93c35e4edef93889ed8421f50be4772", + "sha256": "58c006eea3e0086865cecfdda4747cbbe77f624400ac7422e8b31338a4357aee", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "apache-2.0", + "score": 100, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": false, + "is_unknown": false, + "owner": "Apache Software Foundation", + "homepage_url": "http://www.apache.org/licenses/", + "text_url": "http://www.apache.org/licenses/LICENSE-2.0", + "reference_url": "https://scancode-licensedb.aboutcode.org/apache-2.0", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/apache-2.0.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/apache-2.0.yml", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 3, + "end_line": 13, + "matched_rule": { + "identifier": "apache-2.0_7.RULE", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "referenced_filenames": [], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 85, + "matched_length": 85, + "match_coverage": 100, + "rule_relevance": 100 + }, + "matched_text": "Licensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License." + } + ], + "license_expressions": [ + "apache-2.0" + ], + "percentage_of_license_text": 94.44, + "copyrights": [ + { + "value": "Copyright 2010-2018 Boxfuse GmbH", + "start_line": 1, + "end_line": 1 + } + ], + "holders": [ + { + "value": "Boxfuse GmbH", + "start_line": 1, + "end_line": 1 + } + ], + "authors": [], + "packages": [], + "emails": [], + "urls": [ + { + "url": "http://www.apache.org/licenses/LICENSE-2.0", + "start_line": 7, + "end_line": 7 + } + ], + "is_legal": true, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": true, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "META-INF/MANIFEST.MF", + "type": "file", + "name": "MANIFEST.MF", + "base_name": "MANIFEST", + "extension": ".MF", + "size": 130, + "date": "2018-01-16", + "sha1": "014a1b38bac03c69d00ba12d14fecdc62d04eb33", + "md5": "ce66702162ad3f3e2f842c74133f4b11", + "sha256": "05e10ea0400e4e77f9f4de009a0b4db1fc53809d38d0bba3a51b50b4d1f12f98", + "mime_type": "text/plain", + "file_type": "ASCII text, with CRLF line terminators", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "META-INF/README.txt", + "type": "file", + "name": "README.txt", + "base_name": "README", + "extension": ".txt", + "size": 966, + "date": "2018-01-16", + "sha1": "4034f0e2154272a7bcfcd31d4dae54ef220b2700", + "md5": "ab11671f03862534cb69b10a24e0a200", + "sha256": "69ba88f3d1d4f2cf8dbc0f6d07f5035359633905e39c03fb08df9be6f7a640c8", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "apache-2.0", + "score": 90.53, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": false, + "is_unknown": false, + "owner": "Apache Software Foundation", + "homepage_url": "http://www.apache.org/licenses/", + "text_url": "http://www.apache.org/licenses/LICENSE-2.0", + "reference_url": "https://scancode-licensedb.aboutcode.org/apache-2.0", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/apache-2.0.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/apache-2.0.yml", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 16, + "end_line": 30, + "matched_rule": { + "identifier": "apache-2.0_943.RULE", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "referenced_filenames": [], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "has_unknown": false, + "matcher": "3-seq", + "rule_length": 95, + "matched_length": 86, + "match_coverage": 90.53, + "rule_relevance": 100 + }, + "matched_text": "License\n-------\n[Copyright] ([C]) [2010]-[2015] [Axel] [Fontaine]\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License." + } + ], + "license_expressions": [ + "apache-2.0" + ], + "percentage_of_license_text": 60.99, + "copyrights": [ + { + "value": "Copyright (c) 2010-2015 Axel Fontaine", + "start_line": 18, + "end_line": 18 + } + ], + "holders": [ + { + "value": "Axel Fontaine", + "start_line": 18, + "end_line": 18 + } + ], + "authors": [], + "packages": [], + "emails": [], + "urls": [ + { + "url": "https://flywaydb.org/", + "start_line": 8, + "end_line": 8 + }, + { + "url": "https://flywaydb.org/documentation/contribute/", + "start_line": 13, + "end_line": 13 + }, + { + "url": "http://www.apache.org/licenses/LICENSE-2.0", + "start_line": 24, + "end_line": 24 + } + ], + "is_legal": false, + "is_manifest": false, + "is_readme": true, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "META-INF/maven", + "type": "directory", + "name": "maven", + "base_name": "maven", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "sha256": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 4, + "dirs_count": 2, + "size_count": 408194, + "scan_errors": [] + }, + { + "path": "META-INF/maven/plugin.xml", + "type": "file", + "name": "plugin.xml", + "base_name": "plugin", + "extension": ".xml", + "size": 214274, + "date": "2018-01-16", + "sha1": "0afea464bbac5394d2c60918b97669d2551af565", + "md5": "3f62393cd5ebbd9c3d98e3d76c1a4f2d", + "sha256": "d157b16f3c7103ff149051c868276741edda7246a4508c10873adb928c5575b4", + "mime_type": "text/xml", + "file_type": "XML 1.0 document, ASCII text, with CRLF line terminators", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [ + { + "url": "https://flywaydb.org/assets/balsamiq/command-validate.png"", + "start_line": 3020, + "end_line": 3020 + } + ], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": true, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "META-INF/maven/org.flywaydb", + "type": "directory", + "name": "org.flywaydb", + "base_name": "org.flywaydb", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "sha256": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 3, + "dirs_count": 1, + "size_count": 193920, + "scan_errors": [] + }, + { + "path": "META-INF/maven/org.flywaydb/flyway-maven-plugin", + "type": "directory", + "name": "flyway-maven-plugin", + "base_name": "flyway-maven-plugin", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "sha256": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 3, + "dirs_count": 0, + "size_count": 193920, + "scan_errors": [] + }, + { + "path": "META-INF/maven/org.flywaydb/flyway-maven-plugin/plugin-help.xml", + "type": "file", + "name": "plugin-help.xml", + "base_name": "plugin-help", + "extension": ".xml", + "size": 189337, + "date": "2018-01-16", + "sha1": "cec2e4a47287ed732ca4d5e45bb09f2ac8498fd4", + "md5": "53a8c99944651d4b4ceb9b30edd3628a", + "sha256": "e877805314232ae2248feb9a055c1933362ceb3ff6cf3c0178865e3fa97c54c2", + "mime_type": "text/xml", + "file_type": "XML 1.0 document, ASCII text, with very long lines, with CRLF line terminators", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": true, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "META-INF/maven/org.flywaydb/flyway-maven-plugin/pom.properties", + "type": "file", + "name": "pom.properties", + "base_name": "pom", + "extension": ".properties", + "size": 121, + "date": "2018-01-16", + "sha1": "4a1543c702fec3326ab57e5f977f3879fc465b88", + "md5": "3a88c83d1467da863f050c02328058c2", + "sha256": "58b5ad3c4f05242add1cffef5599f8822c5bd7a5fc6b4832c458157c6e9810cf", + "mime_type": "text/plain", + "file_type": "ASCII text, with CRLF line terminators", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": true, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "META-INF/maven/org.flywaydb/flyway-maven-plugin/pom.xml", + "type": "file", + "name": "pom.xml", + "base_name": "pom", + "extension": ".xml", + "size": 4462, + "date": "2018-01-16", + "sha1": "1517b47c76963ce133d9eff50f992da3b182c3ec", + "md5": "9f941445bc7e47c02b5482f51f4d68a9", + "sha256": "94873b1e54a6d6c4a671133397ac5e13745c20f2760619159785d36346f158b2", + "mime_type": "text/plain", + "file_type": "exported SGML document, ASCII text", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [ + { + "key": "apache-2.0", + "score": 100, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": false, + "is_unknown": false, + "owner": "Apache Software Foundation", + "homepage_url": "http://www.apache.org/licenses/", + "text_url": "http://www.apache.org/licenses/LICENSE-2.0", + "reference_url": "https://scancode-licensedb.aboutcode.org/apache-2.0", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/apache-2.0.LICENSE", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/apache-2.0.yml", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 15, + "matched_rule": { + "identifier": "apache-2.0_7.RULE", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "referenced_filenames": [], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "has_unknown": false, + "matcher": "2-aho", + "rule_length": 85, + "matched_length": 85, + "match_coverage": 100, + "rule_relevance": 100 + }, + "matched_text": "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." + } + ], + "license_expressions": [ + "apache-2.0" + ], + "percentage_of_license_text": 22.91, + "copyrights": [ + { + "value": "Copyright 2010-2018 Boxfuse GmbH", + "start_line": 3, + "end_line": 3 + } + ], + "holders": [ + { + "value": "Boxfuse GmbH", + "start_line": 3, + "end_line": 3 + } + ], + "authors": [], + "packages": [ + { + "type": "maven", + "namespace": "org.flywaydb", + "name": "flyway-maven-plugin", + "version": "5.0.6", + "qualifiers": {}, + "subpath": null, + "primary_language": "Java", + "description": "flyway-maven-plugin", + "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, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "root_path": null, + "dependencies": [ + { + "purl": "pkg:maven/org.apache.maven/maven-plugin-api", + "requirement": null, + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": null + }, + { + "purl": "pkg:maven/org.apache.maven/maven-artifact", + "requirement": null, + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": null + }, + { + "purl": "pkg:maven/org.apache.maven/maven-model", + "requirement": null, + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": null + }, + { + "purl": "pkg:maven/org.apache.maven/maven-core", + "requirement": null, + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": null + }, + { + "purl": "pkg:maven/org.sonatype.plexus/plexus-sec-dispatcher@1.4", + "requirement": "1.4", + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": true + }, + { + "purl": "pkg:maven/org.codehaus.plexus/plexus-utils@1.5.15", + "requirement": "1.5.15", + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": true + }, + { + "purl": "pkg:maven/org.flywaydb/flyway-core@5.0.6", + "requirement": "5.0.6", + "scope": "compile", + "is_runtime": false, + "is_optional": true, + "is_resolved": true + }, + { + "purl": "pkg:maven/org.apache.maven.plugin-tools/maven-plugin-annotations@3.5", + "requirement": "3.5", + "scope": "provided", + "is_runtime": true, + "is_optional": false, + "is_resolved": true + } + ], + "contains_source_code": null, + "source_packages": [ + "pkg:maven/org.flywaydb/flyway-maven-plugin@5.0.6?classifier=sources" + ], + "extra_data": {}, + "purl": "pkg:maven/org.flywaydb/flyway-maven-plugin@5.0.6", + "repository_homepage_url": "https://repo1.maven.org/maven2/org/flywaydb/flyway-maven-plugin/5.0.6/", + "repository_download_url": "https://repo1.maven.org/maven2/org/flywaydb/flyway-maven-plugin/5.0.6/flyway-maven-plugin-5.0.6.jar", + "api_data_url": "https://repo1.maven.org/maven2/org/flywaydb/flyway-maven-plugin/5.0.6/flyway-maven-plugin-5.0.6.pom", + "files": [ + { + "path": "META-INF/maven/org.flywaydb/flyway-maven-plugin/pom.xml", + "type": "file" + } + ] + } + ], + "emails": [], + "urls": [ + { + "url": "http://www.apache.org/licenses/LICENSE-2.0", + "start_line": 9, + "end_line": 9 + }, + { + "url": "http://maven.apache.org/xsd/maven-4.0.0.xsd", + "start_line": 18, + "end_line": 18 + } + ], + "is_legal": false, + "is_manifest": true, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org", + "type": "directory", + "name": "org", + "base_name": "org", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "sha256": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": true, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 10, + "dirs_count": 2, + "size_count": 26084, + "scan_errors": [] + }, + { + "path": "org/flywaydb", + "type": "directory", + "name": "flywaydb", + "base_name": "flywaydb", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "sha256": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 10, + "dirs_count": 1, + "size_count": 26084, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven", + "type": "directory", + "name": "maven", + "base_name": "maven", + "extension": "", + "size": 0, + "date": null, + "sha1": null, + "md5": null, + "sha256": null, + "mime_type": null, + "file_type": null, + "programming_language": null, + "is_binary": false, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 10, + "dirs_count": 0, + "size_count": 26084, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/AbstractFlywayMojo.class", + "type": "file", + "name": "AbstractFlywayMojo.class", + "base_name": "AbstractFlywayMojo", + "extension": ".class", + "size": 14975, + "date": "2018-01-16", + "sha1": "432fa9a32599feb1bbd79d4e13a04288b5636ab9", + "md5": "ad3b70b1b1ff24368f6a99d6f961b7db", + "sha256": "bee3b48287e02bd9e5c084e1e99ed6bbcc917a3107cbd67f8ef537237c10e41f", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/BaselineMojo.class", + "type": "file", + "name": "BaselineMojo.class", + "base_name": "BaselineMojo", + "extension": ".class", + "size": 902, + "date": "2018-01-16", + "sha1": "70a37ad1d12a1e32f37cd2f92f553e7cfe64c0ef", + "md5": "99beb61057f431dda74998243a1793b1", + "sha256": "3e35e8b2f74aa8d747a7a3d1d00f7989cacbb41e1492f7192359feafaf2d55f8", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/CleanMojo.class", + "type": "file", + "name": "CleanMojo.class", + "base_name": "CleanMojo", + "extension": ".class", + "size": 875, + "date": "2018-01-16", + "sha1": "c8a9c63a2cea1218b2f42e5bcab2e15bd427cf90", + "md5": "ecb2b2a8dc9a0c3017ceaec075775ca6", + "sha256": "2590c35bd89f9c8507d354708c81f883857e6ac50279818767c58c2da6225518", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/InfoMojo.class", + "type": "file", + "name": "InfoMojo.class", + "base_name": "InfoMojo", + "extension": ".class", + "size": 2065, + "date": "2018-01-16", + "sha1": "413ec5c8c4ad0b6c21fda34209b87c1cb270e6f5", + "md5": "738708f965414773749591182043cb84", + "sha256": "eaba7c97c45e4d63e294aa93af73319674ca50c4413fd7bbc2144ad0dd411f48", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/MavenLog.class", + "type": "file", + "name": "MavenLog.class", + "base_name": "MavenLog", + "extension": ".class", + "size": 1207, + "date": "2018-01-16", + "sha1": "2f26fd94295eec04bb07d6c0c8c9b402b10f987b", + "md5": "50d690921ffb946bac57b34236b37bc7", + "sha256": "bd5cb7a9f1acde6350c87553bc6a57dd7fb1b51041510cdc36fce91b07d06c8b", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/MavenLogCreator.class", + "type": "file", + "name": "MavenLogCreator.class", + "base_name": "MavenLogCreator", + "extension": ".class", + "size": 1005, + "date": "2018-01-16", + "sha1": "43693f60bf91624917472e9a9e566a897c5e607f", + "md5": "ef3f793e9227dffe03228a806a45eac8", + "sha256": "3be612a6d68be345306dd52ee0276cdf897007725292a5e23e794b54accef6f8", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/MigrateMojo.class", + "type": "file", + "name": "MigrateMojo.class", + "base_name": "MigrateMojo", + "extension": ".class", + "size": 1710, + "date": "2018-01-16", + "sha1": "d0887c74f9179f153c8128e554847aab61d3d2ad", + "md5": "0f03fbd2a956bd554757bca88120d2c0", + "sha256": "bc7ed4fa4b11b0d05fc3eca60091ba699145f0dd8c48db28ed34cf6a399e009e", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/RepairMojo.class", + "type": "file", + "name": "RepairMojo.class", + "base_name": "RepairMojo", + "extension": ".class", + "size": 894, + "date": "2018-01-16", + "sha1": "fe2ae1973625208bd45a09de94e20061924fd947", + "md5": "169de6972eb3c94468dabeb5f37cf582", + "sha256": "9bc5126c9385481f1aebecee8b22396b5bc75de7b9a6a9a65b96733e4d9e6258", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/UndoMojo.class", + "type": "file", + "name": "UndoMojo.class", + "base_name": "UndoMojo", + "extension": ".class", + "size": 1549, + "date": "2018-01-16", + "sha1": "3ad1dc637e89a9cc3f916cb3b4f547ab51046740", + "md5": "919ab55b96176980a9d8e3fa0c5f8c18", + "sha256": "dd1b195f3792ce5c86c603e316b0a97ae69148f11c44a7129779a199d90e5996", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "org/flywaydb/maven/ValidateMojo.class", + "type": "file", + "name": "ValidateMojo.class", + "base_name": "ValidateMojo", + "extension": ".class", + "size": 902, + "date": "2018-01-16", + "sha1": "57e56a93b57ec5e07ba05b041b763aa03428e4ca", + "md5": "67b61ad8d3bbdceb75d7b65ec9e3c1b0", + "sha256": "c611cc9d38af2c198fe7e7689f63448efa616a66c601fb4e7c2a958a33091f14", + "mime_type": "application/x-java-applet", + "file_type": "compiled Java class data, version 52.0 (Java 1.8)", + "programming_language": null, + "is_binary": true, + "is_text": false, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "licenses": [], + "license_expressions": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "packages": [], + "emails": [], + "urls": [], + "is_legal": false, + "is_manifest": false, + "is_readme": false, + "is_top_level": false, + "is_key_file": false, + "is_generated": false, + "is_license_text": false, + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] + } +} \ No newline at end of file diff --git a/test/providers/summary/scancode.js b/test/providers/summary/scancode.js index 45f76221..2bbcf8b3 100644 --- a/test/providers/summary/scancode.js +++ b/test/providers/summary/scancode.js @@ -95,10 +95,17 @@ describe('ScancodeSummarizer basic compatability', () => { assert.equal(licenseFromFiles, 'BSD-3-Clause') const files = summarizer._summarizeFileInfo(harvestData.content.files, coordinates) - const licenseFile = files.find(file => file.natures?.includes('license')) + const licenseFile = files.find((file) => file.natures?.includes('license')) assert.equal(licenseFile.license, 'BSD-3-Clause') }) + it('should detect license from maven license file in version 30.1.0 of ScanCode', () => { + const coordinates = { type: 'maven', provider: 'mavencentral' } + const harvestData = getHarvestData('30.1.0', 'maven-flywaydb-file-license') + const result = summarizer.summarize(coordinates, harvestData) + assert.equal(result.licensed.declared, 'Apache-2.0') + }) + it('throws an error on an invalid scancode version', () => { const version = '0.0.0' const coordinates = { type: 'npm', provider: 'npmjs' }