mirror of
https://github.com/Cacti/cacti.git
synced 2026-10-23 19:47:06 +09:00
* security: consolidate verified GHSA fixes for develop (batch 3) Develop counterparts of the 1.2.x fixes in #8138, each re-verified against develop HEAD. - GHSA-77pr-g949-4v5f: spikekill.php also requires is_graph_allowed() on the target graph, not just the Spike Kill realm. - GHSA-w3qw-762w-6g9v: the include/global.php GET action guard fails closed on an array-form action[] before the scalar denylist comparison. - GHSA-xhpr-w454-cc9w: update_poller_cache() casts the stored output_type to int before interpolation. - GHSA-j3px-vw6r-g25x: graphs_new.php escapes stored snmp_index via db_qstr() in the data-query IN() pivot. - GHSA-h745-3r76-g253: graphs_new.php escapes the data-query and field names in the XML parse error messages (__ -> __esc). GHSA-297h-95ff-r767 does not apply on develop: the clog log-file selector renders through the drop_array filter framework, which escapes. tests/Unit/Security/ConsolidatedBatch3Test.php adds source-scanning regression guards. CHANGELOG (1.3.0-dev) updated; php -l, the security baselines, and check-changelog.py all pass. * chore: lead 1.3.0-dev security CHANGELOG entries with the GHSA id Normalize the 1.3.0-dev -security entries to the approved "-security: GHSA-xxxx [CVE-xxxx] Description" form, moving the advisory id to the front. CVE tokens are omitted because none of these advisories have a CVE issued yet (verified via the repository security-advisories API). Covers the five batch-3 entries plus the pre-existing entries that still used the trailing (GHSA-xxxx) form. * chore: use the -security#GHSA-xxxx: form for the 1.3.0-dev CHANGELOG entries Correct the batch-3 and reconciled 1.3.0-dev -security entries to the approved "-security#GHSA-xxxx: CVE-yyyy Description" form (GHSA id in the prefix). No CVE tokens are added because none of these advisories have a CVE issued yet (verified via the repository security-advisories API). * test: split batch-3 security guards into vulnerability-class files; reconcile CHANGELOG - Move the ConsolidatedBatch3Test.php guards into the matching Auth, Csrf, SqlInjection and Xss folders with behavior-based filenames, and strengthen them per review: the GET-guard test asserts the array branch actually returns 405 and exits; the snmp_index test rejects both raw concatenation branches; the parse-error test asserts every name-bearing message uses __esc(). - Append this pull request number to the five new 1.3.0-dev security entries. - Add issued CVE identifiers to the older -security#GHSA CHANGELOG entries (verified via the repository security-advisories API). Entries with no CVE yet, entries that already carried a CVE, and non-GHSA lines are unchanged.
124 lines
4.0 KiB
PHP
124 lines
4.0 KiB
PHP
<?php
|
|
/*
|
|
+-------------------------------------------------------------------------+
|
|
| Copyright (C) 2004-2026 The Cacti Group |
|
|
| |
|
|
| This program is free software; you can redistribute it and/or |
|
|
| modify it under the terms of the GNU General Public License |
|
|
| as published by the Free Software Foundation; either version 2 |
|
|
| of the License, or (at your option) any later version. |
|
|
| |
|
|
| This program is distributed in the hope that it will be useful, |
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
| GNU General Public License for more details. |
|
|
+-------------------------------------------------------------------------+
|
|
| Cacti: The Complete RRDtool-based Graphing Solution |
|
|
+-------------------------------------------------------------------------+
|
|
| This code is designed, written, and maintained by the Cacti Group. See |
|
|
| about.php and/or the AUTHORS file for specific developer information. |
|
|
+-------------------------------------------------------------------------+
|
|
| http://www.cacti.net/ |
|
|
+-------------------------------------------------------------------------+
|
|
*/
|
|
|
|
require('./include/auth.php');
|
|
require_once(CACTI_PATH_LIBRARY . '/spikekill.php');
|
|
|
|
$debug = false;
|
|
|
|
if (isrv('method')) {
|
|
switch(gnrv('method')) {
|
|
case 'stddev':
|
|
case 'fill':
|
|
case 'float':
|
|
case 'absolute':
|
|
break;
|
|
default:
|
|
print __("FATAL: Spike Kill method '%s' is Invalid", htmle(gnrv('method'))) . PHP_EOL;
|
|
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
$local_graph_id = gfrv('local_graph_id');
|
|
|
|
// GHSA-77pr-g949-4v5f: the Spike Kill realm (1043) only grants use of the
|
|
// feature, not access to a specific graph. Authorize the target graph too so a
|
|
// realm holder cannot destroy the RRD history of a graph they are denied.
|
|
if (is_realm_allowed(1043) && is_graph_allowed($local_graph_id)) {
|
|
$local_data_ids = db_fetch_assoc_prepared('SELECT DISTINCT data_template_rrd.local_data_id
|
|
FROM graph_templates_item
|
|
LEFT JOIN data_template_rrd
|
|
ON graph_templates_item.task_item_id=data_template_rrd.id
|
|
WHERE graph_templates_item.local_graph_id = ?',
|
|
[$local_graph_id]);
|
|
|
|
$results = '';
|
|
|
|
if (cacti_sizeof($local_data_ids)) {
|
|
foreach ($local_data_ids as $local_data_id) {
|
|
if ($local_data_id['local_data_id'] > 0) {
|
|
$data_source_path = get_data_source_path($local_data_id['local_data_id'], true);
|
|
} else {
|
|
$data_source_path = '';
|
|
}
|
|
|
|
if ($data_source_path != '') {
|
|
$html = true;
|
|
$dryrun = false;
|
|
$out_start = '';
|
|
$out_end = '';
|
|
$avgnan = '';
|
|
$method = '';
|
|
$rrdfile = $data_source_path;
|
|
|
|
if (isrv('dryrun')) {
|
|
$dryrun = true;
|
|
}
|
|
|
|
if (isrv('method')) {
|
|
$method = gnrv('method');
|
|
}
|
|
|
|
if (isrv('avgnan')) {
|
|
$avgnan = gnrv('avgnan');
|
|
}
|
|
|
|
if (isrv('outlier-start')) {
|
|
$out_start = gnrv('outlier-start');
|
|
}
|
|
|
|
if (isrv('outlier-end')) {
|
|
$out_end = gnrv('outlier-end');
|
|
}
|
|
|
|
$spiker = new spikekill($rrdfile, $method, $avgnan, '', $out_start, $out_end);
|
|
|
|
$spiker->dryrun = $dryrun;
|
|
$spiker->html = $html;
|
|
|
|
$result = $spiker->remove_spikes();
|
|
|
|
if ($debug) {
|
|
if (!$result) {
|
|
cacti_log("ERROR: SpikeKill failed for $rrdfile. Message is " . $spiker->get_errors(), false, 'SPIKEKILL');
|
|
} else {
|
|
cacti_log("NOTICE: SpikeKill succeeded for $rrdfile. Message is " . $spiker->get_output(), false, 'SPIKEKILL');
|
|
}
|
|
} else {
|
|
if (!$result) {
|
|
$results = $spiker->get_errors();
|
|
} else {
|
|
$results = $spiker->get_output();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
print json_encode(['local_graph_id' => $local_graph_id, 'results' => $results]);
|
|
} else {
|
|
print __('FATAL: Spike Kill Not Allowed') . PHP_EOL;
|
|
}
|