diff --git a/tools/test/travis-ci/scancode_evaluate_test.py b/tools/test/travis-ci/scancode_evaluate_test.py new file mode 100644 index 00000000000..e1014ef87aa --- /dev/null +++ b/tools/test/travis-ci/scancode_evaluate_test.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +# Copyright (c) 2020 Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 +import importlib +import os +import json +from unittest import TestCase + +# TODO: fix scancode to match python naming conventROOTi +SCANCODE_EVALUATE = importlib.import_module("scancode-evaluate") +license_check = SCANCODE_EVALUATE.license_check + +ROOT = os.path.abspath( + os.path.join(os.path.dirname(__file__)) +) + +# path to stub files +stub_path = ROOT + "/scancode_test/" + +# template copyright notices +invalid_header_1 = "/* Copyright (C) Arm Limited, Inc - All Rights Reserved\ + * Unauthorized copying of this. file, via any medium is strictly prohibited\ + * Proprietary and confidential\ + */" + +invalid_header_2 = "/* mbed Microcontroller Library\ + * Copyright (c) 2006-2013 ARM Limited\ + *\ + * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0\ + *\ + * Unless required by applicable law or agreed to in writing, software\ + * distributed under the License is distributed on an \"AS IS\" BASIS,\ + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\ + * See the License for the specific language governing permissions and\ + * limitations under the License.\ + */" + + +# implement test class +class TestScancodeEvaluate(TestCase): + """ Test scancode evaluation script """ + + def test_scancode_case_1(self): + """ Test Case 1 -- faulty json file + @inputs scancode_test_1.json + @outputs -1 if any error in file licenses found + """ + # generate scancode_test_1.json + with open(ROOT + "/scancode_test/scancode_test_1.json", 'w') as f: + json.dump({"headers": {"tool name": "scancode test fail"}}, f) + + self.assertEqual(-1, license_check(ROOT, ROOT + "/scancode_test/scancode_test_1.json")) + os.remove(ROOT + "/scancode_test/scancode_test_1.json") + + def test_scancode_case_2(self): + """ Test Case 2 -- no errors in license headers, try multiple types i.e Apache-2.0, BSD3 + @inputs scancode_test_2.json [4 Apache-2.0, 4 BSD-3.0] + @outputs 0 + """ + self.assertEqual(0, license_check(ROOT, ROOT + "/scancode_test/scancode_test_2.json"), "False Negative(s)") + + def test_scancode_case_3(self): + """ Test Case 3 -- all files containing errors [2 files without a header, 2 files non-permissive + missing SPDX, + 1 missing SPDX] + @inputs scancode_test_3.json + @output 7 + """ + # create stub files with a non-permissive license and missing spdx + for i in range(3, 6): + with open(stub_path + "test" + str(i) + ".h", "w") as file: + if i == 5: + file.write(invalid_header_2) + else: + file.write(invalid_header_1) + + self.assertEqual(7, license_check(ROOT, ROOT + "/scancode_test/scancode_test_3.json"), "False Positive(s)") + # delete stub files + os.remove(stub_path + "test3.h") + os.remove(stub_path + "test4.h") + os.remove(stub_path + "test5.h") + + def test_scancode_case_4(self): + """ Test Case 4 -- license header permissive and "non-permissive license" false positive + @inputs scancode_test_4.json + @outputs 0 + """ + self.assertEqual(0, license_check(ROOT, ROOT + "/scancode_test/scancode_test_4.json"), "Non-Permissive Header False Positive") diff --git a/tools/test/travis-ci/scancode_test/scancode_test_2.json b/tools/test/travis-ci/scancode_test/scancode_test_2.json new file mode 100644 index 00000000000..d270220fc59 --- /dev/null +++ b/tools/test/travis-ci/scancode_test/scancode_test_2.json @@ -0,0 +1,764 @@ +{ +"headers": [ + { + "tool_name": "scancode-toolkit", + "tool_version": "3.1.1", + "options": { + "input": [ + "test.h", + "test2.h", + "test3.h", + "test4.h", + "test5.h", + "test6.h", + "test7.h", + "test8.h" + ], + "--json-pp": "scancode.json", + "--license": 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": "2020-10-01T135040.106260", + "end_timestamp": "2020-10-01T135047.793497", + "message": null, + "errors": [], + "extra_data": { + "files_count": 8 + } + } + ], + "files": [ + { + "path": "tools/test/travis-ci/scancode_test/test.h", + "type": "file", + "licenses": [ + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 2, + "end_line": 2, + "matched_rule": { + "identifier": "spdx-license-identifier: bsd-new", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 8, + "end_line": 8, + "matched_rule": { + "identifier": "bsd-new_360.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 4, + "matched_length": 4, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 11, + "end_line": 11, + "matched_rule": { + "identifier": "bsd-new_10.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + } + ], + "license_expressions": [ + "bsd-new", + "bsd-new", + "bsd-new" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test2.h", + "type": "file", + "licenses": [ + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 2, + "end_line": 2, + "matched_rule": { + "identifier": "spdx-license-identifier: bsd-new", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 8, + "end_line": 8, + "matched_rule": { + "identifier": "bsd-new_360.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 4, + "matched_length": 4, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 11, + "end_line": 11, + "matched_rule": { + "identifier": "bsd-new_10.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + } + ], + "license_expressions": [ + "bsd-new", + "bsd-new", + "bsd-new" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test3.h", + "type": "file", + "licenses": [ + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 2, + "end_line": 2, + "matched_rule": { + "identifier": "spdx-license-identifier: bsd-new", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 8, + "end_line": 8, + "matched_rule": { + "identifier": "bsd-new_360.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 4, + "matched_length": 4, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 11, + "end_line": 11, + "matched_rule": { + "identifier": "bsd-new_10.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + } + ], + "license_expressions": [ + "bsd-new", + "bsd-new", + "bsd-new" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test4.h", + "type": "file", + "licenses": [ + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 2, + "end_line": 2, + "matched_rule": { + "identifier": "spdx-license-identifier: bsd-new", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 8, + "end_line": 8, + "matched_rule": { + "identifier": "bsd-new_360.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 4, + "matched_length": 4, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 11, + "end_line": 11, + "matched_rule": { + "identifier": "bsd-new_10.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + } + ], + "license_expressions": [ + "bsd-new", + "bsd-new", + "bsd-new" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test5.c", + "type": "file", + "licenses": [ + { + "key": "apache-2.0", + "score": 89.58, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 17, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "matcher": "3-seq", + "rule_length": 96, + "matched_length": 86, + "match_coverage": 89.58, + "rule_relevance": 100.0 + } + }, + { + "key": "apache-2.0", + "score": 100.0, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 5, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "apache-2.0", + "apache-2.0" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test6.c", + "type": "file", + "licenses": [ + { + "key": "apache-2.0", + "score": 89.58, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 17, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "matcher": "3-seq", + "rule_length": 96, + "matched_length": 86, + "match_coverage": 89.58, + "rule_relevance": 100.0 + } + }, + { + "key": "apache-2.0", + "score": 100.0, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 5, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "apache-2.0", + "apache-2.0" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test7.c", + "type": "file", + "licenses": [ + { + "key": "apache-2.0", + "score": 89.58, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 17, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "matcher": "3-seq", + "rule_length": 96, + "matched_length": 86, + "match_coverage": 89.58, + "rule_relevance": 100.0 + } + }, + { + "key": "apache-2.0", + "score": 100.0, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 5, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "apache-2.0", + "apache-2.0" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test8.c", + "type": "file", + "licenses": [ + { + "key": "apache-2.0", + "score": 89.58, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 17, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "matcher": "3-seq", + "rule_length": 96, + "matched_length": 86, + "match_coverage": 89.58, + "rule_relevance": 100.0 + } + }, + { + "key": "apache-2.0", + "score": 100.0, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 5, + "end_line": 5, + "matched_rule": { + "identifier": "spdx-license-identifier: apache-2.0", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "apache-2.0", + "apache-2.0" + ], + "scan_errors": [] + } + ] + } diff --git a/tools/test/travis-ci/scancode_test/scancode_test_3.json b/tools/test/travis-ci/scancode_test/scancode_test_3.json new file mode 100644 index 00000000000..c523a8ce952 --- /dev/null +++ b/tools/test/travis-ci/scancode_test/scancode_test_3.json @@ -0,0 +1,169 @@ +{ + "headers": [ + { + "tool_name": "scancode-toolkit", + "tool_version": "3.1.1", + "options": { + "input": [ + "tools/test/travis-ci/scancode_test/test.h", + "tools/test/travis-ci/scancode_test/test2.h", + "tools/test/travis-ci/scancode_test/test3.h", + "tools/test/travis-ci/scancode_test/test4.h", + "tools/test/travis-ci/scancode_test/test5.h" + ], + "--json-pp": "scancode.json", + "--license": 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": "2020-10-01T135040.106260", + "end_timestamp": "2020-10-01T135047.793497", + "message": null, + "errors": [], + "extra_data": { + "files_count": 5 + } + } + ], + "files": [ + { + "path": "tools/test/travis-ci/scancode_test/test.h", + "type": "file", + "licenses": [], + "license_expressions": [], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test2.h", + "type": "file", + "licenses": [], + "license_expressions": [], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test3.h", + "type": "file", + "licenses": [ + { + "key": "proprietary-license", + "score": 77.0, + "name": "Proprietary License", + "short_name": "Proprietary License", + "category": "Proprietary Free", + "is_exception": false, + "owner": "Unspecified", + "homepage_url": null, + "text_url": "", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:proprietary-license", + "spdx_license_key": null, + "spdx_url": "", + "start_line": 2, + "end_line": 3, + "matched_rule": { + "identifier": "proprietary_12.RULE", + "license_expression": "proprietary-license", + "licenses": [ + "proprietary-license" + ], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 14, + "matched_length": 14, + "match_coverage": 100.0, + "rule_relevance": 77 + } + } + ], + "license_expressions": [ + "proprietary-license" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test4.h", + "type": "file", + "licenses": [ + { + "key": "proprietary-license", + "score": 77.0, + "name": "Proprietary License", + "short_name": "Proprietary License", + "category": "Proprietary Free", + "is_exception": false, + "owner": "Unspecified", + "homepage_url": null, + "text_url": "", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:proprietary-license", + "spdx_license_key": null, + "spdx_url": "", + "start_line": 2, + "end_line": 3, + "matched_rule": { + "identifier": "proprietary_12.RULE", + "license_expression": "proprietary-license", + "licenses": [ + "proprietary-license" + ], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 14, + "matched_length": 14, + "match_coverage": 100.0, + "rule_relevance": 77 + } + } + ], + "license_expressions": [ + "proprietary-license" + ], + "scan_errors": [] + }, + { + "path": "tools/test/travis-ci/scancode_test/test5.h", + "type": "file", + "licenses": [ + { + "key": "apache-2.0", + "score": 100.0, + "name": "Apache License 2.0", + "short_name": "Apache 2.0", + "category": "Permissive", + "is_exception": 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://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0", + "spdx_license_key": "Apache-2.0", + "spdx_url": "https://spdx.org/licenses/Apache-2.0", + "start_line": 4, + "end_line": 14, + "matched_rule": { + "identifier": "apache-2.0_7.RULE", + "license_expression": "apache-2.0", + "licenses": [ + "apache-2.0" + ], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 85, + "matched_length": 85, + "match_coverage": 100.0, + "rule_relevance": 100 + } + } + ], + "license_expressions": [ + "apache-2.0" + ], + "scan_errors": [] + } + ] +} diff --git a/tools/test/travis-ci/scancode_test/scancode_test_4.json b/tools/test/travis-ci/scancode_test/scancode_test_4.json new file mode 100644 index 00000000000..1e983209f13 --- /dev/null +++ b/tools/test/travis-ci/scancode_test/scancode_test_4.json @@ -0,0 +1,166 @@ +{ + "headers": [ + { + "tool_name": "scancode-toolkit", + "tool_version": "3.1.1", + "options": { + "input": [ + "test.h" + ], + "--json-pp": "scancode.json", + "--license": 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": "2020-10-01T135040.106260", + "end_timestamp": "2020-10-01T135047.793497", + "message": null, + "errors": [], + "extra_data": { + "files_count": 1 + } + } + ], + "files": [ + { + "path": "tools/test/travis-ci/scancode_test/test.h", + "type": "file", + "licenses": [ + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 2, + "end_line": 2, + "matched_rule": { + "identifier": "spdx-license-identifier: bsd-new", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": false, + "is_license_tag": true, + "matcher": "1-spdx-id", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 8, + "end_line": 8, + "matched_rule": { + "identifier": "bsd-new_360.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 4, + "matched_length": 4, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + }, + { + "key": "elastic-license-2018", + "score": 72.22, + "name": "Elastic License Agreement 2018", + "short_name": "Elastic License 2018", + "category": "Source-available", + "is_exception": false, + "owner": "Elastic", + "homepage_url": "https://github.com/elastic/elasticsearch/blob/0d8aa7527e242fbda9d84867ab8bc955758eebce/licenses/ELASTIC-LICENSE.txt", + "text_url": "https://github.com/elastic/elasticsearch/blob/0d8aa7527e242fbda9d84867ab8bc955758eebce/licenses/ELASTIC-LICENSE.txt", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:elastic-license-2018", + "spdx_license_key": null, + "spdx_url": "", + "start_line": 9, + "end_line": 10, + "matched_rule": { + "identifier": "elastic_1.RULE", + "license_expression": "elastic-license-2018", + "licenses": [ + "elastic-license-2018" + ], + "is_license_text": false, + "is_license_notice": true, + "is_license_reference": false, + "is_license_tag": false, + "matcher": "3-seq", + "rule_length": 18, + "matched_length": 13, + "match_coverage": 72.22, + "rule_relevance": 100.0 + } + }, + { + "key": "bsd-new", + "score": 100.0, + "name": "BSD-3-Clause", + "short_name": "BSD-3-Clause", + "category": "Permissive", + "is_exception": false, + "owner": "Regents of the University of California", + "homepage_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "text_url": "http://www.opensource.org/licenses/BSD-3-Clause", + "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:bsd-new", + "spdx_license_key": "BSD-3-Clause", + "spdx_url": "https://spdx.org/licenses/BSD-3-Clause", + "start_line": 11, + "end_line": 11, + "matched_rule": { + "identifier": "bsd-new_10.RULE", + "license_expression": "bsd-new", + "licenses": [ + "bsd-new" + ], + "is_license_text": false, + "is_license_notice": false, + "is_license_reference": true, + "is_license_tag": false, + "matcher": "2-aho", + "rule_length": 3, + "matched_length": 3, + "match_coverage": 100.0, + "rule_relevance": 100.0 + } + } + ], + "license_expressions": [ + "bsd-new", + "bsd-new", + "elastic-license-2018", + "bsd-new" + ], + "scan_errors": [] + } + ] +}