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

chore(release): merge release-21.04.next into 21.04.x #11909

Merged
merged 18 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1bf57b7
query sanitized in listServiceCategoriesà (#11597) (#11634)
emabassi-ext Aug 29, 2022
3808c88
sanitize and bind in centreon connector queriy (#11637)
emabassi-ext Aug 30, 2022
5b30a8d
Sanitize and bind listVirtualMetrics queries (#11649)
emabassi-ext Aug 30, 2022
a7c4316
sanitize and bind host categories queryà (#11591) (#11646)
emabassi-ext Aug 30, 2022
dd5074e
sanitize insrert queries in db-func (#11652)
emabassi-ext Aug 30, 2022
2bf653b
Sanitized and bound queries in service argumentsXml file (#11655)
emabassi-ext Aug 30, 2022
917ec42
(fix) service status : encoding issue on status page (#11583)
TamazC Aug 31, 2022
6ebe015
Sanitize and bind service group dependecies queries (#11667)
hyahiaoui-ext Sep 2, 2022
226cde8
fix(conf) fix parent template display in service template listing (#1…
a-launois Sep 2, 2022
09fe9e2
fix(details): remove dead code (#11672) (#11684)
adr-mo Sep 5, 2022
47092da
fix(clapi): Check that user is admin to use clapi (#11631) (#11638)
jeremyjaouen Sep 5, 2022
7e6cded
fix(widgets): retrieve possibility to not select poller in pref (#116…
kduret Sep 6, 2022
66a3ec7
fix(details): second part of code cleanup for "tools" (#11725)
adr-mo Sep 8, 2022
3a4ce8b
fix(resource): Fix bad SQL request (#11702) (#11751)
callapa Sep 13, 2022
5a22c15
chore(release): merge release-21.04.next into 21.04.x (#11819) (#11826)
tuntoja Sep 21, 2022
9122ac1
FIX: SQLi in poller's broker configuration 21.04.x (#11779)
hyahiaoui-ext Sep 21, 2022
0f81a7d
chore(release): update version to 21.04.19
tuntoja Sep 27, 2022
cb88853
Merge branch '21.04.x' into release-21.04.next
tuntoja Sep 30, 2022
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
8 changes: 5 additions & 3 deletions www/class/centreonConfigCentreonBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,15 @@ public function insertConfig($values)
/*
* Get the ID
*/
$query = "SELECT config_id FROM cfg_centreonbroker WHERE config_name = '" . $values['name'] . "'";
$query = "SELECT config_id FROM cfg_centreonbroker WHERE config_name = :config_name";
try {
$res = $this->db->query($query);
$statement = $this->db->prepare($query);
$statement->bindValue(':config_name', $values['name'], \PDO::PARAM_STR);
$statement->execute();
} catch (\PDOException $e) {
return false;
}
$row = $res->fetch();
$row = $statement->fetch(\PDO::FETCH_ASSOC);
$id = $row['config_id'];

/*
Expand Down
91 changes: 70 additions & 21 deletions www/include/configuration/configCentreonBroker/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ function enableCentreonBrokerInDB($id)
return;
}

$query = "UPDATE cfg_centreonbroker SET config_activate = '1' WHERE config_id = " . $id;
$pearDB->query($query);
$query = "UPDATE cfg_centreonbroker SET config_activate = '1' WHERE config_id = :config_id";
$statement = $pearDB->prepare($query);
$statement->bindValue(':config_id', (int) $id, \PDO::PARAM_INT);
$statement->execute();
}

/**
Expand All @@ -91,8 +93,10 @@ function disablCentreonBrokerInDB($id)
return;
}

$query = "UPDATE cfg_centreonbroker SET config_activate = '0' WHERE config_id = " . $id;
$pearDB->query($query);
$query = "UPDATE cfg_centreonbroker SET config_activate = '0' WHERE config_id = :config_id";
$statement = $pearDB->prepare($query);
$statement->bindValue(':config_id', (int) $id, \PDO::PARAM_INT);
$statement->execute();
}

/**
Expand All @@ -104,8 +108,10 @@ function deleteCentreonBrokerInDB($ids = array())
{
global $pearDB;

$statement = $pearDB->prepare("DELETE FROM cfg_centreonbroker WHERE config_id = :config_id");
foreach ($ids as $key => $value) {
$pearDB->query("DELETE FROM cfg_centreonbroker WHERE config_id = " . $key);
$statement->bindValue(':config_id', (int) $key, \PDO::PARAM_INT);
$statement->execute();
}
}

Expand Down Expand Up @@ -194,13 +200,7 @@ function multipleCentreonBrokerInDB($ids, $nbrDup)
foreach ($ids as $id => $value) {
$cbObj = new CentreonConfigCentreonBroker($pearDB);

$query = "SELECT config_name, config_filename, config_activate, ns_nagios_server,
event_queue_max_size, cache_directory, daemon "
. "FROM cfg_centreonbroker "
. "WHERE config_id = " . $id . " ";
$dbResult = $pearDB->query($query);
$row = $dbResult->fetch();
$dbResult->closeCursor();
$row = getCfgBrokerData((int) $id);

# Prepare values
$values = array();
Expand All @@ -210,14 +210,11 @@ function multipleCentreonBrokerInDB($ids, $nbrDup)
$values['event_queue_max_size'] = $row['event_queue_max_size'];
$values['cache_directory'] = $row['cache_directory'];
$values['activate_watchdog']['activate_watchdog'] = $row['daemon'];
$query = "SELECT config_key, config_value, config_group, config_group_id "
. "FROM cfg_centreonbroker_info "
. "WHERE config_id = " . $id . " ";
$dbResult = $pearDB->query($query);
$values['output'] = array();
$values['input'] = array();
$values['logger'] = array();
while ($rowOpt = $dbResult->fetch()) {
$brokerCfgInfoData = getCfgBrokerInfoData((int) $id);
foreach ($brokerCfgInfoData as $rowOpt) {
if ($rowOpt['config_key'] == 'filters') {
continue;
} elseif ($rowOpt['config_key'] == 'category') {
Expand All @@ -228,7 +225,6 @@ function multipleCentreonBrokerInDB($ids, $nbrDup)
$rowOpt['config_value'];
}
}
$dbResult->closeCursor();

# Convert values radio button
foreach ($values as $group => $groups) {
Expand All @@ -254,16 +250,18 @@ function multipleCentreonBrokerInDB($ids, $nbrDup)

# Copy the configuration
$j = 1;
$query = "SELECT COUNT(*) as nb FROM cfg_centreonbroker WHERE config_name = :config_name";
$statement = $pearDB->prepare($query);
for ($i = 1; $i <= $nbrDup[$id]; $i++) {
$nameNOk = true;

# Find the name
while ($nameNOk) {
$newname = $row['config_name'] . '_' . $j;
$newfilename = $j . '_' . $row['config_filename'];
$query = "SELECT COUNT(*) as nb FROM cfg_centreonbroker WHERE config_name = '" . $newname . "'";
$res = $pearDB->query($query);
$rowNb = $res->fetch();
$statement->bindValue(':config_name', $newname, \PDO::PARAM_STR);
$statement->execute();
$rowNb = $statement->fetch(\PDO::FETCH_ASSOC);
if ($rowNb['nb'] == 0) {
$nameNOk = false;
}
Expand Down Expand Up @@ -293,3 +291,54 @@ function isPositiveNumeric($size): bool
}
return $isPositive;
}

/**
* Getting Centreon CFG broker data
*
* @param int $configId
* @return array
*/
function getCfgBrokerData(int $configId): array
{
global $pearDB;

$query = "SELECT config_name, config_filename, config_activate, ns_nagios_server,
event_queue_max_size, cache_directory, daemon "
. "FROM cfg_centreonbroker "
. "WHERE config_id = :config_id ";
try {
$statement = $pearDB->prepare($query);
$statement->bindValue(':config_id', $configId, \PDO::PARAM_INT);
$statement->execute();
$cfgBrokerData = $statement->fetch(\PDO::FETCH_ASSOC);
} catch (PDOException $exception) {
throw new \Exception("Cannot fetch Broker config data");
}
$statement->closeCursor();
return $cfgBrokerData;
}

/**
* Getting Centreon CFG broker Info data
*
* @param int $configId
* @return array
*/
function getCfgBrokerInfoData(int $configId): array
{
global $pearDB;

$query = "SELECT config_key, config_value, config_group, config_group_id "
. "FROM cfg_centreonbroker_info "
. "WHERE config_id = :config_id";
try {
$statement = $pearDB->prepare($query);
$statement->bindValue(':config_id', $configId, \PDO::PARAM_INT);
$statement->execute();
$cfgBrokerInfoData = $statement->fetchAll(\PDO::FETCH_ASSOC);
} catch (\PDOException $exception) {
throw new \Exception("Cannot fetch Broker info config data");
}
$statement->closeCursor();
return $cfgBrokerInfoData;
}
2 changes: 1 addition & 1 deletion www/install/insertBaseConf.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Insert version
--

INSERT INTO `informations` (`key` ,`value`) VALUES ('version', '21.04.18');
INSERT INTO `informations` (`key` ,`value`) VALUES ('version', '21.04.19');

--
-- Contenu de la table `contact`
Expand Down
21 changes: 21 additions & 0 deletions www/install/php/Update-21.04.19.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : contact@centreon.com
*
*/
tuntoja marked this conversation as resolved.
Show resolved Hide resolved