From 606bd5f3dbc9c0f4402019779e36cae0f20d9856 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 18 Jul 2023 18:28:11 +0200 Subject: [PATCH] feat(scanner): Add support for ScanCode output format version 3 While in previous outputs formats the primary elements for license entries were single license keys (which needed to be grouped to expressions), starting with output format version 3 the primary license entries are expressions. Resolves #6617. Signed-off-by: Sebastian Schuberth --- .../src/main/kotlin/ScanCodeResultModel.kt | 69 +- .../src/main/kotlin/ScanCodeResultParser.kt | 27 +- ...output-format-3.0.0_mime-types-2.1.18.json | 743 ++++++++++++++++++ .../test/kotlin/ScanCodeResultParserTest.kt | 6 +- 4 files changed, 820 insertions(+), 25 deletions(-) create mode 100644 plugins/scanners/scancode/src/test/assets/scancode-output-format-3.0.0_mime-types-2.1.18.json diff --git a/plugins/scanners/scancode/src/main/kotlin/ScanCodeResultModel.kt b/plugins/scanners/scancode/src/main/kotlin/ScanCodeResultModel.kt index 8d2008c09c31c..ae623dd6d2f0c 100644 --- a/plugins/scanners/scancode/src/main/kotlin/ScanCodeResultModel.kt +++ b/plugins/scanners/scancode/src/main/kotlin/ScanCodeResultModel.kt @@ -49,25 +49,66 @@ data class Options( val input: List ) -@Serializable -data class FileEntry( - val path: String, - val type: String, - val licenses: List, - val copyrights: List, +sealed interface FileEntry { + val path: String + val type: String + val licenses: List + val copyrights: List val scanErrors: List -) + + @Serializable + data class Version1( + override val path: String, + override val type: String, + override val licenses: List, + override val copyrights: List, + override val scanErrors: List + ) : FileEntry + + @Serializable + data class Version3( + override val path: String, + override val type: String, + val licenseDetections: List, + override val copyrights: List, + override val scanErrors: List + ) : FileEntry { + override val licenses = licenseDetections.flatMap { it.matches } + } +} @Serializable -data class LicenseEntry( - val key: String, - val score: Float, - val spdxLicenseKey: String? = null, // This might be explicitly set to null in JSON. - val startLine: Int, - val endLine: Int, - val matchedRule: LicenseRule +data class LicenseDetection( + val matches: List ) +sealed interface LicenseEntry { + val licenseExpression: String + val startLine: Int + val endLine: Int + val score: Float + + @Serializable + data class Version1( + val key: String, + override val score: Float, + val spdxLicenseKey: String? = null, // This might be explicitly set to null in JSON. + override val startLine: Int, + override val endLine: Int, + val matchedRule: LicenseRule + ) : LicenseEntry { + override val licenseExpression = matchedRule.licenseExpression + } + + @Serializable + data class Version3( + override val score: Float, + override val startLine: Int, + override val endLine: Int, + override val licenseExpression: String + ) : LicenseEntry +} + @Serializable data class LicenseRule( val licenseExpression: String diff --git a/plugins/scanners/scancode/src/main/kotlin/ScanCodeResultParser.kt b/plugins/scanners/scancode/src/main/kotlin/ScanCodeResultParser.kt index 85ed4148a1bcd..b32f1fb8a7c15 100644 --- a/plugins/scanners/scancode/src/main/kotlin/ScanCodeResultParser.kt +++ b/plugins/scanners/scancode/src/main/kotlin/ScanCodeResultParser.kt @@ -47,7 +47,7 @@ import org.ossreviewtoolkit.utils.spdx.toSpdxId import org.semver4j.Semver -const val MAX_SUPPORTED_OUTPUT_FORMAT_MAJOR_VERSION = 2 +const val MAX_SUPPORTED_OUTPUT_FORMAT_MAJOR_VERSION = 3 private val LICENSE_REF_PREFIX_SCAN_CODE = "${SpdxConstants.LICENSE_REF_PREFIX}${ScanCode.SCANNER_NAME.lowercase()}-" private val TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HHmmss.n").withZone(ZoneId.of("UTC")) @@ -65,10 +65,20 @@ fun parseResult(result: JsonElement): ScanCodeResult { // Select the correct set of (de-)serializers bundled in a module for parsing the respective format version. val module = when (outputFormatVersion?.major) { null, 1 -> SerializersModule { + polymorphicDefaultDeserializer(FileEntry::class) { FileEntry.Version1.serializer() } + polymorphicDefaultDeserializer(LicenseEntry::class) { LicenseEntry.Version1.serializer() } polymorphicDefaultDeserializer(CopyrightEntry::class) { CopyrightEntry.Version1.serializer() } } + 2 -> SerializersModule { + polymorphicDefaultDeserializer(FileEntry::class) { FileEntry.Version1.serializer() } + polymorphicDefaultDeserializer(LicenseEntry::class) { LicenseEntry.Version1.serializer() } + polymorphicDefaultDeserializer(CopyrightEntry::class) { CopyrightEntry.Version2.serializer() } + } + else -> SerializersModule { + polymorphicDefaultDeserializer(FileEntry::class) { FileEntry.Version3.serializer() } + polymorphicDefaultDeserializer(LicenseEntry::class) { LicenseEntry.Version3.serializer() } polymorphicDefaultDeserializer(CopyrightEntry::class) { CopyrightEntry.Version2.serializer() } } } @@ -119,17 +129,18 @@ fun ScanCodeResult.toScanSummary(): ScanSummary { val filesOfTypeFile = files.filter { it.type == "file" } // Build a map of all ScanCode license keys in the result associated with their corresponding SPDX ID. - val scanCodeKeyToSpdxIdMappings = files.flatMap { file -> - file.licenses.map { license -> - license.key to getSpdxId(license.spdxLicenseKey, license.key) - } - }.toMap() + val scanCodeKeyToSpdxIdMappings = licenseReferences?.associate { it.key to it.spdxLicenseKey } + ?: files.flatMap { file -> + file.licenses.filterIsInstance().map { license -> + license.key to getSpdxId(license.spdxLicenseKey, license.key) + } + }.toMap() filesOfTypeFile.forEach { file -> // ScanCode creates separate license entries for each license in an expression. Deduplicate these by grouping by // the same expression. val licenses = file.licenses.groupBy { - LicenseMatch(it.matchedRule.licenseExpression, it.startLine, it.endLine, it.score) + LicenseMatch(it.licenseExpression, it.startLine, it.endLine, it.score) }.map { // Arbitrarily take the first of the duplicate license entries. it.value.first() @@ -137,7 +148,7 @@ fun ScanCodeResult.toScanSummary(): ScanSummary { licenses.mapTo(licenseFindings) { license -> // ScanCode uses its own license keys as identifiers in license expressions. - val spdxLicenseExpression = license.matchedRule.licenseExpression.mapLicense(scanCodeKeyToSpdxIdMappings) + val spdxLicenseExpression = license.licenseExpression.mapLicense(scanCodeKeyToSpdxIdMappings) LicenseFinding( license = spdxLicenseExpression, diff --git a/plugins/scanners/scancode/src/test/assets/scancode-output-format-3.0.0_mime-types-2.1.18.json b/plugins/scanners/scancode/src/test/assets/scancode-output-format-3.0.0_mime-types-2.1.18.json new file mode 100644 index 0000000000000..6705e668d9f0e --- /dev/null +++ b/plugins/scanners/scancode/src/test/assets/scancode-output-format-3.0.0_mime-types-2.1.18.json @@ -0,0 +1,743 @@ +{ + "headers": [ + { + "tool_name": "scancode-toolkit", + "tool_version": "32.0.4", + "options": { + "input": [ + "." + ], + "--copyright": true, + "--info": true, + "--json-pp": "scancode.json", + "--license": true, + "--license-references": true, + "--processes": "3", + "--strip-root": true, + "--timeout": "300.0" + }, + "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-18T162535.312408", + "end_timestamp": "2023-07-18T162537.405257", + "output_format_version": "3.0.0", + "duration": 2.0928573608398438, + "message": null, + "errors": [], + "warnings": [], + "extra_data": { + "system_environment": { + "operating_system": "linux", + "cpu_architecture": "64", + "platform": "Linux-6.3.12-200.fc38.x86_64-x86_64-with-glibc2.37", + "platform_version": "#1 SMP PREEMPT_DYNAMIC Thu Jul 6 04:05:18 UTC 2023", + "python_version": "3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]" + }, + "spdx_license_list_version": "3.20", + "files_count": 10 + } + } + ], + "license_detections": [ + { + "identifier": "mit-4e7803e6-e54b-c9ca-bcd2-bee9755c0dd7", + "license_expression": "mit", + "detection_count": 1 + }, + { + "identifier": "mit-3ab5a1cd-6f73-3105-a815-d0d7c55b1922", + "license_expression": "mit", + "detection_count": 1 + }, + { + "identifier": "mit-cacd5c0c-204a-85c2-affc-e4c125b2492a", + "license_expression": "mit", + "detection_count": 1 + }, + { + "identifier": "mit-3fce6ea2-8abd-6c6b-3ede-a37af7c6efee", + "license_expression": "mit", + "detection_count": 1 + }, + { + "identifier": "mit-bdcba66f-6e80-f7bd-7994-748183fe5693", + "license_expression": "mit", + "detection_count": 1 + } + ], + "license_references": [ + { + "key": "mit", + "language": "en", + "short_name": "MIT License", + "name": "MIT License", + "category": "Permissive", + "owner": "MIT", + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "notes": "Per SPDX.org, this license is OSI certified.", + "is_builtin": true, + "is_exception": false, + "is_unknown": false, + "is_generic": false, + "spdx_license_key": "MIT", + "other_spdx_license_keys": [], + "osi_license_key": null, + "text_urls": [ + "http://opensource.org/licenses/mit-license.php" + ], + "osi_url": "http://www.opensource.org/licenses/MIT", + "faq_url": "https://ieeexplore.ieee.org/document/9263265", + "other_urls": [ + "https://opensource.com/article/18/3/patent-grant-mit-license", + "https://opensource.com/article/19/4/history-mit-license", + "https://opensource.org/licenses/MIT" + ], + "key_aliases": [], + "minimum_coverage": 0, + "standard_notice": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [], + "ignorable_emails": [], + "text": "Permission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", + "scancode_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "licensedb_url": "https://scancode-licensedb.aboutcode.org/mit", + "spdx_url": "https://spdx.org/licenses/MIT" + } + ], + "license_rule_references": [ + { + "license_expression": "mit", + "identifier": "mit.LICENSE", + "language": "en", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE", + "is_license_text": true, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "is_continuous": false, + "is_builtin": true, + "is_from_license": true, + "is_synthetic": false, + "length": 161, + "relevance": 100, + "minimum_coverage": 0, + "referenced_filenames": [], + "notes": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [], + "ignorable_emails": [], + "text": "Permission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." + }, + { + "license_expression": "mit", + "identifier": "mit_126.RULE", + "language": "en", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_126.RULE", + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "is_license_intro": false, + "is_continuous": false, + "is_builtin": true, + "is_from_license": false, + "is_synthetic": false, + "length": 2, + "relevance": 100, + "minimum_coverage": 100, + "referenced_filenames": [], + "notes": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [], + "ignorable_emails": [], + "text": "MIT Licensed" + }, + { + "license_expression": "mit", + "identifier": "mit_27.RULE", + "language": "en", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_27.RULE", + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "is_license_intro": false, + "is_continuous": false, + "is_builtin": true, + "is_from_license": false, + "is_synthetic": false, + "length": 3, + "relevance": 100, + "minimum_coverage": 80, + "referenced_filenames": [], + "notes": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [], + "ignorable_emails": [], + "text": "the MIT License" + }, + { + "license_expression": "mit", + "identifier": "mit_30.RULE", + "language": "en", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_30.RULE", + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "is_license_intro": false, + "is_continuous": false, + "is_builtin": true, + "is_from_license": false, + "is_synthetic": false, + "length": 2, + "relevance": 100, + "minimum_coverage": 100, + "referenced_filenames": [], + "notes": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [], + "ignorable_emails": [], + "text": "License: MIT" + }, + { + "license_expression": "mit", + "identifier": "mit_31.RULE", + "language": "en", + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_31.RULE", + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "is_license_intro": false, + "is_continuous": false, + "is_builtin": true, + "is_from_license": false, + "is_synthetic": false, + "length": 3, + "relevance": 100, + "minimum_coverage": 80, + "referenced_filenames": [], + "notes": null, + "ignorable_copyrights": [], + "ignorable_holders": [], + "ignorable_authors": [], + "ignorable_urls": [], + "ignorable_emails": [], + "text": "License: MIT license" + } + ], + "files": [ + { + "path": ".eslintignore", + "type": "file", + "name": ".eslintignore", + "base_name": ".eslintignore", + "extension": "", + "size": 22, + "date": "2022-12-12", + "sha1": "6acc65c0437c4dfee46393694d82032ec55e250a", + "md5": "38bfc956dbeb91a5fc2770d67e51490a", + "sha256": "0b2e7bd6fe8e195b1b6eea336b8bf52a906125a75a799e1bfa3b7cf6d918efe7", + "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, + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": ".eslintrc", + "type": "file", + "name": ".eslintrc", + "base_name": ".eslintrc", + "extension": "", + "size": 28, + "date": "2022-12-12", + "sha1": "96be83d7bb17676e365d625ed72a3206968d9eb6", + "md5": "58e33291e06991fe8d46686f0ed04f45", + "sha256": "f12764948fdb96693910f1abeaf19c808be30c034406bccc08394aa3c80a68cd", + "mime_type": "application/json", + "file_type": "JSON data", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": ".travis.yml", + "type": "file", + "name": ".travis.yml", + "base_name": ".travis", + "extension": ".yml", + "size": 1128, + "date": "2022-12-12", + "sha1": "a56bb611572c8932bb34412e90724977d6422af9", + "md5": "8171613679d8f14acc1b60563fce4770", + "sha256": "f8f51d063ab08f7f04cff73be7cbbee8be5a2ea95bf9e0c14dcebc3911760bc0", + "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, + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "HISTORY.md", + "type": "file", + "name": "HISTORY.md", + "base_name": "HISTORY", + "extension": ".md", + "size": 5193, + "date": "2022-12-12", + "sha1": "cde432c1ca703b4d0782e98491fc6249d6a6554d", + "md5": "482dda4ec77788258aee5469ad331f84", + "sha256": "7d5946b10e82242de82848f1095f4e2b440bb4195ebd5892dd9a2c14ccd9ba1f", + "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, + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "index.js", + "type": "file", + "name": "index.js", + "base_name": "index", + "extension": ".js", + "size": 3663, + "date": "2022-12-12", + "sha1": "8d1f07ae6192c4dd6bc08a9247a91af4a0a51eca", + "md5": "bf015bb6811afc5c98e3e5f7072fdc79", + "sha256": "8cfccaac306beb650d60c7f069ae0f4b39d648f1e3914696b18c133ab33e6419", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "detected_license_expression": "mit", + "detected_license_expression_spdx": "MIT", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 5, + "end_line": 5, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit_126.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_126.RULE" + } + ], + "identifier": "mit-4e7803e6-e54b-c9ca-bcd2-bee9755c0dd7" + } + ], + "license_clues": [], + "percentage_of_license_text": 0.47, + "copyrights": [ + { + "copyright": "Copyright (c) 2014 Jonathan Ong", + "start_line": 3, + "end_line": 3 + }, + { + "copyright": "Copyright (c) 2015 Douglas Christopher Wilson", + "start_line": 4, + "end_line": 4 + } + ], + "holders": [ + { + "holder": "Jonathan Ong", + "start_line": 3, + "end_line": 3 + }, + { + "holder": "Douglas Christopher Wilson", + "start_line": 4, + "end_line": 4 + } + ], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "LICENSE", + "type": "file", + "name": "LICENSE", + "base_name": "LICENSE", + "extension": "", + "size": 1167, + "date": "2022-12-12", + "sha1": "f027af3e61af3880fd7f7b8ba9452a85dd215738", + "md5": "bf1f9ad1e2e1d507aef4883fff7103de", + "sha256": "71f83c4c0621102a56d9853812777b85751bce7e9726f686f5b056c1f8a4b0e6", + "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, + "detected_license_expression": "mit", + "detected_license_expression_spdx": "MIT", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 1, + "end_line": 1, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit_27.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_27.RULE" + } + ], + "identifier": "mit-3ab5a1cd-6f73-3105-a815-d0d7c55b1922" + }, + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 6, + "end_line": 23, + "matched_length": 161, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit.LICENSE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE" + } + ], + "identifier": "mit-cacd5c0c-204a-85c2-affc-e4c125b2492a" + } + ], + "license_clues": [], + "percentage_of_license_text": 90.61, + "copyrights": [ + { + "copyright": "Copyright (c) 2014 Jonathan Ong ", + "start_line": 3, + "end_line": 3 + }, + { + "copyright": "Copyright (c) 2015 Douglas Christopher Wilson ", + "start_line": 4, + "end_line": 4 + } + ], + "holders": [ + { + "holder": "Jonathan Ong", + "start_line": 3, + "end_line": 3 + }, + { + "holder": "Douglas Christopher Wilson", + "start_line": 4, + "end_line": 4 + } + ], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "package.json", + "type": "file", + "name": "package.json", + "base_name": "package", + "extension": ".json", + "size": 1198, + "date": "2022-12-12", + "sha1": "24a84da16e7d0bdc3f64f7a1adadcabfb7cb6731", + "md5": "ecee7be49e1352af8b37966b45b89e42", + "sha256": "d87d3aeb7c81341a2df51e0f7853113a349e62d103f96968501bc4332c6da445", + "mime_type": "application/json", + "file_type": "JSON data", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "detected_license_expression": "mit", + "detected_license_expression_spdx": "MIT", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 10, + "end_line": 10, + "matched_length": 2, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit_30.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_30.RULE" + } + ], + "identifier": "mit-3fce6ea2-8abd-6c6b-3ede-a37af7c6efee" + } + ], + "license_clues": [], + "percentage_of_license_text": 1.37, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "README.md", + "type": "file", + "name": "README.md", + "base_name": "README", + "extension": ".md", + "size": 3120, + "date": "2022-12-12", + "sha1": "3f25621607960c6e73fc4f9b8bf97327e210a9f2", + "md5": "40f806a97b423ce26a485afe986fb151", + "sha256": "b66ddab5ca562f3bcb6580a7d9d1e78bd755503210762d3530fad80366b1b8b2", + "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, + "detected_license_expression": "mit", + "detected_license_expression_spdx": "MIT", + "license_detections": [ + { + "license_expression": "mit", + "matches": [ + { + "score": 100.0, + "start_line": 95, + "end_line": 97, + "matched_length": 3, + "match_coverage": 100.0, + "matcher": "2-aho", + "license_expression": "mit", + "rule_identifier": "mit_31.RULE", + "rule_relevance": 100, + "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mit_31.RULE" + } + ], + "identifier": "mit-bdcba66f-6e80-f7bd-7994-748183fe5693" + } + ], + "license_clues": [], + "percentage_of_license_text": 0.67, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "test", + "type": "directory", + "name": "test", + "base_name": "test", + "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, + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 2, + "dirs_count": 0, + "size_count": 8712, + "scan_errors": [] + }, + { + "path": "test/.eslintrc", + "type": "file", + "name": ".eslintrc", + "base_name": ".eslintrc", + "extension": "", + "size": 37, + "date": "2022-12-12", + "sha1": "fab2c62ea27ead3a21414082be68afa90b51cbb2", + "md5": "134d3e9b8b48a3f1296a2241efc9fb97", + "sha256": "df3b8c89895282ef450ed682e2c6a66c6cce2bc8a02998020be6e6052cda65d2", + "mime_type": "application/json", + "file_type": "JSON data", + "programming_language": null, + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": false, + "is_script": false, + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + }, + { + "path": "test/test.js", + "type": "file", + "name": "test.js", + "base_name": "test", + "extension": ".js", + "size": 8675, + "date": "2022-12-12", + "sha1": "2135e026ffb360520d296ae170fe36113606e6fc", + "md5": "d3ffdd77f2eced26602895f9e4b60966", + "sha256": "600ac210b84288ea57738851c5d5b394c5e07c4df470e0d69dfe5638ac0e3e7c", + "mime_type": "text/plain", + "file_type": "ASCII text", + "programming_language": "JavaScript", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_media": false, + "is_source": true, + "is_script": false, + "detected_license_expression": null, + "detected_license_expression_spdx": null, + "license_detections": [], + "license_clues": [], + "percentage_of_license_text": 0, + "copyrights": [], + "holders": [], + "authors": [], + "files_count": 0, + "dirs_count": 0, + "size_count": 0, + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/plugins/scanners/scancode/src/test/kotlin/ScanCodeResultParserTest.kt b/plugins/scanners/scancode/src/test/kotlin/ScanCodeResultParserTest.kt index 44473c731e53b..1aa4bce24cc29 100644 --- a/plugins/scanners/scancode/src/test/kotlin/ScanCodeResultParserTest.kt +++ b/plugins/scanners/scancode/src/test/kotlin/ScanCodeResultParserTest.kt @@ -120,7 +120,7 @@ class ScanCodeResultParserTest : FreeSpec({ } } - "for output format 3.0.0 should" - { + "for output format 4.0.0 should" - { "create an issue about an unsupported version" { val headers = """ { @@ -142,7 +142,7 @@ class ScanCodeResultParserTest : FreeSpec({ }, "start_timestamp": "2022-12-12T065635.691832", "end_timestamp": "2022-12-12T065637.770792", - "output_format_version": "3.0.0" + "output_format_version": "4.0.0" } ], "files": [ @@ -155,7 +155,7 @@ class ScanCodeResultParserTest : FreeSpec({ summary.issues.map { it.copy(timestamp = Instant.EPOCH) } shouldHaveSingleElement Issue( timestamp = Instant.EPOCH, source = ScanCode.SCANNER_NAME, - message = "The output format version 3.0.0 exceeds the supported major version " + + message = "The output format version 4.0.0 exceeds the supported major version " + "$MAX_SUPPORTED_OUTPUT_FORMAT_MAJOR_VERSION. Results may be incomplete or incorrect.", severity = Severity.WARNING )