Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions .github/workflows/plugin-ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3', '8.4']
php: ['8.2', '8.3', '8.4']
os: [ubuntu-latest]

services:
Expand Down Expand Up @@ -82,7 +82,9 @@ jobs:
run: php -v

- name: Run apt-get update
run: sudo apt-get update
run: |
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update

- name: Install System Dependencies
run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping libapache2-mod-php${{ matrix.php }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

--- develop ---

* security: Sanitize and bind the filter search on the CA, proxy and credential pages
* security: Require a CSRF token on the enable, disable and purge GET actions

--- 0.4 ---

* feature: Add cpu/memory statistics
Expand Down
5 changes: 3 additions & 2 deletions servcheck_ca.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ function request_validation() {
'default' => '1'
],
'filter' => [
'filter' => FILTER_DEFAULT,
'filter' => FILTER_CALLBACK,
'pageset' => true,
'options' => ['options' => 'sanitize_search_string'],
'default' => ''
],
'sort_column' => [
Expand Down Expand Up @@ -256,7 +257,7 @@ function data_list() {
$sql_where = '';

if (get_request_var('filter') != '') {
$sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE "%' . get_request_var('filter');
$sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE ' . db_qstr('%' . get_request_var('filter') . '%');
}

$sql_order = get_order_string();
Expand Down
5 changes: 3 additions & 2 deletions servcheck_credential.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,9 @@ function request_validation() {
'default' => '1'
],
'filter' => [
'filter' => FILTER_DEFAULT,
'filter' => FILTER_CALLBACK,
'pageset' => true,
'options' => ['options' => 'sanitize_search_string'],
'default' => ''
],
'sort_column' => [
Expand Down Expand Up @@ -724,7 +725,7 @@ function data_list() {
$sql_where = '';

if (get_request_var('filter') != '') {
$sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE "%' . get_request_var('filter') . '%"';
$sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE ' . db_qstr('%' . get_request_var('filter') . '%');
}

$sql_order = get_order_string();
Expand Down
5 changes: 3 additions & 2 deletions servcheck_proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ function request_validation() {
'default' => '1'
],
'filter' => [
'filter' => FILTER_DEFAULT,
'filter' => FILTER_CALLBACK,
'pageset' => true,
'options' => ['options' => 'sanitize_search_string'],
'default' => ''
],
'sort_column' => [
Expand Down Expand Up @@ -259,7 +260,7 @@ function data_list() {
$sql_where = '';

if (get_request_var('filter') != '') {
$sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE "%' . get_request_var('filter') . '%" OR hostname LIKE "%' . get_request_var('filter') . '%"';
$sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ' OR hostname LIKE ' . db_qstr('%' . get_request_var('filter') . '%');
}

$sql_order = get_order_string();
Expand Down
12 changes: 6 additions & 6 deletions servcheck_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
case 'enable':
$id = get_filter_request_var('id');

if ($id > 0) {
if ($id > 0 && csrf_guard()->validate(get_nfilter_request_var('__csrf_magic'))) {
db_execute_prepared('UPDATE plugin_servcheck_test
SET enabled = "on"
WHERE id = ?', [$id]);
Expand All @@ -71,7 +71,7 @@
case 'disable':
$id = get_filter_request_var('id');

if ($id > 0) {
if ($id > 0 && csrf_guard()->validate(get_nfilter_request_var('__csrf_magic'))) {
db_execute_prepared('UPDATE plugin_servcheck_test
SET enabled = ""
WHERE id = ?', [$id]);
Expand All @@ -84,7 +84,7 @@
case 'purge':
$id = get_filter_request_var('id');

if ($id > 0) {
if ($id > 0 && csrf_guard()->validate(get_nfilter_request_var('__csrf_magic'))) {
purge_log_events($id);
}

Expand Down Expand Up @@ -1169,11 +1169,11 @@ function data_list() {
</a>";

if ($row['enabled'] == '') {
print "<a class='pic' href='" . html_escape($config['url_path'] . 'plugins/servcheck/servcheck_test.php?action=enable&id=' . $row['id']) . "' title='" . __esc('Enable Service Check', 'servcheck') . "'>
print "<a class='pic' href='" . html_escape($config['url_path'] . 'plugins/servcheck/servcheck_test.php?action=enable&id=' . $row['id'] . '&__csrf_magic=' . urlencode(csrf_get_tokens())) . "' title='" . __esc('Enable Service Check', 'servcheck') . "'>
<i class='tholdGlyphEnable fas fa-play-circle'></i>
</a>";
} else {
print "<a class='pic' href='" . html_escape($config['url_path'] . 'plugins/servcheck/servcheck_test.php?action=disable&id=' . $row['id']) . "' title='" . __esc('Disable Service Check', 'servcheck') . "'>
print "<a class='pic' href='" . html_escape($config['url_path'] . 'plugins/servcheck/servcheck_test.php?action=disable&id=' . $row['id'] . '&__csrf_magic=' . urlencode(csrf_get_tokens())) . "' title='" . __esc('Disable Service Check', 'servcheck') . "'>
<i class='tholdGlyphDisable fas fa-stop-circle'></i>
</a>";
}
Expand Down Expand Up @@ -1436,7 +1436,7 @@ function clearFilter() {
}

function purgeEvents() {
strURL = '<?php print htmlspecialchars(basename($_SERVER['PHP_SELF'])); ?>?action=purge&id=<?php print get_request_var('id'); ?>';
strURL = '<?php print htmlspecialchars(basename($_SERVER['PHP_SELF'])); ?>?action=purge&id=<?php print get_request_var('id'); ?>&__csrf_magic=<?php print urlencode(csrf_get_tokens()); ?>';
loadPageNoHeader(strURL);
}

Expand Down
Loading