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

Snyk: Sanitize and bind Auth class queries 22.04.x #11448

Merged
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
32 changes: 18 additions & 14 deletions www/class/centreonAuth.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,13 @@ protected function checkUser($username, $password, $token)
if ($dbResult->rowCount()) {
$this->userInfos = $dbResult->fetch();
if ($this->userInfos["default_page"]) {
$dbResult2 = $this->pearDB->query(
"SELECT topology_url_opt FROM topology WHERE topology_page = "
. $this->userInfos["default_page"]
$statement = $this->pearDB->prepare(
"SELECT topology_url_opt FROM topology WHERE topology_page = :topology_page"
);
if ($dbResult2->numRows()) {
$data = $dbResult2->fetch();
$statement->bindValue(':topology_page', (int) $this->userInfos["default_page"], \PDO::PARAM_INT);
$statement->execute();
if ($statement->rowCount()) {
$data = $statement->fetch(\PDO::FETCH_ASSOC);
$this->userInfos["default_page"] .= $data["topology_url_opt"];
}
}
Expand Down Expand Up @@ -382,20 +383,23 @@ protected function checkUser($username, $password, $token)
/*
* Reset userInfos with imported information
*/
$dbResult = $this->pearDB->query(
$statement = $this->pearDB->prepare(
"SELECT * FROM `contact` " .
"WHERE `contact_alias` = '" . $this->pearDB->escape($username, true) . "'" .
"WHERE `contact_alias` = :contact_alias" .
"AND `contact_activate` = '1' AND `contact_register` = '1' LIMIT 1"
);
if ($dbResult->rowCount()) {
$this->userInfos = $dbResult->fetch();
$statement->bindValue(':contact_alias', $this->pearDB->escape($username, true), \PDO::PARAM_STR);
$statement->execute();
if ($statement->rowCount()) {
$this->userInfos = $statement->fetch(\PDO::FETCH_ASSOC);
if ($this->userInfos["default_page"]) {
$dbResult2 = $this->pearDB->query(
"SELECT topology_url_opt FROM topology WHERE topology_page = "
. $this->userInfos["default_page"]
$statement = $this->pearDB->prepare(
"SELECT topology_url_opt FROM topology WHERE topology_page = :topology_page"
);
if ($dbResult2->numRows()) {
$data = $dbResult2->fetch();
$statement->bindValue(':topology_page', (int) $this->userInfos["default_page"], \PDO::PARAM_INT);
$statement->execute();
if ($statement->rowCount()) {
$data = $statement->fetch(\PDO::FETCH_ASSOC);
$this->userInfos["default_page"] .= $data["topology_url_opt"];
}
}
Expand Down