From 7f91ea8261bc0cc01350bbc2fed330ce0de947e2 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 7 Oct 2026 17:43:01 -0400 Subject: [PATCH] security: move inline event handlers to CSP-safe bindings Cacti's Content-Security-Policy script-src-attr directive blocks inline event-handler attributes. This converts the plugin's remaining inline handlers: - The confirmation-page Cancel buttons across servcheck_ca.php, servcheck_credential.php, servcheck_proxy.php, servcheck_restapi.php and servcheck_test.php switch from onClick='cactiReturnTo()' to the CSP-safe cactiReturnTo class. - The filter "rows" selects on the CA, credential and proxy pages drop their inline onChange='applyFilter()' and are bound in each page's existing ready block via change() (not click(), which never fired for a  "; + $save_html = " "; } } else { raise_message(40); @@ -423,7 +423,7 @@ function servcheck_filter(): void { - ' . __('Default', 'servcheck') . ''; @@ -463,7 +463,7 @@ function clearFilter() { } $(function() { - $('#rows').click(function() { + $('#rows').change(function() { applyFilter(); }); diff --git a/servcheck_credential.php b/servcheck_credential.php index 2118d5c..0eca37b 100644 --- a/servcheck_credential.php +++ b/servcheck_credential.php @@ -155,7 +155,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } elseif (get_filter_request_var('drp_action') == 2) { // duplicate print " @@ -163,7 +163,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } } else { raise_message(40); @@ -944,7 +944,7 @@ function servcheck_filter(): void { - ' . __('Default', 'servcheck') . ''; @@ -984,6 +984,10 @@ function clearFilter() { } $(function() { + $('#rows').change(function() { + applyFilter(); + }); + $('#refresh').click(function() { applyFilter(); }); diff --git a/servcheck_proxy.php b/servcheck_proxy.php index f4343a8..286d935 100644 --- a/servcheck_proxy.php +++ b/servcheck_proxy.php @@ -132,7 +132,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } } else { raise_message(40); @@ -436,7 +436,7 @@ function servcheck_filter(): void { - ' . __('Default', 'servcheck') . ''; @@ -476,7 +476,7 @@ function clearFilter() { } $(function() { - $('#rows').click(function() { + $('#rows').change(function() { applyFilter(); }); diff --git a/servcheck_restapi.php b/servcheck_restapi.php index 0bf77a2..7ecd940 100644 --- a/servcheck_restapi.php +++ b/servcheck_restapi.php @@ -168,7 +168,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } elseif ($action == 'duplicate') { print " @@ -177,7 +177,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } } else { raise_message(40); diff --git a/servcheck_test.php b/servcheck_test.php index 5dd0352..566a576 100644 --- a/servcheck_test.php +++ b/servcheck_test.php @@ -230,7 +230,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } elseif (get_filter_request_var('drp_action') == 2) { // disable print " @@ -239,7 +239,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } elseif (get_filter_request_var('drp_action') == 3) { // enable print " @@ -248,7 +248,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } elseif (get_filter_request_var('drp_action') == 4) { // duplicate print " @@ -257,7 +257,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } elseif (get_filter_request_var('drp_action') == 5) { // clear statistics print " @@ -266,7 +266,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } elseif (get_filter_request_var('drp_action') == 6) { // clear log print " @@ -275,7 +275,7 @@ function form_actions(): void { "; - $save_html = " "; + $save_html = " "; } } else { raise_message(40); diff --git a/tests/bin/patch-coverage.php b/tests/bin/patch-coverage.php index e65b53d..f9b08b2 100644 --- a/tests/bin/patch-coverage.php +++ b/tests/bin/patch-coverage.php @@ -160,6 +160,11 @@ function changed_lines($base_ref) { * Empty by default; add entries per repository as the need arises. */ $unmeasured_allowlist = [ + 'servcheck_ca.php', // web UI entry point (require auth.php); not loadable in the isolated unit process + 'servcheck_credential.php', // web UI entry point (require auth.php); not loadable in the isolated unit process + 'servcheck_proxy.php', // web UI entry point (require auth.php); not loadable in the isolated unit process + 'servcheck_restapi.php', // web UI entry point (require auth.php); not loadable in the isolated unit process + 'servcheck_test.php', // web UI entry point (require auth.php); not loadable in the isolated unit process ]; $unmeasured = array_values(array_diff(array_keys($changed), array_keys($measured))); $unexpected_unmeasured = array_values(array_diff($unmeasured, $unmeasured_allowlist));