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

Commit

Permalink
enh(BE): replace order filter's regexp using whitelist (#8094)
Browse files Browse the repository at this point in the history
* enh(UI): replace regexp by whitelist

* fix(CI): sonar coding style issue
  • Loading branch information
sc979 authored and callapa committed Nov 12, 2019
1 parent 1d6676e commit 7a788c5
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 101 deletions.
12 changes: 1 addition & 11 deletions www/include/monitoring/status/HostGroups/xml/hostGroupXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,7 @@
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));
$instance = filter_input(INPUT_GET, 'instance', FILTER_VALIDATE_INT, array('options' => array('default' => -1)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down
20 changes: 7 additions & 13 deletions www/include/monitoring/status/Hosts/xml/hostXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,7 @@
$num = filter_input(INPUT_GET, 'num', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down Expand Up @@ -350,10 +340,14 @@
$obj->XML->writeElement("ha", $data["acknowledged"]);
$obj->XML->writeElement("hdtm", $data["scheduled_downtime_depth"]);
$obj->XML->writeElement(
"hdtmXml", "./include/monitoring/downtime/xml/broker/makeXMLForDowntime.php?hid=" . $data['host_id']);
"hdtmXml",
"./include/monitoring/downtime/xml/broker/makeXMLForDowntime.php?hid=" . $data['host_id']
);
$obj->XML->writeElement("hdtmXsl", "./include/monitoring/downtime/xsl/popupForDowntime.xsl");
$obj->XML->writeElement(
"hackXml", "./include/monitoring/acknowlegement/xml/broker/makeXMLForAck.php?hid=" . $data['host_id']);
"hackXml",
"./include/monitoring/acknowlegement/xml/broker/makeXMLForAck.php?hid=" . $data['host_id']
);
$obj->XML->writeElement("hackXsl", "./include/monitoring/acknowlegement/xsl/popupForAck.xsl");
$obj->XML->writeElement("hae", $data["active_checks"]);
$obj->XML->writeElement("hpe", $data["passive_checks"]);
Expand Down
12 changes: 1 addition & 11 deletions www/include/monitoring/status/Services/xml/serviceGridXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,7 @@
$num = filter_input(INPUT_GET, 'num', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down
12 changes: 1 addition & 11 deletions www/include/monitoring/status/Services/xml/serviceSummaryXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,7 @@
$num = filter_input(INPUT_GET, 'num', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down
12 changes: 1 addition & 11 deletions www/include/monitoring/status/Services/xml/serviceXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,7 @@
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));
$nc = filter_input(INPUT_GET, 'nc', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,7 @@
$num = filter_input(INPUT_GET, 'num', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,7 @@
$num = filter_input(INPUT_GET, 'num', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,7 @@
$num = filter_input(INPUT_GET, 'num', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,7 @@
$num = filter_input(INPUT_GET, 'num', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
$limit = filter_input(INPUT_GET, 'limit', FILTER_VALIDATE_INT, array('options' => array('default' => 20)));

$order = filter_input(
INPUT_GET,
'order',
FILTER_VALIDATE_REGEXP,
array(
'options' => array(
'default' => "ASC",
'regexp' => '/^(ASC|DESC)$/'
)
)
);
$order = isset($_GET['order']) && $_GET['order'] === "DESC" ? "DESC" : "ASC";

// string values from the $_GET sanitized using the checkArgument() which call CentreonDB::escape() method
$o = $obj->checkArgument("o", $_GET, "h");
Expand Down

0 comments on commit 7a788c5

Please sign in to comment.