Skip to content

Commit 434e291

Browse files
author
Maximilien Bersoult
committed
* Better SQL escape
1 parent 97b290a commit 434e291

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

Diff for: www/include/common/javascript/autologoutXMLresponse.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
if (isset($_SESSION['centreon'])) {
5454
$oreon = $_SESSION['centreon'];
5555
$currentTime = $oreon->CentreonGMT->getDate(_("Y/m/d G:i"), time(), $oreon->user->getMyGMT());
56-
$DBRESULT = $pearDB->query("SELECT user_id FROM session WHERE session_id = '" . htmlentities($_GET['sid'], ENT_QUOTES, "UTF-8") . "'");
56+
$DBRESULT = $pearDB->query("SELECT user_id FROM session WHERE session_id = '" . $pearDB->escape($_GET['sid']) . "'");
5757
if ($DBRESULT->numRows()) {
5858
$buffer->writeElement("state", "ok");
5959
} else {
@@ -70,4 +70,4 @@
7070
header('Expires: 0');
7171
header('Cache-Control: no-cache, must-revalidate');
7272
$buffer->output();
73-
?>
73+
?>

Diff for: www/include/common/javascript/commandGetArgs/cmdGetExample.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ function myDecodeService($arg) {
5555
$pearDB = new CentreonDB();
5656

5757
if (isset($_POST["index"])){
58-
$DBRESULT = $pearDB->query("SELECT `command_example` FROM `command` WHERE `command_id` = '". $_POST["index"] ."'");
58+
$DBRESULT = $pearDB->query("SELECT `command_example` FROM `command` WHERE `command_id` = '". $pearDB->escape($_POST["index"]) ."'");
5959
while ($arg = $DBRESULT->fetchRow())
6060
echo myDecodeService($arg["command_example"]);
6161
unset($arg);
6262
unset($DBRESULT);
6363
$pearDB->disconnect();
6464
}
65-
?>
65+
?>

Diff for: www/include/reporting/dashboard/xmlInformations/GetXmlHost.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
$pearDB = new CentreonDB();
5151
$pearDBO = new CentreonDB("centstorage");
5252

53-
$DBRESULT = $pearDB->query("SELECT * FROM session WHERE session_id = '" . htmlentities($_GET['session'], ENT_QUOTES, "UTF-8") . "'");
53+
$DBRESULT = $pearDB->query("SELECT * FROM session WHERE session_id = '" . $pearDB->escape($_GET['session']) . "'");
5454
if (!$DBRESULT->numRows())
5555
exit();
5656

@@ -67,7 +67,7 @@
6767
$color[$key] = htmlentities($value, ENT_QUOTES, "UTF-8");
6868
}
6969

70-
$DBRESULT = $pearDBO->query("SELECT * FROM `log_archive_host` WHERE host_id = " . $_GET["id"] . " order by date_start desc");
70+
$DBRESULT = $pearDBO->query("SELECT * FROM `log_archive_host` WHERE host_id = " . $pearDBO->escape($_GET["id"]) . " order by date_start desc");
7171
while ($row = $DBRESULT->fetchRow()) {
7272
fillBuffer($statesTab, $row, $color);
7373
}
@@ -78,4 +78,4 @@
7878
$buffer->endElement();
7979
header('Content-Type: text/xml');
8080
$buffer->output();
81-
?>
81+
?>

Diff for: www/include/reporting/dashboard/xmlInformations/GetXmlHostGroup.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
$pearDB = new CentreonDB();
5252
$pearDBO = new CentreonDB("centstorage");
5353

54-
$DBRESULT = $pearDB->query("SELECT * FROM session WHERE session_id = '" . htmlentities($_GET['session'], ENT_QUOTES, "UTF-8") . "'");
54+
$DBRESULT = $pearDB->query("SELECT * FROM session WHERE session_id = '" . $pearDB->escape($_GET['session']) . "'");
5555
if (!$DBRESULT->numRows())
5656
exit();
5757

@@ -93,4 +93,4 @@
9393

9494
header('Content-Type: text/xml');
9595
$buffer->output();
96-
?>
96+
?>

Diff for: www/include/reporting/dashboard/xmlInformations/GetXmlService.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
$pearDB = new CentreonDB();
5151
$pearDBO = new CentreonDB("centstorage");
5252

53-
$DBRESULT = $pearDB->query("SELECT * FROM session WHERE session_id = '" . htmlentities($_GET['session'], ENT_QUOTES, "UTF-8") . "'");
53+
$DBRESULT = $pearDB->query("SELECT * FROM session WHERE session_id = '" . $pearDB->escape($_GET['session']) . "'");
5454
if (!$DBRESULT->numRows())
5555
exit();
5656

@@ -68,7 +68,7 @@
6868
$color[$key] = htmlentities($value, ENT_QUOTES, "UTF-8");
6969
}
7070

71-
$DBRESULT = $pearDBO->query("SELECT * FROM `log_archive_service` WHERE host_id = '".$_GET["host_id"]."' AND service_id = ".$_GET["id"]." ORDER BY `date_start` DESC");
71+
$DBRESULT = $pearDBO->query("SELECT * FROM `log_archive_service` WHERE host_id = '".$pearDBO->escape($_GET["host_id"])."' AND service_id = ".$pearDBO->escape($_GET["id"])." ORDER BY `date_start` DESC");
7272
while ($row = $DBRESULT->fetchRow()) {
7373
fillBuffer($statesTab, $row, $color);
7474
}
@@ -81,4 +81,4 @@
8181

8282
header('Content-Type: text/xml');
8383
$buffer->output();
84-
?>
84+
?>

Diff for: www/include/reporting/dashboard/xmlInformations/GetXmlServiceGroup.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
$pearDB = new CentreonDB();
5252
$pearDBO = new CentreonDB("centstorage");
5353

54-
$DBRESULT = $pearDB->query("SELECT * FROM session WHERE session_id = '" . htmlentities($_GET['session'], ENT_QUOTES, "UTF-8") . "'");
54+
$DBRESULT = $pearDB->query("SELECT * FROM session WHERE session_id = '" . $pearDB->escape($_GET['session']) . "'");
5555
if (!$DBRESULT->numRows())
5656
exit();
5757

@@ -99,4 +99,4 @@
9999

100100
header('Content-Type: text/xml');
101101
$buffer->output();
102-
?>
102+
?>

Diff for: www/menu/userMenuPreferences.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
/*
5252
* Check session id
5353
*/
54-
$session = $pearDB->query("SELECT user_id FROM `session` WHERE session_id = '".htmlentities(session_id(), ENT_QUOTES, "UTF-8")."' AND user_id = '".htmlentities($_GET['uid'], ENT_QUOTES, "UTF-8")."'");
54+
$session = $pearDB->query("SELECT user_id FROM `session` WHERE session_id = '".$pearDB->escape(session_id())."' AND user_id = '".$pearDB->escape($_GET['uid'])."'");
5555
if (!$session->numRows()){
5656
exit;
5757
}
@@ -67,4 +67,4 @@
6767
$_SESSION['_Div_' . $my_div] = 1;
6868
}
6969
}
70-
?>
70+
?>

Diff for: www/menu/xml/menuXML.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
/*
6161
* Check Session existence
6262
*/
63-
$session = $pearDB->query("SELECT user_id FROM `session` WHERE session_id = '".htmlentities($_GET["sid"], ENT_QUOTES, "UTF-8")."'");
63+
$session = $pearDB->query("SELECT user_id FROM `session` WHERE session_id = '".$pearDB->escape($_GET["sid"])."'");
6464
if (!$session->numRows()){
6565
$buffer = new CentreonXML();
6666
$buffer->startElement("root");
@@ -95,7 +95,7 @@
9595
/*
9696
* Get CSS
9797
*/
98-
$DBRESULT2 = $pearDB->query("SELECT css_name FROM `css_color_menu` WHERE menu_nb = '".htmlentities($_GET["menu"], ENT_QUOTES, "UTF-8")."' LIMIT 1");
98+
$DBRESULT2 = $pearDB->query("SELECT css_name FROM `css_color_menu` WHERE menu_nb = '".$pearDB->escape($_GET["menu"])."' LIMIT 1");
9999
$menu_style = $DBRESULT2->fetchRow();
100100

101101
ob_start();
@@ -154,4 +154,4 @@
154154
header('Content-Type: text/xml');
155155
header('Cache-Control: no-cache');
156156
$buffer->output();
157-
?>
157+
?>

0 commit comments

Comments
 (0)