diff --git a/Makefile b/Makefile index d85d04d..7e23bb7 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,9 @@ test_commitmessage: test_files: PYTHONPATH=`pwd`/autospec python3 tests/test_files.py +test_license: + PYTHONPATH=`pwd`/autospec python3 tests/test_license.py + test_autospec: python3 tests/test_autospec.py -c ${CASES} diff --git a/autospec/autospec.py b/autospec/autospec.py index 3fefa9c..a4f94cb 100644 --- a/autospec/autospec.py +++ b/autospec/autospec.py @@ -155,7 +155,7 @@ def main(workingdir): license.add_license(word) except: pass - license.scan_for_licenses(name, _dir) + license.scan_for_licenses(_dir) exit(0) config.setup_patterns() @@ -166,7 +166,7 @@ def main(workingdir): buildreq.set_build_req() buildreq.scan_for_configure(name, _dir, build.download_path) specdescription.scan_for_description(name, _dir) - license.scan_for_licenses(name, _dir) + license.scan_for_licenses(_dir) commitmessage.scan_for_changes(build.download_path, _dir) add_sources(build.download_path, args.archives) test.scan_for_tests(_dir) diff --git a/autospec/commitmessage.py b/autospec/commitmessage.py index 8660a47..d46275a 100644 --- a/autospec/commitmessage.py +++ b/autospec/commitmessage.py @@ -41,7 +41,6 @@ def scan_for_changes(download_path, directory): """ found = [] interests = config.transforms.keys() - print(interests) for dirpath, dirnames, files in os.walk(directory, topdown=False): hits = [x for x in files if x.lower() in interests and x.lower() not in found] for item in hits: diff --git a/autospec/config.py b/autospec/config.py index 5dbab32..832b0c8 100644 --- a/autospec/config.py +++ b/autospec/config.py @@ -65,6 +65,7 @@ signature = None failed_commands = {} maven_jars = {} gems = {} +license_hashes = {} cves = [] @@ -334,9 +335,11 @@ def setup_patterns(): global failed_commands global maven_jars global gems + global license_hashes read_pattern_conf("failed_commands", failed_commands) read_pattern_conf("maven_jars", maven_jars) read_pattern_conf("gems", gems) + read_pattern_conf("license_hashes", license_hashes) def parse_existing_spec(path, name): diff --git a/autospec/license.py b/autospec/license.py index 9e3711f..1dcc20b 100644 --- a/autospec/license.py +++ b/autospec/license.py @@ -23,6 +23,7 @@ import sys import os +import re import tarball import pycurl import urllib @@ -33,8 +34,6 @@ from util import print_fatal, print_warning default_license = "TO BE DETERMINED" -LICENSE_HASH_FILE = "common/licenses" - licenses = [] license_translations = { @@ -54,7 +53,6 @@ license_translations = { "LGPLv2.1": "LGPL-2.1", "LGPLv2+": "LGPL-2.1+", "LGPL-2.0+": "LGPL-2.0+", - "LGPL-2.1": "LGPL-2.1", "LGPLv2.1": "LGPL-2.1", "LGPL-2.1+": "LGPL-2.1+", "LGPLv2.1+": "LGPL-2.1+", @@ -111,117 +109,118 @@ license_translations = { "CC0": "CC0-1.0" } -license_blacklist = { - "and": True, - "BSD": True, - "3BSD": True, - "LGPL": True, - "GPL": True, - "ASL": True, - "2.0": True, - "advertising": True, - "LGPL+BSD": True, - "UN": True, - "GNU": True, - "new": True, - "none": True, - "License": True, - "License": True, - "license": True, - "Standard": True, - "PIL": True, - "Software": True, - "|": True, - "+": True, - "UNKNOWN": True, - "unknown": True, - "BSD-like": True, - "or": True, - "Modified": True, - "3-clause": True, - "Unlimited": True, - "BSD_3_clause": True, - "BSD(3": True, - "clause)": True, - "GFDL": True, - "MPL": True, - "Muddy-MIT": True, - "LGPL/MIT": True, - "License,": True, - "Lucent": True, - "Public": True, - "LICENCE": True, - "-": True, - "See": True, - "details": True, - "for": True, - "Version-2.0": True, - "exceptions": True, - "http://nmap.org/man/man-legal.html": True, - "with": True, - "style": True, - "Foundation": True, - "~": True, - "open_source": True, - "BSDish": True, - "EPL": True, - "Artistic": True, - "(specified": True, - "using": True, - "classifiers)": True, - "APL-2.0": True, - "dual": True, - ".git": True, - ".mit": True, - "GPL/BSD": True, - "GPLv2.1": True, - "version-2": True, - "public": True, - "domain": True, - "Commercial": True, - "ndg/httpsclient/LICENCE": True, - "License-2.0": True, - "BSD-style": True, - "Licences": True, - "New": True, - "License(==-2.0)": True, - "1.0": True, - "Version": True, -} +license_blacklist = [ + "and", + "BSD", + "3BSD", + "LGPL", + "GPL", + "ASL", + "2.0", + "advertising", + "LGPL+BSD", + "UN", + "GNU", + "new", + "none", + "License", + "license", + "Standard", + "PIL", + "Software", + "|", + "+", + "UNKNOWN", + "unknown", + "BSD-like", + "or", + "Modified", + "3-clause", + "Unlimited", + "BSD_3_clause", + "BSD(3", + "clause)", + "GFDL", + "MPL", + "Muddy-MIT", + "LGPL/MIT", + "License,", + "Lucent", + "Public", + "LICENCE", + "-", + "See", + "details", + "for", + "Version-2.0", + "exceptions", + "http://nmap.org/man/man-legal.html", + "with", + "style", + "Foundation", + "~", + "open_source", + "BSDish", + "EPL", + "Artistic", + "(specified", + "using", + "classifiers)", + "APL-2.0", + "dual", + ".git", + ".mit", + "GPL/BSD", + "GPLv2.1", + "version-2", + "public", + "domain", + "Commercial", + "ndg/httpsclient/LICENCE", + "License-2.0", + "BSD-style", + "Licences", + "New", + "License(==-2.0)", + "1.0", + "Version" +] def add_license(lic): + """ + Add license from license string lic after checking for duplication or + presence in the blacklist. + """ global licenses lic = lic.strip() - # Bail if the license isn't one we recognize, is a blacklisted word or has already been added - if lic in licenses: - return False - if lic in license_blacklist: - return False - if lic not in license_translations: - licenses.append(lic) - return True - if license_translations[lic] in licenses: + # Translate the license if a translation exists + real_lic = license_translations.get(lic, lic) + # Return False if not adding to licenses + if real_lic in licenses or real_lic in license_blacklist: return False - licenses.append(license_translations[lic]) + licenses.append(real_lic) return True def license_from_copying_content(copying): + """ + Scan the copying file for strings indicating which license it represents. + Add that license to the licenses list using add_license(lic) + """ with open(copying, 'r', encoding="latin-1") as content_file: content = content_file.read() - if content.find("Version 2, June 1991") >= 0: - add_license("GPL-2.0") - if content.find("Version 3, 29 June 2007") >= 0: - add_license("GPL-3.0") - if content.find("Version 2.1, February 1999") >= 0: - add_license("LGPL-2.1") - if content.find("Source Code is licensed under MIT license") >= 0: - add_license("MIT") - if content.find("Version 2.0, January 2004") >= 0: - add_license("Apache-2.0") + + cp_content_map = {"Version 2, June 1991": "GPL-2.0", + "Version 3, 29 June 2007": "GPL-3.0", + "Version 2.1, February 1999": "LGPL-2.1", + "Source Code is licensed under MIT license": "MIT", + "Version 2.0, January 2004": "Apache-2.0"} + for cp_str, lic in cp_content_map.items(): + if cp_str in content: + add_license(lic) def license_from_copying_hash(copying): @@ -234,65 +233,73 @@ def license_from_copying_hash(copying): if config.license_fetch: with open(copying, "r", encoding="latin-1") as myfile: data = myfile.read() - values = {'hash': hash_sum, 'text': data, 'package': tarball.name} - data = urllib.parse.urlencode(values) - data = data.encode('utf-8') - buffer = BytesIO() - c = pycurl.Curl() - c.setopt(c.URL, config.license_fetch) - c.setopt(c.WRITEDATA, buffer) - c.setopt(c.POSTFIELDS, data) - c.perform() - c.close() + values = {'hash': hash_sum, 'text': data, 'package': tarball.name} + data = urllib.parse.urlencode(values) + data = data.encode('utf-8') - response = buffer.getvalue() - the_page = response.decode('utf-8') + buffer = BytesIO() + c = pycurl.Curl() + c.setopt(c.URL, config.license_fetch) + c.setopt(c.WRITEDATA, buffer) + c.setopt(c.POSTFIELDS, data) + c.perform() + c.close() - if len(the_page.strip()) > 0: - print("License : ", the_page.strip(), " (server) (", hash_sum, ")") - add_license(the_page.strip()) - return - else: - if os.path.exists(LICENSE_HASH_FILE): - with open(LICENSE_HASH_FILE, "r") as file: - licenses_list = file.readlines() - licenses_dict = dict(license.split(" | ") for license in licenses_list) + response = buffer.getvalue() + page = response.decode('utf-8').strip() + if page: + print("License : ", page, " (server) (", hash_sum, ")") + add_license(page) + return - if hash_sum in licenses_dict: - add_license(licenses_dict[hash_sum]) + if hash_sum in config.license_hashes: + add_license(config.license_hashes[hash_sum]) else: if not config.license_show: return print_warning("Unknown license {0} with hash {1}".format(copying, hash_sum)) - hashUrl = config.license_show % {'HASH': hash_sum} - print_warning("Visit {0} to enter".format(hashUrl)) + hash_url = config.license_show % {'HASH': hash_sum} + print_warning("Visit {0} to enter".format(hash_url)) def license_from_doc(doc): """ Scan for documentation license in the given file """ with open(doc, 'r', encoding="latin-1") as content_file: content = content_file.read() - if content.find("GNU Free Documentation License, Version 1.3") >= 0: - add_license("GFDL-1.3") - elif content.find("GNU Free Documentation License, Version 1.2") >= 0: - add_license("GFDL-1.2") - elif content.find("GNU Free Documentation License, Version 1.1") >= 0: - add_license("GFDL-1.1") - elif content.find("(The MIT License)") >= 0: - add_license("MIT") + + doc_content_map = { + "GNU Free Documentation License, Version 1.3": "GFDL-1.3", + "GNU Free Documentation License, Version 1.2": "GFDL-1.2", + "GNU Free Documentation License, Version 1.1": "GFDL-1.1", + "(The MIT License)": "MIT" + } + + for doc_str, lic in doc_content_map.items(): + if doc_str in content: + add_license(lic) -# -# Scan the project directory for things we can use to guess a description -# and summary -# - -def scan_for_licenses(package, dir): - for dirpath, dirnames, files in os.walk(dir): +def scan_for_licenses(srcdir): + """ + Scan the project directory for things we can use to guess a description + and summary + """ + targets = ["copyright", + "copyright.txt", + "apache-2.0", + "libcurllicense", + "gpl.txt", + "gplv2.txt", + "notice", + "copyrights", + "about_bsd.txt"] + # look for files that start with copying or licen[cs]e (spelling errors) + # or end with licen[cs]e + target_pat = re.compile(r"^((copying)|(licen[cs]e))|(licen[cs]e)$") + for dirpath, dirnames, files in os.walk(srcdir): for name in files: - if (name.lower() in ("copyright", "copyright.txt", "apache-2.0", "libcurllicense", "gpl.txt", "gplv2.txt", "notice", "copyrights", "about_bsd.txt") or - name.lower().startswith("copying") or name.lower().startswith("license") or name.lower().endswith("license") or name.lower().startswith("licence") or name.lower().endswith("licence")): + if name.lower() in targets or target_pat.search(name.lower()): license_from_copying_hash(os.path.join(dirpath, name)) license_from_copying_content(os.path.join(dirpath, name)) else: @@ -302,13 +309,12 @@ def scan_for_licenses(package, dir): if ext in ("man", "texi", "rdoc"): license_from_doc(os.path.join(dirpath, name)) - if len(licenses) == 0: - print_fatal(" Cannot find any license or " + tarball.name + ".license file!\n") + if not licenses: + print_fatal(" Cannot find any license or {}.license file!\n".format(tarball.name)) sys.exit(1) - else: - print("Licenses : ", " ".join(sorted(licenses))) + + print("Licenses : ", " ".join(sorted(licenses))) def load_specfile(specfile): - lics = licenses if licenses else [default_license] - specfile.licenses = lics + specfile.licenses = licenses if licenses else [default_license] diff --git a/autospec/license_hashes b/autospec/license_hashes new file mode 100644 index 0000000..a8ef37a --- /dev/null +++ b/autospec/license_hashes @@ -0,0 +1,287 @@ +# This file contains license hashes and the licenses they are associated with +# in the form: , +# Lines beginning with '#' are ignored. +94e50e74aa533e042a8fb41a0d5b07460cdc3b91, GPL-2.0 +3348e5430ba4fb49fa8eb6e9caf4f06266639d0d, EPL-1.0 +ef51e850423393335a21c5069af73674cdf6753f, GPL-2.0 +83ba6546e00f890f3a26a9bedd264084f8527d5e, LGPL-2.0 +003da9a1871de68693740b39bee3ddca66707ad3, LGPL-2.1 +01a6b4bf79aca9b556822601186afab86e8c4fbf, LGPL-2.1 +06877624ea5c77efe3b7e39b0f909eda6e25a4ec, GPL-2.0 +075d599585584bb0e4b526f5c40cb6b17e0da35a, GPL-2.0 +090586b9e4c51fd5ef3c39f25d2469a8be8e33c9, AFL-2.1 GPL-2.0+ +10782dd732f42f49918c839e8a5e2894c508b079, GPL-2.0 +11c746c0c250304a17169f4d6aa4a82d09fd7157, GPL-2.0 +12549569098cbb0efa8a4aa91f5f38068791fe42, GPL-2.0 +13d2034b5ee3cb8d1a076370cf8f0e344a5d0855, GPL-2.0 +14c1f9f1263a82d58615c51369e1443c3d9f15bf, LGPL-2.1 +14e8b95e4871fb8a09ebbb5082d34a3c1c7da5a3, BSD MPL +18b0624b094dd81f099af8672ff5a05259249059, GPL-2.0+ LGPL-2.1+ +1adfe59a1df9ae50ec572004dd5ebd5f45cc85f7, GPL-3.0+ +1c0c6888759a63c32bca7eb63353af2cd9bd5d9e, bzip2-1.0.6 +1cf6c2c767c8f1d457c8156aafc9220dd9dedbe5, BSD +1d6467e08284270291d138c7ea07f24689483068, BSD +1e2bf763a406378034f0722de926e819c31ed211, GPL-3.0 +1f9b387f1c4c2857808696c5f2d7f9f31c26b911, OldMIT +21e40770dfa802576ee515345cef47ecedff6524, LGPL-2.0+ +253c30cd74e4812f13e9e561cb54cbab26bc19dc, GPL-2.0 +2a4fd3610e85e2efdefe2dc331b555794f9e0cb3, GPL-3.0 +2d29c273fda30310211bbf6a24127d589be09b6c, GPL-2.0 +329173a86dabff7ed1c8bd39117d410401c46a05, GPL-2.0+ LGPL-2.0+ +39a21f33cadea18adcc23bf808d7d5ea6419c8b1, LGPL-2.1 +3ee0019d4f4ea0a9d3f50800833f30dc14e2968e, GPL-2.0 +430bd4bbe476b94eb686e5751395a242fc2354e0, BSD +4386a89a4295085459ef1d54f3ab8859f1f1d28c, LGPL-2.1 +44f7289042b71631acac29b2f143330d2da2479e, LGPL-2.0 +480ff2fd1236e94295d10551b0b333296f639300, LGPL-2.1+ +4cc77b90af91e615a64ae04893fdffa7939db84c, GPL-2.0 +4d328180e5349a9f65193ed4f424300d0c2c6adc, GPL-2.0 +4df5d4b947cf4e63e675729dd3f168ba844483c7, LGPL-2.1 +4f485ab7059ac53d9e3818278ad82217ce976a36, GFDL-1.1 +503df7650052cf38efde55e85f0fe363e59b9739, GPL-2.0 +53afb4c86c46b4980f3f8bb129628c55e740226e, LGPL-2.0 +5405311284eab5ab51113f87c9bfac435c695bb9, GPL-2.0 +545f380fb332eb41236596500913ff8d582e3ead, LGPL-2.1 +570d185ea721e7d6aee7426be1b10a800af98aa8, LGPL-2.0 +5bb165c9b21503806d60c4559af198f569dc46f6, LGPL-2.1 +5fb362ef1680e635fe5fb212b55eef4db9ead48f, LGPL-2.0 +61bb7a8ea669080cfc9e7dbf37079eae70b535fb, MIT +62066b13a35774834f104c2ff075ce679a0f75a3, EvolutionMix +654d5ed6dd2d6ab7904d4047cde6345730f9d174, GPL-3.0 +66c77efd1cf9c70d4f982ea59487b2eeb6338e26, LGPL-2.1 +68c94ffc34f8ad2d7bfae3f5a6b996409211c1b1, GPL-2.0 +72b40d717fc8757da66964a3a5b565aae69d8b39, GPL-3.0 +72d42b3c12e7765c1539d6741cbc2054c2d11260, GPL-3.0+ +74a8a6531a42e124df07ab5599aad63870fa0bd4, GPL-2.0 +8088b44375ef05202c0fca4e9e82d47591563609, LGPL-2.1 +80a39eb9544a657a0e23f53a15daff8a1d6a0e7d, LGPL-2.1 +8244c6af44d86382af14ef78dc6f430925cb46a7, Perl +83b927c3fa44af01d2515ea8575f8d4848cc10ec, GPL-2.0+ LGPL-2.0+ +842745cb706f8f2126506f544492f7a80dbe29b3, GPL-3.0 +8570a5c766d8b7eda6fa171a7f6674e335b50c5e, MIT +8624bcdae55baeef00cd11d5dfcfa60f68710a02, GPL-3.0 +89e91cab64960b7c852e3b31da3802029af6ef88, GPL-2.0 +8e57ffebd0ed4417edc22e3f404ea3664d7fed27, MIT +8edc79a3e927a60794fbccaaa22835f9e1ef5c9a, GPL-3.0+ +943fb830004a8813177c761482ac5d583ee09351, GPL-3.0 +99b5245b4714b9b89e7584bfc88da64e2d315b81, BSD +a6adc13d0c809ab8cb68e6e3b6eb7571bd0e2920, GPL-3.0 +a7a897a4bde987e597c04f16a9c28f6d3f57916d, GPL-2.0 +aade406c56b751113933f3b64890fb8d5b489a2c, LGPL-3.0 +aba8d76d0af67d57da3c3c321caa59f3d242386b, MPL-1.1 +adcc6ae0ba0e1e4fae77bd2b98db0d5a1aae2e75, BSD-2-Clause +b256632dcce76559734ff0a23330d2898b7d3a3b, GPL-2.0 +b47456e2c1f38c40346ff00db976a2badf36b5e3, GPL-2.0 +b72fac76415d8029e2823485e3fb9ddb650b879e, GPL-2.0 +b7e55cb48a9fb891583a221fa909ccd75e2ceaaf, LGPL-2.0 +b972655523ae3fdb35306d830b8426e4af30d29c, GPL-2.0+ +ba8966e2473a9969bdcab3dc82274c817cfd98a1, LGPL-2.0 +ba905468a032e17d551b8185bccecea5807b7638, GPL-3.0 +bf50bac24e7ec325dbb09c6b6c4dcc88a7d79e8f, LGPL-2.0 +c2e8ebe3551b42d4a868922ec922a8af6452c48b, LGPL-3.0 +c3de6dd37753714ce85482acd8292525d4515595, GPL-2.0 +c540cc53356ba854b2673e53fabc05b2f579404c, GPL-2.0 +c61905dc64311e8bcee6afc425fa40f917a45131, GFDL1.1 +c931aad3017d975b7f20666cde0953234a9efde3, GPL-2.0 +caeb68c46fa36651acf592771d09de7937926bb3, LGPL-2.1 +cfea9b772a9da707b5f092d3c18b4572fa4bd520, LGPL-2.0 +d129361510b2cbbf83a0c2d3dc0381b76d87ac9a, LGPL-2.1 MPL-1.1 +d83b6378d06fdf228b1afc0bf97e09b44bbb2e7b, LGPL-2.0 +dfac199a7539a404407098a2541b9482279f690d, GPL-2.0 +e00070d4eca0371dd3ca3df4a2472cc2db599bad, GPL-2.0 +e16364503a826791c0588c304c794ee8d210b7bc, GPL-1.0 +e1d31e42d2a477d6def889000aa8ffc251f2354c, GFDL-1.3 +e3afbcad74dd08819b5de5ad0338203369731f67, GPL-2.0 +e60c2e780886f95df9c9ee36992b8edabec00bcc, LGPL-2.1 +e7d563f52bf5295e6dba1d67ac23e9f6a160fab9, GPL-3.0 +f33b4d7ca167851483857c947ea7484d533d9b05, GFDL CCBYSA +f45ee1c765646813b442ca58de72e20a64a7ddba, GPL-3.0 +f4c513b3be30f40bb34a6e4d8c4f45a5bf1b6a10, Meta +f6e0bb551b32440d84c3886a34ddbd3d1aec7b56, Apache2.0 +fbf1ca3836c050241ed2fde6ac3a515313f30e8b, GPL-2.0 +5e7b36dfb18c7b8002bb9c41f87b65d280abd2ae, GFDL1.1 +9a1929f4700d2407c70b507b3b2aaf6226a9543c, LGPL-2.1 +faa78032a41c2bfe6bfd1df72ccd1bb7ab4f7a10, GPL-2.0 +2b8b815229aa8a61e483fb4ba0588b8b6c491890, Apache-2.0 +cc1e4801215dbc785fbc3d2b9910b2f093466041, GPL-2.0 +c5041828c23a816cc38e662b61032e959cb86893, LGPL-2.1 +2b9d60c2972b476384af9900276837ac81954e80, GPL-2.0 +597bf5f9c0904bd6c48ac3a3527685818d11246d, LGPL-2.1 +74acefbff6c13e5c81492d7460b82e2b5ec16c1b, LGPL-2.1 +061048a4b794b6b63e2b81f93404a9eaf5f61f11, GPL Ghostscript +715a897b37b8e535c5812e5f4e663c30b5a67115, MIT +73ccddd0c27b4492f8182c35f0f7c434b998757c, GPL-2.0 +313e4788e0730c747b41fad603f0fba3765a022d, MIT +1665590806e57d72419af943374652cebc42571f, LGPL-2.1 MPL1.0 +669dfab6308e814f23c524fd51f565a39536ec21, MIT +38f27835622344a460610effe7888c9c2ef40c74, MPL-1.0 LGPL-2.1 +1b07b3f8b3b7d79c074d00dfb39a5be425e70cb8, GPL-2.0 +4cc8868f0a2c423cc8d63fede50ae0fecd58a720, GPL-3.0+ +c3795529e138884da8f5b836db7e2fe1025526cd, GPL-2.0 +63b588642ebe669d50ab658ea1d079bb99086396, GPL-2.0 +51ae38c0bc1c4f8b798d3181a3673ceebc93c54b, GPL-2.0 +79cd7284f964b96ba6df6c35dee5e8a92b9e9b49, 3BSD GPL-2.0+ +cc4023c25020d429d9f4a4adf1a2461c8f334597, 4BSD +46243828d8d29354fd01836ba3a12254c072eedc, GFDL-1.2 +40a59387a5d3ab7449e77079f542f86018c16bff, GPL-2.0 +9e010b11705daec7ebf9c01a32d6f09ee444968d, GPL-2.0+ +df734091d6dbc9d20382b4084e68396a483582bd, 2BSD Ruby +4c7d9cdbd787a28d9d0d4e1a425cd1e826621e41, LGPL-2.1 +4d1d37f306ed270cda5b2741fac3abf0a7b012e5, GPL-2.0 +bc06cbdf781c87d2df2fe385214f936d010dd2a2, 3BSD +cb9f6ee72658f9cb9fceb8b4a3d3e280a4586f20, LGPL-2.1 +72f59fbac43fa1a7f0607d7fdba747832e626656, 3BSD +50147984b983a89bb0a981968bad2e431f0a1423, MIT +909b58c9b803acb8d063ac6b2147e56afc8055f6, GPL-2.0 +b9c8da2c5e4162fc7e321fda0b8d3d084681e764, 2BSD +0e8e850b0580fbaaa0872326cb1b8ad6adda9b0d, LGPL-2.0 +6723aef56fa8b33bec08e1477f4393e6707c973c, MIT +2aaa700763cac84c6ee8ce491a4148064850a761, Chinese something +7cdb2709d5ce063238a7fae991c5d6cbe3bc7d7f, LGPL-2.1Apache2 +58e79a1175dc5c95f8ac7dc1d23f1ffc61a9fee7, WEIRD +f7e86954cf5438549ec8948212f2713024119c68, GPL-1.0+ Artistic +ce714346889d1becdd3132cf7380c734a985ecf1, GPL-1.0 Perl +4aa399e286b0bfbfba4819711a9c143b79aa01d0, GPL-2.0 +5eb1e4cf540bfae563680ce53c71c261abb5f076, CERT weird +00bf1929edfbe209d33d4b58a47e0178280bd606, MIT +14daa45932568feb416c5dd45f1cd909294fb3b0, MIT +174c509aa1452ab3a56faa01aec149015c391e99, LGPL-2.1+ GPL-2.0+ +1c74b6200eb29fa8c10588f6e32f3f7cf8eda03f, MIT +1cc9ab3464ce507485f4982670d12916ec5a3c0e, MIT +235350d09d078e0fb82939483642d7567b1d1245, MIT +24790001231306234389a547f69e43601471db75, BSD-3-Clause +254aec9ad4aa42eb4f11c7a58ea1d297e14c43ae, MIT +254f719409a77168a80aed51593017f6f44165c7, LGPL-2.1 MPL-1.1 +2aa8684f0abf57011bd8bf5c30b0390cc2c85a03, MIT +2b61cd7d9b22e98804387e896a3cfa382c1bc4ef, MIT +2cf9061e85ff400986a10c505a6177ff2b5e992d, MIT +32b0302709046c7d107587b2a4435e91bcea2be8, MIT +3785dd882865259e99bf41ce033b122370e25ce1, MIT +3b90aaf730fa20460f8fe3fd20c16daf3acaba59, MIT +3c33e98325d414f0290c82bc32b0d8c28cbeeb9b, MIT +40f6d7c0dba74ddd10663dfa50c2659cbe251423, MIT +4406aeb00f12a2c9cfba8066eef1a7a0c9b32f43, 3BSD +47ca90dc423091f8db250f2cc45f28aba88d11ed, 2BSD +48703751ffc7d48dc3aa9609be19dd542cf9776b, GPL-3.0 +4f35a76dbcc982e002982b97c5d93f3d95c5e57f, MIT +4ff4760dfc54975ddb40a3455633574849bc5611, BSD-2-Clause +5b550d122aa18a381e29e5be5f4814aeb7b6b800, MIT +5c96c2383498d529b9f62385b9db5ed6f290a890, MIT +5d1a41800996f1c023b69f4b1c3a93b194a66e80, MIT +5fb122a984b09d5c687513bb34a51eeeff2b13a7, BSD-3-Clause GPL-1.0 +61200da0f665a7b331f2f17b065b5a948fad40b8, MIT +618c9d05efe2932bc3aa4745ecfb548303dd8f08, MIT +62ba6d3ef166a2b04cf4dcec7039c7afa9dcc2bc, MIT +6596e03f9467e3d698993a49289a502c4baf7e08, MIT +6700131aba37c25eb7f67b0c4071d02df6de75bc, MIT +6af05e5d7c8c49b139d589a27cddd8468e65a5a3, MIT +6c394114eefb35de30b9675a99cc1500c6e574cb, MIT +6c6ec2b7a40bad98fa4a5b55c3855258e5d2a05e, LGPL-2.1 GPL-2.0 +70c32f13c99ca9bb7d53d5cb35fa8243dfa30e76, MIT +74cb2bfd42807a875d1386f2bae67be20c4e19cc, MIT +a2f64f2a85f5fd34bda8eb713c3aad008adbb589, MIT +7f3f67aef48ead049bebdab307c04c2e03342710, 3BSD +7f673c53e3a7840abd45c5869b6ab8aeb2d34c10, MIT +84d1b5be6b879fb3967c937a581292206a68ab45, MIT +88aacfcae9d42c894660950b01e7229cc2895cad, MIT +904c53ec5a9edfd5d08fcef5fb8ff9c844aed213, MIT +952348c4126a5946c98385d2fe5a4801735f174d, MIT +97cf1f1fdaaff217f90d58faa9d1b2c0e387fd96, MIT +a08228c5c15d51b7072c406b0d30d862af339ada, MIT +a280389ff9a8a9d58c76b406ac8a9b64d679f587, MIT +a7c968e282631e3b29c66bcf4a438fc72b68be27, MIT +bb38ed62633b427973e8bcbe95c88fc1e00fd77d, MIT +b307e9607ffa7ab6dc4ab7c019d0e62a627b9532, MIT +b55b6493b790dc1291794a6b4f04064ce06bf435, MIT +b7c6cc817dedc6e9c0aff3bb5a50cbc1e7f9548f, MIT +bb306f5409529d1c19b78d60f705d37e3c470124, MIT +b6e9e05950ebcd16852fe9795b564a3f5d976223, Unknown +bb5cc149358d8c36484f012e24ce694f66bd3b12, FONT +bc252631805cf037048f64fef562f98c2a0bdc9e, 3BSD +bd67b052cf8bd1c31dbcdbe56955b6b5d22243f7, MIT +be90ae29e7e0977910b397571efe56601c123793, MIT +cb03b5ef1e3d983356601be29e306eebdc6a9257, MIT +cbfdfb0078ac466712aa0a82242b8fc955b0bc00, MIT +ce154c6a0d76d90cd20ef010636eb8e98a4f9fe5, MIT +893c940eb56cd6a45620c65c72b9a8c48bd79217, MIT +d004d8de0c32dfd3e86ca5f4a4552332bf5bbb67, GPL-2.0 LGPL-3.0 APL-2.0 GFDL-1.3 +d13c7d638806dc37e5c9b6bbc39366cd904d04de, MIT +d1845ff7fcb2cdc1f5713dd18140e89de2ab0204, MIT +d46d26c49b071f6f17913af46023b538bf1768e7, MIT +d6dad56b15f36205dc3c605a3e5a98ccac1275f2, MIT +dcc7cc194ef7fcd3e5f8e9bc20ddad371ee1d36c, MIT +de9f614d7db67dd479cfa87b10a57ecc4abc7295, MIT +e4b3a39cf858dd93c1d5766b8bf1b49fbe9a1d67, BSD-3-Clause +e895154f04fa9aa52d1742728d984428f26a764b, LIBPNG +e911adf5641a09f13fdd5d59962ad37da043df79, MIT +e2f32873edf33dd9f03272bb5aa47f825369b905, MIT +fddb19e45cceea1a6c3a9b16547b824bb768eceb, MIT +f9e3dfab1d42d7282b0654e921706147795be7cb, LGPL-2.1 GPL-2.0+ +747f912a17321a200ab786514210c32116eb51b4, MIT +f35b1294fe252bc8ec243713fe9e214bbe5c6069, MIT +0005480dce93b70f7d62fa311f49e3c6c1a6dcfa, MIT +0292928b4571cd06a52307940df8bcffc4c51ea4, MIT +11464e106e37066a94a23fe4912581799daa3e41, 3BSD +6745330da3e7bde244b20b96a42eae659644e731, BSD-3-Clause +196f0bcaf72257201b7e9d499a3c5b5f3f75c170, MIT +23a1e6369b12379f07c61bbbaa73e13704ebc30e, MIT +87d59feee73204c7334b7e00ae1cec3f3c583474, MIT +2504e714566874eaff0a4ff3ca44d354b135efe9, MIT +2c938b2fe439b3d78ca579e5fc5cf49b3218c0ab, MIT +31b3a6df67bb414219baa57025a5c8d6b79555a5, MIT +3c53de6040bbb05b7ad825a48f8d7341f9e3d6f4, MIT +4882eb6580148a083a7745785ef76768de52086c, MIT +4e791d47822f12167fcddffaa7b8231b0c3b300a, MIT +5050f00b9e4605253a0a9d03d227bf0fb74fd676, MIT +613732109bb85dacf28dccf37b7ec0c212124ecd, MIT +6ae662f45f5458787a717d7280b6074d352de549, MIT +6b1edb9ab8161370f1ba8686ec730eb2cc0c1a13, MIT +922e3ebe82d80cae2f6c89bbb065ae455d0265b6, MIT +9384394a530b4a93530da89f95e05ac86c4880a0, MIT +a4777b6caf11b08abc996727d094e2dafc16caaa, MIT +a9fbc5ee6bc3b991c1fee735b96204001a8d64fe, SGI-B +b0fbb2162c8af440cb60a412a145a01195644b3b, 3BSD +b37df50521fc00c23c1835b592967fcce90cd23b, MIT +bb40dd090e18e858168d53bf519129e990f156dc, MIT +bbdf8e1d71045a407fee797ad27983e3eafa3ee6, MIT +c89f43c4122e411a59ba705cfcf89a3f88019fcf, 3BSD +cbd3c98acb262700c79d534692dc08cf05ec7f00, MIT +cf0f32a176b91013767b8a4a727a369156c6558c, MIT +d8b8b6fadbff8363d66d5c703971ab0c86696e26, MIT +deed0c8eb4eb962dc74006326c98f750e08c8e3f, 2BSD 3BSD LGPL +ea754f5e8f103855a5574468c9101889553c917e, MIT +fd02365360c1936fdd069b08d29c16c6b16e4ea4, MIT +f0236e5d5e53eb7b386cd3ac80b852814e3112dc, GPL-2.0 LGPL-2.1 +be0b40ce8f9532b75966a20d14af123d3c6b05aa, GPL-2.0 +900806db6414f1bb309ab7438c0a5bac52eb3c2b, CCSA3.0 +d4e89d1a1e7812dae053aa8cb891f452891df932, GPL-2.0 +f9c9a2d3495a0766b4cf20d4b90cfe714dab3dc1, MIT +8313e316436df0f02ce407f0b52b77f8195bfae6, PublicDomain +2a18f0964f8f7f91a74026ffe45927c83441f333, 3BSD +a5771f371f97e15ece15ad91386b8897cb06a95a, 3BSD +5292f678d9f514464de238e26705c4e81c90366c, MIT Apache-2.0 BSD-3-Clause +96784c94078c65a3af7fe6e26b60448042aea27a, IPL-1.0 +edce7bb3398021ac27115ab50d8db9efaf3408c7, LGPL-2.1 +70e64fe9090c157e441681779e0f31aad34f35cb, GPL-3.0 +d25eb6311e5d0398a98818545298bc0fa10efab1, GPL-2.0 +0b184ad51ba2a79e85d2288d5fcf8a1ea0481ea4, GPL-2.0 +48d3aad525d9acd423ac6021c44fa4d15d4ee9ad, BSD-3-Clause +9dc4c58e46864b14d95a1368a6ebac37aad89d32, BSD-3-Clause +aa4e6280a7b029d15f5be03d2858e5e4c1655ac8, BSD-2-Clause +0305317c0f694ba11e8f059938fd0c880356e7bc, BSD-3-Clause +5b811940f3ef0c79e86f6ab11b0e4eced5e7eb14, BSD-3-Clause +098e171b1c9c7f15e05e696a187328e3c9aa0099, BSD-4-Clause +937157040d49ab4bbcf2070ed8f9b6849fdfa442, MIT +d0bee23991ce69abdc36d8711f54982ca2fd615c, MIT +b034fd3ba225f77f2b5853bcc65393b50761dfd7, MIT +49113556cdf35023603d71001aa073eadbd26b7e, BSD-3-Clause +57e93c186a48f2ccdd65f1872314534524825e94, MIT +cf3eaf29116a37a7d9ba773e776104c067c8e5fc, MIT +7b7e5d72495f3cd2b0d1307b28b92df4ad68a0a8, BSD-3-Clause +2807f3f1c4cb33b214defc4c7ab72f7e4e70a305, MIT +e4a57e19916359bf6f6f36847712b1761204feed, BSD-3-Clause +d86fb3f981d36e1f2890c7aaea6f8bcbb7ad4a27, Muddy-MIT +38abaf3c887f1799769b604e6d1ada4fcb81f8a0, MIT +750b9d9cc986bfc80b47c9672c48ca615cac0c87, BSD-3-Clause +175e59be229a5bedc6be93e958a970385bb04a62, Apache-2.0 +794a893e510ca5c15c9c97a609ce47b0df74fc1a, BSD-2-Clause diff --git a/tests/COPYING_TEST b/tests/COPYING_TEST new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/tests/COPYING_TEST @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/tests/test_license.py b/tests/test_license.py new file mode 100644 index 0000000..e56950b --- /dev/null +++ b/tests/test_license.py @@ -0,0 +1,257 @@ +import license +import unittest +import pycurl +import tempfile +import os +from contextlib import redirect_stdout +from io import BytesIO, StringIO +from unittest.mock import patch, mock_open, MagicMock + + +class TestLicense(unittest.TestCase): + + @classmethod + def setUpClass(self): + license.config.setup_patterns() + + def setUp(self): + license.licenses = [] + license.config.license_fetch = None + + def test_add_license(self): + """ + Test add_license from valid string, Apache-2 should be translated to + Apache-2.0 + """ + self.assertTrue(license.add_license('Apache-2')) + self.assertIn('Apache-2.0', license.licenses) + + def test_add_license_present(self): + """ + Test add_license from valid string, but license is already present in + the licenses list. Should return False and should not modify the + licenses list. GPL-3 translates to GPL-3.0. + """ + license.licenses.append('GPL-3.0') + self.assertFalse(license.add_license('GPL-3')) + self.assertEqual(['GPL-3.0'], license.licenses) + + def test_add_license_blacklisted(self): + """ + Test add_license from string in license_blacklist. Should return False + and should not modify the licenses list. + """ + # sanity check to make sure the licenses list is empty before the later + # assertIn() call + self.assertEqual(license.licenses, []) + + self.assertFalse(license.add_license('License')) + self.assertNotIn('License', license.licenses) + + def test_license_from_copying_content(self): + """ + Test license_from_copying_content with valid string in copying content. + """ + open_name = 'license.open' + content = 'Version 2.1, February 1999' + m_open = mock_open(read_data=content) + with patch(open_name, m_open, create=True): + license.license_from_copying_content('copying.txt') + self.assertIn('LGPL-2.1', license.licenses) + + def test_license_from_copying_content_not_present(self): + """ + Test license_from_copying_content with no valid strings in copying + content. + """ + open_name = 'license.open' + content = 'Version 9, February 1999' + m_open = mock_open(read_data=content) + with patch(open_name, m_open, create=True): + license.license_from_copying_content('copying.txt') + self.assertEquals(license.licenses, []) + + def test_license_from_copying_hash(self): + """ + Test license_from_copying_hash with valid license file + """ + # Calls out to tarball.get_sha1sum to get the hash of the license + # we might as well test that is returning what it should because it + # doesn't call any external resources, it just calculates the hash. + open_name = 'tarball.open' + with open('tests/COPYING_TEST', 'rb') as copyingf: + content = copyingf.read() + + m_open = mock_open(read_data=content) + with patch(open_name, m_open, create=True): + license.license_from_copying_hash('copying.txt') + + self.assertIn('GPL-3.0', license.licenses) + + def test_license_from_copying_hash_bad_license(self): + """ + Test license_from_copying_hash with invalid license file + """ + # Calls out to tarball.get_sha1sum to get the hash of the license + # we might as well test that is returning what it should because it + # doesn't call any external resources, it just calculates the hash. + open_name = 'tarball.open' + with open('tests/COPYING_TEST', 'rb') as copyingf: + # note the replace corrupting the file contents + content = copyingf.read().replace(b"GNU", b"SNU") + + m_open = mock_open(read_data=content) + with patch(open_name, m_open, create=True): + license.license_from_copying_hash('copying.txt') + + self.assertEquals(license.licenses, []) + + @patch('pycurl.Curl') + def test_license_from_copying_hash_license_server(self, mock_pycurl_curl): + """ + Test license_from_copying_hash with license server. This is heavily + mocked. + """ + class MockBytesIO(BytesIO): + """ + Mock class for BytesIO to set returnvalue of BytesIO.getvalue() + """ + def getvalue(_): + return 'GPL-3.0'.encode('utf-8') + + # set the mocks + mock_pycurl_curl.return_value = MagicMock() + license.BytesIO = MockBytesIO + + license.config.license_fetch = 'license.server.url' + with open('tests/COPYING_TEST', 'rb') as copyingf: + # note the replace corrupting the file contents + content = copyingf.read() + + # Calls out to tarball.get_sha1sum to get the hash of the license + # we might as well test that is returning what it should because it + # doesn't call any external resources, it just calculates the hash. + # Also patch the open in license.py + m_open = mock_open(read_data=content) + with patch('tarball.open', m_open, create=True): + with patch('license.open', m_open, create=True): + # let's check that the proper thing is being printed as well + out = StringIO() + with redirect_stdout(out): + license.license_from_copying_hash('copying.txt') + + self.assertIn('GPL-3.0', license.licenses) + self.assertIn('License : GPL-3.0 (server)', out.getvalue()) + + # unset the manual mock + license.BytesIO = BytesIO + + def test_license_from_doc(self): + """ + Test license_from_doc with valid string in doc license content. + """ + open_name = 'license.open' + content = 'This is the GNU Free Documentation License, Version 1.3' + m_open = mock_open(read_data=content) + with patch(open_name, m_open, create=True): + license.license_from_doc('copying.txt') + self.assertIn('GFDL-1.3', license.licenses) + + def test_license_from_doc_not_present(self): + """ + Test license_from_doc with no valid strings in doc content. + """ + open_name = 'license.open' + content = '(This is the Modified MIT License)' + m_open = mock_open(read_data=content) + with patch(open_name, m_open, create=True): + license.license_from_doc('copying.txt') + self.assertEquals(license.licenses, []) + + def test_scan_for_licenses(self): + """ + Test scan_for_licenses in temporary directory with valid license file + """ + with open('tests/COPYING_TEST', 'rb') as copyingf: + content = copyingf.read() + + with tempfile.TemporaryDirectory() as tmpd: + # create the copying file + with open(os.path.join(tmpd, 'COPYING'), 'w') as newcopyingf: + newcopyingf.write(content.decode('utf-8')) + # create some cruft for testing + for testf in ['testlib.c', 'testmain.c', 'testheader.h']: + with open(os.path.join(tmpd, testf), 'w') as newtestf: + newtestf.write('test content') + license.scan_for_licenses(tmpd) + + self.assertIn('GPL-3.0', license.licenses) + + def test_scan_for_licenses_doc(self): + """ + Test scan_for_licenses in temporary directory with valid doc license + file. + """ + with tempfile.TemporaryDirectory() as tmpd: + # create the copying file + with open(os.path.join(tmpd, 'test.man'), 'w') as docf: + docf.write( + 'This is the GNU Free Documentation License, Version 1.3') + # create some cruft for testing + for testf in ['testlib.c', 'testmain.c', 'testheader.h']: + with open(os.path.join(tmpd, testf), 'w') as newtestf: + newtestf.write('test content') + license.scan_for_licenses(tmpd) + + self.assertIn('GFDL-1.3', license.licenses) + + def test_scan_for_licenses_none(self): + """ + Test scan_for_licenses in temporary directory with no matching files. + Should not add any licenses, should print a fatal message, should exit + with a status code of 1. + """ + with tempfile.TemporaryDirectory() as tmpd: + # create some cruft for testing + for testf in ['testlib.c', 'testmain.c', 'testheader.h']: + with open(os.path.join(tmpd, testf), 'w') as newtestf: + newtestf.write('test content') + # let's check that the proper thing is being printed as well + out = StringIO() + with redirect_stdout(out): + with self.assertRaises(SystemExit) as thread: + license.scan_for_licenses(tmpd) + + self.assertEqual(thread.exception.code, 1) + self.assertIn("Cannot find any license", out.getvalue()) + self.assertEqual(license.licenses, []) + + def test_load_specfile(self): + """ + Test load_specfile with populated license list. This method is not + normally tested but there is some logic here. + """ + class MockSpecfile(object): + licenses = [] + + license.licenses = ['GPL-3.0', 'MIT'] + specfile = MockSpecfile() + license.load_specfile(specfile) + self.assertEqual(specfile.licenses, license.licenses) + + def test_load_specfile_none(self): + """ + Test load_specfile with unpopulated license list. This method is not + normally tested but there is some logic here. + """ + class MockSpecfile(object): + licenses = [] + + license.licenses = [] + specfile = MockSpecfile() + license.load_specfile(specfile) + self.assertEqual(specfile.licenses, [license.default_license]) + + +if __name__ == '__main__': + unittest.main(buffer=True)