add new rule

This commit is contained in:
Frédéric FRANCE
2020-05-21 00:02:33 +02:00
parent 954d928467
commit 43dcd9beb5
63 changed files with 315 additions and 534 deletions

View File

@@ -154,7 +154,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$filesarray = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, '\.php', null, 'fullname');
foreach($filesarray as $key => $file)
foreach ($filesarray as $key => $file)
{
if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) continue;
if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) continue;
@@ -170,7 +170,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$matches=array();
// Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
preg_match_all('/'.preg_quote('get_class($this)."::".__METHOD__', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
foreach($matches as $key => $val)
foreach ($matches as $key => $val)
{
$ok=false;
break;
@@ -183,7 +183,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$matches=array();
// Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER);
foreach($matches as $key => $val)
foreach ($matches as $key => $val)
{
if ($val[1] != '\'"' && $val[1] != '\'\'')
{
@@ -201,7 +201,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$matches=array();
// Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
preg_match_all('/(=|sql.+)\s*\'"\s*\.\s*\$this->(....)/', $filecontent, $matches, PREG_SET_ORDER);
foreach($matches as $key => $val)
foreach ($matches as $key => $val)
{
if ($val[2] != 'db->' && $val[2] != 'esca')
{
@@ -220,7 +220,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$matches=array();
// Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER);
foreach($matches as $key => $val)
foreach ($matches as $key => $val)
{
if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(')
{
@@ -236,7 +236,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$matches=array();
// Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER);
foreach($matches as $key => $val)
foreach ($matches as $key => $val)
{
$ok=false;
break;
@@ -249,7 +249,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$matches=array();
// Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
preg_match_all('/<br \/>/', $filecontent, $matches, PREG_SET_ORDER);
foreach($matches as $key => $val)
foreach ($matches as $key => $val)
{
if ($file['name'] != 'functions.lib.php')
{
@@ -265,7 +265,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$matches=array();
// Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
preg_match_all('/@var\s+array\(/', $filecontent, $matches, PREG_SET_ORDER);
foreach($matches as $key => $val)
foreach ($matches as $key => $val)
{
$ok=false;
break;