Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
*.swp
.DS_Store
locales/po/*.mo
.omc/
41 changes: 37 additions & 4 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,28 @@ function plugin_webseer_refresh_servers() {
$data['action'] = 'GETSERVERS';
$results = $cc->post($server['url'], $data);

if (!is_string($results)) {
return;
}

$results = explode("\n", $results);

foreach ($results as $r) {
if (!is_string($r)) {
continue;
}
if (substr($r, 0, 8) == 'SERVERS=') {
$servers = substr($r, 8);
$servers = unserialize(base64_decode($servers));
$encoded = substr($r, 8);
$decoded = base64_decode($encoded, true);
if ($decoded === false) {
cacti_log('WARNING: plugin_webseer_refresh_servers failed to base64_decode response', false, 'WEBSEER');
break;
}
$servers = @unserialize($decoded, array('allowed_classes' => false));
if (!is_array($servers)) {
cacti_log('WARNING: plugin_webseer_refresh_servers failed to unserialize response', false, 'WEBSEER');
break;
}
if (isset($servers[0]['id'])) {
db_execute('TRUNCATE TABLE plugin_webseer_servers');
foreach ($servers as $save) {
Expand All @@ -99,12 +115,29 @@ function plugin_webseer_refresh_urls () {
$data = array();
$data['action'] = 'GETURLS';
$results = $cc->post($server['url'], $data);

if (!is_string($results)) {
return;
}

$results = explode("\n", $results);

foreach ($results as $r) {
if (!is_string($r)) {
continue;
}
if (substr($r, 0, 5) == 'URLS=') {
$urls = substr($r, 5);
$urls = unserialize(base64_decode($urls));
$encoded = substr($r, 5);
$decoded = base64_decode($encoded, true);
if ($decoded === false) {
cacti_log('WARNING: plugin_webseer_refresh_urls failed to base64_decode response', false, 'WEBSEER');
break;
}
$urls = @unserialize($decoded, array('allowed_classes' => false));
if (!is_array($urls)) {
cacti_log('WARNING: plugin_webseer_refresh_urls failed to unserialize response', false, 'WEBSEER');
break;
}

Comment on lines 129 to 141
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above: base64_decode() does not accept an allowed_classes option array, so this change does not actually harden unserialize(). Pass array('allowed_classes' => false) as the 2nd parameter to unserialize() (and optionally use strict mode in base64_decode()).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed; options array moved to unserialize() second param.

if (isset($urls[0]['id'])) {
db_execute('TRUNCATE TABLE plugin_webseer_urls');
Expand Down
2 changes: 1 addition & 1 deletion poller_webseer.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function plugin_webseer_update_servers() {
foreach ($servers as $server) {
$server['debug_type'] = 'Server';

$cc = new cURL(true, 'cookies.txt', $server['compression'], '', $server);;
$cc = new cURL(true, 'cookies.txt', $server['compression'], '', $server);

$data = array();
$data['action'] = 'HEARTBEAT';
Expand Down
18 changes: 9 additions & 9 deletions webseer.php
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ function list_urls() {
var title = $(this).attr('title');

if (title != undefined && title.indexOf('/') >= 0) {
$(this).click(function() {
$(this).on('click', function() {
window.open(title, 'webseer');
});
}
Expand Down Expand Up @@ -973,19 +973,19 @@ function clearFilter() {
}

$(function() {
$('#refresh, #state, #rows, #rfilter').change(function() {
$('#refresh, #state, #rows, #rfilter').on('change', function() {
applyFilter();
});

$('#go').click(function() {
$('#go').on('click', function() {
applyFilter();
});

$('#clear').click(function() {
$('#clear').on('click', function() {
clearFilter();
});

$('#form_webseer').submit(function(event) {
$('#form_webseer').on('submit', function(event) {
event.preventDefault();
applyFilter();
});
Expand Down Expand Up @@ -1094,19 +1094,19 @@ function purgeEvents() {
}

$(function() {
$('#rows').change(function() {
$('#rows').on('change', function() {
applyFilter();
});

$('#clear').click(function() {
$('#clear').on('click', function() {
clearFilter();
});

$('#purge').click(function() {
$('#purge').on('click', function() {
purgeEvents();
});

$('#webseer').submit(function(event) {
$('#webseer').on('submit', function(event) {
event.preventDefault();
applyFilter();
});
Expand Down
6 changes: 3 additions & 3 deletions webseer_proxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,15 @@ function clearFilter() {
}

$(function() {
$('#rows').change(function() {
$('#rows').on('change', function() {
applyFilter();
});

$('#clear').click(function() {
$('#clear').on('click', function() {
clearFilter();
});

$('#webseer').submit(function(event) {
$('#webseer').on('submit', function(event) {
event.preventDefault();
applyFilter();
});
Expand Down
14 changes: 7 additions & 7 deletions webseer_servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ function list_servers() {
title = $(this).attr('title');

if (title != undefined && title.indexOf('/') >= 0) {
$(this).click(function() {
$(this).on('click', function() {
window.open(title, 'webseer');
});
}
Expand Down Expand Up @@ -710,15 +710,15 @@ function clearFilter() {
}

$(function() {
$('#refresh, #state, #rows').change(function() {
$('#refresh, #state, #rows').on('change', function() {
applyFilter();
});

$('#clear').click(function() {
$('#clear').on('click', function() {
clearFilter();
});

$('#webseer').submit(function(event) {
$('#webseer').on('submit', function(event) {
event.preventDefault();
applyFilter();
});
Expand Down Expand Up @@ -811,15 +811,15 @@ function clearFilter() {
}

$(function() {
$('#rows').change(function() {
$('#rows').on('change', function() {
applyFilter();
});

$('#clear').click(function() {
$('#clear').on('click', function() {
clearFilter();
});

$('#webseer').submit(function(event) {
$('#webseer').on('submit', function(event) {
event.preventDefault();
applyFilter();
});
Expand Down