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

Commit

Permalink
SNYK: Sanitize and bind Broker listing queries (#11553)
Browse files Browse the repository at this point in the history
* Sanitizing and binding broker listing queries

* applying suggested changes
  • Loading branch information
hyahiaoui-ext authored Aug 9, 2022
1 parent 5967804 commit b8eb592
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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 @@ -148,23 +154,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"];

// Number of logger
Expand Down

0 comments on commit b8eb592

Please sign in to comment.