forked from Wavyzz/dolibarr
More sql sanitizing
This commit is contained in:
@@ -1299,7 +1299,7 @@ class BOMLine extends CommonObjectLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class CProductNature // extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' WHERE ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -239,12 +239,12 @@ class Ctyperesource
|
|||||||
$sqlwhere = array();
|
$sqlwhere = array();
|
||||||
if (count($filter) > 0) {
|
if (count($filter) > 0) {
|
||||||
foreach ($filter as $key => $value) {
|
foreach ($filter as $key => $value) {
|
||||||
$sqlwhere [] = $key." LIKE '%".$this->db->escape($value)."%'";
|
$sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' WHERE '.implode(' '.$filtermode.' ', $sqlwhere);
|
$sql .= ' WHERE '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ class CUnits // extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' WHERE ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ class DefaultValues extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ class EcmFiles extends CommonObject
|
|||||||
$sql .= " AND entity IN (" . getEntity('ecmfiles') . ")";
|
$sql .= " AND entity IN (" . getEntity('ecmfiles') . ")";
|
||||||
}*/
|
}*/
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
|
$sql .= ' AND '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ class ConferenceOrBooth extends ActionComm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -677,7 +677,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' WHERE '.implode(' '.$filtermode.' ', $sqlwhere);
|
$sql .= ' WHERE '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ class KnowledgeRecord extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ class Mo extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
@@ -1557,7 +1557,7 @@ class MoLine extends CommonObjectLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ class Partnership extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ class ProductFournisseurPrice extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ class ProductStockEntrepot extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
|
$sql .= ' AND '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($fk_product) && $fk_product > 0) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ class RecruitmentCandidature extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ class RecruitmentJobPosition extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ class CTicketCategory extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -3526,7 +3526,7 @@ class User extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ class Website extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
|
$sql .= ' AND '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ class WebsitePage extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= " AND (".implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= " AND (".implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
@@ -543,7 +543,7 @@ class WebsitePage extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ class Workstation extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ class Hook extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
$sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
|||||||
// Check string sql|set...'.$yyy->xxx with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request.
|
// Check string sql|set...'.$yyy->xxx with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request.
|
||||||
preg_match_all('/(\$sql|SET\s|WHERE\s|INSERT\s|VALUES\s|VALUES\().+\s*\'\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER);
|
preg_match_all('/(\$sql|SET\s|WHERE\s|INSERT\s|VALUES\s|VALUES\().+\s*\'\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER);
|
||||||
foreach ($matches as $key => $val) {
|
foreach ($matches as $key => $val) {
|
||||||
if (! in_array($val[2], array('this->db-', 'db->sanit', 'conf->ent', 'key : \'\')', 'key])."\')', 'excludefi', 'regexstri', 'filtermod'))) {
|
if (! in_array($val[2], array('this->db-', 'db->sanit', 'conf->ent', 'key : \'\')', 'key])."\')', 'excludefi', 'regexstri', ''))) {
|
||||||
$ok=false;
|
$ok=false;
|
||||||
var_dump($matches);
|
var_dump($matches);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user