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

Commit

Permalink
Fix: Sanitize and bind menu topology listing (#11832)
Browse files Browse the repository at this point in the history
* sanitize and bind menu topology listing

* fix bug in query closing

* editing TopologyRepositoryTest file and change the query

* typo
  • Loading branch information
emabassi-ext committed Sep 27, 2022
1 parent b000506 commit 360d75c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/Centreon/Domain/Repository/TopologyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ public function getReactTopologiesPerUserWithAcl($user)
if ($DBRESULT->rowCount()) {
$topology = array();
$tmp_topo_page = array();
$statement = $this->db->prepare("SELECT topology_topology_id, acl_topology_relations.access_right "
. "FROM acl_topology_relations, acl_topology "
. "WHERE acl_topology.acl_topo_activate = '1' "
. "AND acl_topology.acl_topo_id = acl_topology_relations.acl_topo_id "
. "AND acl_topology_relations.acl_topo_id = :acl_topo_id ");
while ($topo_group = $DBRESULT->fetchRow()) {
$query2 = "SELECT topology_topology_id, acl_topology_relations.access_right "
. "FROM acl_topology_relations, acl_topology "
. "WHERE acl_topology.acl_topo_activate = '1' "
. "AND acl_topology.acl_topo_id = acl_topology_relations.acl_topo_id "
. "AND acl_topology_relations.acl_topo_id = '" . $topo_group["acl_topology_id"] . "' ";
$DBRESULT2 = $this->db->query($query2);
while ($topo_page = $DBRESULT2->fetchRow()) {
$statement->bindValue(':acl_topo_id', $topo_group["acl_topology_id"], \PDO::PARAM_INT);
$statement->execute();
while ($topo_page = $statement->fetch(\PDO::FETCH_ASSOC)) {
$topology[] = (int)$topo_page["topology_topology_id"];
if (!isset($tmp_topo_page[$topo_page['topology_topology_id']])) {
$tmp_topo_page[$topo_page["topology_topology_id"]] = $topo_page["access_right"];
Expand All @@ -127,7 +128,7 @@ public function getReactTopologiesPerUserWithAcl($user)
}
}
}
$DBRESULT2->closeCursor();
$statement->closeCursor();
}
$DBRESULT->closeCursor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function setUp(): void
. "FROM acl_topology_relations, acl_topology "
. "WHERE acl_topology.acl_topo_activate = '1' "
. "AND acl_topology.acl_topo_id = acl_topology_relations.acl_topo_id "
. "AND acl_topology_relations.acl_topo_id = '1' ",
. "AND acl_topology_relations.acl_topo_id = :acl_topo_id ",
'data' => [
[
'topology_topology_id' => 1,
Expand Down

0 comments on commit 360d75c

Please sign in to comment.