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

Commit 59a70af

Browse files
tuntojakduretemabassi-extvhsantoshyahiaoui-ext
authored
chore(release): merge release-21.10.next into 21.10.x (#11910)
* fix(git): resync 21.10.x to dev-21.10.x (#11499) * fix(test): wait 8s before checking downtime is active in rest api v1 test (#11498) (#11505) Refs: MON-14585 * fix(UI): Include host_id when selecting ServiceGroups on dashreports (#11428) (#11520) Co-authored-by: VHS <[email protected]> Co-authored-by: VHS <[email protected]> * [SNYK] Sanitize and bind centreonGraph class queries (#11409) (#11518) 1122 1153 1134 * [Snyk] Sanitize and bind ACL action access queries (#11385) (#11515) * Sanitize and bind ACL action access queries _ sanitize if possible each variables inserted in a query _ use PDO prepared statement and bind() method _ Do not use $pearDB->escape on which is for examples useless on integers and on non closed HTML tags (svg, img, etc) * fix line length * fix failed checks * fix(cron): Escape database name in CentACL 21.10.x (#11509) * fix(pendo): correctly set locale when language is detection by browser (#11484) (#11529) * fix(test): fix random fails on virtual metric test (#11524) Refs: MON-14359 * enh(platform): Use API to select metrics in virtual metrics configuration form 21.10.x (#11508) Refs: MON-14359 * doc(ack): acknowledge Hakaï security (#11539) * fix(web): fix the comment deletion for host monitored by poller (#11138) (#11557) Refs: MON-12828 Co-authored-by: Stéphane Duret <[email protected]> * SNYK: Sanitize and bind Broker listing queries (#11551) * Sanitizing and binding broker listing queries * applying suggested changes * fix(conf) fix encoding in template service listing (#11558) (#11565) * fix encoding * remove useless function * SNYK: Sanitize and bind generateImage queries (#11562) * sanitize and bind generate image queries * adding throw exception * applying suggested changes * Update www/include/views/graphs/generateGraphs/generateImage.php Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> * SNYK: Sanitize and bind ACL actions queries (#11548) * sanitizing and binding acl actions queries * fix missing bind * MON-14501 - sanitize query in centreonXmlbgRequest class (#11571) * sanitize query in centreonXmlbgRequest class * add closeCursor func to resolve conv * SNYK: Sanitize and bind Meta-Services dependency queries (#11568) * sanityze 2 insert queries * spaces removed in a query * chore(release): merge release 21.10.9 into 21.10.x (#11628) (#11629) * fix(git): resync 21.10.x to dev-21.10.x (#11499) * fix(test): wait 8s before checking downtime is active in rest api v1 test (#11498) (#11505) Refs: MON-14585 * fix(UI): Include host_id when selecting ServiceGroups on dashreports (#11428) (#11520) Co-authored-by: VHS <[email protected]> Co-authored-by: VHS <[email protected]> * [SNYK] Sanitize and bind centreonGraph class queries (#11409) (#11518) 1122 1153 1134 * [Snyk] Sanitize and bind ACL action access queries (#11385) (#11515) * Sanitize and bind ACL action access queries _ sanitize if possible each variables inserted in a query _ use PDO prepared statement and bind() method _ Do not use $pearDB->escape on which is for examples useless on integers and on non closed HTML tags (svg, img, etc) * fix line length * fix failed checks * fix(cron): Escape database name in CentACL 21.10.x (#11509) * fix(pendo): correctly set locale when language is detection by browser (#11484) (#11529) * fix(test): fix random fails on virtual metric test (#11524) Refs: MON-14359 * enh(platform): Use API to select metrics in virtual metrics configuration form 21.10.x (#11508) Refs: MON-14359 * doc(ack): acknowledge Hakaï security (#11539) * fix(web): fix the comment deletion for host monitored by poller (#11138) (#11557) Refs: MON-12828 Co-authored-by: Stéphane Duret <[email protected]> * SNYK: Sanitize and bind Broker listing queries (#11551) * Sanitizing and binding broker listing queries * applying suggested changes * fix(conf) fix encoding in template service listing (#11558) (#11565) * fix encoding * remove useless function * SNYK: Sanitize and bind generateImage queries (#11562) * sanitize and bind generate image queries * adding throw exception * applying suggested changes * Update www/include/views/graphs/generateGraphs/generateImage.php Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> * SNYK: Sanitize and bind ACL actions queries (#11548) * sanitizing and binding acl actions queries * fix missing bind * MON-14501 - sanitize query in centreonXmlbgRequest class (#11571) * sanitize query in centreonXmlbgRequest class * add closeCursor func to resolve conv * SNYK: Sanitize and bind Meta-Services dependency queries (#11568) * sanityze 2 insert queries * spaces removed in a query * chore(install): Update version to 21.10.9 * fix(sql): fix query to select contact during ldap import (#11579) Refs: MON-14263 * (fix)MON-14742 Escape database name in CentACL (#11602) * fixed issue of using special chars in db names * fix escape database name * fixed security issue on sql requests * fix(platform) : Issue with cross databases query when the name contains some characters (#11279) (#11619) Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> * query sanitized in listServiceCategoriesà (#11597) (#11633) * Sanitize and bind listVirtualMetrics queries (#11648) * sanitize insrert queries in db-func (#11651) MON-14667 * Sanitized and bound queries in service argumentsXml file (#11654) MON-14669 * sanitize and bind host categories query (#11644) * Fix encoding issue on status serviceXML (#11582) * sanitize and bind in centreon connector query (#11636) * chore(git): update codeowners (#11593) * fix(conf) fix parent template display in service template listing (#11671) (#11677) * fix(poller): fix remote server duplication (#11552) (#11675) Refs: MON-14579 * fix(clapi): Check that user is admin to use clapi (#11631) (#11639) * Fix: Sanitize and bind service group dependecies queries 21.10.x (#11666) * fix(widgets): retrieve possibility to not select poller in pref (#11696) (#11699) Refs: MON-14919 * Fix: In Acces group the second select not working [ACL] 21.10.x (#11710) * fix second select not working * applying suggested changes * fix(details): remove dead code (#11672) (#11685) * fix(details): second part of code cleanup for "tools" (#11718) (#11722) * FIX: Sanitize and bind graph configuration queries 21.10.x (#11730) * Fix: Sanitize and bind CLAPI poller configuration 21.10.x (#11732) * sanitize and bind CLAPI poller config * remove unecessary comment * revert deleted imports * FIX: Sanitize and bind Meta Service configuration 21.10.x (#11734) * sanitize and bind meta service config * applying suggested changes * [Fix]:Sanitize and bind queries in template of service listing (#11745) * fix(resource): Fix bad SQL request (#11702) (#11750) * FIX: Sanitize and bind command configuration queries 21.10.x (#11755) * Rebase dev2110x on 2110x (#11825) * chore(release): merge release 21.10.9 into 21.10.x (#11628) * fix(git): resync 21.10.x to dev-21.10.x (#11499) * fix(test): wait 8s before checking downtime is active in rest api v1 test (#11498) (#11505) Refs: MON-14585 * fix(UI): Include host_id when selecting ServiceGroups on dashreports (#11428) (#11520) Co-authored-by: VHS <[email protected]> Co-authored-by: VHS <[email protected]> * [SNYK] Sanitize and bind centreonGraph class queries (#11409) (#11518) 1122 1153 1134 * [Snyk] Sanitize and bind ACL action access queries (#11385) (#11515) * Sanitize and bind ACL action access queries _ sanitize if possible each variables inserted in a query _ use PDO prepared statement and bind() method _ Do not use $pearDB->escape on which is for examples useless on integers and on non closed HTML tags (svg, img, etc) * fix line length * fix failed checks * fix(cron): Escape database name in CentACL 21.10.x (#11509) * fix(pendo): correctly set locale when language is detection by browser (#11484) (#11529) * fix(test): fix random fails on virtual metric test (#11524) Refs: MON-14359 * enh(platform): Use API to select metrics in virtual metrics configuration form 21.10.x (#11508) Refs: MON-14359 * doc(ack): acknowledge Hakaï security (#11539) * fix(web): fix the comment deletion for host monitored by poller (#11138) (#11557) Refs: MON-12828 Co-authored-by: Stéphane Duret <[email protected]> * SNYK: Sanitize and bind Broker listing queries (#11551) * Sanitizing and binding broker listing queries * applying suggested changes * fix(conf) fix encoding in template service listing (#11558) (#11565) * fix encoding * remove useless function * SNYK: Sanitize and bind generateImage queries (#11562) * sanitize and bind generate image queries * adding throw exception * applying suggested changes * Update www/include/views/graphs/generateGraphs/generateImage.php Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> * SNYK: Sanitize and bind ACL actions queries (#11548) * sanitizing and binding acl actions queries * fix missing bind * MON-14501 - sanitize query in centreonXmlbgRequest class (#11571) * sanitize query in centreonXmlbgRequest class * add closeCursor func to resolve conv * SNYK: Sanitize and bind Meta-Services dependency queries (#11568) * sanityze 2 insert queries * spaces removed in a query * chore(install): Update version to 21.10.9 * fix(sql): fix query to select contact during ldap import (#11579) Refs: MON-14263 * (fix)MON-14742 Escape database name in CentACL (#11602) * fixed issue of using special chars in db names * fix escape database name * fixed security issue on sql requests * fix(platform) : Issue with cross databases query when the name contains some characters (#11279) (#11619) Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> * chore(release): merge release-21.10.next into 21.10.x (#11820) * fix(git): resync 21.10.x to dev-21.10.x (#11499) * fix(test): wait 8s before checking downtime is active in rest api v1 test (#11498) (#11505) Refs: MON-14585 * fix(UI): Include host_id when selecting ServiceGroups on dashreports (#11428) (#11520) Co-authored-by: VHS <[email protected]> Co-authored-by: VHS <[email protected]> * [SNYK] Sanitize and bind centreonGraph class queries (#11409) (#11518) 1122 1153 1134 * [Snyk] Sanitize and bind ACL action access queries (#11385) (#11515) * Sanitize and bind ACL action access queries _ sanitize if possible each variables inserted in a query _ use PDO prepared statement and bind() method _ Do not use $pearDB->escape on which is for examples useless on integers and on non closed HTML tags (svg, img, etc) * fix line length * fix failed checks * fix(cron): Escape database name in CentACL 21.10.x (#11509) * fix(pendo): correctly set locale when language is detection by browser (#11484) (#11529) * fix(test): fix random fails on virtual metric test (#11524) Refs: MON-14359 * enh(platform): Use API to select metrics in virtual metrics configuration form 21.10.x (#11508) Refs: MON-14359 * doc(ack): acknowledge Hakaï security (#11539) * fix(web): fix the comment deletion for host monitored by poller (#11138) (#11557) Refs: MON-12828 Co-authored-by: Stéphane Duret <[email protected]> * SNYK: Sanitize and bind Broker listing queries (#11551) * Sanitizing and binding broker listing queries * applying suggested changes * fix(conf) fix encoding in template service listing (#11558) (#11565) * fix encoding * remove useless function * SNYK: Sanitize and bind generateImage queries (#11562) * sanitize and bind generate image queries * adding throw exception * applying suggested changes * Update www/include/views/graphs/generateGraphs/generateImage.php Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> * SNYK: Sanitize and bind ACL actions queries (#11548) * sanitizing and binding acl actions queries * fix missing bind * MON-14501 - sanitize query in centreonXmlbgRequest class (#11571) * sanitize query in centreonXmlbgRequest class * add closeCursor func to resolve conv * SNYK: Sanitize and bind Meta-Services dependency queries (#11568) * sanityze 2 insert queries * spaces removed in a query * chore(release): merge release 21.10.9 into 21.10.x (#11628) (#11629) * fix(git): resync 21.10.x to dev-21.10.x (#11499) * fix(test): wait 8s before checking downtime is active in rest api v1 test (#11498) (#11505) Refs: MON-14585 * fix(UI): Include host_id when selecting ServiceGroups on dashreports (#11428) (#11520) Co-authored-by: VHS <[email protected]> Co-authored-by: VHS <[email protected]> * [SNYK] Sanitize and bind centreonGraph class queries (#11409) (#11518) 1122 1153 1134 * [Snyk] Sanitize and bind ACL action access queries (#11385) (#11515) * Sanitize and bind ACL action access queries _ sanitize if possible each variables inserted in a query _ use PDO prepared statement and bind() method _ Do not use $pearDB->escape on which is for examples useless on integers and on non closed HTML tags (svg, img, etc) * fix line length * fix failed checks * fix(cron): Escape database name in CentACL 21.10.x (#11509) * fix(pendo): correctly set locale when language is detection by browser (#11484) (#11529) * fix(test): fix random fails on virtual metric test (#11524) Refs: MON-14359 * enh(platform): Use API to select metrics in virtual metrics configuration form 21.10.x (#11508) Refs: MON-14359 * doc(ack): acknowledge Hakaï security (#11539) * fix(web): fix the comment deletion for host monitored by poller (#11138) (#11557) Refs: MON-12828 Co-authored-by: Stéphane Duret <[email protected]> * SNYK: Sanitize and bind Broker listing queries (#11551) * Sanitizing and binding broker listing queries * applying suggested changes * fix(conf) fix encoding in template service listing (#11558) (#11565) * fix encoding * remove useless function * SNYK: Sanitize and bind generateImage queries (#11562) * sanitize and bind generate image queries * adding throw exception * applying suggested changes * Update www/include/views/graphs/generateGraphs/generateImage.php Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> * SNYK: Sanitize and bind ACL actions queries (#11548) * sanitizing and binding acl actions queries * fix missing bind * MON-14501 - sanitize query in centreonXmlbgRequest class (#11571) * sanitize query in centreonXmlbgRequest class * add closeCursor func to resolve conv * SNYK: Sanitize and bind Meta-Services dependency queries (#11568) * sanityze 2 insert queries * spaces removed in a query * chore(install): Update version to 21.10.9 * fix(sql): fix query to select contact during ldap import (#11579) Refs: MON-14263 * (fix)MON-14742 Escape database name in CentACL (#11602) * fixed issue of using special chars in db names * fix escape database name * fixed security issue on sql requests * fix(platform) : Issue with cross databases query when the name contains some characters (#11279) (#11619) Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> * query sanitized in listServiceCategoriesà (#11597) (#11633) * Sanitize and bind listVirtualMetrics queries (#11648) * sanitize insrert queries in db-func (#11651) MON-14667 * Sanitized and bound queries in service argumentsXml file (#11654) MON-14669 * sanitize and bind host categories query (#11644) * Fix encoding issue on status serviceXML (#11582) * sanitize and bind in centreon connector query (#11636) * chore(git): update codeowners (#11593) * fix(conf) fix parent template display in service template listing (#11671) (#11677) * fix(poller): fix remote server duplication (#11552) (#11675) Refs: MON-14579 * fix(clapi): Check that user is admin to use clapi (#11631) (#11639) * Fix: Sanitize and bind service group dependecies queries 21.10.x (#11666) * fix(widgets): retrieve possibility to not select poller in pref (#11696) (#11699) Refs: MON-14919 * Fix: In Acces group the second select not working [ACL] 21.10.x (#11710) * fix second select not working * applying suggested changes * fix(details): remove dead code (#11672) (#11685) * fix(details): second part of code cleanup for "tools" (#11718) (#11722) * FIX: Sanitize and bind graph configuration queries 21.10.x (#11730) * Fix: Sanitize and bind CLAPI poller configuration 21.10.x (#11732) * sanitize and bind CLAPI poller config * remove unecessary comment * revert deleted imports * FIX: Sanitize and bind Meta Service configuration 21.10.x (#11734) * sanitize and bind meta service config * applying suggested changes * [Fix]:Sanitize and bind queries in template of service listing (#11745) * fix(resource): Fix bad SQL request (#11702) (#11750) * FIX: Sanitize and bind command configuration queries 21.10.x (#11755) Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Charles Gautier <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> Co-authored-by: TamazC <[email protected]> Co-authored-by: Adrien Morais-Mestre <[email protected]> Co-authored-by: Laurent Calvet <[email protected]> Co-authored-by: Charles Gautier <[email protected]> Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> Co-authored-by: TamazC <[email protected]> Co-authored-by: Adrien Morais-Mestre <[email protected]> Co-authored-by: Laurent Calvet <[email protected]> * Fix: Remove obsolete code in ACL configuration listing (#11793) * [Fix]: Sanitize and bind service by hostgroups listing (#11795) * sanitize nad bind service by hostgroups listing * fix exceeded linee * Fix : Sanitize and bind centreon hostgroups class (#11800) * Fix: Sanitize and bind CLAPI Centreon Hostgroup class (#11802) * Fix: Sanitize and bind host category listing (#11805) * fix(conf/export) broker RRDcacheD export (#11811) (#11834) * FIX: SQLi in poller's broker configuration 21.10.x (#11778) * sanitize and bind pollers broker config queries * applying suggested changes * FIX: Sanitize and bind default configuration queries 21.10.x (#11787) * FIX: Sanitize and bind Centreon Notification class 21.10.x (#11792) * FIX: Sanitize and bind Centreon Notification class (#11757) * Update www/class/centreonNotification.class.php Co-authored-by: TamazC <[email protected]> * FIX: Sanitize and bind LDAP CLAPI listing 21.10.x (#11797) * sanitize and bind clapi LDAP listing * removing unecessary code * FIX: Sanitize and bind service listing 21.10.x (#11801) * sanitizing and binding service listing queries * removing var casting * FIX: Sanitize and bind SNMP Traps groups configuration 21.10.x (#11807) * Fix: Sanitize and bind Media import (#11788) * Fix: Remove obsolete code in monitoring common functions (#11844) * Fix: Sanitize and bind SNMP Traps listing (#11842) * Fix: Remove obsolete code in Criticality class (#11841) * remove obsolete function getHostTplCriticality in criticality class * Update www/class/centreonCriticality.class.php Co-authored-by: TamazC <[email protected]> Co-authored-by: TamazC <[email protected]> * Fix: Sanitize and bind CALPI Centreon service class (#11836) * sanitize and bine clapi centreon service class * Update www/class/centreon-clapi/centreonService.class.php space added into query Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> * FIX: Remove unused mechanism for modules to add restart/reload actions after restart of pollers 21.10.x (#11855) * removing obsolet code * removing more useless code * FIX: Removing unused code and fixing bug of generating csv in multiple periods graphs 21.10.x (#11857) * FIX: Sanitize and bind Knowledge Base host listing 21.10.x (#11859) * Fix: Remove obsolete code in database partitioning functions (#11839) * FIX: Sanitize and bind Centreon Service class 21.10.x (#11865) * sanitize and bind service class queries and fix bug mediawiki links * fixing links host templates mediawiki * backport MON-14223 -> dev-21.10.x (#11863) * FIX: SQLi in contact groups form 21.10.x (#11875) * Fix: Remove obsolete code in legacy service detail page (#11848) (#11880) * Remove obsolete code in legacy service detail page * restore deleted code * remove obsolete code in legacy service detail page and query sanitizeà * Fix: Sanitize and bind menu topology listing (#11832) (#11883) * sanitize and bind menu topology listing * fix bug in query closing * editing TopologyRepositoryTest file and change the query * typo * chore(release): update version to 21.10.11 Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Charles Gautier <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> Co-authored-by: TamazC <[email protected]> Co-authored-by: Adrien Morais-Mestre <[email protected]> Co-authored-by: Laurent Calvet <[email protected]>
1 parent 640435a commit 59a70af

39 files changed

+347
-369
lines changed

src/Centreon/Domain/Repository/TopologyRepository.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,15 @@ public function getReactTopologiesPerUserWithAcl($user)
103103
if ($DBRESULT->rowCount()) {
104104
$topology = array();
105105
$tmp_topo_page = array();
106+
$statement = $this->db->prepare("SELECT topology_topology_id, acl_topology_relations.access_right "
107+
. "FROM acl_topology_relations, acl_topology "
108+
. "WHERE acl_topology.acl_topo_activate = '1' "
109+
. "AND acl_topology.acl_topo_id = acl_topology_relations.acl_topo_id "
110+
. "AND acl_topology_relations.acl_topo_id = :acl_topo_id ");
106111
while ($topo_group = $DBRESULT->fetchRow()) {
107-
$query2 = "SELECT topology_topology_id, acl_topology_relations.access_right "
108-
. "FROM acl_topology_relations, acl_topology "
109-
. "WHERE acl_topology.acl_topo_activate = '1' "
110-
. "AND acl_topology.acl_topo_id = acl_topology_relations.acl_topo_id "
111-
. "AND acl_topology_relations.acl_topo_id = '" . $topo_group["acl_topology_id"] . "' ";
112-
$DBRESULT2 = $this->db->query($query2);
113-
while ($topo_page = $DBRESULT2->fetchRow()) {
112+
$statement->bindValue(':acl_topo_id', $topo_group["acl_topology_id"], \PDO::PARAM_INT);
113+
$statement->execute();
114+
while ($topo_page = $statement->fetch(\PDO::FETCH_ASSOC)) {
114115
$topology[] = (int)$topo_page["topology_topology_id"];
115116
if (!isset($tmp_topo_page[$topo_page['topology_topology_id']])) {
116117
$tmp_topo_page[$topo_page["topology_topology_id"]] = $topo_page["access_right"];
@@ -125,7 +126,7 @@ public function getReactTopologiesPerUserWithAcl($user)
125126
}
126127
}
127128
}
128-
$DBRESULT2->closeCursor();
129+
$statement->closeCursor();
129130
}
130131
$DBRESULT->closeCursor();
131132

src/Centreon/Tests/Domain/Repository/TopologyRepositoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function setUp(): void
4646
. "FROM acl_topology_relations, acl_topology "
4747
. "WHERE acl_topology.acl_topo_activate = '1' "
4848
. "AND acl_topology.acl_topo_id = acl_topology_relations.acl_topo_id "
49-
. "AND acl_topology_relations.acl_topo_id = '1' ",
49+
. "AND acl_topology_relations.acl_topo_id = :acl_topo_id ",
5050
'data' => [
5151
[
5252
'topology_topology_id' => 1,

www/class/centreon-clapi/centreonHostGroup.class.php

+15-10
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public function getparam($parameters = null)
174174
$listParam = explode('|', $params[1]);
175175
$exportedFields = [];
176176
$resultString = "";
177+
$paramString = "";
177178
foreach ($listParam as $paramSearch) {
178179
if (!$paramString) {
179180
$paramString = $paramSearch;
@@ -257,20 +258,24 @@ public function initUpdateParameters($parameters = null)
257258
public function getIdIcon($path)
258259
{
259260
$iconData = explode('/', $path);
260-
$query = 'SELECT dir_id FROM view_img_dir WHERE dir_name = "' . $iconData[0] . '"';
261-
$res = $this->db->query($query);
262-
$row = $res->fetch();
261+
$dirStatement = $this->db->prepare("SELECT dir_id FROM view_img_dir WHERE dir_name = :IconData");
262+
$dirStatement->bindValue(':IconData', $iconData[0], \PDO::PARAM_STR);
263+
$dirStatement->execute();
264+
$row = $dirStatement->fetch();
263265
$dirId = $row['dir_id'];
264266

265-
$query = 'SELECT img_id FROM view_img WHERE img_path = "' . $iconData[1] . '"';
266-
$res = $this->db->query($query);
267-
$row = $res->fetch();
267+
$imgStatement = $this->db->prepare("SELECT img_id FROM view_img WHERE img_path = :iconData");
268+
$imgStatement->bindValue(':iconData', $iconData[1], \PDO::PARAM_STR);
269+
$imgStatement->execute();
270+
$row = $imgStatement->fetch();
268271
$iconId = $row['img_id'];
269272

270-
$query = 'SELECT vidr_id FROM view_img_dir_relation ' .
271-
'WHERE dir_dir_parent_id = ' . $dirId . ' AND img_img_id = ' . $iconId;
272-
$res = $this->db->query($query);
273-
$row = $res->fetch();
273+
$vidrStatement = $this->db->prepare("SELECT vidr_id FROM view_img_dir_relation " .
274+
"WHERE dir_dir_parent_id = :dirId AND img_img_id = :iconId");
275+
$vidrStatement->bindValue(':dirId', (int) $dirId, \PDO::PARAM_INT);
276+
$vidrStatement->bindValue(':iconId', (int) $iconId, \PDO::PARAM_INT);
277+
$vidrStatement->execute();
278+
$row = $vidrStatement->fetch();
274279
return $row['vidr_id'];
275280
}
276281

www/class/centreon-clapi/centreonLDAP.class.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ public function showserver($arName = null)
184184
}
185185
$sql = "SELECT ldap_host_id, host_address, host_port, use_ssl, use_tls, host_order
186186
FROM auth_ressource_host
187-
WHERE auth_ressource_id = " . $arId . "
187+
WHERE auth_ressource_id = :auth_ressource_id
188188
ORDER BY host_order";
189-
$res = $this->db->query($sql);
190-
$row = $res->fetchAll();
189+
$statement = $this->db->prepare($sql);
190+
$statement->bindValue(':auth_ressource_id', (int) $arId, \PDO::PARAM_INT);
191+
$statement->execute();
192+
$row = $statement->fetchAll(\PDO::FETCH_ASSOC);
191193
echo "id;address;port;ssl;tls;order\n";
192194
foreach ($row as $srv) {
193195
echo $srv['ldap_host_id'] . $this->delim .

www/class/centreon-clapi/centreonService.class.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1584,12 +1584,12 @@ public function getCustomMacroInDb($serviceId = null, $template = null)
15841584
$arr = array();
15851585
$i = 0;
15861586
if ($serviceId) {
1587-
$res = $this->db->query("SELECT svc_macro_name, svc_macro_value, is_password, description
1588-
FROM on_demand_macro_service
1589-
WHERE svc_svc_id = " .
1590-
$serviceId . "
1591-
ORDER BY macro_order ASC");
1592-
while ($row = $res->fetch()) {
1587+
$statement = $this->db->prepare("SELECT svc_macro_name, svc_macro_value, is_password, description " .
1588+
"FROM on_demand_macro_service " .
1589+
"WHERE svc_svc_id = :serviceId ORDER BY macro_order ASC");
1590+
$statement->bindValue(':serviceId', (int) $serviceId, \PDO::PARAM_INT);
1591+
$statement->execute();
1592+
while ($row = $statement->fetch()) {
15931593
if (preg_match('/\$_SERVICE(.*)\$$/', $row['svc_macro_name'], $matches)) {
15941594
$arr[$i]['svc_macro_name'] = $matches[1];
15951595
$arr[$i]['svc_macro_value'] = $row['svc_macro_value'];

www/class/centreon-knowledge/procedures.class.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,15 @@ public function getMyHostMultipleTemplateModels($host_id = null)
139139
"WHERE host_host_id = '" . $host_id . "' " .
140140
"ORDER BY `order`"
141141
);
142+
$statement = $this->centreon_DB->prepare(
143+
"SELECT host_name " .
144+
"FROM host " .
145+
"WHERE host_id = :host_id LIMIT 1"
146+
);
142147
while ($row = $dbResult->fetch()) {
143-
$dbResult2 = $this->centreon_DB->query(
144-
"SELECT host_name " .
145-
"FROM host " .
146-
"WHERE host_id = '" . $row['host_tpl_id'] . "' LIMIT 1"
147-
);
148-
$hTpl = $dbResult2->fetch();
148+
$statement->bindValue(':host_id', $row['host_tpl_id'], \PDO::PARAM_INT);
149+
$statement->execute();
150+
$hTpl = $statement->fetch(\PDO::FETCH_ASSOC);
149151
$tplArr[$row['host_tpl_id']] = html_entity_decode($hTpl["host_name"], ENT_QUOTES);
150152
}
151153
unset($row);

www/class/centreon-partition/partEngine.class.php

-38
Original file line numberDiff line numberDiff line change
@@ -426,44 +426,6 @@ public function updateParts($table, $db)
426426
}
427427
}
428428

429-
/**
430-
* optimize all partitions for a table
431-
*
432-
* @param MysqlTable $table
433-
*/
434-
public function optimizeTablePartitions($table, $db)
435-
{
436-
$tableName = "`" . $table->getSchema() . "`." . $table->getName();
437-
if (!$table->exists()) {
438-
throw new Exception("Optimize error: Table " . $tableName . " does not exists\n");
439-
}
440-
441-
$request = "SELECT PARTITION_NAME FROM information_schema.`PARTITIONS` ";
442-
$request .= "WHERE `TABLE_NAME`='" . $table->getName() . "' ";
443-
$request .= "AND TABLE_SCHEMA='" . $table->getSchema() . "' ";
444-
try {
445-
$dbResult = $db->query($request);
446-
} catch (\PDOException $e) {
447-
throw new Exception(
448-
"Error : Cannot get table schema information for "
449-
. $tableName . ", " . $e->getMessage() . "\n"
450-
);
451-
}
452-
453-
while ($row = $dbResult->fetch()) {
454-
$request = "ALTER TABLE " . $tableName . " OPTIMIZE PARTITION `" . $row["PARTITION_NAME"] . "`;";
455-
try {
456-
$dbResult2 = $db->query($request);
457-
} catch (\PDOException $e) {
458-
throw new Exception(
459-
"Optimize error : Cannot optimize partition " . $row["PARTITION_NAME"]
460-
. " of table " . $tableName . ", " . $e->getMessage() . "\n"
461-
);
462-
}
463-
}
464-
465-
$dbResult->closeCursor();
466-
}
467429

468430
/**
469431
* list all partitions for a table

www/class/centreon.class.php

-10
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,12 @@ public function creatModuleList()
162162
$this->modules[$result["name"]] = array(
163163
"name" => $result["name"],
164164
"gen" => false,
165-
"restart" => false,
166165
"license" => false
167166
);
168167

169168
if (is_dir("./modules/" . $result["name"] . "/generate_files/")) {
170169
$this->modules[$result["name"]]["gen"] = true;
171170
}
172-
if (is_dir("./modules/" . $result["name"] . "/restart_pollers/")) {
173-
$this->modules[$result["name"]]["restart"] = true;
174-
}
175-
if (is_dir("./modules/" . $result["name"] . "/restart_pollers/")) {
176-
$this->modules[$result["name"]]["restart"] = true;
177-
}
178-
if (file_exists("./modules/" . $result["name"] . "/license/merethis_lic.zl")) {
179-
$this->modules[$result["name"]]["license"] = true;
180-
}
181171
}
182172
$dbResult = null;
183173
}

www/class/centreonConfigCentreonBroker.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,15 @@ public function insertConfig($values)
731731
/*
732732
* Get the ID
733733
*/
734-
$query = "SELECT config_id FROM cfg_centreonbroker WHERE config_name = '" . $values['name'] . "'";
734+
$query = "SELECT config_id FROM cfg_centreonbroker WHERE config_name = :config_name";
735735
try {
736-
$res = $this->db->query($query);
736+
$statement = $this->db->prepare($query);
737+
$statement->bindValue(':config_name', $values['name'], \PDO::PARAM_STR);
738+
$statement->execute();
737739
} catch (\PDOException $e) {
738740
return false;
739741
}
740-
$row = $res->fetch();
742+
$row = $statement->fetch(\PDO::FETCH_ASSOC);
741743
$id = $row['config_id'];
742744

743745
/*

www/class/centreonCriticality.class.php

-25
Original file line numberDiff line numberDiff line change
@@ -358,29 +358,4 @@ protected function getServiceCriticality($service_id)
358358
}
359359
return 0;
360360
}
361-
362-
public function getHostTplCriticities($host_id, $cache)
363-
{
364-
global $pearDB;
365-
366-
if (!$host_id) {
367-
return null;
368-
}
369-
370-
$rq = "SELECT host_tpl_id " .
371-
"FROM host_template_relation " .
372-
"WHERE host_host_id = '".$host_id."' " .
373-
"ORDER BY `order`";
374-
$DBRESULT = $pearDB->query($rq);
375-
while ($row = $DBRESULT->fetchRow()) {
376-
if (isset($cache[$row['host_tpl_id']])) {
377-
return $this->getData($cache[$row['host_tpl_id']], false);
378-
} else {
379-
if ($result_field = $this->getHostTplCriticities($row['host_tpl_id'], $cache)) {
380-
return $result_field;
381-
}
382-
}
383-
}
384-
return null;
385-
}
386361
}

www/class/centreonDB.class.php

+43
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,47 @@ public function isColumnExist(string $table = null, string $column = null): int
447447
return -1;
448448
}
449449
}
450+
451+
/**
452+
* Write SQL errors messages and queries
453+
*
454+
* @param string $query the query string to write to log
455+
* @param string $message the message to write to log
456+
*/
457+
private function logSqlError(string $query, string $message): void
458+
{
459+
$this->log->insertLog(2, $message . " QUERY : " . $query);
460+
}
461+
462+
/**
463+
* This method returns a column type from a given table and column.
464+
*
465+
* @param string $tableName
466+
* @param string $columnName
467+
* @return string
468+
*/
469+
public function getColumnType(string $tableName, string $columnName): string
470+
{
471+
$query = 'SELECT COLUMN_TYPE
472+
FROM INFORMATION_SCHEMA.COLUMNS
473+
WHERE TABLE_SCHEMA = :dbName
474+
AND TABLE_NAME = :tableName
475+
AND COLUMN_NAME = :columnName';
476+
477+
$stmt = $this->prepare($query);
478+
479+
try {
480+
$stmt->bindValue(':dbName', $this->dsn['database'], \PDO::PARAM_STR);
481+
$stmt->bindValue(':tableName', $tableName, \PDO::PARAM_STR);
482+
$stmt->bindValue(':columnName', $columnName, \PDO::PARAM_STR);
483+
$stmt->execute();
484+
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
485+
if (! empty($result)) {
486+
return $result['COLUMN_TYPE'];
487+
}
488+
throw new \PDOException("Unable to get column type");
489+
} catch (\PDOException $e) {
490+
$this->logSqlError($query, $e->getMessage());
491+
}
492+
}
450493
}

www/class/centreonHostgroups.class.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,19 @@ public function getHostGroupHosts($hg_id = null)
100100
}
101101

102102
$hosts = array();
103-
$DBRESULT = $this->DB->query(
104-
"SELECT hgr.host_host_id " .
103+
$statement = $this->DB->prepare("SELECT hgr.host_host_id " .
105104
"FROM hostgroup_relation hgr, host h " .
106-
"WHERE hgr.hostgroup_hg_id = '" . $this->DB->escape($hg_id) . "' " .
105+
"WHERE hgr.hostgroup_hg_id = :hgId " .
107106
"AND h.host_id = hgr.host_host_id " .
108-
"ORDER by h.host_name"
109-
);
110-
while ($elem = $DBRESULT->fetchRow()) {
107+
"ORDER by h.host_name");
108+
$statement->bindValue(':hgId', (int) $hg_id, \PDO::PARAM_INT);
109+
$statement->execute();
110+
111+
while ($elem = $statement->fetchRow()) {
111112
$ref[$elem["host_host_id"]] = $elem["host_host_id"];
112113
$hosts[] = $elem["host_host_id"];
113114
}
114-
$DBRESULT->closeCursor();
115+
$statement->closeCursor();
115116
unset($elem);
116117

117118
if (isset($hostgroups) && count($hostgroups)) {

www/class/centreonMedia.class.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,12 @@ public function addImage($parameters, $binary = null)
410410
$imageId = $row['img_id'];
411411

412412
// Insert relation between directory and image
413-
$query = 'INSERT INTO view_img_dir_relation '
414-
. '(dir_dir_parent_id, img_img_id) '
415-
. 'VALUES ('
416-
. $directoryId . ', '
417-
. $imageId . ' '
418-
. ') ';
413+
$statement = $this->db->prepare("INSERT INTO view_img_dir_relation (dir_dir_parent_id, img_img_id) " .
414+
"VALUES (:dirId, :imgId) ");
415+
$statement->bindValue(':dirId', (int) $directoryId, \PDO::PARAM_INT);
416+
$statement->bindValue(':imgId', (int) $imageId, \PDO::PARAM_INT);
419417
try {
420-
$this->db->query($query);
418+
$statement->execute();
421419
} catch (\PDOException $e) {
422420
throw new \Exception('Error while inserting relation between' . $imageName . ' and ' . $directoryName);
423421
}

www/class/centreonNotification.class.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,12 @@ protected function getHostTemplateNotifications($hostId, $templates)
342342
FROM host_template_relation htr
343343
LEFT JOIN contact_host_relation ctr ON htr.host_host_id = ctr.host_host_id
344344
LEFT JOIN contactgroup_host_relation ctr2 ON htr.host_host_id = ctr2.host_host_id
345-
WHERE htr.host_host_id = " . $hostId . "
345+
WHERE htr.host_host_id = :host_id
346346
ORDER BY `order`";
347-
$res = $this->db->query($sql);
348-
while ($row = $res->fetchRow()) {
347+
$statement = $this->db->prepare($sql);
348+
$statement->bindValue(':host_id', (int) $hostId, \PDO::PARAM_INT);
349+
$statement->execute();
350+
while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
349351
if ($row['contact_id']) {
350352
$this->hostBreak[1] = true;
351353
}

www/class/centreonService.class.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -1727,12 +1727,14 @@ public function getTemplatesChain($svcId, $alreadyProcessed = array())
17271727
} else {
17281728
$alreadyProcessed[] = $svcId;
17291729

1730-
$res = $this->db->query(
1731-
"SELECT service_template_model_stm_id FROM service WHERE service_id = " . $this->db->escape($svcId)
1730+
$statement = $this->db->prepare(
1731+
"SELECT service_template_model_stm_id FROM service WHERE service_id = :service_id"
17321732
);
1733+
$statement->bindValue(':service_id', (int) $svcId, \PDO::PARAM_INT);
1734+
$statement->execute();
17331735

1734-
if ($res->rowCount()) {
1735-
$row = $res->fetchRow();
1736+
if ($statement->rowCount()) {
1737+
$row = $statement->fetch(\PDO::FETCH_ASSOC);
17361738
if (!empty($row['service_template_model_stm_id']) && $row['service_template_model_stm_id'] !== null) {
17371739
$svcTmpl = array_merge(
17381740
$svcTmpl,

0 commit comments

Comments
 (0)