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

[SNYK] Sanitize and bind ACL host dependency queries #11389

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Changes from 1 commit
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
27 changes: 17 additions & 10 deletions www/include/configuration/configObject/host_dependency/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ function multipleHostDependencyInDB($dependencies = array(), $nbrDup = array())
$dbResult = $pearDB->query($query);
$fields["dep_serviceChilds"] = "";
while ($service = $dbResult->fetch()) {
$query = "INSERT INTO dependency_serviceChild_relation VALUES ('" .
$maxId["MAX(dep_id)"] . "', '" . $service["service_service_id"] . "', '" .
$service["host_host_id"] . "')";
$pearDB->query($query);
$statement = $pearDB->prepare("INSERT INTO dependency_serviceChild_relation " .
" VALUES (:max_dep_id, :service_service_id, :host_host_id)");
emabassi-ext marked this conversation as resolved.
Show resolved Hide resolved
$statement->bindValue(':max_dep_id', (int)$maxId["MAX(dep_id)"], \PDO::PARAM_INT);
$statement->bindValue(':service_service_id', (int)$service["service_service_id"], \PDO::PARAM_INT);
$statement->bindValue(':host_host_id', (int)$service["host_host_id"], \PDO::PARAM_INT);
$statement->execute();

$fields["dep_serviceChilds"] .= $service["host_host_id"] .
'-' . $service["service_service_id"] . ",";
}
Expand All @@ -137,9 +140,11 @@ function multipleHostDependencyInDB($dependencies = array(), $nbrDup = array())
$dbResult = $pearDB->query($query);
$fields["dep_hostParents"] = "";
while ($host = $dbResult->fetch()) {
$query = "INSERT INTO dependency_hostParent_relation " .
"VALUES ('" . $maxId["MAX(dep_id)"] . "', '" . $host["host_host_id"] . "')";
$pearDB->query($query);
$statement = $pearDB->prepare("INSERT INTO dependency_hostParent_relation " .
"VALUES (:max_dep_id, :host_host_id)");
emabassi-ext marked this conversation as resolved.
Show resolved Hide resolved
$statement->bindValue(':max_dep_id', (int)$maxId["MAX(dep_id)"], \PDO::PARAM_INT);
$statement->bindValue(':host_host_id', (int)$host["host_host_id"], \PDO::PARAM_INT);
$statement->execute();
$fields["dep_hostParents"] .= $host["host_host_id"] . ",";
}
$fields["dep_hostParents"] = trim($fields["dep_hostParents"], ",");
Expand All @@ -149,9 +154,11 @@ function multipleHostDependencyInDB($dependencies = array(), $nbrDup = array())
$dbResult = $pearDB->query($query);
$fields["dep_hostChilds"] = "";
while ($host = $dbResult->fetch()) {
$query = "INSERT INTO dependency_hostChild_relation " .
"VALUES ('" . $maxId["MAX(dep_id)"] . "', '" . $host["host_host_id"] . "')";
$pearDB->query($query);
$statement = $pearDB->prepare("INSERT INTO dependency_hostChild_relation " .
"VALUES (:max_dep_id, :host_host_id)");
emabassi-ext marked this conversation as resolved.
Show resolved Hide resolved
$statement->bindValue(':max_dep_id', (int)$maxId["MAX(dep_id)"], \PDO::PARAM_INT);
$statement->bindValue(':host_host_id', (int)$host["host_host_id"], \PDO::PARAM_INT);
$statement->execute();
$fields["dep_hostChilds"] .= $host["host_host_id"] . ",";
}
$fields["dep_hostChilds"] = trim($fields["dep_hostChilds"], ",");
Expand Down