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

Fix: Sanitize and bind CLAPI Centreon Hostgroup class dev-21.10.x #11802

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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