mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-12-31 21:51:46 +00:00
move lists of GPL and compatible licenses to separate files
This commit is contained in:
parent
92ff3e2bec
commit
02ccd6fa65
@ -11,4 +11,4 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
; The valid constants to search for
|
; The valid constants to search for
|
||||||
constants="Apache,Artistic,BSD,CC0,Creative Commons Attribution,MIT,MPL"
|
constants=""
|
||||||
|
@ -47,6 +47,20 @@ class JedcheckerRulesGpl extends JEDcheckerRule
|
|||||||
*/
|
*/
|
||||||
protected $description = 'COM_JEDCHECKER_RULE_PH1_DESC';
|
protected $description = 'COM_JEDCHECKER_RULE_PH1_DESC';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regular expression to match GPL licenses.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $regex_gpl_licenses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regular expression to match GPL-compatible licenses.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $regex_compat_licenses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates the file search and check
|
* Initiates the file search and check
|
||||||
*
|
*
|
||||||
@ -54,6 +68,9 @@ class JedcheckerRulesGpl extends JEDcheckerRule
|
|||||||
*/
|
*/
|
||||||
public function check()
|
public function check()
|
||||||
{
|
{
|
||||||
|
// Prepare regexp
|
||||||
|
$this->init();
|
||||||
|
|
||||||
// Find all php files of the extension
|
// Find all php files of the extension
|
||||||
$files = JFolder::files($this->basedir, '.php$', true, true);
|
$files = JFolder::files($this->basedir, '.php$', true, true);
|
||||||
|
|
||||||
@ -70,7 +87,94 @@ class JedcheckerRulesGpl extends JEDcheckerRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a file and searches for the _JEXEC statement
|
* Initialization (prepare regular expressions)
|
||||||
|
*/
|
||||||
|
protected function init()
|
||||||
|
{
|
||||||
|
$gpl_licenses = (array) file(__DIR__ . '/gpl_gnu.txt');
|
||||||
|
$this->regex_gpl_licenses = $this->generate_regexp($gpl_licenses);
|
||||||
|
|
||||||
|
$compat_licenses = (array) file(__DIR__ . '/gpl_compat.txt');
|
||||||
|
|
||||||
|
$extra_licenses = $this->params->get('constants');
|
||||||
|
$extra_licenses = explode(',', $extra_licenses);
|
||||||
|
|
||||||
|
$compat_licenses = array_merge($compat_licenses, $extra_licenses);
|
||||||
|
|
||||||
|
$this->regex_compat_licenses = $this->generate_regexp($compat_licenses);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate regular expression to match the given list of license names
|
||||||
|
* @param $lines
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function generate_regexp($lines)
|
||||||
|
{
|
||||||
|
$titles = array();
|
||||||
|
$ids = array();
|
||||||
|
|
||||||
|
foreach ($lines as $line)
|
||||||
|
{
|
||||||
|
$line = trim($line);
|
||||||
|
if ($line === '' || $line[0] === '#')
|
||||||
|
{
|
||||||
|
// skip empty and commented lines
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = $line;
|
||||||
|
if (substr($line, -1, 1) === ')')
|
||||||
|
{
|
||||||
|
// extract identifier
|
||||||
|
$pos = strrpos($line, '(');
|
||||||
|
if ($pos !== false)
|
||||||
|
{
|
||||||
|
$title = trim(substr($line, 0, $pos));
|
||||||
|
|
||||||
|
$id = trim(substr($line, $pos + 1, -1));
|
||||||
|
|
||||||
|
if ($id !== '')
|
||||||
|
{
|
||||||
|
$id = preg_quote($id, '#');
|
||||||
|
$ids[$id] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($title !== '')
|
||||||
|
{
|
||||||
|
$title = preg_quote($title, '#');
|
||||||
|
|
||||||
|
// expand vN.N to different version formats
|
||||||
|
$title = preg_replace('/(?<=\S)\s+v(?=\d)/', ',?\s+(?:v\.?\s*|version\s+)?', $title);
|
||||||
|
|
||||||
|
$title = preg_replace('/\s+/', '\s+', $title);
|
||||||
|
|
||||||
|
$titles[$title] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($titles) === 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$titles = implode('|', array_keys($titles));
|
||||||
|
|
||||||
|
if (count($ids))
|
||||||
|
{
|
||||||
|
$ids = implode('|', array_keys($ids));
|
||||||
|
$titles .=
|
||||||
|
'|\blicense\b.+?(?:' . $ids . ')' .
|
||||||
|
'|\b(?:' . $ids . ')\s+license\b';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '#^.*?(?:' . $titles . ').*?$#im';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a file and searches for its license
|
||||||
*
|
*
|
||||||
* @param string $file - The path to the file
|
* @param string $file - The path to the file
|
||||||
*
|
*
|
||||||
@ -78,72 +182,37 @@ class JedcheckerRulesGpl extends JEDcheckerRule
|
|||||||
*/
|
*/
|
||||||
protected function find($file)
|
protected function find($file)
|
||||||
{
|
{
|
||||||
$content = (array) file($file);
|
// check the file is empty (i.e. comments-only)
|
||||||
|
$content = php_strip_whitespace($file);
|
||||||
// Get the constants to look for
|
if (preg_match('#^<\?php\s+$#', $content))
|
||||||
$licenses = $this->params->get('constants');
|
|
||||||
$licenses = explode(',', $licenses);
|
|
||||||
|
|
||||||
$hascode = 0;
|
|
||||||
|
|
||||||
foreach ($content AS $key => $line)
|
|
||||||
{
|
{
|
||||||
$tline = trim($line);
|
return true;
|
||||||
|
|
||||||
if ($tline == '' || $tline == '<?php' || $tline == '?>')
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($tline['0'] != '/' && $tline['0'] != '*')
|
|
||||||
{
|
|
||||||
$hascode = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for GPL license
|
|
||||||
$gpl = stripos($line, 'GPL');
|
|
||||||
$gnu = stripos($line, 'GNU');
|
|
||||||
$gpl_long = stripos($line, 'general public license');
|
|
||||||
|
|
||||||
if ($gpl || $gnu || $gpl_long)
|
|
||||||
{
|
|
||||||
$this->report->addInfo(
|
|
||||||
$file,
|
|
||||||
JText::_('COM_JEDCHECKER_PH1_LICENSE_FOUND') . ':' . '<strong>' . $line . '</strong>',
|
|
||||||
$key
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for the constant name
|
|
||||||
foreach ($licenses AS $license)
|
|
||||||
{
|
|
||||||
$license = trim($license);
|
|
||||||
|
|
||||||
// Search for the license
|
|
||||||
$found = strpos($line, $license);
|
|
||||||
|
|
||||||
// Skip the line if the license is not found
|
|
||||||
if ($found === false)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->report->addInfo(
|
|
||||||
$file,
|
|
||||||
JText::_('COM_JEDCHECKER_GPL_COMPATIBLE_LICENSE_WAS_FOUND') . ':' . '<strong>' . $line . '</strong>',
|
|
||||||
$key
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($content);
|
$content = file_get_contents($file);
|
||||||
|
|
||||||
return $hascode ? false : true;
|
if (preg_match($this->regex_gpl_licenses, $content, $match, PREG_OFFSET_CAPTURE))
|
||||||
|
{
|
||||||
|
$line_no = substr_count($content, "\n", 0, $match[0][1]) + 1;
|
||||||
|
$this->report->addInfo(
|
||||||
|
$file,
|
||||||
|
JText::_('COM_JEDCHECKER_PH1_LICENSE_FOUND') . ':' . '<strong>' . $match[0][0] . '</strong>',
|
||||||
|
$line_no
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match($this->regex_compat_licenses, $content, $match, PREG_OFFSET_CAPTURE))
|
||||||
|
{
|
||||||
|
$line_no = substr_count($content, "\n", 0, $match[0][1]) + 1;
|
||||||
|
$this->report->addInfo(
|
||||||
|
$file,
|
||||||
|
JText::_('COM_JEDCHECKER_GPL_COMPATIBLE_LICENSE_WAS_FOUND') . ':' . '<strong>' . $match[0][0] . '</strong>',
|
||||||
|
$line_no
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,169 @@
|
|||||||
|
# Based on:
|
||||||
|
# https://www.gnu.org/licenses/license-list.en.html
|
||||||
|
# https://opensource.org/licenses/alphabetical
|
||||||
|
# https://spdx.org/licenses/
|
||||||
|
|
||||||
|
# Comments are marked with the "#" character in the first position of the line
|
||||||
|
|
||||||
|
# Each line contains the full name of the license with the optional abbreviation in parenthesis
|
||||||
|
|
||||||
|
# The version of the license (if presented) should be written in the form
|
||||||
|
# [space][the letter "v"][digit(s)]
|
||||||
|
# (see examples below)
|
||||||
|
|
||||||
|
|
||||||
|
# BSD Licenses
|
||||||
|
BSD License
|
||||||
|
0-clause BSD License (0BSD)
|
||||||
|
BSD Zero Clause License
|
||||||
|
Zero-Clause BSD / Free Public License v1.0.0
|
||||||
|
1-clause BSD License (BSD-1-Clause)
|
||||||
|
BSD 1-Clause License
|
||||||
|
2-clause BSD License (BSD-2-Clause)
|
||||||
|
BSD 2-Clause "Simplified" License
|
||||||
|
BSD-2-Clause Plus Patent License (BSD-2-Clause-Patent)
|
||||||
|
BSD+Patent
|
||||||
|
FreeBSD License
|
||||||
|
3-clause BSD License (BSD-3-Clause)
|
||||||
|
BSD 3-Clause "New" or "Revised" License
|
||||||
|
Lawrence Berkeley National Labs BSD variant License (BSD-3-Clause-LBNL)
|
||||||
|
Modified BSD License
|
||||||
|
Clear BSD License
|
||||||
|
|
||||||
|
# Other OSI Licenses
|
||||||
|
Academic Free License v1.1 (AFL-1.1)
|
||||||
|
Academic Free License v1.2 (AFL-1.2)
|
||||||
|
Academic Free License v2.0 (AFL-2.0)
|
||||||
|
Academic Free License v2.1 (AFL-2.1)
|
||||||
|
Academic Free License v3.0 (AFL-3.0)
|
||||||
|
Adaptive Public License (APL-1.0)
|
||||||
|
Apache License v1.1 (Apache-1.1)
|
||||||
|
Apache Software License v1.1
|
||||||
|
Apache License v2.0 (Apache-2.0)
|
||||||
|
Apple Public Source License v1.0 (APSL-1.0)
|
||||||
|
Apple Public Source License v1.1 (APSL-1.1)
|
||||||
|
Apple Public Source License v1.2 (APSL-1.2)
|
||||||
|
Apple Public Source License v2.0 (APSL-2.0)
|
||||||
|
Apple Public Source License
|
||||||
|
Artistic License v1.0 (Artistic-1.0)
|
||||||
|
Artistic License
|
||||||
|
Artistic License v2.0 (Artistic-2.0)
|
||||||
|
Attribution Assurance License (AAL)
|
||||||
|
Berkeley Database License
|
||||||
|
Boost Software License (BSL-1.0)
|
||||||
|
CeCILL v2
|
||||||
|
CeCILL License v2.1 (CECILL-2.1)
|
||||||
|
CeCILL Free Software License Agreement v2.1
|
||||||
|
CERN Open Hardware Licence v2 - Permissive (CERN-OHL-P-2.0)
|
||||||
|
CERN Open Hardware Licence v2 - Weakly Reciprocal (CERN-OHL-W-2.0)
|
||||||
|
CERN Open Hardware Licence v2 - Strongly Reciprocal (CERN-OHL-S-2.0)
|
||||||
|
Clarified Artistic License
|
||||||
|
Common Development and Distribution License v1.0 (CDDL-1.0)
|
||||||
|
Common Public Attribution License v1.0 (CPAL-1.0)
|
||||||
|
Common Public License v1.0 (CPL-1.0)
|
||||||
|
Computer Associates Trusted Open Source License v1.1 (CATOSL-1.1)
|
||||||
|
Cryptix General License
|
||||||
|
Cryptographic Autonomy License v1.0 (CAL-1.0)
|
||||||
|
CUA Office Public License v1.0 (CUA-OPL-1.0)
|
||||||
|
Eclipse Public License v1.0 (EPL-1.0)
|
||||||
|
Eclipse Public License v2.0 (EPL-2.0)
|
||||||
|
eCos License v2.0 (eCos-2.0)
|
||||||
|
Educational Community License v1.0 (ECL-1.0)
|
||||||
|
Educational Community License v2.0 (ECL-2.0)
|
||||||
|
Eiffel Forum License v1.0 (EFL-1.0)
|
||||||
|
Eiffel Forum License v2.0 (EFL-2.0)
|
||||||
|
Entessa Public License (Entessa)
|
||||||
|
EU DataGrid Software License (EUDatagrid)
|
||||||
|
European Union Public License v1.1 (EUPL-1.1)
|
||||||
|
European Union Public License v1.2 (EUPL-1.2)
|
||||||
|
Expat License
|
||||||
|
Fair License (Fair)
|
||||||
|
Frameworx License (Frameworx-1.0)
|
||||||
|
Frameworx Open License v1.0
|
||||||
|
Freetype Project License
|
||||||
|
Historical Permission Notice and Disclaimer (HPND)
|
||||||
|
IBM Public License v1.0 (IPL-1.0)
|
||||||
|
Independent JPEG Group License
|
||||||
|
Intel Open Source License (Intel)
|
||||||
|
IPA Font License (IPA)
|
||||||
|
ISC License (ISC)
|
||||||
|
Jabber Open Source License
|
||||||
|
LaTeX Project Public License v1.3c (LPPL-1.3c)
|
||||||
|
Licence Libre du Québec – Permissive (LiLiQ-P) v1.1 (LiliQ-P)
|
||||||
|
Licence Libre du Québec – Permissive v1.1 (LiLiQ-P-1.1)
|
||||||
|
Licence Libre du Québec – Réciprocité (LiLiQ-R) v1.1 (LiliQ-R)
|
||||||
|
Licence Libre du Québec – Réciprocité v1.1 (LiLiQ-R-1.1)
|
||||||
|
Licence Libre du Québec – Réciprocité forte (LiLiQ-R+) v1.1 (LiliQ-R+)
|
||||||
|
Licence Libre du Québec – Réciprocité forte v1.1 (LiLiQ-Rplus-1.1)
|
||||||
|
Lucent Public License ("Plan9") v1.0 (LPL-1.0)
|
||||||
|
Lucent Public License v1.0
|
||||||
|
Lucent Public License v1.02 (LPL-1.02)
|
||||||
|
Microsoft Public License (MS-PL)
|
||||||
|
Microsoft Reciprocal License (MS-RL)
|
||||||
|
MirOS Licence (MirOS)
|
||||||
|
MIT License (MIT)
|
||||||
|
MIT No Attribution (MIT-0)
|
||||||
|
MITRE Collaborative Virtual Workspace License (CVW)
|
||||||
|
Motosoto License (Motosoto)
|
||||||
|
Mozilla Public License v1.0 (MPL-1.0)
|
||||||
|
Mozilla Public License v1.1 (MPL-1.1)
|
||||||
|
Mozilla Public License v2.0 (MPL-2.0)
|
||||||
|
Mulan Permissive Software License v2 (MulanPSL-2.0)
|
||||||
|
Multics License (Multics)
|
||||||
|
NASA Open Source Agreement v1.3 (NASA-1.3)
|
||||||
|
Naumen Public License (Naumen)
|
||||||
|
Nethack General Public License (NGPL)
|
||||||
|
Nokia Open Source License (Nokia)
|
||||||
|
Non-Profit Open Software License v3.0 (NPOSL-3.0)
|
||||||
|
NTP License (NTP)
|
||||||
|
OCLC Research Public License v2.0 (OCLC-2.0)
|
||||||
|
Open Group Test Suite License (OGTSL)
|
||||||
|
Open Software License v1.0 (OSL-1.0)
|
||||||
|
Open Software License v2.0 (OSL-2.0)
|
||||||
|
Open Software License v2.1 (OSL-2.1)
|
||||||
|
Open Software License v3.0 (OSL-3.0)
|
||||||
|
OpenLDAP License v2.7
|
||||||
|
OpenLDAP Public License v2.8 (OLDAP-2.8)
|
||||||
|
Open LDAP Public License v2.8
|
||||||
|
OSET Public License v2.1 (OSET-PL-2.1)
|
||||||
|
PHP License v3.0 (PHP-3.0)
|
||||||
|
PHP License v3.01 (PHP-3.01)
|
||||||
|
PostgreSQL License (PostgreSQL)
|
||||||
|
Python License (Python-2.0)
|
||||||
|
CNRI Python License (CNRI-Python)
|
||||||
|
Q Public License (QPL-1.0)
|
||||||
|
RealNetworks Public Source License v1.0 (RPSL-1.0)
|
||||||
|
Reciprocal Public License v1.1 (RPL-1.1)
|
||||||
|
Reciprocal Public License v1.5 (RPL-1.5)
|
||||||
|
Ricoh Source Code Public License (RSCPL)
|
||||||
|
SGI Free Software License B v2.0
|
||||||
|
SIL Open Font License v1.1 (OFL-1.1)
|
||||||
|
Simple Public License v2.0 (SimPL-2.0)
|
||||||
|
Sleepycat License (Sleepycat)
|
||||||
|
Sleepycat Software Product License
|
||||||
|
Standard ML of New Jersey Copyright License
|
||||||
|
Sun Industry Standards Source License (SISSL)
|
||||||
|
Sun Public License v1.0 (SPL-1.0)
|
||||||
|
Sybase Open Watcom Public License v1.0 (Watcom-1.0)
|
||||||
|
Unicode Data Files and Software License (Unicode-DFS-2016)
|
||||||
|
Unicode License Agreement - Data Files and Software
|
||||||
|
Unicode, Inc. License Agreement for Data Files and Software
|
||||||
|
Universal Permissive License (UPL)
|
||||||
|
Universal Permissive License v1.0 (UPL-1.0)
|
||||||
|
University of Illinois/NCSA Open Source License (NCSA)
|
||||||
|
NCSA/University of Illinois Open Source License
|
||||||
|
Unlicense
|
||||||
|
Upstream Compatibility License v1.0 (UCL-1.0)
|
||||||
|
Vovida Software License v.1.0 (VSL-1.0)
|
||||||
|
W3C License (W3C)
|
||||||
|
W3C Software Notice and License
|
||||||
|
WTFPL v2
|
||||||
|
WxWidgets Library License
|
||||||
|
wxWindows Library License (WXwindows)
|
||||||
|
X11 License
|
||||||
|
XFree86 v1.1 License
|
||||||
|
X.Net License (Xnet)
|
||||||
|
Zope Public License v2.0 (ZPL-2.0)
|
||||||
|
Zope Public License v2.1
|
||||||
|
zlib/libpng License (Zlib)
|
||||||
|
zlib License
|
@ -0,0 +1,38 @@
|
|||||||
|
# GPL Licenses
|
||||||
|
|
||||||
|
# Based on:
|
||||||
|
# https://www.gnu.org/licenses/license-list.en.html
|
||||||
|
# https://opensource.org/licenses/alphabetical
|
||||||
|
# https://spdx.org/licenses/
|
||||||
|
|
||||||
|
# Comments are marked with the "#" character in the first position of the line
|
||||||
|
|
||||||
|
# Each line contains the full name of the license with the optional abbreviation in parenthesis
|
||||||
|
|
||||||
|
# The version of the license (if presented) should be written in the form
|
||||||
|
# [space][the letter "v"][digit(s)]
|
||||||
|
# (see examples below)
|
||||||
|
|
||||||
|
|
||||||
|
GNU General Public License
|
||||||
|
GNU GPL
|
||||||
|
GNU/GPL
|
||||||
|
GNU Lesser General Public License
|
||||||
|
GNU LGPL
|
||||||
|
GNU/LGPL
|
||||||
|
|
||||||
|
GNU General Public License v2 (GPL-2.0)
|
||||||
|
//www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
||||||
|
GNU General Public License v3 (GPL-3.0)
|
||||||
|
//www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
GNU Affero General Public License v3 (AGPL-3.0)
|
||||||
|
GNU Affero General Public License (AGPL) v3
|
||||||
|
GNU Library General Public License v2 (LGPL-2.0)
|
||||||
|
GNU Lesser General Public License v2.1 (LGPL-2.1)
|
||||||
|
GNU Lesser General Public License (LGPL) v2.1
|
||||||
|
GNU Lesser General Public License v3 (LGPL-3.0)
|
||||||
|
GNU Lesser General Public License (LGPL) v3
|
||||||
|
|
||||||
|
GNU All-Permissive License
|
Loading…
Reference in New Issue
Block a user