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

SNYK: Sanitize and bind Broker listing queries 22.04.x #11550

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
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
$elemArr = array();
$centreonToken = createCSRFToken();

$statementBrokerInfo = $pearDB->prepare(
"SELECT COUNT(DISTINCT(config_group_id)) as num " .
"FROM cfg_centreonbroker_info " .
"WHERE config_group = :config_group " .
"AND config_id = :config_id"
);

for ($i = 0; $config = $dbResult->fetch(); $i++) {
$moptions = "";
Expand All @@ -147,23 +153,16 @@
. "style=\"margin-bottom:0px;\" name='dupNbr[" . $config['config_id'] . "]'></input>";

// Number of output
$res = $pearDB->query(
"SELECT COUNT(DISTINCT(config_group_id)) as num " .
"FROM cfg_centreonbroker_info " .
"WHERE config_group = 'output' " .
"AND config_id = " . $config['config_id']
);
$row = $res->fetch();
$statementBrokerInfo->bindValue(':config_id', (int) $config['config_id'], \PDO::PARAM_INT);
$statementBrokerInfo->bindValue(':config_group', 'output', \PDO::PARAM_STR);
$statementBrokerInfo->execute();
$row = $statementBrokerInfo->fetch(\PDO::FETCH_ASSOC);
$outputNumber = $row["num"];

// Number of input
$res = $pearDB->query(
"SELECT COUNT(DISTINCT(config_group_id)) as num " .
"FROM cfg_centreonbroker_info " .
"WHERE config_group = 'input' " .
"AND config_id = " . $config['config_id']
);
$row = $res->fetch();
$statementBrokerInfo->bindValue(':config_group', 'input', \PDO::PARAM_STR);
$statementBrokerInfo->execute();
$row = $statementBrokerInfo->fetch(\PDO::FETCH_ASSOC);
$inputNumber = $row["num"];

$elemArr[$i] = array(
Expand Down