diff --git a/etc/thirdparty/apache-2.0.LICENSE b/etc/thirdparty/apache-2.0.LICENSE deleted file mode 100644 index f49a4e16..00000000 --- a/etc/thirdparty/apache-2.0.LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. \ No newline at end of file diff --git a/etc/thirdparty/bsd-new.LICENSE b/etc/thirdparty/bsd-new.LICENSE deleted file mode 100644 index 57326dd0..00000000 --- a/etc/thirdparty/bsd-new.LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/etc/thirdparty/bsd-simplified.LICENSE b/etc/thirdparty/bsd-simplified.LICENSE deleted file mode 100644 index f1fd48f7..00000000 --- a/etc/thirdparty/bsd-simplified.LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/etc/thirdparty/isc.LICENSE b/etc/thirdparty/isc.LICENSE deleted file mode 100644 index a169aff7..00000000 --- a/etc/thirdparty/isc.LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/etc/thirdparty/lgpl-2.1-plus.LICENSE b/etc/thirdparty/lgpl-2.1-plus.LICENSE deleted file mode 100644 index ab1cb2a3..00000000 --- a/etc/thirdparty/lgpl-2.1-plus.LICENSE +++ /dev/null @@ -1,325 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, 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 this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be introduced by others. - - Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those libraries into non-free programs. - - When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating system. - - Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must - be optional: if the application does not supply it, the square root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in these notices. - - Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies the executable. - - It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the Sections above. - - b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), -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 distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is -implemented by public license practices. Many people have made generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively -convey 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 library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! \ No newline at end of file diff --git a/etc/thirdparty/mit.LICENSE b/etc/thirdparty/mit.LICENSE deleted file mode 100644 index e662c786..00000000 --- a/etc/thirdparty/mit.LICENSE +++ /dev/null @@ -1,5 +0,0 @@ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/etc/thirdparty/python.LICENSE b/etc/thirdparty/python.LICENSE deleted file mode 100644 index 81829681..00000000 --- a/etc/thirdparty/python.LICENSE +++ /dev/null @@ -1,192 +0,0 @@ -PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 --------------------------------------------- - -1. This LICENSE AGREEMENT is between the Python Software Foundation -("PSF"), and the Individual or Organization ("Licensee") accessing and -otherwise using this software ("Python") in source or binary form and -its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, PSF -hereby grants Licensee a nonexclusive, royalty-free, world-wide -license to reproduce, analyze, test, perform and/or display publicly, -prepare derivative works, distribute, and otherwise use Python -alone or in any derivative version, provided, however, that PSF's -License Agreement and PSF's notice of copyright, i.e., "Copyright (c) -2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation; All Rights -Reserved" are retained in Python alone or in any derivative version -prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to Python. - -4. PSF is making Python available to Licensee on an "AS IS" -basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON -FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS -A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any -relationship of agency, partnership, or joint venture between PSF and -Licensee. This License Agreement does not grant permission to use PSF -trademarks or trade name in a trademark sense to endorse or promote -products or services of Licensee, or any third party. - -8. By copying, installing or otherwise using Python, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - -BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 -------------------------------------------- - -BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 - -1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an -office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the -Individual or Organization ("Licensee") accessing and otherwise using -this software in source or binary form and its associated -documentation ("the Software"). - -2. Subject to the terms and conditions of this BeOpen Python License -Agreement, BeOpen hereby grants Licensee a non-exclusive, -royalty-free, world-wide license to reproduce, analyze, test, perform -and/or display publicly, prepare derivative works, distribute, and -otherwise use the Software alone or in any derivative version, -provided, however, that the BeOpen Python License is retained in the -Software, alone or in any derivative version prepared by Licensee. - -3. BeOpen is making the Software available to Licensee on an "AS IS" -basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE -SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS -AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY -DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -5. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -6. This License Agreement shall be governed by and interpreted in all -respects by the law of the State of California, excluding conflict of -law provisions. Nothing in this License Agreement shall be deemed to -create any relationship of agency, partnership, or joint venture -between BeOpen and Licensee. This License Agreement does not grant -permission to use BeOpen trademarks or trade names in a trademark -sense to endorse or promote products or services of Licensee, or any -third party. As an exception, the "BeOpen Python" logos available at -http://www.pythonlabs.com/logos.html may be used according to the -permissions granted on that web page. - -7. By copying, installing or otherwise using the software, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - -CNRI OPEN SOURCE LICENSE AGREEMENT (for Python 1.6b1) --------------------------------------------------- - -IMPORTANT: PLEASE READ THE FOLLOWING AGREEMENT CAREFULLY. - -BY CLICKING ON "ACCEPT" WHERE INDICATED BELOW, OR BY COPYING, -INSTALLING OR OTHERWISE USING PYTHON 1.6, beta 1 SOFTWARE, YOU ARE -DEEMED TO HAVE AGREED TO THE TERMS AND CONDITIONS OF THIS LICENSE -AGREEMENT. - -1. This LICENSE AGREEMENT is between the Corporation for National -Research Initiatives, having an office at 1895 Preston White Drive, -Reston, VA 20191 ("CNRI"), and the Individual or Organization -("Licensee") accessing and otherwise using Python 1.6, beta 1 -software in source or binary form and its associated documentation, -as released at the www.python.org Internet site on August 4, 2000 -("Python 1.6b1"). - -2. Subject to the terms and conditions of this License Agreement, CNRI -hereby grants Licensee a non-exclusive, royalty-free, world-wide -license to reproduce, analyze, test, perform and/or display -publicly, prepare derivative works, distribute, and otherwise use -Python 1.6b1 alone or in any derivative version, provided, however, -that CNRIs License Agreement is retained in Python 1.6b1, alone or -in any derivative version prepared by Licensee. - -Alternately, in lieu of CNRIs License Agreement, Licensee may -substitute the following text (omitting the quotes): "Python 1.6, -beta 1, is made available subject to the terms and conditions in -CNRIs License Agreement. This Agreement may be located on the -Internet using the following unique, persistent identifier (known -as a handle): 1895.22/1011. This Agreement may also be obtained -from a proxy server on the Internet using the -URL:http://hdl.handle.net/1895.22/1011". - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python 1.6b1 or any part thereof, and wants to make -the derivative work available to the public as provided herein, -then Licensee hereby agrees to indicate in any such work the nature -of the modifications made to Python 1.6b1. - -4. CNRI is making Python 1.6b1 available to Licensee on an "AS IS" -basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR -FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6b1 -WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. - -5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE -SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR -LOSS AS A RESULT OF USING, MODIFYING OR DISTRIBUTING PYTHON 1.6b1, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY -THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. This License Agreement shall be governed by and interpreted in all -respects by the law of the State of Virginia, excluding conflict of -law provisions. Nothing in this License Agreement shall be deemed -to create any relationship of agency, partnership, or joint venture -between CNRI and Licensee. This License Agreement does not grant -permission to use CNRI trademarks or trade name in a trademark -sense to endorse or promote products or services of Licensee, or -any third party. - -8. By clicking on the "ACCEPT" button where indicated, or by copying, -installing or otherwise using Python 1.6b1, Licensee agrees to be -bound by the terms and conditions of this License Agreement. - -ACCEPT - -CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 --------------------------------------------------- - -Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, -The Netherlands. All rights reserved. - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/etc/thirdparty/virtualenv.pyz b/etc/thirdparty/virtualenv.pyz deleted file mode 100644 index f89a8ead..00000000 Binary files a/etc/thirdparty/virtualenv.pyz and /dev/null differ diff --git a/etc/thirdparty/virtualenv.pyz.ABOUT b/etc/thirdparty/virtualenv.pyz.ABOUT deleted file mode 100644 index 9305787e..00000000 --- a/etc/thirdparty/virtualenv.pyz.ABOUT +++ /dev/null @@ -1,13 +0,0 @@ -about_resource: virtualenv.pyz -name: get-virtualenv -version: 20.16.5 -download_url: https://github.com/pypa/get-virtualenv/raw/20.16.5/public/virtualenv.pyz -description: virtualenv is a tool to create isolated Python environments. -homepage_url: https://github.com/pypa/virtualenv -license_expression: lgpl-2.1-plus AND (bsd-new OR apache-2.0) AND mit AND python AND bsd-new - AND apache-2.0 AND isc AND (bsd-simplified OR apache-2.0) -copyright: Copyright (c) The Python Software Foundation and others -redistribute: yes -attribute: yes -track_changes: yes -package_url: pkg:github/pypa/get-virtualenv@20.16.5#public/virtualenv.pyz \ No newline at end of file diff --git a/minecode/collectors/__init__.py b/minecode/collectors/__init__.py new file mode 100644 index 00000000..2eb8f9f0 --- /dev/null +++ b/minecode/collectors/__init__.py @@ -0,0 +1,8 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# purldb is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/purldb for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# diff --git a/minecode/collectors/maven.py b/minecode/collectors/maven.py new file mode 100644 index 00000000..aab631fb --- /dev/null +++ b/minecode/collectors/maven.py @@ -0,0 +1,95 @@ +from dateutil.parser import parse as dateutil_parse +from minecode.visitors.maven import get_artifacts, is_worthy_artifact, build_url_and_filename +from packagedcode.maven import get_urls +from minecode.utils import fetch_http, get_temp_file +from packagedcode.models import PackageData + + +MAVEN_INDEX_URL = 'https://repo1.maven.org/maven2/.index/nexus-maven-repository-index.gz' + + +class MavenNexusCollector: + """ + Download and process a Nexus Maven index file. + WARNING: Processing is rather long: a full index is ~600MB. + """ + + def fetch_index(self, uri=MAVEN_INDEX_URL, timeout=10): + """ + Return a temporary location where the fetched content was saved. + Does not return the content proper as a regular fetch does. + + `timeout` is a default timeout. + """ + content = fetch_http(uri, timeout=timeout) + temp_file = get_temp_file('NonPersistentHttpVisitor') + with open(temp_file, 'wb') as tmp: + tmp.write(content) + return temp_file + + def get_packages(self, content=None): + """ + Yield Package objects from maven index + """ + if content: + index_location = content + else: + index_location = self.fetch_index() + + artifacts = get_artifacts(index_location, worthyness=is_worthy_artifact) + + for artifact in artifacts: + # we cannot do much without these + group_id = artifact.group_id + artifact_id = artifact.artifact_id + version = artifact.version + extension = artifact.extension + + if not (group_id and artifact_id and version and extension): + continue + + qualifiers = {} + if extension and extension != 'jar': + qualifiers['type'] = extension + + classifier = artifact.classifier + if classifier: + qualifiers['classifier'] = classifier + + # FIXME: also use the Artifact.src_exist flags too? + + # build a URL: This is the real JAR download URL + # FIXME: this should be set at the time of creating Artifacts + # instead togther with the filename... especially we could use + # different REPOs. + jar_download_url, _ = build_url_and_filename( + group_id, artifact_id, version, extension, classifier) + + # FIXME: should this be set in the yielded URI too + last_mod = artifact.last_modified + + urls = get_urls( + namespace=group_id, + name=artifact_id, + version=version, + qualifiers=qualifiers or None, + ) + + repository_homepage_url = urls['repository_homepage_url'] + repository_download_url = urls['repository_download_url'] + api_data_url = urls['api_data_url'] + + yield PackageData( + type='maven', + namespace=group_id, + name=artifact_id, + version=version, + qualifiers=qualifiers or None, + download_url=jar_download_url, + size=artifact.size, + sha1=artifact.sha1, + release_date=last_mod, + repository_homepage_url=repository_homepage_url, + repository_download_url=repository_download_url, + api_data_url=api_data_url, + ) diff --git a/minecode/management/commands/update_maven_package_data.py b/minecode/management/commands/update_maven_package_data.py new file mode 100644 index 00000000..0106364d --- /dev/null +++ b/minecode/management/commands/update_maven_package_data.py @@ -0,0 +1,366 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# purldb is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/purldb for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# +from dateutil.parser import parse as dateutil_parse +from os.path import basename +import logging +import sys +import traceback + +from django.db import transaction +from django.db.utils import DataError +from django.utils import timezone +from packageurl import normalize_qualifiers + +from minecode.collectors.maven import MavenNexusCollector +from minecode.management.commands import VerboseCommand +from minecode.models import ProcessingError +from packagedb.models import Package + +DEFAULT_TIMEOUT = 30 + +TRACE = False + +logger = logging.getLogger(__name__) +logging.basicConfig(stream=sys.stdout) +logger.setLevel(logging.INFO) + + +def update_packages(packages, fields_to_update): + try: + with transaction.atomic(): + Package.objects.bulk_update( + objs=packages, + fields=fields_to_update + ) + updated_packages_count = len(packages) + except DataError: + updated_packages_count = 0 + with transaction.atomic(): + # Update each record individually and then try to catch the package causing problems + for package in packages: + try: + package.save() + updated_packages_count += 1 + except DataError: + service = basename(__file__) + traceback_message = traceback.format_exc() + message = f'Error updating Package {package.package_uid}:\n\n{traceback_message}' + ProcessingError.objects.create( + service=service, + date=timezone.now(), + error_message=message, + ) + logger.error(message) + finally: + return updated_packages_count + + +def create_packages(packages): + try: + with transaction.atomic(): + Package.objects.bulk_create(packages) + created_packages_count = len(packages) + except DataError: + created_packages_count = 0 + for package in packages: + try: + package.save() + created_packages_count += 1 + except DataError: + service = basename(__file__) + traceback_message = traceback.format_exc() + message = f'Error creating Package {package.purl}:\n\n{traceback_message}' + ProcessingError.objects.create( + service=service, + date=timezone.now(), + error_message=message, + ) + logger.error(message) + finally: + return created_packages_count + + +def delete_packages(packages): + package_pks_to_delete = [p.pk for p in packages] + Package.objects.filter(pk__in=package_pks_to_delete).delete() + deleted_packages_count = len(packages) + return deleted_packages_count + + +def process_packages( + unsaved_existing_packages, + unsaved_existing_packages_lowercased, + unsaved_new_packages, + packages_to_delete, + updated_packages_count, + created_packages_count, + deleted_packages_count, +): + updated = False + if unsaved_existing_packages: + fields_to_update = [ + 'download_url', + 'repository_homepage_url', + 'repository_download_url', + 'api_data_url', + 'release_date', + 'last_modified_date', + 'history', + ] + upc = update_packages(unsaved_existing_packages, fields_to_update) + updated_packages_count += upc + unsaved_existing_packages = [] + if upc > 0: + updated = True + + if unsaved_existing_packages_lowercased: + fields_to_update=[ + 'namespace', + 'name', + 'version', + 'qualifiers', + 'download_url', + 'repository_homepage_url', + 'repository_download_url', + 'api_data_url', + 'release_date', + 'last_modified_date', + 'history', + ] + upc = update_packages(unsaved_existing_packages_lowercased, fields_to_update) + updated_packages_count += upc + unsaved_existing_packages_lowercased = [] + if upc > 0: + updated = True + + if updated: + logger.info(f'Updated {updated_packages_count:,} Maven Packages') + + if unsaved_new_packages: + cpc = create_packages(unsaved_new_packages) + created_packages_count += cpc + unsaved_new_packages = [] + if cpc > 0: + logger.info(f'Created {created_packages_count:,} Maven Packages') + + if packages_to_delete: + dpc = delete_packages(packages_to_delete) + packages_to_delete = [] + deleted_packages_count += dpc + if dpc > 0: + logger.info(f'Deleted {deleted_packages_count:,} Duplicate Maven Packages') + + return unsaved_existing_packages, unsaved_existing_packages_lowercased, unsaved_new_packages, packages_to_delete + + +def update_package_fields(package, maven_package, field_names): + updated_fields = [] + for field in field_names: + p_val = getattr(package, field) + value = getattr(maven_package, field) + if field == 'qualifiers': + value = normalize_qualifiers(value, encode=True) + if field == 'release_date': + value = dateutil_parse(value) + if p_val != value: + setattr(package, field, value) + if field == 'release_date': + p_val = str(p_val) + value = str(value) + entry = dict( + field=field, + old_value=p_val, + new_value=value, + ) + updated_fields.append(entry) + + if updated_fields: + data = { + 'updated_fields': updated_fields, + } + package.append_to_history( + 'Package field values have been updated.', + data=data, + ) + logger.debug(f'Updated existing Package {package.package_uid}') + return package + + +def update_maven_packages(maven_package, fields_to_update, lowercased_purl_fields=False): + namespace = maven_package.namespace + name = maven_package.name + version = maven_package.version + normalized_qualifiers = normalize_qualifiers(maven_package.qualifiers, encode=True) + + if lowercased_purl_fields: + namespace = namespace.lower() + name = name.lower() + version = version.lower() + normalize_qualifiers = normalize_qualifiers.lower() + + existing_packages = Package.objects.filter( + type='maven', + namespace=namespace, + name=name, + version=version, + qualifiers=normalized_qualifiers or '' + ) + if existing_package.exists(): + duplicate_packages = [] + for existing_package in existing_packages: + if existing_package.download_url != maven_package.download_url: + logger.debug(f'Deleted duplicate Package with incorrect download URL {existing_package.package_uid}') + duplicate_packages.append(existing_package) + + duplicate_packages_pks = [p.pk for p in duplicate_packages] + existing_package = Package.objects.exclude( + pk__in=duplicate_packages_pks + ).get_or_none( + type='maven', + namespace=namespace, + name=name, + version=version, + qualifiers=normalized_qualifiers or '' + ) + if existing_package: + existing_package = update_package_fields( + existing_package, + maven_package, + fields_to_update + ) + return existing_package, duplicate_packages + else: + return None, [] + + +class Command(VerboseCommand): + help = 'Update maven Package values' + + def add_arguments(self, parser): + parser.add_argument( + '--create_package', + type=bool, + help='Create new Maven Packages if it does not exist in our database' + ) + + def handle(self, *args, **options): + create_package = options.get('create_package', False) + updated_packages_count = 0 + created_packages_count = 0 + deleted_packages_count = 0 + unsaved_new_packages = [] + unsaved_existing_packages = [] + unsaved_existing_packages_lowercased = [] + packages_to_delete = [] + + logger.info('Updating or Adding new Packages from Maven Index') + collector = MavenNexusCollector() + for i, maven_package in enumerate(collector.get_packages()): + if not i % 1000: + logger.info(f'Processed {i:,} Maven Artifacts') + if not i % 2000: + ( + unsaved_existing_packages, + unsaved_existing_packages_lowercased, + unsaved_new_packages, + packages_to_delete, + updated_packages_count, + created_packages_count, + deleted_packages_count, + ) = process_packages( + unsaved_existing_packages=unsaved_existing_packages, + unsaved_existing_packages_lowercased=unsaved_existing_packages_lowercased, + unsaved_new_packages=unsaved_new_packages, + packages_to_delete=packages_to_delete, + updated_packages_count=updated_packages_count, + created_packages_count=created_packages_count, + deleted_packages_count=deleted_packages_count, + ) + + fields_to_update = [ + 'download_url', + 'repository_homepage_url', + 'repository_download_url', + 'api_data_url', + 'release_date', + ] + existing_package, duplicate_packages = update_maven_packages( + maven_package, + fields_to_update + ) + if existing_package: + unsaved_existing_packages.append(existing_package) + packages_to_delete.extend(duplicate_packages) + continue + + fields_to_update = [ + 'namespace', + 'name', + 'version', + 'qualifiers', + 'download_url', + 'repository_homepage_url', + 'repository_download_url', + 'api_data_url', + 'release_date', + ] + existing_package_lowercased, duplicate_packages = update_maven_packages( + maven_package, + fields_to_update, + lowercased_purl_fields=True + ) + if existing_package_lowercased: + unsaved_existing_packages_lowercased.append(existing_package_lowercased) + packages_to_delete.extend(duplicate_packages) + continue + + if Package.objects.filter(download_url=maven_package.download_url).exists(): + logger.debug(f'Skipping creation of {maven_package.purl} - already exists') + continue + + if create_package: + normalized_qualifiers = normalize_qualifiers( + maven_package.qualifiers, + encode=True + ) + new_package = Package( + type=maven_package.type, + namespace=maven_package.namespace, + name=maven_package.name, + version=maven_package.version, + qualifiers=normalized_qualifiers or '', + download_url=maven_package.download_url, + size=maven_package.size, + sha1=maven_package.sha1, + release_date=dateutil_parse(maven_package.release_date), + repository_homepage_url=maven_package.repository_homepage_url, + repository_download_url=maven_package.repository_download_url, + api_data_url=maven_package.api_data_url, + ) + new_package.created_date = timezone.now() + unsaved_new_packages.append(new_package) + logger.debug(f'Created Package {maven_package.purl}') + + ( + unsaved_existing_packages, + unsaved_existing_packages_lowercased, + unsaved_new_packages, + packages_to_delete, + updated_packages_count, + created_packages_count, + deleted_packages_count, + ) = process_packages( + unsaved_existing_packages=unsaved_existing_packages, + unsaved_existing_packages_lowercased=unsaved_existing_packages_lowercased, + unsaved_new_packages=unsaved_new_packages, + packages_to_delete=packages_to_delete, + updated_packages_count=updated_packages_count, + created_packages_count=created_packages_count, + deleted_packages_count=deleted_packages_count, + ) diff --git a/minecode/migrations/0037_processingerror.py b/minecode/migrations/0037_processingerror.py new file mode 100644 index 00000000..bd4b759a --- /dev/null +++ b/minecode/migrations/0037_processingerror.py @@ -0,0 +1,155 @@ +# Generated by Django 4.1.2 on 2023-11-06 19:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("minecode", "0036_priorityresourceuri_addon_pipelines"), + ] + + operations = [ + migrations.CreateModel( + name="ProcessingError", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "uri", + models.CharField( + db_index=True, + help_text="URI for this resource. This is the unmodified original URI.", + max_length=2048, + ), + ), + ( + "canonical", + models.CharField( + db_index=True, + help_text="Canonical form of the URI for this resource that must be unique across all ResourceURI.", + max_length=3000, + ), + ), + ( + "source_uri", + models.CharField( + blank=True, + help_text="Optional: real source remote URI for this visit.For example for a package repository index is a typical source via which a first level of package data is fetched. And it is not the URI in the uri field. It is just the source of the fetchOr the source may be a mirror URI used for fetching.", + max_length=2048, + null=True, + ), + ), + ( + "priority", + models.PositiveIntegerField( + db_index=True, + default=0, + help_text="Absolute procdssing priority of a URI (default to zero), higher number means higher priority, zero means lowest priority.", + ), + ), + ( + "wip_date", + models.DateTimeField( + blank=True, + db_index=True, + help_text="Work In Progress. This is a timestamp set at the start of a visit or mapping or indexing or null when no processing is in progress.", + null=True, + ), + ), + ( + "file_name", + models.CharField( + blank=True, + db_index=True, + help_text="File name of a resource sometimes part of the URI proper and sometimes only available through an HTTP header.", + max_length=255, + null=True, + ), + ), + ( + "size", + models.PositiveIntegerField( + blank=True, + db_index=True, + help_text="Size in bytes of the file represented by this ResourceURI.", + null=True, + ), + ), + ( + "sha1", + models.CharField( + blank=True, + db_index=True, + help_text="SHA1 checksum hex-encoded (as in the sha1sum command) of the content of the file represented by this ResourceURI.", + max_length=40, + null=True, + ), + ), + ( + "md5", + models.CharField( + blank=True, + db_index=True, + help_text="MD5 checksum hex-encoded (as in the md5sum command) of the content of the file represented by this ResourceURI.", + max_length=32, + null=True, + ), + ), + ( + "sha256", + models.CharField( + blank=True, + db_index=True, + help_text="SHA256 checksum hex-encoded (as in the sha256sum command) of the content of the file represented by this ResourceURI.", + max_length=64, + null=True, + ), + ), + ( + "last_modified_date", + models.DateTimeField( + blank=True, + db_index=True, + help_text="Timestamp set to the last modified date of the remote resource represented by this URI such as the modified date of a file, the lastmod value on a sitemap or the modified date returned by an HTTP resource.", + null=True, + ), + ), + ( + "service", + models.CharField( + blank=True, + help_text="The name of the service running where the error occured.", + max_length=100, + null=True, + ), + ), + ( + "date", + models.DateTimeField( + blank=True, + db_index=True, + help_text="Timestamp set to the date of when this error occured.", + null=True, + ), + ), + ( + "error_message", + models.TextField( + blank=True, + help_text="The message associated with this error", + null=True, + ), + ), + ], + options={ + "verbose_name": "Processing Error", + }, + ), + ] diff --git a/minecode/models.py b/minecode/models.py index 9e8f2e00..50c6c513 100644 --- a/minecode/models.py +++ b/minecode/models.py @@ -1089,3 +1089,28 @@ def save(self, *args, **kwargs): """ self.normalize_fields() super(ImportableURI, self).save(*args, **kwargs) + + +class ProcessingError(BaseURI): + service = models.CharField( + max_length=100, + null=True, + blank=True, + help_text='The name of the service running where the error occured.' + ) + + date = models.DateTimeField( + null=True, + blank=True, + db_index=True, + help_text='Timestamp set to the date of when this error occured.', + ) + + error_message = models.TextField( + null=True, + blank=True, + help_text='The message associated with this error' + ) + + class Meta: + verbose_name = 'Processing Error' diff --git a/minecode/tests/test_apache.py b/minecode/tests/test_apache.py index a3ddca9c..918a120c 100644 --- a/minecode/tests/test_apache.py +++ b/minecode/tests/test_apache.py @@ -43,8 +43,8 @@ def test_ApacheChecksumVisitor(self): mock_http_get.return_value = mocked_requests_get(uri, test_loc) uris, data, _ = apache.ApacheChecksumVisitor(uri) - self.assertEquals(None, uris) - self.assertEquals(b'0b5f2c334916c289f06c03f8577a9879', data) + self.assertEqual(None, uris) + self.assertEqual(b'0b5f2c334916c289f06c03f8577a9879', data) def test_ApacheChecksumVisitor_2(self): uri = 'http://archive.apache.org/dist/groovy/2.4.6/distribution/apache-groovy-docs-2.4.6.zip.md5' diff --git a/minecode/tests/test_cran.py b/minecode/tests/test_cran.py index 2534cbbf..ea2733fe 100644 --- a/minecode/tests/test_cran.py +++ b/minecode/tests/test_cran.py @@ -61,4 +61,4 @@ def test_replace_downloadurl(self): url = "../../../src/contrib/Archive/ANN2" result = get_download_url(url) expected_url = 'https://cloud.r-project.org/src/contrib/Archive/ANN2' - self.assertEquals(expected_url, result) + self.assertEqual(expected_url, result) diff --git a/minecode/tests/test_debian.py b/minecode/tests/test_debian.py index ea3b93c4..881d7b16 100644 --- a/minecode/tests/test_debian.py +++ b/minecode/tests/test_debian.py @@ -121,22 +121,22 @@ def test_parse_deb822_dsc(self): def test_parse_email(self): content = 'Debian TeX Maintainers ' name, email = debutils.parse_email(content) - self.assertEquals('Debian TeX Maintainers', name) - self.assertEquals('debian-tex-maint@lists.debian.org', email) + self.assertEqual('Debian TeX Maintainers', name) + self.assertEqual('debian-tex-maint@lists.debian.org', email) def test_parse_email_2(self): # Space left Purposefully content = ' Debian TeX Maintainers ' name, email = debutils.parse_email(content) - self.assertEquals('Debian TeX Maintainers', name) - self.assertEquals(None, email) + self.assertEqual('Debian TeX Maintainers', name) + self.assertEqual(None, email) def test_parse_email_3(self): # Space left Purposefully content = '< debian-tex-maint@lists.debian.org >' name, email = debutils.parse_email(content) - self.assertEquals(None, name) - self.assertEquals("debian-tex-maint@lists.debian.org", email) + self.assertEqual(None, name) + self.assertEqual("debian-tex-maint@lists.debian.org", email) def test_comma_separated(self): tags = 'implemented-in::perl, role::program, use::converting, works-with::pim' @@ -209,7 +209,7 @@ def test_parse_copyright_allinfo_basic(self): 'copyright': 'Copyright 1998 Jane Doe ' } ] - self.assertEquals(expected, copyright_data) + self.assertEqual(expected, copyright_data) @expectedFailure def test_parse_copyright_allinfo_with_invalid_file(self): @@ -399,11 +399,11 @@ def test_get_dependencies(self): } keys = ['build1', 'build2'] result = debian_mapper.get_dependencies(test, keys) - self.assertEquals(2, len(result)) - self.assertEquals('build', result[0].purl) - self.assertEquals(None, result[0].requirement) - self.assertEquals('build2', result[1].purl) - self.assertEquals(None, result[1].requirement) + self.assertEqual(2, len(result)) + self.assertEqual('build', result[0].purl) + self.assertEqual(None, result[0].requirement) + self.assertEqual('build2', result[1].purl) + self.assertEqual(None, result[1].requirement) def test_get_programming_language(self): tags = ['role::program', 'implemented-in::perl', 'use::converting', 'works-with::pim'] diff --git a/minecode/tests/test_eclipse.py b/minecode/tests/test_eclipse.py index 8a0755c2..58c4e947 100644 --- a/minecode/tests/test_eclipse.py +++ b/minecode/tests/test_eclipse.py @@ -43,7 +43,7 @@ def test_visit_eclipse_project(self): mock_http_get.return_value = mocked_requests_get(uri, test_loc) _, data, _ = eclipse.EclipseSingleProjectVisitor(uri) with open(self.get_test_loc('eclipse/acceleo_expected.html'), 'rb') as data_file: - self.assertEquals(data_file.read(), data) + self.assertEqual(data_file.read(), data) def test_visit_eclipse_git_repo(self): uri = 'http://git.eclipse.org/c' diff --git a/minecode/tests/test_maven.py b/minecode/tests/test_maven.py index db6e0fee..1c3173b2 100644 --- a/minecode/tests/test_maven.py +++ b/minecode/tests/test_maven.py @@ -946,7 +946,7 @@ def test_url_parts(self): scheme, netloc, path_segments = maven_visitor.url_parts(url) self.assertEqual('https', scheme) self.assertEqual('example.com', netloc) - self.assertEquals(['foo', 'bar', 'baz.jar'], path_segments) + self.assertEqual(['foo', 'bar', 'baz.jar'], path_segments) def test_create_url(self): scheme = 'https' diff --git a/minecode/tests/test_migrations.py b/minecode/tests/test_migrations.py index bfe732dd..31f04c86 100644 --- a/minecode/tests/test_migrations.py +++ b/minecode/tests/test_migrations.py @@ -85,7 +85,7 @@ def test_populate_has_error_fields(self): 'visit_error': None }, ] - self.assertEquals(results, expected) + self.assertEqual(results, expected) class TestSetIsVisitableForMavenIndexURIs(TestMigrations): @@ -130,7 +130,7 @@ def test_set_is_visitable_for_maven_index_uris(self): 'uri': 'maven-index://repo1.maven.org/zone/src/sheaf/logback-sheaf/1.1.7/logback-sheaf-1.1.7.jar' } ] - self.assertEquals(results, expected) + self.assertEqual(results, expected) class TestSetIsVisitableForMavenIndexURIs(TestMigrations): app_name = "minecode" @@ -174,7 +174,7 @@ def test_set_is_visitable_for_maven_index_uris(self): 'uri': 'maven-index://repo1.maven.org/zone/src/sheaf/logback-sheaf/1.1.7/logback-sheaf-1.1.7.jar' } ] - self.assertEquals(results, expected) + self.assertEqual(results, expected) class TestReplaceHttpWithHttpsInMavenURIs(TestMigrations): @@ -214,4 +214,4 @@ def test_replace_http_with_https_in_maven_uris(self): 'uri': 'https://repo1.maven.org/maven2/xyz/upperlevel/command/spigot/spigot-command-api/1.1.1/spigot-command-api-1.1.1.pom' } ] - self.assertEquals(results, expected) + self.assertEqual(results, expected) diff --git a/minecode/tests/test_rsync.py b/minecode/tests/test_rsync.py index 21a72472..4a4f5f3e 100644 --- a/minecode/tests/test_rsync.py +++ b/minecode/tests/test_rsync.py @@ -24,7 +24,7 @@ def test_modules(self): output = list(rsync.modules(inp)) expected = '''apache CPAN CTAN eclipse flightgear gnualpha gnuftp mozdev mozilla opencsw simgear sugar xemacs'''.split() - self.assertEquals(expected, output) + self.assertEqual(expected, output) def test_entry_rsync_31(self): # $ rsync --no-motd --recursive rsync/rsync_dir/ @@ -47,7 +47,7 @@ def test_entry_rsync_31(self): for test, exp in zip(lines, expected): result = rsync.entry(test) - self.assertEquals(exp, result) + self.assertEqual(exp, result) def test_entry(self): lines = [ @@ -68,7 +68,7 @@ def test_entry(self): for test, exp in zip(lines, expected): result = rsync.entry(test) - self.assertEquals(exp, result) + self.assertEqual(exp, result) def test_directory(self): test_dir = self.get_test_loc('rsync/rsync_wicket.dir') @@ -98,7 +98,7 @@ def test_directory(self): rsync.Entry(type='-', perm='rw-rw-r--', size=29890658, date='2014-02-14T15:51:23+00:00', path='6.14.0/binaries/apache-wicket-6.14.0-bin.zip') ] expected = [dict(x._asdict()) for x in expected] - self.assertEquals(expected, output) + self.assertEqual(expected, output) def test_directory_weird_file_types_are_ignored(self): self.maxDiff = None @@ -106,7 +106,7 @@ def test_directory_weird_file_types_are_ignored(self): output = rsync.directory_entries(inp) results = [e['path'] for e in output if e['type'] == '-'] expected = ['dev/.udev/rules.d/root.rules'] - self.assertEquals(expected, results) + self.assertEqual(expected, results) @skipIf(ON_WINDOWS, 'rsync is not available on windows') def test_fetch_directory(self): diff --git a/minecode/tests/test_rubygems.py b/minecode/tests/test_rubygems.py index 49f36f37..2deb3ea1 100644 --- a/minecode/tests/test_rubygems.py +++ b/minecode/tests/test_rubygems.py @@ -105,7 +105,7 @@ def test_RubyGemsPackageArchiveMetadataVisitor(self): _, data, _ = RubyGemsPackageArchiveMetadataVisitor(uri) expected_loc = self.get_test_loc('rubygems/a_okay-0.1.0.gem.metadata') with open(expected_loc) as expect_file: - self.assertEquals(expect_file.read(), data) + self.assertEqual(expect_file.read(), data) class RubyGemsApiMapperTest(JsonBasedTesting): diff --git a/minecode/tests/test_run_map.py b/minecode/tests/test_run_map.py index e3738638..e269bbbe 100644 --- a/minecode/tests/test_run_map.py +++ b/minecode/tests/test_run_map.py @@ -306,7 +306,7 @@ def mock_mapper(uri, resource_uri): def test_run_map_command(self): output = StringIO() management.call_command('run_map', exit_on_empty=True, stdout=output) - self.assertEquals('', output.getvalue()) + self.assertEqual('', output.getvalue()) def test_map_uri_does_update_with_same_mining_level(self): # setup diff --git a/minecode/tests/test_run_visit.py b/minecode/tests/test_run_visit.py index 9ff51287..73e200c5 100644 --- a/minecode/tests/test_run_visit.py +++ b/minecode/tests/test_run_visit.py @@ -474,7 +474,7 @@ def test_run_visit_command(self): output = StringIO() management.call_command('run_visit', exit_on_empty=True, stdout=output) expected = 'Visited 0 URIs\nInserted 0 new URIs\n' - self.assertEquals(expected, output.getvalue()) + self.assertEqual(expected, output.getvalue()) def test_visit_uri_always_inserts_new_uri(self): # test proper diff --git a/minecode/tests/test_tasks.py b/minecode/tests/test_tasks.py index 4a5e880f..557c7689 100644 --- a/minecode/tests/test_tasks.py +++ b/minecode/tests/test_tasks.py @@ -52,7 +52,7 @@ def test_minecode_tasks_process_scan_results(self, mock_delete): self.assertFalse(self.package1.size) self.assertFalse(self.package1.declared_license_expression) self.assertFalse(self.package1.copyright) - self.assertEquals(0, self.package1.resources.count()) + self.assertEqual(0, self.package1.resources.count()) scan_file_location = self.get_test_loc('scancodeio/get_scan_data.json') summary_file_location = self.get_test_loc('scancodeio/scan_summary_response.json') project_extra_data = json.dumps(self.project_extra_data1) diff --git a/minecode/utils.py b/minecode/utils.py index 7034ea52..51dd20fa 100644 --- a/minecode/utils.py +++ b/minecode/utils.py @@ -7,7 +7,7 @@ # See https://aboutcode.org for more information about nexB OSS projects. # - +import copy import hashlib import logging import os @@ -391,3 +391,27 @@ def validate_uuid(uuid_string): except ValueError: return False return str(val).lower() == uuid_string.lower() + + +# This is from https://stackoverflow.com/questions/4856882/limiting-memory-use-in-a-large-django-queryset/5188179#5188179 +class MemorySavingQuerysetIterator(object): + def __init__(self,queryset,max_obj_num=1000): + self._base_queryset = queryset + self._generator = self._setup() + self.max_obj_num = max_obj_num + + def _setup(self): + for i in range(0,self._base_queryset.count(),self.max_obj_num): + # By making a copy of of the queryset and using that to actually access + # the objects we ensure that there are only `max_obj_num` objects in + # memory at any given time + smaller_queryset = copy.deepcopy(self._base_queryset)[i:i+self.max_obj_num] + logger.debug('Grabbing next %s objects from DB' % self.max_obj_num) + for obj in smaller_queryset.iterator(): + yield obj + + def __iter__(self): + return self._generator + + def next(self): + return self._generator.next() diff --git a/packagedb/management/commands/fix_purl_values.py b/packagedb/management/commands/fix_purl_values.py new file mode 100644 index 00000000..440a1ea9 --- /dev/null +++ b/packagedb/management/commands/fix_purl_values.py @@ -0,0 +1,200 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# purldb is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/purldb for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + +from dateutil.parser import parse as dateutil_parse +import copy +import logging +import sys + +from urllib3.util import Retry +from packageurl import PackageURL +from packagedcode.maven import get_urls, build_filename +from requests import Session +from requests.adapters import HTTPAdapter +import requests + +from minecode.management.commands import VerboseCommand +from minecode.utils import MemorySavingQuerysetIterator +from minecode.visitors.maven import collect_links_from_text +from minecode.visitors.maven import filter_for_artifacts +from packagedb.models import Package + +DEFAULT_TIMEOUT = 30 + +TRACE = False + +logger = logging.getLogger(__name__) +logging.basicConfig(stream=sys.stdout) +logger.setLevel(logging.INFO) + +session = Session() +session.mount('https://', HTTPAdapter(max_retries=Retry(10))) +headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36', +} + + +def get_timestamps_by_links(package_version_page_url): + timestamps_by_links = {} + response = requests.get(package_version_page_url) + if response: + timestamps_by_links = collect_links_from_text(response.text, filter=filter_for_artifacts) + timestamps_by_links = { + link: dateutil_parse(timestamp) for link, timestamp in timestamps_by_links.items() + } + return timestamps_by_links + + +class MavenArtifact(object): + def __init__(self, namespace, name, version, qualifiers='', ec=[]): + type = 'maven' + self.type = type + self.namespace = namespace + self.name = name + self.version = version + self.qualifiers = qualifiers + self.package_url = PackageURL( + type=type, + namespace=namespace, + name=name, + version=version, + qualifiers=qualifiers + ) + urls = get_urls( + namespace=namespace, + name=name, + version=version, + qualifiers=self.package_url.qualifiers, + ) + self.download_url = urls['repository_download_url'] + self.repository_homepage_url = urls['repository_homepage_url'] + self.api_data_url = urls['api_data_url'] + + qualifiers_mapping = self.package_url.qualifiers + filename = build_filename( + artifact_id=name, + version=version, + extension=qualifiers_mapping.get('type') or 'jar', + classifier=qualifiers_mapping.get('classifier'), + ) + timestamps_by_links = get_timestamps_by_links(self.repository_homepage_url) + self.release_date = timestamps_by_links.get(filename) + self.related_artifacts = list( + self._populate_related_artifacts( + namespace=namespace, + name=name, + version=version, + ec=ec, + ) + ) + + @classmethod + def _populate_related_artifacts(cls, namespace, name, version, ec): + filtered_ec = [entry for entry in ec if not entry.startswith('.')] + for entry in filtered_ec: + _, ending = entry.split('-') + split_ending = ending.split('.') + classifier = None + if len(split_ending) > 0: + classifier = split_ending[0] + qualifiers = f'classifier={classifier}' + yield cls( + namespace=namespace, + name=name, + version=version, + qualifiers=qualifiers, + ) + + +def query_sha1_on_maven(sha1, timeout=DEFAULT_TIMEOUT): + maven_api_search_url = f'https://search.maven.org/solrsearch/select?q=1:{sha1}' + try: + response = session.get(maven_api_search_url, timeout=timeout) + response.raise_for_status() + except (requests.RequestException, ValueError, TypeError) as exception: + logger.debug(f"[Exception] {exception}") + return False + if not response.ok: + return f"API query failed for: {maven_api_search_url}" + contents = response.json() + resp = contents.get('response', {}) + matched_artifacts = [] + if resp.get('numFound', 0) > 0: + for matched_artifact in resp.get('docs', []): + namespace = matched_artifact.get('g', '') + name = matched_artifact.get('a', '') + version = matched_artifact.get('v', '') + ec = matched_artifact.get('ec', []) + if not namespace and name and version: + continue + matched_artifacts.append( + MavenArtifact( + namespace=namespace, + name=name, + version=version, + ec=ec, + ) + ) + return matched_artifacts + + +class Command(VerboseCommand): + help = 'Update maven Package download_url values' + + def handle(self, *args, **options): + maven_packages = Package.objects.filter(type='maven', sha1__is_null=False) + maven_packages_count = maven_packages.count() + logger.info(f'Checking {maven_packages_count:,} Maven Package PackageURL values') + packages_to_delete = [] + + for package in MemorySavingQuerysetIterator(maven_packages): + matched_artifacts = query_sha1_on_maven(package.sha1) + if not matched_artifacts: + # Remove this package from the database because it's not on maven + packages_to_delete.append(package) + for artifact in matched_artifacts: + artifact_namespace = artifact.namespace + artifact_name = artifact.name + artifact_version = artifact.version + artifact_qualifiers = artifact.qualifiers + + package_different_case = Package.objects.get_or_none( + namespace__iexact=artifact_namespace, + name__iexact=artifact_name, + version__iexact=artifact_version, + artifact_qualifiers__iexact=artifact_qualifiers, + ) + + # check to see if the artifact matches the current package + if ( + package.namespace == artifact_namespace + and package.name == artifact_name + and package.version == artifact_version + and package.qualifiers == artifact_qualifiers + ): + # check download url + if requests.head(package.download_url): + # Continue if it resolves + continue + else: + package.download_url = artifact.download_url + package.release_date = artifact.release_date + package.save() + elif package_different_case: + package_different_case.namespace = artifact_namespace + package_different_case.name = artifact_name + package_different_case.version = artifact_version + package_different_case.qualifiers = artifact_qualifiers + package_different_case.download_url = artifact.download_url + package_different_case.release_date = artifact.release_date + package_different_case.repository_homepage_url = artifact.repository_homepage_url + package_different_case.repository_download_url = artifact.repository_download_url + package_different_case.api_data_url = artifact.api_data_url + package_different_case.sha1 = package.sha1 + package_different_case.save() diff --git a/packagedb/models.py b/packagedb/models.py index f1069e45..139976db 100644 --- a/packagedb/models.py +++ b/packagedb/models.py @@ -66,7 +66,7 @@ def get_or_none(self, *args, **kwargs): """ try: return self.get(*args, **kwargs) - except self.model.DoesNotExist: + except Package.DoesNotExist: return def paginated(self, per_page=5000): diff --git a/packagedb/tests/test_api.py b/packagedb/tests/test_api.py index 7af3e1b2..a2983858 100644 --- a/packagedb/tests/test_api.py +++ b/packagedb/tests/test_api.py @@ -1206,7 +1206,7 @@ def test_api_purl_validation_empty_request(self): } } - self.assertAlmostEquals(expected, response.data) + self.assertAlmostEqual(expected, response.data) class PurlValidateApiTestCase(TestCase): @@ -1279,7 +1279,7 @@ def test_api_purl_validation_empty_request(self): } } - self.assertAlmostEquals(expected, response1.data) + self.assertAlmostEqual(expected, response1.data) class PackageWatchTestCase(TestCase): diff --git a/packagedb/tests/test_models.py b/packagedb/tests/test_models.py index 8cc10ff2..4353450f 100644 --- a/packagedb/tests/test_models.py +++ b/packagedb/tests/test_models.py @@ -151,8 +151,8 @@ def test_packagedb_package_model_get_latest_version(self): def test_packagedb_package_model_update_fields(self): p1 = Package.objects.create(download_url='http://a.a', name='name', version='1.0') self.assertFalse(p1.history) - self.assertEquals('', p1.namespace) - self.assertEquals(None, p1.homepage_url) + self.assertEqual('', p1.namespace) + self.assertEqual(None, p1.homepage_url) package, updated_fields = p1.update_fields(namespace='test', homepage_url='https://example.com') self.assertEqual( sorted(updated_fields), @@ -284,14 +284,14 @@ def test_packagedb_package_model_update_fields_special_cases(self): for entry in p1.history: entry.pop('timestamp') history.append(entry) - self.assertEquals(expected_history, history) + self.assertEqual(expected_history, history) def test_packagedb_package_model_update_fields_related_models(self): p1 = Package.objects.create(download_url='http://a.a', name='name', version='1.0') path = 'asdf' resources = [Resource(package=p1, path=path)] _, updated_fields = p1.update_fields(resources=resources) - self.assertEquals( + self.assertEqual( sorted(['resources', 'history']), sorted(updated_fields) ) @@ -341,7 +341,7 @@ def test_packagedb_package_model_update_fields_related_models(self): } ] _, updated_fields = p2.update_fields(resources=resources) - self.assertEquals( + self.assertEqual( sorted(['resources', 'history']), sorted(updated_fields) ) @@ -361,7 +361,7 @@ def test_packagedb_package_model_update_fields_related_models(self): ) ] _, updated_fields = p3.update_fields(parties=parties) - self.assertEquals( + self.assertEqual( sorted(['parties', 'history']), sorted(updated_fields) ) @@ -382,7 +382,7 @@ def test_packagedb_package_model_update_fields_related_models(self): ) ] _, updated_fields = p4.update_fields(parties=parties) - self.assertEquals( + self.assertEqual( sorted(['parties', 'history']), sorted(updated_fields) ) @@ -403,7 +403,7 @@ def test_packagedb_package_model_update_fields_related_models(self): ) ] _, updated_fields = p5.update_fields(dependencies=dependencies) - self.assertEquals( + self.assertEqual( sorted(['dependencies', 'history']), sorted(updated_fields) ) @@ -425,7 +425,7 @@ def test_packagedb_package_model_update_fields_related_models(self): ) ] _, updated_fields = p6.update_fields(dependencies=dependencies) - self.assertEquals( + self.assertEqual( sorted(['dependencies', 'history']), sorted(updated_fields) ) @@ -465,7 +465,7 @@ def setUp(self, mock_create_new_job): def test_package_watch_no_duplicate(self): self.assertRaises( IntegrityError, - PackageWatch.objects.create, + PackageWatch.objects.create, package_url="pkg:maven/org.test/test-package", ) @@ -508,7 +508,7 @@ def test_package_watch_reschedule_on_modification(self, mock_create_new_job): self.assertEqual(None, self.package_watch1.schedule_work_id) - + def test_get_or_none(self): Package.objects.create(download_url='http://a.ab', name='name', version='1.0', type="foo") package = Package.objects.filter(