Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Fix: Sanitize and bind CLAPI Centreon Hostgroup class (#11802)
Browse files Browse the repository at this point in the history
  • Loading branch information
emabassi-ext authored Sep 21, 2022
1 parent 683b485 commit cfb89b4
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions www/class/centreon-clapi/centreonHostGroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public function getparam($parameters = null)
$listParam = explode('|', $params[1]);
$exportedFields = [];
$resultString = "";
$paramString = "";
foreach ($listParam as $paramSearch) {
if (!$paramString) {
$paramString = $paramSearch;
Expand Down Expand Up @@ -257,20 +258,24 @@ public function initUpdateParameters($parameters = null)
public function getIdIcon($path)
{
$iconData = explode('/', $path);
$query = 'SELECT dir_id FROM view_img_dir WHERE dir_name = "' . $iconData[0] . '"';
$res = $this->db->query($query);
$row = $res->fetch();
$dirStatement = $this->db->prepare("SELECT dir_id FROM view_img_dir WHERE dir_name = :IconData");
$dirStatement->bindValue(':IconData', $iconData[0], \PDO::PARAM_STR);
$dirStatement->execute();
$row = $dirStatement->fetch();
$dirId = $row['dir_id'];

$query = 'SELECT img_id FROM view_img WHERE img_path = "' . $iconData[1] . '"';
$res = $this->db->query($query);
$row = $res->fetch();
$imgStatement = $this->db->prepare("SELECT img_id FROM view_img WHERE img_path = :iconData");
$imgStatement->bindValue(':iconData', $iconData[1], \PDO::PARAM_STR);
$imgStatement->execute();
$row = $imgStatement->fetch();
$iconId = $row['img_id'];

$query = 'SELECT vidr_id FROM view_img_dir_relation ' .
'WHERE dir_dir_parent_id = ' . $dirId . ' AND img_img_id = ' . $iconId;
$res = $this->db->query($query);
$row = $res->fetch();
$vidrStatement = $this->db->prepare("SELECT vidr_id FROM view_img_dir_relation " .
"WHERE dir_dir_parent_id = :dirId AND img_img_id = :iconId");
$vidrStatement->bindValue(':dirId', (int) $dirId, \PDO::PARAM_INT);
$vidrStatement->bindValue(':iconId', (int) $iconId, \PDO::PARAM_INT);
$vidrStatement->execute();
$row = $vidrStatement->fetch();
return $row['vidr_id'];
}

Expand Down

0 comments on commit cfb89b4

Please sign in to comment.