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

[SNYK] Sanitize and bind host categories query #11591

Merged
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ function multipleHostCategoriesInDB($hostCategories = [], $nbrDup = [])
$statement3->bindValue(':hc_id', $hcId, \PDO::PARAM_INT);
$statement3->execute();
$fields["hc_hosts"] = "";
$hrstatement = $pearDB->prepare("INSERT INTO hostcategories_relation VALUES (:maxId, :hostId)");
while ($host = $statement3->fetch()) {
$query = "INSERT INTO hostcategories_relation VALUES ('" . $maxId["MAX(hc_id)"] .
"', '" . $host["host_host_id"] . "')";
$pearDB->query($query);
$hrstatement->bindValue(':maxId', (int) $maxId["MAX(hc_id)"], \PDO::PARAM_INT);
$hrstatement->bindValue(':hostId', (int) $host["host_host_id"], \PDO::PARAM_INT);
$hrstatement->execute();
$fields["hc_hosts"] .= $host["host_host_id"] . ",";
}
$fields["hc_hosts"] = trim($fields["hc_hosts"], ",");
Expand Down