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

Commit

Permalink
fix(security): do not allow to get all services using downtime ajax f…
Browse files Browse the repository at this point in the history
…ile (#8022)
  • Loading branch information
kduret authored Oct 28, 2019
1 parent 0a02bd2 commit 1722da5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1,025 deletions.
119 changes: 0 additions & 119 deletions www/include/monitoring/recurrentDowntime/GetXMLHost4Services.php

This file was deleted.

33 changes: 12 additions & 21 deletions www/include/monitoring/recurrentDowntime/ajaxPeriods.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,21 @@
*
*/

header('Content-Type: application/json');
header('Cache-Control: no-cache');
header('Content-Type: application/json');
header('Cache-Control: no-cache');

require_once realpath(dirname(__FILE__) . "/../../../../config/centreon.config.php");
require_once _CENTREON_PATH_ . "/www/class/centreonDB.class.php";
require_once _CENTREON_PATH_ . "/www/class/centreonDowntime.class.php";
require_once __DIR__ . "/../../../../config/centreon.config.php";
require_once _CENTREON_PATH_ . "/www/class/centreonDB.class.php";
require_once _CENTREON_PATH_ . "/www/class/centreonDowntime.class.php";

$pearDB = new CentreonDB();

if (isset($_GET['dt_id'])) {
$id = $_GET['dt_id'];
} else {
$id = 0;
}

$path = _CENTREON_PATH_ . "www/include/monitoring/recurrentDowntime/";
$downtimeId = filter_input(INPUT_GET, 'dt_id', FILTER_VALIDATE_INT);

if (!empty($downtimeId)) {
$pearDB = new CentreonDB();
$downtime = new CentreonDowntime($pearDB);

require_once $path . 'json.php';
if ($id == 0) {
$periods = array();
$periods = $downtime->getPeriods($downtimeId);
} else {
$periods = $downtime->getPeriods($id);
$periods = array();
}
$json = new Services_JSON();
print $json->encode($periods);

print json_encode($periods);
56 changes: 0 additions & 56 deletions www/include/monitoring/recurrentDowntime/formDowntime.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,62 +53,6 @@
return false;
}

function getXhrHost4Svc(){
if (window.XMLHttpRequest) // Firefox et autres
var xhrT = new XMLHttpRequest();
else if(window.ActiveXObject){ // Internet Explorer
try {
var xhrT = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
var xhrT = new ActiveXObject("Microsoft.XMLHTTP");
}
} else { // XMLHttpRequest non support2 par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
var xhrT = false;
}
return xhrT;
}

function getServices(host_id) {
var arg = 'host_id='+host_id;
var xhrT = getXhrHost4Svc();

xhrT.open("POST","./include/monitoring/recurrentDowntime/GetXMLHost4Services.php", true);
xhrT.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhrT.send(arg);

/* Responce */
xhrT.onreadystatechange = function()
{
// Responce Ok
if (xhrT && xhrT.readyState == 4 && xhrT.status == 200 && xhrT.responseXML){
reponseT = xhrT.responseXML.documentElement;
var _services = reponseT.getElementsByTagName("service");

var _selbox = document.getElementById("svc_relation-f");
while ( _selbox.options.length > 0 ){
_selbox.options[0] = null;
}


if (_services.length == 0) {
_selbox.setAttribute('disabled', 'disabled');
} else {
_selbox.removeAttribute('disabled');
}

for (var i = 0 ; i < _services.length ; i++) {
var _service = _services[i];
var _id = _service.getElementsByTagName("id")[0].firstChild.nodeValue;
var _name = _service.getElementsByTagName("name")[0].firstChild.nodeValue;

new_elem = new Option(_name,_id);
_selbox.options[_selbox.length] = new_elem;
}
}
};
}

/*
* Validate form
*/
Expand Down
Loading

0 comments on commit 1722da5

Please sign in to comment.